@d3plus/core 4.10.0 → 4.12.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/es/index.js +1 -1
- package/es/internal.js +178 -9
- package/es/src/charts/Alluvial/aggregate.js +145 -0
- package/es/src/charts/Alluvial/applyLayout.js +125 -0
- package/es/src/charts/Alluvial/dimensions.js +56 -0
- package/es/src/charts/Alluvial/emit.js +73 -0
- package/es/src/charts/Alluvial/hover.js +101 -0
- package/es/src/charts/Alluvial/index.js +176 -0
- package/es/src/charts/Alluvial/layout.js +137 -0
- package/es/src/charts/Alluvial/meta.js +57 -0
- package/es/src/charts/Alluvial/titles.js +101 -0
- package/es/src/charts/ArcDiagram/applyLayout.js +386 -0
- package/es/src/charts/ArcDiagram/arcGeometry.js +275 -0
- package/es/src/charts/ArcDiagram/arcLabels.js +171 -0
- package/es/src/charts/ArcDiagram/arcLoops.js +78 -0
- package/es/src/charts/ArcDiagram/emit.js +192 -0
- package/es/src/charts/ArcDiagram/events.js +148 -0
- package/es/src/charts/ArcDiagram/index.js +217 -0
- package/es/src/charts/BarChart/index.js +12 -7
- package/es/src/charts/BoxWhisker/index.js +22 -0
- package/es/src/charts/BubbleChart/emit.js +31 -0
- package/es/src/charts/BubbleChart/index.js +54 -0
- package/es/src/charts/Calendar/emit.js +1 -1
- package/es/src/charts/Calendar/index.js +5 -2
- package/es/src/charts/Candlestick/buffer.js +6 -4
- package/es/src/charts/Candlestick/index.js +6 -11
- package/es/src/charts/Chord/applyLayout.js +56 -69
- package/es/src/charts/Chord/emit.js +55 -24
- package/es/src/charts/Chord/index.js +14 -10
- package/es/src/charts/Chord/labels.js +105 -0
- package/es/src/charts/Donut/index.js +5 -11
- package/es/src/charts/Dumbbell/index.js +2 -4
- package/es/src/charts/Gantt/applyLayout.js +160 -0
- package/es/src/charts/Gantt/emit.js +142 -0
- package/es/src/charts/Gantt/ganttDecor.js +207 -0
- package/es/src/charts/Gantt/ganttGeometry.js +107 -0
- package/es/src/charts/Gantt/ganttLabels.js +85 -0
- package/es/src/charts/Gantt/ganttRows.js +111 -0
- package/es/src/charts/Gantt/ganttTooltip.js +136 -0
- package/es/src/charts/Gantt/index.js +219 -0
- package/es/src/charts/Geomap/applyLayout.js +90 -49
- package/es/src/charts/Geomap/basemapTheme.js +3 -48
- package/es/src/charts/Geomap/emit.js +19 -2
- package/es/src/charts/Geomap/flowEmit.js +137 -0
- package/es/src/charts/Geomap/flowEvents.js +86 -0
- package/es/src/charts/Geomap/flowFields.js +91 -0
- package/es/src/charts/Geomap/flowGeometry.js +225 -0
- package/es/src/charts/Geomap/flowLinks.js +239 -0
- package/es/src/charts/Geomap/geoCache.js +180 -0
- package/es/src/charts/Geomap/globeKeys.js +131 -0
- package/es/src/charts/Geomap/globeRotate.js +208 -0
- package/es/src/charts/Geomap/index.js +51 -16
- package/es/src/charts/Geomap/pointLabels.js +107 -0
- package/es/src/charts/Hexbin/binning.js +103 -0
- package/es/src/charts/Hexbin/buffer.js +33 -0
- package/es/src/charts/Hexbin/contourLabels.js +234 -0
- package/es/src/charts/Hexbin/contours.js +48 -0
- package/es/src/charts/Hexbin/emit.js +142 -0
- package/es/src/charts/Hexbin/index.js +206 -0
- package/es/src/charts/Hexbin/layers.js +212 -0
- package/es/src/charts/Hexbin/settings.js +86 -0
- package/es/src/charts/Hexbin/tooltip.js +77 -0
- package/es/src/charts/Histogram/binData.js +31 -4
- package/es/src/charts/Histogram/index.js +32 -15
- package/es/src/charts/Histogram/labels.js +18 -0
- package/es/src/charts/Icicle/index.js +6 -4
- package/es/src/charts/LinePlot/index.js +7 -0
- package/es/src/charts/Marimekko/index.js +7 -4
- package/es/src/charts/Matrix/applyLayout.js +20 -9
- package/es/src/charts/Matrix/index.js +19 -1
- package/es/src/charts/Network/applyLayout.js +171 -96
- package/es/src/charts/Network/bundle.js +82 -0
- package/es/src/charts/Network/clusterLabels.js +423 -0
- package/es/src/charts/Network/clusters.js +290 -0
- package/es/src/charts/Network/emit.js +257 -75
- package/es/src/charts/Network/graph.js +146 -0
- package/es/src/charts/Network/graphFluent.js +81 -0
- package/es/src/charts/Network/index.js +91 -106
- package/es/src/charts/Network/minNodeDistance.js +64 -0
- package/es/src/charts/Network/polygonRows.js +44 -0
- package/es/src/charts/Pack/applyLayout.js +16 -5
- package/es/src/charts/Pack/emit.js +15 -8
- package/es/src/charts/Pack/groupRows.js +61 -0
- package/es/src/charts/Pack/index.js +8 -1
- package/es/src/charts/Pack/neutralPaint.js +20 -0
- package/es/src/charts/Pack/nodeNames.js +35 -0
- package/es/src/charts/ParallelCoordinates/axes.js +22 -22
- package/es/src/charts/ParallelCoordinates/chrome.js +18 -0
- package/es/src/charts/ParallelCoordinates/index.js +3 -1
- package/es/src/charts/ParallelCoordinates/titles.js +17 -9
- package/es/src/charts/Pie/applyLayout.js +86 -27
- package/es/src/charts/Pie/arcFit.js +152 -0
- package/es/src/charts/Pie/curvedLabels.js +134 -0
- package/es/src/charts/Pie/emit.js +51 -96
- package/es/src/charts/Pie/index.js +74 -31
- package/es/src/charts/Pie/labelRoom.js +154 -0
- package/es/src/charts/Pie/outsideLabels.js +224 -0
- package/es/src/charts/Pie/outsideNodes.js +267 -0
- package/es/src/charts/Pie/pieLabels.js +137 -0
- package/es/src/charts/Pie/sectorBox.js +223 -0
- package/es/src/charts/Pie/straightLabels.js +96 -0
- package/es/src/charts/Pie/straightLayout.js +215 -0
- package/es/src/charts/Plot/alongLegend.js +76 -0
- package/es/src/charts/Plot/areaEnter.js +68 -0
- package/es/src/charts/Plot/areaLabelsAlong.js +333 -0
- package/es/src/charts/Plot/axisHoverScene.js +2 -1
- package/es/src/charts/Plot/axisValues.js +43 -0
- package/es/src/charts/Plot/barWidth.js +59 -11
- package/es/src/charts/Plot/circleLabels.js +98 -0
- package/es/src/charts/Plot/connectGaps.js +237 -0
- package/es/src/charts/Plot/connectGapsScene.js +188 -0
- package/es/src/charts/Plot/draw.js +34 -14
- package/es/src/charts/Plot/fillBetween.js +2 -1
- package/es/src/charts/Plot/forecastScene.js +3 -4
- package/es/src/charts/Plot/index.js +19 -17
- package/es/src/charts/Plot/labelPlacement.js +1 -1
- package/es/src/charts/Plot/lineLabelEmit.js +82 -0
- package/es/src/charts/Plot/lineLabelSides.js +51 -0
- package/es/src/charts/Plot/lineLabelSpread.js +65 -0
- package/es/src/charts/Plot/lineLabelsAlong.js +282 -0
- package/es/src/charts/Plot/lineMarkerKeys.js +19 -0
- package/es/src/charts/Plot/pipeline.js +66 -19
- package/es/src/charts/Plot/pipelineAxisLayout.js +5 -1
- package/es/src/charts/Plot/pipelineDomains.js +16 -3
- package/es/src/charts/Plot/pipelineLineLabels.js +144 -52
- package/es/src/charts/Plot/pipelineScales.js +40 -8
- package/es/src/charts/Plot/plotFacet.js +12 -1
- package/es/src/charts/Plot/plotInit.js +40 -5
- package/es/src/charts/Plot/plotRangeBreaks.js +85 -0
- package/es/src/charts/Plot/referenceDomains.js +133 -0
- package/es/src/charts/Plot/shapeDefaults.js +10 -5
- package/es/src/charts/Plot/shapeLabelLegend.js +67 -0
- package/es/src/charts/Plot/sharedHover.js +2 -1
- package/es/src/charts/Plot/sharedTooltip.js +13 -3
- package/es/src/charts/Plot/stackLegendOrder.js +176 -0
- package/es/src/charts/Plot/trendLabels.js +183 -0
- package/es/src/charts/Plot/trendLines.js +1 -0
- package/es/src/charts/Plot/trendScene.js +6 -3
- package/es/src/charts/Plot/trendTooltip.js +5 -1
- package/es/src/charts/PolarArea/index.js +4 -3
- package/es/src/charts/Priestley/applyLayout.js +21 -23
- package/es/src/charts/Priestley/index.js +4 -37
- package/es/src/charts/Priestley/timeAxis.js +103 -0
- package/es/src/charts/Pyramid/gutter.js +52 -16
- package/es/src/charts/Pyramid/index.js +55 -7
- package/es/src/charts/Pyramid/scene.js +4 -4
- package/es/src/charts/Radar/applyLayout.js +31 -33
- package/es/src/charts/Radar/axisDecorations.js +62 -13
- package/es/src/charts/Radar/curvedLabels.js +228 -0
- package/es/src/charts/Radar/emit.js +30 -15
- package/es/src/charts/Radar/index.js +43 -5
- package/es/src/charts/Radar/points.js +85 -0
- package/es/src/charts/RadialBar/curvedLabels.js +111 -0
- package/es/src/charts/RadialBar/emit.js +9 -1
- package/es/src/charts/RadialBar/index.js +26 -9
- package/es/src/charts/RadialBar/trackLayout.js +43 -13
- package/es/src/charts/RadialMatrix/applyLayout.js +115 -31
- package/es/src/charts/RadialMatrix/index.js +18 -9
- package/es/src/charts/Rings/applyLayout.js +39 -161
- package/es/src/charts/Rings/emit.js +219 -63
- package/es/src/charts/Rings/index.js +88 -32
- package/es/src/charts/Rings/ringsCurves.js +156 -0
- package/es/src/charts/Rings/ringsGraph.js +28 -9
- package/es/src/charts/Rings/ringsLoops.js +73 -0
- package/es/src/charts/Rings/ringsParallel.js +183 -0
- package/es/src/charts/Rings/ringsPlacement.js +152 -0
- package/es/src/charts/Rings/ringsSizing.js +61 -38
- package/es/src/charts/Sankey/applyLayout.js +130 -39
- package/es/src/charts/Sankey/circularLayout.js +208 -0
- package/es/src/charts/Sankey/circularLinks.js +301 -0
- package/es/src/charts/Sankey/emit.js +164 -94
- package/es/src/charts/Sankey/index.js +78 -75
- package/es/src/charts/Sankey/labels.js +80 -0
- package/es/src/charts/Sankey/ribbons.js +88 -0
- package/es/src/charts/Sankey/sankeyCycles.js +117 -0
- package/es/src/charts/Sankey/sankeyLayout.js +8 -3
- package/es/src/charts/Sankey/sankeyLinks.js +47 -0
- package/es/src/charts/Scatter/index.js +25 -0
- package/es/src/charts/SlopeChart/index.js +116 -0
- package/es/src/charts/SlopeChart/slope.js +95 -0
- package/es/src/charts/Streamgraph/index.js +51 -0
- package/es/src/charts/Sunburst/curvedLabels.js +74 -0
- package/es/src/charts/Sunburst/emit.js +83 -64
- package/es/src/charts/Sunburst/index.js +16 -4
- package/es/src/charts/Tree/applyLayout.js +44 -14
- package/es/src/charts/Tree/emit.js +5 -5
- package/es/src/charts/Tree/index.js +12 -18
- package/es/src/charts/Tree/keys.js +33 -0
- package/es/src/charts/Tree/nodeLabel.js +15 -0
- package/es/src/charts/Treemap/emitGroupHeaders.js +3 -5
- package/es/src/charts/Treemap/index.js +2 -5
- package/es/src/charts/Violin/inner.js +3 -5
- package/es/src/charts/definition/makeChart.js +14 -2
- package/es/src/charts/drawSteps/backControl.js +17 -5
- package/es/src/charts/drawSteps/gestureHover.js +79 -0
- package/es/src/charts/drawSteps/minimap.js +10 -25
- package/es/src/charts/drawSteps/minimapMarkup.js +25 -9
- package/es/src/charts/drawSteps/searchControls.js +2 -1
- package/es/src/charts/drawSteps/searchControlsMarkup.js +11 -2
- package/es/src/charts/drawSteps/tableViewMarkup.js +17 -10
- package/es/src/charts/drawSteps/zoomActions.js +36 -0
- package/es/src/charts/drawSteps/zoomControls.js +52 -23
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +23 -4
- package/es/src/charts/drawSteps/zoomDrag.js +188 -0
- package/es/src/charts/drawSteps/zoomFit.js +69 -0
- package/es/src/charts/events/click.legend.js +11 -4
- package/es/src/charts/events/click.shape.js +13 -4
- package/es/src/charts/events/mouseenter.js +6 -16
- package/es/src/charts/events/mouseleave.js +9 -2
- package/es/src/charts/events/mousemove.legend.js +28 -32
- package/es/src/charts/events/mousemove.shape.js +45 -42
- package/es/src/charts/facet/drawFacets.js +14 -5
- package/es/src/charts/features/annotationFrame.js +179 -0
- package/es/src/charts/features/annotationText.js +83 -0
- package/es/src/charts/features/annotationTypes.js +10 -0
- package/es/src/charts/features/attributionFeature.js +6 -11
- package/es/src/charts/features/axes.js +17 -5
- package/es/src/charts/features/axesFinal.js +10 -3
- package/es/src/charts/features/axesMeasure.js +33 -12
- package/es/src/charts/features/axisTooltip.js +138 -0
- package/es/src/charts/features/calloutLayout.js +121 -0
- package/es/src/charts/features/calloutScene.js +155 -0
- package/es/src/charts/features/centerLabel.js +177 -0
- package/es/src/charts/features/chartGeometry.js +1 -1
- package/es/src/charts/features/circleLabelPlacement.js +297 -0
- package/es/src/charts/features/circleLabels.js +207 -0
- package/es/src/charts/features/colorScaleBivariate.js +83 -0
- package/es/src/charts/features/colorScaleBucket.js +20 -1
- package/es/src/charts/features/colorScaleHover.js +33 -7
- package/es/src/charts/features/colorScaleLimit.js +73 -0
- package/es/src/charts/features/colorScaleTooltip.js +77 -0
- package/es/src/charts/features/colorScaleTop.js +61 -0
- package/es/src/charts/features/colorScaleValue.js +97 -0
- package/es/src/charts/features/curvedArrows.js +191 -0
- package/es/src/charts/features/depthKey.js +26 -0
- package/es/src/charts/features/edgeArrows.js +220 -5
- package/es/src/charts/features/edgeBundling.js +442 -0
- package/es/src/charts/features/edgeBundlingSmooth.js +117 -0
- package/es/src/charts/features/ensureZoomDom.js +32 -8
- package/es/src/charts/features/features.js +32 -14
- package/es/src/charts/features/featuresColorScale.js +75 -20
- package/es/src/charts/features/featuresLegend.js +15 -24
- package/es/src/charts/features/hoverTicks.js +41 -0
- package/es/src/charts/features/idleQueue.js +72 -0
- package/es/src/charts/features/legendKeys.js +64 -0
- package/es/src/charts/features/lineLabels.js +55 -46
- package/es/src/charts/features/linkBundle.js +19 -0
- package/es/src/charts/features/linkColor.js +72 -0
- package/es/src/charts/features/linkFields.js +86 -0
- package/es/src/charts/features/linkFocus.js +118 -0
- package/es/src/charts/features/linkInteraction.js +364 -0
- package/es/src/charts/features/linkKeys.js +20 -0
- package/es/src/charts/features/linkLabelGeometry.js +209 -0
- package/es/src/charts/features/linkLabelPath.js +162 -0
- package/es/src/charts/features/linkLabels.js +340 -0
- package/es/src/charts/features/linkWidths.js +32 -0
- package/es/src/charts/features/networkMeasures.js +241 -0
- package/es/src/charts/features/nodeStats.js +309 -0
- package/es/src/charts/features/pathLabelGeometry.js +232 -0
- package/es/src/charts/features/pathLabels.js +50 -0
- package/es/src/charts/features/plotAnnotations.js +68 -17
- package/es/src/charts/features/plotEndLabels.js +28 -7
- package/es/src/charts/features/plotPaint.js +46 -12
- package/es/src/charts/features/polyline.js +129 -0
- package/es/src/charts/features/referenceAnnotations.js +403 -0
- package/es/src/charts/features/referenceLabelPlacement.js +106 -0
- package/es/src/charts/features/ringLabelNodes.js +93 -0
- package/es/src/charts/features/ringLabels.js +222 -0
- package/es/src/charts/features/sceneBounds.js +26 -6
- package/es/src/charts/features/selfLoops.js +306 -0
- package/es/src/charts/features/shapeEmit.js +54 -32
- package/es/src/charts/features/sharedFields.js +15 -2
- package/es/src/charts/features/textHalo.js +30 -0
- package/es/src/charts/index.js +8 -0
- package/es/src/charts/partition/chartFields.js +14 -5
- package/es/src/charts/partition/interaction.js +19 -10
- package/es/src/charts/partition/zoom.js +7 -6
- package/es/src/charts/pipeline/insetPlacement.js +22 -9
- package/es/src/charts/pipeline/preDrawData.js +46 -3
- package/es/src/charts/pipeline/runVizPipeline.js +5 -0
- package/es/src/charts/pipeline/vizPreDraw.js +5 -3
- package/es/src/charts/plotBuffers/discreteBuffer.js +7 -4
- package/es/src/charts/polar/chrome.js +81 -9
- package/es/src/charts/polar/config.js +6 -3
- package/es/src/charts/polar/wedgeLayout.js +2 -1
- package/es/src/charts/viz/Viz.js +61 -49
- package/es/src/charts/viz/VizBase.js +57 -14
- package/es/src/charts/viz/backgroundInk.js +23 -7
- package/es/src/charts/viz/emphasis.js +14 -0
- package/es/src/charts/viz/fillStroke.js +10 -0
- package/es/src/charts/viz/focusRing.js +104 -0
- package/es/src/charts/viz/focusTargets.js +208 -0
- package/es/src/charts/viz/history.js +74 -0
- package/es/src/charts/viz/interactionOpacity.js +115 -32
- package/es/src/charts/viz/keyboardNav.js +297 -0
- package/es/src/charts/viz/keyboardNavHost.js +95 -0
- package/es/src/charts/viz/loaderFormat.js +114 -0
- package/es/src/charts/viz/missingFields.js +2 -1
- package/es/src/charts/viz/mountTarget.js +9 -0
- package/es/src/charts/viz/nearestHover.js +183 -0
- package/es/src/charts/viz/nearestHoverSurface.js +92 -0
- package/es/src/charts/viz/ordinalColor.js +14 -12
- package/es/src/charts/viz/pageTheme.js +83 -0
- package/es/src/charts/viz/pointTooltipAnchor.js +59 -0
- package/es/src/charts/viz/pointVoronoi.js +124 -0
- package/es/src/charts/viz/reducedMotion.js +27 -0
- package/es/src/charts/viz/reportDrawError.js +15 -0
- package/es/src/charts/viz/setCursor.js +29 -0
- package/es/src/charts/viz/tooltipEnabled.js +38 -0
- package/es/src/charts/viz/userClick.js +34 -0
- package/es/src/charts/viz/vizDataPolling.js +8 -4
- package/es/src/charts/viz/vizDefaults.js +28 -57
- package/es/src/charts/viz/vizFields.js +41 -1
- package/es/src/charts/viz/vizRender.js +76 -31
- package/es/src/charts/viz/vizTheme.js +96 -0
- package/es/src/charts/viz/vizVisibility.js +26 -2
- package/es/src/components/Axis/Axis.js +35 -2
- package/es/src/components/Axis/AxisBottom.js +1 -0
- package/es/src/components/Axis/AxisLeft.js +1 -0
- package/es/src/components/Axis/AxisRight.js +1 -0
- package/es/src/components/Axis/AxisTop.js +1 -0
- package/es/src/components/Axis/axisBreak.js +33 -8
- package/es/src/components/Axis/axisDefaults.js +16 -9
- package/es/src/components/Axis/axisLabelKinds.js +36 -0
- package/es/src/components/Axis/axisLabelLineHeight.js +19 -0
- package/es/src/components/Axis/axisLabelRoom.js +37 -0
- package/es/src/components/Axis/axisLabelSize.js +171 -0
- package/es/src/components/Axis/axisLabelThinning.js +98 -4
- package/es/src/components/Axis/axisLayout.js +71 -46
- package/es/src/components/Axis/axisLayoutLabels.js +82 -140
- package/es/src/components/Axis/axisLayoutScale.js +16 -11
- package/es/src/components/Axis/axisLimit.js +27 -0
- package/es/src/components/Axis/axisMaxSize.js +39 -0
- package/es/src/components/Axis/axisRangeBreaks.js +77 -0
- package/es/src/components/Axis/axisRender.js +20 -8
- package/es/src/components/Axis/axisRounding.js +16 -1
- package/es/src/components/Axis/axisScene.js +11 -2
- package/es/src/components/Axis/axisTitle.js +53 -0
- package/es/src/components/Axis/axisTooltipTargets.js +128 -0
- package/es/src/components/Axis/brokenTimeScale.js +196 -0
- package/es/src/components/Axis/rangeBreaks.js +201 -0
- package/es/src/components/Axis/timeValues.js +19 -4
- package/es/src/components/ColorScale/ColorScale.js +77 -27
- package/es/src/components/ColorScale/bivariateRender.js +353 -0
- package/es/src/components/ColorScale/bivariateScale.js +150 -0
- package/es/src/components/ColorScale/bucketBounds.js +32 -3
- package/es/src/components/ColorScale/colorScaleHoverMark.js +3 -3
- package/es/src/components/ColorScale/colorScaleRender.js +32 -2
- package/es/src/components/ColorScale/colorScaleScale.js +28 -15
- package/es/src/components/ColorScale/colorScaleSwatchTooltips.js +77 -0
- package/es/src/components/Legend/Legend.js +13 -2
- package/es/src/components/Legend/legendConfig.js +2 -6
- package/es/src/components/Legend/legendCut.js +108 -0
- package/es/src/components/Legend/legendRender.js +38 -13
- package/es/src/components/SizeLegend/SizeLegend.js +1 -0
- package/es/src/components/TextBox.js +34 -67
- package/es/src/components/Timeline/Timeline.js +12 -3
- package/es/src/components/Timeline/timelineConfig.js +20 -10
- package/es/src/components/Timeline/timelineMode.js +26 -0
- package/es/src/components/Timeline/timelineRender.js +9 -4
- package/es/src/components/Tooltip.js +15 -5
- package/es/src/components/fontStack.js +20 -0
- package/es/src/components/textBoxLayout.js +58 -21
- package/es/src/components/textBoxPath.js +73 -0
- package/es/src/components/textBoxScene.js +226 -0
- package/es/src/components/textBoxWords.js +70 -0
- package/es/src/components/textEllipsis.js +7 -0
- package/es/src/components/tooltipDom.js +8 -5
- package/es/src/fluent.js +48 -0
- package/es/src/shapes/Area.js +1 -0
- package/es/src/shapes/Bar.js +1 -0
- package/es/src/shapes/Box.js +1 -0
- package/es/src/shapes/Circle.js +1 -0
- package/es/src/shapes/Line.js +1 -0
- package/es/src/shapes/Path.js +1 -0
- package/es/src/shapes/Rect.js +1 -0
- package/es/src/shapes/Shape.js +1 -0
- package/es/src/shapes/Whisker.js +1 -0
- package/es/src/utils/BaseClass.js +30 -12
- package/es/src/utils/configPrep.js +2 -1
- package/es/src/utils/configValue.js +9 -0
- package/es/src/utils/constant.js +13 -1
- package/es/src/utils/displayName.js +12 -0
- package/es/src/utils/theme.js +190 -0
- package/es/src/utils/themeInk.js +68 -0
- package/package.json +14 -11
- package/types/index.d.ts +6 -2
- package/types/internal.d.ts +268 -9
- package/types/src/charts/Alluvial/aggregate.d.ts +98 -0
- package/types/src/charts/Alluvial/applyLayout.d.ts +67 -0
- package/types/src/charts/Alluvial/dimensions.d.ts +40 -0
- package/types/src/charts/Alluvial/emit.d.ts +9 -0
- package/types/src/charts/Alluvial/hover.d.ts +31 -0
- package/types/src/charts/Alluvial/index.d.ts +27 -0
- package/types/src/charts/Alluvial/layout.d.ts +70 -0
- package/types/src/charts/Alluvial/meta.d.ts +54 -0
- package/types/src/charts/Alluvial/titles.d.ts +46 -0
- package/types/src/charts/ArcDiagram/applyLayout.d.ts +70 -0
- package/types/src/charts/ArcDiagram/arcGeometry.d.ts +150 -0
- package/types/src/charts/ArcDiagram/arcLabels.d.ts +89 -0
- package/types/src/charts/ArcDiagram/arcLoops.d.ts +48 -0
- package/types/src/charts/ArcDiagram/emit.d.ts +24 -0
- package/types/src/charts/ArcDiagram/events.d.ts +29 -0
- package/types/src/charts/ArcDiagram/index.d.ts +28 -0
- package/types/src/charts/BubbleChart/emit.d.ts +20 -0
- package/types/src/charts/BubbleChart/index.d.ts +16 -0
- package/types/src/charts/Chord/applyLayout.d.ts +3 -0
- package/types/src/charts/Chord/labels.d.ts +66 -0
- package/types/src/charts/Donut/index.d.ts +2 -1
- package/types/src/charts/Gantt/applyLayout.d.ts +64 -0
- package/types/src/charts/Gantt/emit.d.ts +17 -0
- package/types/src/charts/Gantt/ganttDecor.d.ts +41 -0
- package/types/src/charts/Gantt/ganttGeometry.d.ts +57 -0
- package/types/src/charts/Gantt/ganttLabels.d.ts +41 -0
- package/types/src/charts/Gantt/ganttRows.d.ts +84 -0
- package/types/src/charts/Gantt/ganttTooltip.d.ts +57 -0
- package/types/src/charts/Gantt/index.d.ts +36 -0
- package/types/src/charts/Geomap/applyLayout.d.ts +8 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +2 -19
- package/types/src/charts/Geomap/emit.d.ts +2 -2
- package/types/src/charts/Geomap/flowEmit.d.ts +36 -0
- package/types/src/charts/Geomap/flowEvents.d.ts +20 -0
- package/types/src/charts/Geomap/flowFields.d.ts +7 -0
- package/types/src/charts/Geomap/flowGeometry.d.ts +91 -0
- package/types/src/charts/Geomap/flowLinks.d.ts +97 -0
- package/types/src/charts/Geomap/geoCache.d.ts +47 -0
- package/types/src/charts/Geomap/globeKeys.d.ts +41 -0
- package/types/src/charts/Geomap/globeRotate.d.ts +70 -0
- package/types/src/charts/Geomap/index.d.ts +3 -0
- package/types/src/charts/Geomap/pointLabels.d.ts +24 -0
- package/types/src/charts/Hexbin/binning.d.ts +64 -0
- package/types/src/charts/Hexbin/buffer.d.ts +18 -0
- package/types/src/charts/Hexbin/contourLabels.d.ts +95 -0
- package/types/src/charts/Hexbin/contours.d.ts +48 -0
- package/types/src/charts/Hexbin/emit.d.ts +23 -0
- package/types/src/charts/Hexbin/index.d.ts +25 -0
- package/types/src/charts/Hexbin/layers.d.ts +94 -0
- package/types/src/charts/Hexbin/settings.d.ts +122 -0
- package/types/src/charts/Hexbin/tooltip.d.ts +26 -0
- package/types/src/charts/Histogram/binData.d.ts +20 -1
- package/types/src/charts/Histogram/index.d.ts +3 -2
- package/types/src/charts/Histogram/labels.d.ts +7 -0
- package/types/src/charts/Marimekko/index.d.ts +2 -1
- package/types/src/charts/Matrix/applyLayout.d.ts +4 -2
- package/types/src/charts/Network/applyLayout.d.ts +11 -0
- package/types/src/charts/Network/bundle.d.ts +69 -0
- package/types/src/charts/Network/clusterLabels.d.ts +112 -0
- package/types/src/charts/Network/clusters.d.ts +115 -0
- package/types/src/charts/Network/graph.d.ts +73 -0
- package/types/src/charts/Network/graphFluent.d.ts +20 -0
- package/types/src/charts/Network/minNodeDistance.d.ts +18 -0
- package/types/src/charts/Network/polygonRows.d.ts +29 -0
- package/types/src/charts/Pack/applyLayout.d.ts +2 -0
- package/types/src/charts/Pack/groupRows.d.ts +46 -0
- package/types/src/charts/Pack/index.d.ts +3 -0
- package/types/src/charts/Pack/neutralPaint.d.ts +14 -0
- package/types/src/charts/Pack/nodeNames.d.ts +23 -0
- package/types/src/charts/ParallelCoordinates/chrome.d.ts +12 -0
- package/types/src/charts/ParallelCoordinates/index.d.ts +1 -0
- package/types/src/charts/ParallelCoordinates/titles.d.ts +7 -2
- package/types/src/charts/Pie/applyLayout.d.ts +31 -3
- package/types/src/charts/Pie/arcFit.d.ts +63 -0
- package/types/src/charts/Pie/curvedLabels.d.ts +57 -0
- package/types/src/charts/Pie/labelRoom.d.ts +83 -0
- package/types/src/charts/Pie/outsideLabels.d.ts +119 -0
- package/types/src/charts/Pie/outsideNodes.d.ts +93 -0
- package/types/src/charts/Pie/pieLabels.d.ts +85 -0
- package/types/src/charts/Pie/sectorBox.d.ts +95 -0
- package/types/src/charts/Pie/straightLabels.d.ts +24 -0
- package/types/src/charts/Pie/straightLayout.d.ts +88 -0
- package/types/src/charts/Plot/alongLegend.d.ts +42 -0
- package/types/src/charts/Plot/areaEnter.d.ts +34 -0
- package/types/src/charts/Plot/areaLabelsAlong.d.ts +119 -0
- package/types/src/charts/Plot/axisValues.d.ts +24 -0
- package/types/src/charts/Plot/barWidth.d.ts +38 -4
- package/types/src/charts/Plot/circleLabels.d.ts +29 -0
- package/types/src/charts/Plot/connectGaps.d.ts +99 -0
- package/types/src/charts/Plot/connectGapsScene.d.ts +55 -0
- package/types/src/charts/Plot/forecastScene.d.ts +5 -0
- package/types/src/charts/Plot/index.d.ts +16 -15
- package/types/src/charts/Plot/lineLabelEmit.d.ts +48 -0
- package/types/src/charts/Plot/lineLabelSides.d.ts +50 -0
- package/types/src/charts/Plot/lineLabelSpread.d.ts +15 -0
- package/types/src/charts/Plot/lineLabelsAlong.d.ts +116 -0
- package/types/src/charts/Plot/lineMarkerKeys.d.ts +11 -0
- package/types/src/charts/Plot/pipeline.d.ts +15 -1
- package/types/src/charts/Plot/pipelineLineLabels.d.ts +68 -0
- package/types/src/charts/Plot/plotFacet.d.ts +5 -0
- package/types/src/charts/Plot/plotInit.d.ts +14 -0
- package/types/src/charts/Plot/plotRangeBreaks.d.ts +35 -0
- package/types/src/charts/Plot/referenceDomains.d.ts +49 -0
- package/types/src/charts/Plot/shapeLabelLegend.d.ts +19 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +7 -1
- package/types/src/charts/Plot/stackLegendOrder.d.ts +83 -0
- package/types/src/charts/Plot/trendLabels.d.ts +73 -0
- package/types/src/charts/Plot/trendTooltip.d.ts +6 -0
- package/types/src/charts/Priestley/timeAxis.d.ts +79 -0
- package/types/src/charts/Pyramid/gutter.d.ts +28 -6
- package/types/src/charts/Pyramid/scene.d.ts +1 -1
- package/types/src/charts/Radar/applyLayout.d.ts +2 -3
- package/types/src/charts/Radar/axisDecorations.d.ts +12 -4
- package/types/src/charts/Radar/curvedLabels.d.ts +129 -0
- package/types/src/charts/Radar/emit.d.ts +5 -2
- package/types/src/charts/Radar/index.d.ts +7 -2
- package/types/src/charts/Radar/points.d.ts +50 -0
- package/types/src/charts/RadialBar/curvedLabels.d.ts +31 -0
- package/types/src/charts/RadialBar/trackLayout.d.ts +34 -3
- package/types/src/charts/RadialMatrix/applyLayout.d.ts +6 -4
- package/types/src/charts/Rings/emit.d.ts +72 -0
- package/types/src/charts/Rings/index.d.ts +4 -2
- package/types/src/charts/Rings/ringsCurves.d.ts +50 -0
- package/types/src/charts/Rings/ringsGraph.d.ts +39 -7
- package/types/src/charts/Rings/ringsLoops.d.ts +13 -0
- package/types/src/charts/Rings/ringsParallel.d.ts +45 -0
- package/types/src/charts/Rings/ringsPlacement.d.ts +47 -0
- package/types/src/charts/Rings/ringsSizing.d.ts +36 -9
- package/types/src/charts/Sankey/circularLayout.d.ts +103 -0
- package/types/src/charts/Sankey/circularLinks.d.ts +178 -0
- package/types/src/charts/Sankey/emit.d.ts +58 -0
- package/types/src/charts/Sankey/labels.d.ts +19 -0
- package/types/src/charts/Sankey/ribbons.d.ts +36 -0
- package/types/src/charts/Sankey/sankeyCycles.d.ts +24 -0
- package/types/src/charts/Sankey/sankeyLayout.d.ts +6 -0
- package/types/src/charts/Sankey/sankeyLinks.d.ts +36 -0
- package/types/src/charts/Scatter/index.d.ts +15 -0
- package/types/src/charts/SlopeChart/index.d.ts +43 -0
- package/types/src/charts/SlopeChart/slope.d.ts +43 -0
- package/types/src/charts/Streamgraph/index.d.ts +28 -0
- package/types/src/charts/Sunburst/curvedLabels.d.ts +56 -0
- package/types/src/charts/Tree/applyLayout.d.ts +20 -0
- package/types/src/charts/Tree/keys.d.ts +25 -0
- package/types/src/charts/Tree/nodeLabel.d.ts +11 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +26 -0
- package/types/src/charts/definition/makeChart.d.ts +3 -2
- package/types/src/charts/drawSteps/backControl.d.ts +7 -22
- package/types/src/charts/drawSteps/gestureHover.d.ts +33 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +5 -4
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +3 -1
- package/types/src/charts/drawSteps/zoomActions.d.ts +30 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +15 -0
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +16 -1
- package/types/src/charts/drawSteps/zoomDrag.d.ts +71 -0
- package/types/src/charts/drawSteps/zoomFit.d.ts +30 -0
- package/types/src/charts/drawSteps/zoomGesture.d.ts +32 -0
- package/types/src/charts/events/click.legend.d.ts +2 -1
- package/types/src/charts/facet/facetConfig.d.ts +4 -2
- package/types/src/charts/features/annotationFrame.d.ts +108 -0
- package/types/src/charts/features/annotationText.d.ts +57 -0
- package/types/src/charts/features/annotationTypes.d.ts +161 -0
- package/types/src/charts/features/axesMeasure.d.ts +4 -0
- package/types/src/charts/features/axisTooltip.d.ts +49 -0
- package/types/src/charts/features/calloutLayout.d.ts +78 -0
- package/types/src/charts/features/calloutScene.d.ts +40 -0
- package/types/src/charts/features/centerLabel.d.ts +75 -0
- package/types/src/charts/features/chartGeometry.d.ts +1 -1
- package/types/src/charts/features/circleLabelPlacement.d.ts +97 -0
- package/types/src/charts/features/circleLabels.d.ts +130 -0
- package/types/src/charts/features/colorScaleBivariate.d.ts +50 -0
- package/types/src/charts/features/colorScaleBucket.d.ts +10 -0
- package/types/src/charts/features/colorScaleHover.d.ts +13 -3
- package/types/src/charts/features/colorScaleLimit.d.ts +60 -0
- package/types/src/charts/features/colorScaleTooltip.d.ts +43 -0
- package/types/src/charts/features/colorScaleTop.d.ts +30 -0
- package/types/src/charts/features/colorScaleValue.d.ts +35 -0
- package/types/src/charts/features/curvedArrows.d.ts +119 -0
- package/types/src/charts/features/depthKey.d.ts +19 -0
- package/types/src/charts/features/edgeArrows.d.ts +103 -4
- package/types/src/charts/features/edgeBundling.d.ts +86 -0
- package/types/src/charts/features/edgeBundlingSmooth.d.ts +29 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +19 -1
- package/types/src/charts/features/featuresLegend.d.ts +4 -3
- package/types/src/charts/features/hoverTicks.d.ts +30 -0
- package/types/src/charts/features/idleQueue.d.ts +46 -0
- package/types/src/charts/features/legendKeys.d.ts +34 -0
- package/types/src/charts/features/lineLabels.d.ts +15 -12
- package/types/src/charts/features/linkBundle.d.ts +16 -0
- package/types/src/charts/features/linkColor.d.ts +48 -0
- package/types/src/charts/features/linkFields.d.ts +16 -0
- package/types/src/charts/features/linkFocus.d.ts +51 -0
- package/types/src/charts/features/linkInteraction.d.ts +192 -0
- package/types/src/charts/features/linkKeys.d.ts +11 -0
- package/types/src/charts/features/linkLabelGeometry.d.ts +67 -0
- package/types/src/charts/features/linkLabelPath.d.ts +85 -0
- package/types/src/charts/features/linkLabels.d.ts +77 -0
- package/types/src/charts/features/linkWidths.d.ts +19 -0
- package/types/src/charts/features/networkMeasures.d.ts +53 -0
- package/types/src/charts/features/nodeStats.d.ts +93 -0
- package/types/src/charts/features/pathLabelGeometry.d.ts +99 -0
- package/types/src/charts/features/pathLabels.d.ts +41 -0
- package/types/src/charts/features/plotAnnotations.d.ts +23 -8
- package/types/src/charts/features/plotEndLabels.d.ts +14 -1
- package/types/src/charts/features/plotPaint.d.ts +17 -0
- package/types/src/charts/features/polyline.d.ts +32 -0
- package/types/src/charts/features/referenceAnnotations.d.ts +130 -0
- package/types/src/charts/features/referenceLabelPlacement.d.ts +58 -0
- package/types/src/charts/features/ringLabelNodes.d.ts +63 -0
- package/types/src/charts/features/ringLabels.d.ts +164 -0
- package/types/src/charts/features/sceneBounds.d.ts +6 -0
- package/types/src/charts/features/selfLoops.d.ts +165 -0
- package/types/src/charts/features/shapeEmit.d.ts +3 -1
- package/types/src/charts/features/sharedFields.d.ts +11 -2
- package/types/src/charts/features/textHalo.d.ts +15 -0
- package/types/src/charts/index.d.ts +8 -0
- package/types/src/charts/partition/chartFields.d.ts +6 -1
- package/types/src/charts/partition/interaction.d.ts +6 -3
- package/types/src/charts/partition/zoom.d.ts +4 -4
- package/types/src/charts/pipeline/insetPlacement.d.ts +6 -0
- package/types/src/charts/pipeline/preDrawData.d.ts +14 -1
- package/types/src/charts/pipeline/stages.d.ts +7 -0
- package/types/src/charts/plotBuffers/discreteBuffer.d.ts +0 -5
- package/types/src/charts/polar/chrome.d.ts +19 -6
- package/types/src/charts/viz/Viz.d.ts +25 -4
- package/types/src/charts/viz/VizBase.d.ts +37 -8
- package/types/src/charts/viz/backgroundInk.d.ts +19 -4
- package/types/src/charts/viz/emphasis.d.ts +17 -0
- package/types/src/charts/viz/fillStroke.d.ts +7 -0
- package/types/src/charts/viz/focusRing.d.ts +25 -0
- package/types/src/charts/viz/focusTargets.d.ts +56 -0
- package/types/src/charts/viz/history.d.ts +35 -0
- package/types/src/charts/viz/keyboardNav.d.ts +55 -0
- package/types/src/charts/viz/keyboardNavHost.d.ts +53 -0
- package/types/src/charts/viz/loaderFormat.d.ts +78 -0
- package/types/src/charts/viz/mountTarget.d.ts +7 -0
- package/types/src/charts/viz/nearestHover.d.ts +75 -0
- package/types/src/charts/viz/nearestHoverSurface.d.ts +21 -0
- package/types/src/charts/viz/ordinalColor.d.ts +10 -8
- package/types/src/charts/viz/pageTheme.d.ts +34 -0
- package/types/src/charts/viz/pointTooltipAnchor.d.ts +36 -0
- package/types/src/charts/viz/pointVoronoi.d.ts +65 -0
- package/types/src/charts/viz/reducedMotion.d.ts +25 -0
- package/types/src/charts/viz/reportDrawError.d.ts +12 -0
- package/types/src/charts/viz/setCursor.d.ts +26 -0
- package/types/src/charts/viz/tooltipEnabled.d.ts +31 -0
- package/types/src/charts/viz/userClick.d.ts +35 -0
- package/types/src/charts/viz/vizDefaults.d.ts +0 -9
- package/types/src/charts/viz/vizFields.d.ts +37 -0
- package/types/src/charts/viz/vizRender.d.ts +2 -1
- package/types/src/charts/viz/vizTheme.d.ts +40 -0
- package/types/src/charts/viz/vizTypes.d.ts +100 -7
- package/types/src/charts/viz/vizVisibility.d.ts +13 -0
- package/types/src/components/Axis/Axis.d.ts +34 -3
- package/types/src/components/Axis/AxisBottom.d.ts +1 -0
- package/types/src/components/Axis/AxisLeft.d.ts +1 -0
- package/types/src/components/Axis/AxisRight.d.ts +1 -0
- package/types/src/components/Axis/AxisTop.d.ts +1 -0
- package/types/src/components/Axis/axisBreak.d.ts +21 -3
- package/types/src/components/Axis/axisDefaults.d.ts +12 -0
- package/types/src/components/Axis/axisLabelKinds.d.ts +22 -0
- package/types/src/components/Axis/axisLabelLineHeight.d.ts +27 -0
- package/types/src/components/Axis/axisLabelRoom.d.ts +17 -0
- package/types/src/components/Axis/axisLabelSize.d.ts +82 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +38 -2
- package/types/src/components/Axis/axisLayout.d.ts +9 -2
- package/types/src/components/Axis/axisLayoutLabels.d.ts +28 -33
- package/types/src/components/Axis/axisLayoutScale.d.ts +3 -1
- package/types/src/components/Axis/axisLimit.d.ts +18 -0
- package/types/src/components/Axis/axisMaxSize.d.ts +48 -0
- package/types/src/components/Axis/axisRangeBreaks.d.ts +25 -0
- package/types/src/components/Axis/axisRounding.d.ts +8 -0
- package/types/src/components/Axis/axisTitle.d.ts +30 -0
- package/types/src/components/Axis/axisTooltipTargets.d.ts +82 -0
- package/types/src/components/Axis/brokenTimeScale.d.ts +51 -0
- package/types/src/components/Axis/rangeBreaks.d.ts +82 -0
- package/types/src/components/Axis/timeValues.d.ts +1 -1
- package/types/src/components/ColorScale/ColorScale.d.ts +22 -11
- package/types/src/components/ColorScale/bivariateRender.d.ts +53 -0
- package/types/src/components/ColorScale/bivariateScale.d.ts +92 -0
- package/types/src/components/ColorScale/bucketBounds.d.ts +15 -1
- package/types/src/components/ColorScale/colorScaleSwatchTooltips.d.ts +48 -0
- package/types/src/components/Legend/Legend.d.ts +6 -0
- package/types/src/components/Legend/legendCut.d.ts +31 -0
- package/types/src/components/Legend/legendRender.d.ts +6 -1
- package/types/src/components/SizeLegend/SizeLegend.d.ts +1 -0
- package/types/src/components/TextBox.d.ts +5 -0
- package/types/src/components/Timeline/Timeline.d.ts +1 -0
- package/types/src/components/Timeline/timelineConfig.d.ts +5 -0
- package/types/src/components/Timeline/timelineMode.d.ts +17 -0
- package/types/src/components/Tooltip.d.ts +4 -3
- package/types/src/components/fontStack.d.ts +10 -0
- package/types/src/components/textBoxLayout.d.ts +18 -9
- package/types/src/components/textBoxPath.d.ts +59 -0
- package/types/src/components/textBoxScene.d.ts +51 -0
- package/types/src/components/textBoxWords.d.ts +33 -0
- package/types/src/components/textEllipsis.d.ts +6 -0
- package/types/src/fluent.d.ts +18 -0
- package/types/src/shapes/Area.d.ts +1 -0
- package/types/src/shapes/Bar.d.ts +1 -0
- package/types/src/shapes/Box.d.ts +1 -0
- package/types/src/shapes/Circle.d.ts +1 -0
- package/types/src/shapes/Line.d.ts +1 -0
- package/types/src/shapes/Path.d.ts +1 -0
- package/types/src/shapes/Rect.d.ts +1 -0
- package/types/src/shapes/Shape.d.ts +1 -0
- package/types/src/shapes/Whisker.d.ts +1 -0
- package/types/src/shapes/emitLabels.d.ts +1 -1
- package/types/src/utils/BaseClass.d.ts +9 -0
- package/types/src/utils/D3plusConfig.d.ts +1093 -266
- package/types/src/utils/configPrep.d.ts +2 -0
- package/types/src/utils/configValue.d.ts +8 -0
- package/types/src/utils/constant.d.ts +8 -0
- package/types/src/utils/displayName.d.ts +10 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/src/utils/theme.d.ts +170 -0
- package/types/src/utils/themeInk.d.ts +56 -0
- package/types/umd-entry.d.ts +4 -0
- package/umd/d3plus-core.full.js +72239 -41465
- package/umd/d3plus-core.full.min.js +2 -2
- package/umd/d3plus-core.js +46249 -19519
- package/umd/d3plus-core.min.js +2 -2
- package/es/src/components/Axis/gridStroke.js +0 -10
- package/types/src/components/Axis/gridStroke.d.ts +0 -8
package/umd/d3plus-core.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.12.0
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
4
|
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-selection"),require("@d3plus/dom"),require("@d3plus/render"),require("@d3plus/data"),require("@d3plus/text"),require("@d3plus/color"),require("d3-scale"),require("@d3plus/locales"),require("d3-color"),require("d3-array"),require("d3-transition"),require("@d3plus/format"),require("@d3plus/math"),require("@floating-ui/dom"),require("d3-brush"),require("d3-time-format"),require("d3-shape"),require("d3-interpolate"),require("d3-zoom"),require("@d3plus/export"),require("d3-time"),require("d3-chord"),require("d3-tile"),require("d3-geo"),require("topojson-client"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-hierarchy"),require("d3-force"),require("d3-polygon")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","d3-selection","@d3plus/dom","@d3plus/render","@d3plus/data","@d3plus/text","@d3plus/color","d3-scale","@d3plus/locales","d3-color","d3-array","d3-transition","@d3plus/format","@d3plus/math","@floating-ui/dom","d3-brush","d3-time-format","d3-shape","d3-interpolate","d3-zoom","@d3plus/export","d3-time","d3-chord","d3-tile","d3-geo","topojson-client","d3-geo-projection","d3-composite-projections","d3-hierarchy","d3-force","d3-polygon"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3plus=e.d3plus||{},e.d3,e.d3plus,e.d3plus,e.d3plus,e.d3plus,e.d3plus,e.d3,e.d3plus,e.d3,e.d3,e.d3,e.d3plus,e.d3plus,e.FloatingUIDOM,e.d3,e.d3,e.d3,e.d3,e.d3,e.d3plus,e.d3,e.d3,e.d3,e.d3,e.topojson,e.d3,e.d3,e.d3,e.d3,e.d3)}(this,function(e,t,n,i,o,a,r,s,c,l,h,u,d,f,m,p,g,y,x,b,_,k,v,w,S,C,M,$,A,z,D){"use strict";function F(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var B=F(s),L=F(y),P=F(S),R=F($),E=Object.freeze({__proto__:null,get Area(){return Io},get Bar(){return Vo},get Box(){return Sa},get Circle(){return Uo},get Image(){return Ma},get Line(){return ya},get Path(){return Aa},get Rect(){return Yo},get Shape(){return jo},get Whisker(){return _a}});function N(e){return function(){return e}}function T(e,t){return void 0===t?t=>t[e]:n=>void 0===n[e]?t:n[e]}const O="D3PLUS-COMMON-RESET";function W(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}const j=Symbol("d3plus.resolvesReset");function H(e){return W(e)?I({},e):Array.isArray(e)?e.slice():e}function I(e,t,n){for(const i of Object.keys(t)){const o=t[i],a=W(n)?n[i]:void 0;if(o===O)void 0===a?delete e[i]:e[i]=H(a);else if(W(o)){const t=e[i];e[i]=I(W(t)?t:{},o,a)}else e[i]=H(o)}return e}function G(e,t,n){return I(H(e),t,n)}function V(e){return e===O||W(e)&&Object.values(e).some(V)}function q(e,t){if("function"==typeof e.coerce)return e.coerce(t);switch(e.coerce){case"accessor":return"function"==typeof t?t:"string"==typeof t?T(t):N(t);case"const":return"function"==typeof t?t:N(t);default:return t}}function Y(e,t,n,i){const o=V(n)?e._defaultConfig?.()[t]:void 0;if(n===O)return W(o)?G({},o):{};const a=arguments.length>3?i:e.schema[t];return G(W(a)?a:{},W(n)?n:{},o)}function K(e,...t){for(const n of t){const t=e[n];if("function"!=typeof t)throw new Error(`resolvesReset: "${n}" is not a method`);t[j]=!0}}function U(e,t,n){return n===O?H(e._defaultConfig?.()[t]):Y(e,t,n)}const X=Symbol("d3plus.fluentAccessor"),Q=new WeakMap;function Z(e){return"function"==typeof e&&X in e}function J(e,t){for(let n=e;n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return!Z(e.value)}return!1}function ee(e,t,n={}){e.schema||(e.schema={});for(const i of t){const t=i.key,o=t in n;if("default"in i||void 0!==i.factory){const n="default"in i?i.default:i.factory(e);let o=q(i,n);i.decorate&&(o=i.decorate(e,o));const a=e.schema[t],r=i.merge&&W(o)?G(W(a)?a:{},o):o;e.schema[t]=r,i.onSet?.(e,r)}else if(o&&void 0===e.schema[t]){const o=q(i,n[t]);e.schema[t]=o,i.onSet?.(e,o)}}const i=Object.getPrototypeOf(e);if(!i)return;let o=Q.get(i);if(o||Q.set(i,o=new WeakSet),!o.has(t)){o.add(t);for(const e of t){if(J(i,e.key))continue;const t=e.key;i[t]=function(...n){if(!n.length)return this.schema[t];const i=q(e,n[0]),o=e.merge?U(this,t,i):i;return this.schema[t]=o,e.onSet?.(this,o),this},e.merge&&(i[t][j]=!0),Object.defineProperty(i[t],X,{value:!0})}}}const te={drawDepth:"_drawDepth",id:"_id",ids:"_ids",drawLabel:"_drawLabel",timeFilter:"_timeFilter",filteredData:"_filteredData",legendData:"_legendData"};function ne(e,t){let n=e;const i=e.viz;for(const e of t){const t=e(n);n=Object.assign({},n,t);for(const e of Object.keys(t)){const n=te[e],o=t[e];n&&void 0!==o&&(i[n]=o)}}return n}function ie(e){return{width:e.schema.width-e._margin.left-e._margin.right,height:e.schema.height-e._margin.top-e._margin.bottom}}function oe(e,t,n){return{x:e._margin.left+t/2,y:e._margin.top+n/2}}function ae(e){const{width:t,height:n}=ie(e);return{type:"rect",x:e._margin.left,y:e._margin.top,width:t,height:n}}const re=e=>Number(n.date(Number(e)));function se(e,t,i,o){const a=e._xFunc,r=e._yFunc,s=e._x,c=e._y,l=e._id,h=e.schema.time;if(!(a&&r&&s&&c&&e._data&&h))return[];const u=function(e){const t=new Set,n=e=>!0===e||"number"==typeof e&&e>0,i=e=>{for(const o of e)!n(o.trailPersist)||"circle"!==o.type&&"rect"!==o.type||t.add(o.key),"group"===o.type&&i(o.children)};return i(e.root.children),t}(t);if(!u.size)return[];const d=new Set;e._data.forEach((e,t)=>d.add(re(h(e,t))));const f=[...d].filter(e=>e>i&&e<o).sort((e,t)=>e-t);if(!f.length)return[];const m=new Map;e._data.forEach((e,t)=>{const n=l(e,t);if(!u.has(n))return;let i=m.get(n);i||m.set(n,i=new Map),i.set(re(h(e,t)),{d:e,i:t})});const p=t=>e._yTime?n.date(t):t;return f.map(t=>({sequence:t,positions:[...u].flatMap(i=>{const o=m.get(i)?.get(t);return o?[{key:i,x:a((l=s(o.d,o.i),e._xTime?n.date(l):l)),y:r(p(c(o.d,o.i)))}]:[];var l})})).filter(e=>e.positions.length>0)}const ce=new WeakSet,le=new Set,he=new WeakMap;let ue=!0;function de(e){return ce.add(e),e}function fe(e){return"object"==typeof e&&null!==e&&ce.has(e)}function me(e,t){pe(`${e} received unknown property "${t}".`)}function pe(e){ue&&!le.has(e)&&(le.add(e),console.warn(e))}function ge(e,t,n){if(!ue)return;let i=he.get(e);i||he.set(e,i=new Set),i.has(t)||(i.add(t),console.warn(n))}const ye=["d3plus-render-svg","d3plus-render-canvas"];function xe(e){return(e?.elements?.()??[]).filter(e=>"svg"===e.localName||"canvas"===e.localName)}const be=new WeakMap;function _e(e){const t=(Array.isArray(e)?e:[e]).flatMap(e=>"string"==typeof e?e.split(/\s+/).filter(Boolean):[]);return Array.from(new Set(t))}function ke(e,t,n=[]){const i=_e(t);for(const t of be.get(e)??[])i.includes(t)||n.includes(t)||e.classList.remove(t);for(const t of i)e.classList.add(t);be.set(e,i)}function ve(e){for(const{el:t,keep:n}of e._classNameTargets())ke(t,e.schema.className,n)}const we=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");function Se(e,t){if(!W(e)||!V(e))return e;const i={...e},o=n.isObject(t)?t:{};for(const e of Object.keys(i))e.startsWith("_")||(i[e]===O?void 0===o[e]?delete i[e]:i[e]=o[e]:i[e]=Se(i[e],o[e]));return i}function Ce(e){let t=[];do{t=t.concat(Object.getOwnPropertyNames(e)),e=Object.getPrototypeOf(e)}while(e&&e!==Object.prototype);return t.filter(e=>0!==e.indexOf("_")&&!["config","constructor","destroy","measure","parent","render","renderMode","toScene"].includes(e))}function Me(e,t,n){if(!n.has(e)){n.add(e),e.schema.colorDefaults={...e.schema.colorDefaults,...t};for(const i of[...Object.values(e),...Object.values(e.ctx)])i instanceof $e&&Me(i,t,n)}}class $e{config(e){const t=this._defaultConfig();if(arguments.length){for(const n in e)if({}.hasOwnProperty.call(e,n))if(n in this){const i=e[n],o=this[n];i===O&&"on"===n?this.schema.on=t[n]:o[j]?o.call(this,i):i===O?o.call(this,t[n]):o.call(this,Se(i,t[n]))}else fe(e)||me(`${this.constructor.name}.config()`,n);return this}{const e={};return Ce(Object.getPrototypeOf(this)).forEach(t=>{e[t]=this[t]()}),e}}_defaultConfig(){if(!this._configDefault){const e={};Ce(Object.getPrototypeOf(this)).forEach(t=>{const i=this[t]();i!==this&&(e[t]=n.isObject(i)?n.assign({},i):i)}),this._configDefault=e}return this._configDefault}locale(e){return arguments.length?(this.schema.locale=c.findLocale(e),this):this.schema.locale}className(e){return arguments.length?(this.schema.className=e,ve(this),this):this.schema.className}_classNameTargets(){return xe(this._sceneRenderer).map(e=>({el:e,keep:ye}))}colorDefaults(e){if(!arguments.length)return this.schema.colorDefaults;const{scale:t,...n}=e??{},i={...n};return Array.isArray(t)?i.scale=s.scaleOrdinal().range(t):t&&(i.scale=t),Me(this,i,new WeakSet),this}on(e,t){return 2===arguments.length?(this.schema.on[e]=t,this):arguments.length?"string"==typeof e?this.schema.on[e]:(this.schema.on=Object.assign({},this.schema.on,e),this):this.schema.on}parent(e){return arguments.length?(this.schema.parent=e,this):this.schema.parent}translate(e){return arguments.length?(this.schema.translate=e,this):this.schema.translate}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}constructor(){this.schema={},this.ctx={},this.schema.colorDefaults={...r.colorDefaults},this.schema.locale="en-US",this.schema.on={},this.schema.parent={},this.schema.translate=(e,t=this.schema.locale)=>{const n=c.translateLocale[t],i=e;return n&&n[i]?n[i]:e},this._uuid=crypto.randomUUID()}}function Ae(e=this.schema.shapeConfig,t="shape",n=!1){const i={duration:this.schema.duration,on:{}},o=e=>(t,n,i,o)=>{if(!e)return e;let a;for(;t.__d3plus__;)a&&(t.__d3plusParent__=a),a=t,n=t.i,t=t.data||t.feature;return e.bind(this)(t,n,i||a,o)},a=(e,n)=>{for(const i in n)({}.hasOwnProperty.call(n,i)&&!i.includes(".")||i.includes(`.${t}`))&&(e.on[i]=o(n[i]))},r=e=>e.map(e=>e instanceof Array?r(e):"object"==typeof e?s({},e):"function"==typeof e?o(e):e),s=(e,t)=>{for(const n in t)({}).hasOwnProperty.call(t,n)&&("on"===n?a(e,t[n]):"sort"===n?e[n]=t[n]:"function"==typeof t[n]?e[n]=o(t[n]):t[n]instanceof Array?e[n]=r(t[n]):"object"==typeof t[n]?(e[n]||(e[n]={}),e[n].on={},s(e[n],t[n])):e[n]=t[n]);return e};return s(i,e),this.schema.on&&a(i,this.schema.on),n&&e[n]&&(s(i,e[n]),e[n].on&&a(i,e[n].on)),de(i)}function ze(e,t,n){return t[e]||this.schema[e](t,n)}function De(e){const t=e._select,n=t&&"function"==typeof t.node?t.node():null;if(!(n instanceof Element))return;const o=n,a=e.schema.width??400,r=e.schema.height??200;e._sceneRenderer?e._sceneRenderer.resize(a,r):(e._sceneRenderer=new i.SvgRenderer,e._sceneRenderer.mount({container:o,width:a,height:r}));const s={root:{type:"group",key:"root",children:[e.toScene()]},width:a,height:r};e._sceneRenderer.drawScene(s,{duration:0}),ve(e)}K($e.prototype,"shapeConfig");const Fe=new WeakMap;function Be(e){const t=T(e);return"string"==typeof e&&Fe.set(t,e),t}function Le(e){return"function"==typeof e?Fe.get(e):void 0}const Pe={fontSize:12,fontWeight:600,padding:4,textAnchor:"middle"},Re=4/3;function Ee(e){return"function"==typeof e?e:"string"==typeof e&&e?Be(e):void 0}function Ne(e){const t=e??{},n=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0;return{columns:n(t.columns),rows:n(t.rows),padding:"number"==typeof t.padding&&t.padding>=0?t.padding:20,sort:t.sort??"ascending",scales:"shared"===t.scales||"independent"===t.scales?t.scales:void 0,axes:Oe(t.axes),title:!1===t.title||"function"==typeof t.title?t.title:void 0,titleConfig:{...Pe,...t.titleConfig??{}}}}const Te=e=>"outer"===e||"all"===e;function Oe(e){if(Te(e))return e;if(!e||"object"!=typeof e)return;const{x:t,y:n}=e,i={};return Te(t)&&(i.x=t),Te(n)&&(i.y=n),i.x||i.y?i:void 0}function We(e,t){return"object"==typeof e?e[t]:e}function je(e,t,n,i){const o="function"==typeof n.axes?n.axes(e):n.axes,a=n.fixedAxes?n.fixedAxes(e):{},r=e=>"outer"===(We(t.axes,e)??We(o,e)??"outer")&&(i||!!a[e]);return{x:r("x"),y:r("y")}}function He(e,t){return"shared"===(e.scales??t.scales??"shared")}function Ie(e){return"function"==typeof e.schema.facet}const Ge="__d3plusGroupDepth",Ve="__d3plusGroupLabel";function qe(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function Ye(e){const t=qe(e),n=t?t[Ge]:void 0;return"number"==typeof n?n:void 0}function Ke(e,t,n){const i=qe(t);return e.slice(0,n+1).map(e=>e(i,0))}function Ue(e,t,n,i){const o=qe(n);return!!o&&t.every((t,n)=>{const a=e[n](o,i);return a===t||Array.isArray(a)&&a.includes(t)})}function Xe(e,t,n){return n.some((n,i)=>!Ue(e,t,n,i))}const Qe=new Set(["rect","circle","line","area","path"]);function Ze(e,t){const n=new Set,i=e=>{if(Qe.has(e.type)&&void 0!==e.datum){const i=e.datum,o=i&&i.data?i.data:i;if(void 0!==o&&!n.has(o)){n.add(o);const i="number"==typeof e.index?e.index:"number"==typeof o.i?o.i:0;t(o,i,e)}}const o=e.children;o&&o.forEach(i)};e.forEach(i)}const Je=new Map,et=new Map,tt=new Set,nt=new WeakMap;function it(e){const t=e.schema.link;if(!t)return null;const n="string"==typeof t?{group:t}:t;if(!n.group)return null;const i="function"==typeof n.by?n.by:"string"==typeof n.by?T(n.by):(t,n)=>e._id?.(t,n);return{group:n.group,by:i,hover:!1!==n.hover,active:!1!==n.active,highlight:!1!==n.highlight,legend:!1!==n.legend,color:!1!==n.color}}function ot(e){at(e);const t=it(e);if(!t)return;let n=Je.get(t.group);n||Je.set(t.group,n=new Set),n.add(e),e._linkGroup=t.group}function at(e){const t=e._linkGroup;if(void 0===t)return;const n=Je.get(t);n&&(n.delete(e),n.size||(Je.delete(t),et.delete(t))),e._linkGroup=void 0}function rt(e){const t=e.schema.colorDefaults,n=e._linkGroup;if(void 0===n||t.scale!==e._autoColorScale)return t;if(!it(e)?.color)return t;let i=et.get(n);return i||(i=s.scaleOrdinal().range(t.scale.range()),et.set(n,i)),{...t,scale:i}}function st(e){const t=Array.isArray(e)?e:[e],n=[];for(const e of t)null!=e&&n.push(e instanceof Date?""+ +e:`${e}`);return n}function ct(e,t,n){const i=new Set,o=(e,o)=>{if(n(e,o))for(const n of st(t(e,o)))i.add(n)},a=e._chartScene;return a&&a.length?Ze(a,o):(e._filteredData??[]).forEach(o),i}function lt(e,t){return(n,i)=>st(e.by(n,i)).some(e=>t.has(e))}function ht(e,t){nt.set(e,t)}function ut(e,t,n){if(tt.has(t.group))return;const i=Je.get(t.group);if(i&&!(i.size<2)){tt.add(t.group);try{for(const t of i){if(t===e)continue;const i=it(t);i&&n(t,i)}}finally{tt.delete(t.group)}}}function dt(e,t,n){const i=nt.get(e);if(nt.delete(e),void 0===n)return;const o=it(e);if(!o||!o[t])return;const a="function"==typeof n?i??n:null;let r=null;ut(e,o,(n,i)=>{if(!i[t])return;const s=n[t];s&&(a&&!r&&(r=ct(e,o.by,a)),s.call(n,!!r&<(i,r)))})}function ft(e,t,n){const i=e._id(t,n);return Array.isArray(i)?i:[i]}function mt(e,t,n){const i=new Set;return n.length?((e._legendData??[]).forEach((o,a)=>{if(ft(e,o,a).some(e=>n.includes(e)))for(const e of st(t.by(o,a)))i.add(e)}),i):i}function pt(e){const t=it(e);if(!t||!t.legend)return;const n=mt(e,t,e._hidden),i=mt(e,t,e._solo);ut(e,t,(e,t)=>{if(!t.legend||!e._legendData?.length)return;const o=[],a=[];e._legendData.forEach((r,s)=>{const c=st(t.by(r,s)),l=ft(e,r,s),h=e=>{for(const t of l)e.includes(t)||e.push(t)};i.size&&c.some(e=>i.has(e))?h(a):n.size&&c.length&&c.every(e=>n.has(e))&&h(o)});const r=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e));r(o,e._hidden)&&r(a,e._solo)||(e._hidden=a.length?[]:o,e._solo=a,e.render?.())})}function gt(e){const t=e.schema.shapeConfig;return Boolean(e._hoverOutline)||1!==t?.hoverOpacity}const yt={},xt=new WeakMap;function bt(){return"undefined"!=typeof IntersectionObserver}function _t(e,n,i,o=0,a){const r=function(e){return!e||"undefined"!=typeof window&&e===window?null:"string"==typeof e?t.select(e).node():"undefined"!=typeof Element&&e instanceof Element?e:null}(n),s=r||yt;let c=xt.get(s);if(!c){const e=new Map,t=new IntersectionObserver(t=>{t.forEach(t=>{e.get(t.target)?.forEach(e=>{clearTimeout(e.timer),e.timer=void 0,t.isIntersecting?e.delay>0?e.timer=setTimeout(e.onVisible,e.delay):e.onVisible():e.onHidden?.()})})},{root:r,rootMargin:"25% 0px"});c={targets:e,io:t},xt.set(s,c)}const{targets:l,io:h}=c,u={delay:o,onHidden:a,onVisible:i};let d=l.get(e);return d||l.set(e,d=new Set),d.add(u),h.unobserve(e),h.observe(e),()=>{clearTimeout(u.timer),d.delete(u),d.size||(l.delete(e),h.unobserve(e))}}function kt(e){if(!(e.schema.detectVisible&&e.schema.detectVisibleUnload&&bt()))return e._unloadUnobserve?.(),void(e._unloadUnobserve=void 0);e._unloadUnobserve||(e._unloadUnobserve=_t(e._select.node(),e.schema.scrollContainer,()=>function(e){e._unloaded&&(e._unloaded=!1,e._instantNextDraw=!0,e._forceVisible=!0,e.render())}(e),0,()=>function(e){if(e._unloaded)return;e._unloaded=!0,e._resizePoll=clearTimeout(e._resizePoll);const t=e._select.node()?.parentNode;t&&e._resizeObserver?.unobserve(t),e._tooltipClass.data([]).render(),null!=e._sceneRepaintRAF&&(cancelAnimationFrame(e._sceneRepaintRAF),e._sceneRepaintRAF=void 0),e._sceneRenderer&&"function"==typeof e._sceneRenderer.destroy&&(e._sceneRenderer.destroy(),e._sceneRenderer=void 0),e._select.selectAll("g.data-table").remove()}(e)))}function vt(e){return e instanceof Array?e.some(o.isData):o.isData(e)}function wt(e){const t=JSON.stringify(e)??"";let n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`${t.length}:${(n>>>0).toString(36)}`}function St(e,t,n){return new Promise((i,a)=>{let r;const s={_cache:!1,_lrucache:e._lrucache,_data:[],config:e=>{r=e}},c=function(e){return(e instanceof Array?e:[e]).map(e=>{if(!o.isData(e))return e;if("string"==typeof e)return{url:e,cache:"no-cache"};const t=e;return"cache"in t?t:{...t,cache:"no-cache"}})}(t);o.load.call(s,c,n,"data",(e,t)=>{e?a(e):i({data:t??[],config:r})})})}function Ct(e){e._dataPollStop?.(),e._dataPollStop=void 0,e._dataPollFor=void 0}function Mt(e){return[e.schema.dataPollingInterval,e._userData,e._userDataFormat,e.schema.detectVisible,e.schema.scrollContainer]}function $t(e,t){const n=e._userData,i=e._userDataFormat,o=e._select?.node()?.ownerDocument;let a=!1;const r=function(e){let t,n=!1,i=!1,o=!1,a=!1;const r=()=>{t=setTimeout(c,e.interval)},s=()=>{o=!1,i=!0,Promise.resolve().then(e.fetch).then(t=>{n||(a=!1,e.onData(t))},t=>{n||(a||e.onError(t),a=!0)}).catch(t=>{n||e.onError(t)}).finally(()=>{i=!1,n||r()})};function c(){t=void 0,n||(e.paused()?o=!0:s())}return r(),{stop(){n=!0,clearTimeout(t),t=void 0},resume(){n||!o||i||e.paused()||s()}}}({interval:t,fetch:()=>St(e,n,i),onData:t=>function(e,{data:t,config:n}){const i=wt(t);i!==e._dataSignature&&(e._dataSignature=i,n&&e.config(n),e._data=t,e.schema.timeFilter||(e._timelineSelection=!1),e.render())}(e,t),onError:e=>{console.warn("d3plus: dataPollingInterval could not refresh the data; keeping the last data and retrying.",e)},paused:()=>a||"hidden"===o?.visibilityState}),s=()=>{"hidden"!==o?.visibilityState&&r.resume()};o?.addEventListener("visibilitychange",s);const c=e.schema.detectVisible&&bt()?_t(e._select.node(),e.schema.scrollContainer,()=>{a=!1,r.resume()},0,()=>{a=!0}):void 0;e._dataPollFor=Mt(e),e._dataPollStop=()=>{r.stop(),o?.removeEventListener("visibilitychange",s),c?.()}}function At(e){const t=e.schema.dataPollingInterval,n="number"==typeof t&&t>0&&isFinite(t);if(n&&!vt(e._userData)&&pe(`${e.constructor.name}: dataPollingInterval only polls data loaded from a URL.`),!n||e._ssr||!vt(e._userData))return void Ct(e);const i=Mt(e),o=e._dataPollFor;o&&o.every((e,t)=>e===i[t])||(Ct(e),$t(e,t))}function zt(e=a.textSplit){return(t,n)=>e(t,n).reduce((e,t)=>{const n=e.length-1;return n>=0&&e[n].endsWith(a.softHyphen)?e[n]=e[n].slice(0,-1)+t:e.push(t),e},[])}const Dt=zt();function Ft(e,t){if(e.truncated)return{fits:!1,result:e};if(!e.lines.slice(0,-1).some(e=>e.endsWith("-")))return{fits:!0,result:e};const n=t();return n.truncated?{fits:!1,result:e}:{fits:!0,result:n}}function Bt(e){let t=(e%360+360)%360;return t>180&&(t-=360),t>90?t-=180:t<-90&&(t+=180),0===t?0:t}function Lt(e){return"number"==typeof e&&Number.isFinite(e)?Bt(e):-90}const Pt={rotate:!1,angle:0,slant:!1};const Rt=e=>"top"===e?30:-30;function Et(e){return"number"==typeof e?Number.isFinite(e)&&0!==Bt(e):!0===e}function Nt(e,t){return!(!Et(e)||"number"!=typeof e)&&(!t||90!==Math.abs(Bt(e)))}function Tt(e,t){const n=Math.abs(e)*Math.PI/180;return t?n:Math.PI/2-n}function Ot(e){return"bottom"===e?{x:0,y:1}:"top"===e?{x:0,y:-1}:"left"===e?{x:-1,y:0}:{x:1,y:0}}function Wt(e,t){const n=t*Math.PI/180,i=Ot(e),o=Math.cos(n)*i.x+Math.sin(n)*i.y;return Math.abs(o)<1e-9?"middle":o<0?"end":"start"}function jt(e,t,n,i,o,a){const r=t*Math.PI/180,s=Math.cos(r),c=Math.sin(r),l=-Math.sin(r),h=Math.cos(r),u=Ot(e),d=Wt(e,t),f=Math.abs(l*u.x+h*u.y),m=u.x*(a+i/2*f),p=u.y*(a+i/2*f),g="end"===d?n:"start"===d?0:n/2,y=i/2,x=(e,t)=>({x:m+(e-g)*s+(t-y)*l,y:p+(e-g)*c+(t-y)*h}),b=x(n/2,o/2);return{x:b.x-n/2,y:b.y-o/2,width:n,height:o,corners:[x(0,0),x(n,0),x(n,i),x(0,i)]}}function Ht(e,t,n,i){const o="top"===e||"bottom"===e,a=jt(e,t,n,i,i,0).corners.map(e=>o?e.x:e.y);return[Math.max(0,-Math.min(...a)),Math.max(0,Math.max(...a))]}function It(e,t,n,i,o){const a=Tt(e,t),r=Math.sin(a);return r<1e-9?{width:i,height:n}:{width:Math.max(0,(n-o*Math.cos(a))/r),height:Math.max(o,i*r)}}function Gt(e,t,i){if(t<2)return i;const o=e.map(({text:e,fontFamily:o,fontSize:r,lineHeight:s})=>{const c={"font-family":o,"font-size":r},l=n.textWidth(`${e}`,c),h=`${e}`.split(/\s+/).filter(Boolean),u=Math.max(0,...h.map(e=>n.textWidth(e,c))),d=a.textWrap().fontFamily(o).fontSize(r).lineHeight(s).split(Dt).height(s*(t+1));return function(e,t,n,i,o=1.08){for(let a=Math.max(1,n);a<i;a*=o)if(e(a)<=t)return Math.ceil(a);return i}(t=>d.width(t)(`${e}`).lines.filter(e=>""!==e).length,t,Math.max(u+1,l/t),i)});return Math.min(i,Math.max(0,...o))}function Vt(e,t){const n=e.lines.length,i=n?(n-1)*e.lineHeight+e.fS:0;if(e.slant){const n=Math.sin(Tt(e.angle,t));return n<1e-9?e.width:i/n}return Boolean(e.rotate)!==t?e.width:i}function qt(e,t,n,i){const o=e=>t[e.i]-2*e.fP,a=new Set(e.filter(e=>!e.fits)),r=(t,n,i)=>{for(let o=t+n;o>=0&&o<e.length;o+=n)if(!(e[o].truncated||i&&a.has(e[o])))return e[o]},s=(e,t)=>{const s=[r(e.i,-1,t),r(e.i,1,t)].filter(e=>void 0!==e).map(t=>2*(Math.abs(t.position-e.position)-(e=>a.has(e)?Math.min(e.width,o(e)):e.width)(t)/2-e.fP)),c=Math.floor(s.length?Math.min(...s):Math.max(...n)-Math.min(...n));return c>o(e)&&i(e,c),e.fits};let c=Math.min(...n);const l=e.map(e=>{const t=Math.max(0,2*(e.position-c));return c+=t,t});[...a].sort((e,t)=>l[t.i]-l[e.i]).forEach(e=>{a.delete(e),s(e,!1)||s(e,!0),e.truncated=!e.fits})}function Yt(e,t,n){let i=1;const o=n=>e.some((i,o)=>o>=n&&o%n===0&&function(e,t,n){return Math.abs(t.position-e.position)-(Vt(e,n)+Vt(t,n))/2<t.fP}(e[o-n],i,t));for(;i<e.length&&o(i);)i++,n?.(i,!1);i>1&&n?.(i,!0),e.forEach((e,t)=>e.truncated=t%i!==0)}function Kt(e,t){const n=e.slice().reverse();e.forEach(i=>{const{fP:o,i:a,position:r}=i,s=e=>Vt(e,t);let c=a?n.find(e=>e.i<a&&!e.truncated):void 0;if(a===e.length-1)for(;c&&r-s(i)/2-o<c.position+s(c)/2;)c.truncated=!0,c=n.find(e=>e.i<a&&!e.truncated);i.truncated=!!c&&r-s(i)/2-o<c.position+s(c)/2})}function Ut(e,t,n,i){const o=h.min([e.schema.maxSize,e.schema.width]),a=h.min([e.schema.maxSize,e.schema.height]);return t?a-n-i-e._margin.top-e._margin.bottom:o-n-i-e._margin.left-e._margin.right}function Xt(e,t){const{labels:n,rangeOuter:i,horizontal:o,hBuff:r,p:s,tickFormat:c,offset:l=1,ownSpace:u}=t,d=o&&!e._labelRotation&&Qt(e,n);e._shownLabels=n;const f={horizontal:o,hBuff:r,p:s,tickFormat:c,wholeLine:d};let m=function(e,t){const{fontSize:n}=e.schema.shapeConfig.labelConfig,i=e.schema.shapeConfig.labelConfig.fontFamily||a.fontFamily,o=e.schema.shapeConfig.labelConfig.padding,r=e._labelRotation?e._labelAngle:0,s=!!e._labelRotation&&e._labelSlant;return t.map((t,a)=>{const c="function"==typeof i?i(t,a):i,l="function"==typeof o?o(t,a):o,h="function"==typeof n?n(t,a):n,u=e._getPosition(t);return{d:t,i:a,fF:c,fP:l,fS:h,lineHeight:e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t,a):1.4*h,position:u,rotate:e._labelRotation,angle:r,slant:s}})}(e,n);const p=function(e,t,n){return"band"===e.schema.scale?e._d3Scale.bandwidth():t.reduce((i,o,a)=>{const{position:r}=o,s=a?r-(r-t[a-1].position):1===t.length?n[0]:r-(t[a+1].position-r),c=Math.abs(r-s),l=a==t.length-1?1===t.length?n[1]:r+(r-t[a-1].position):r-(r-t[a+1].position),u=Math.abs(r-l),d="point"===e.schema.scale?1:2;return h.max([h.max([c,u])*d,i])},0)}(e,m,i);f.slantWidth=function(e,t,n){const i=t[0];if(!i?.slant)return;const{horizontal:o,hBuff:a,p:r,tickFormat:s,space:c}=n,l=t=>e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t.d,t.i):Math.ceil(1.4*t.fS),h=It(i.angle,o,Ut(e,o,a,r),c-2*i.fP,l(i));return Gt(t.map(e=>({text:s(e.d),fontFamily:e.fF,fontSize:e.fS,lineHeight:l(e)})),((e,t)=>Math.max(1,Math.min(3,Math.floor(e/t+1e-9))))(h.height,l(i)),h.width)}(e,m,{...f,space:p});const g=u?function(e,t){return e.length<2?e.map(()=>Math.abs(t[t.length-1]-t[0])):e.map((t,n)=>{const i=[e[n-1],e[n+1]].filter(e=>void 0!==e).map(e=>Math.abs(t-e));return Math.min(...i)})}(m.map(e=>e.position),i):void 0,y=new Map,x=(t,n=(g?g[t.i]:p)-2*t.fP)=>{t.space=n;const{lines:i,widths:r,width:s,height:c,fits:l}=function(e,t,n,i){const{horizontal:o,hBuff:r,p:s,tickFormat:c}=n,{d:l,i:u,fF:d,fP:f,fS:m,rotate:p,space:g,angle:y,slant:x}=t,b=p?"width":"height",_=p?"height":"width",k=e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(l,u):void 0,v=c(l),w=h.min([e.schema.maxSize,e.schema.width]),S=Ut(e,o,r,s),C=x?It(y,o,S,g,k??Math.ceil(1.4*m)):void 0,M=i&&JSON.stringify([v,d,f,m,k,p,x&&y,x&&n.slantWidth,g]),$=M?i.get(M):void 0;if($)return{...$,lines:$.lines.slice(),widths:$.widths.slice()};const A=a.textWrap().fontFamily(d).fontSize(m).lineHeight(k);let z,D;return C?A.split(Dt).width(Math.min(C.width,n.slantWidth??1/0)).height(C.height):(A[_](o?g:S),A[b](o?S:g)),n.wholeLine?(A.width(e.schema.width-2*s),z=A(v),D=!z.truncated&&z.lines.filter(e=>""!==e).length<=1):(z=A(v),D=Ft(z,()=>A.split(Dt)(v)).fits,o&&!p&&`${v}`.trim()&&!z.lines.some(e=>""!==e)&&(A.width(w-2*s),z=A(v))),z.fits=D,z.lines=z.lines.filter(e=>""!==e),z.width=z.lines.length?Math.ceil(h.max(z.widths)):0,z.height=z.lines.length?Math.ceil(z.lines.length*A.lineHeight())+f:0,M&&i.set(M,{lines:z.lines.slice(),widths:z.widths.slice(),width:z.width,height:z.height,fits:D}),z}(e,t,f,y);return o&&!t.rotate?t.space=Math.max(t.space,Math.ceil(s)):!o&&!t.rotate&&c-t.fP>t.space&&(t.space=Math.ceil(c)),Object.assign(t,{lines:i,widths:r,width:s,height:c,fits:l})};m=m.map(e=>x(e));const b=(t,n=t)=>{e._shownLabels=t.map(e=>e.d),n.forEach(e=>x(e))};return Zt(e.schema.scale)?Yt(m,o,d?(e,t)=>{const n=m.filter((t,n)=>n%e===0);b(n,t?m:n)}:void 0):g&&o&&!e._labelRotation?qt(m,g,e._d3Scale.range(),x):d?function(e,t,n){let i=e;for(let o=0;o<4;o++){Kt(e,t);const o=e.filter(e=>!e.truncated);if(o.length===i.length&&o.every((e,t)=>e===i[t]))return;i=o,n(i,e)}}(m,o,b):Kt(m,o),l>1&&function(e=[],t){let n=0;e.forEach(i=>{const o=e[i.i-1],a=i.rotate&&t||!i.rotate&&!t?"width":"height",r=i.rotate&&t||!i.rotate&&!t?"height":"width";o?o.position+o[r]/2>i.position-i[r]/2&&(n?(i.offset=o[a],n=0):n=1):n=1})}(m,o),m}function Qt(e,t){const{scale:n}=e.schema;return"time"===n||Zt(n)&&t.length>0&&t.every(e=>e instanceof Date||!isNaN(e))}function Zt(e){return["band","ordinal","point"].includes(e)}function Jt(e,t){return e.slant?function(e,t,n,i){const o=Tt(e,t);return n*Math.sin(o)+i*Math.cos(o)}(e.angle,t,e.width,e.height-e.fP)+(t?e.fP:0):e[e.rotate||!t?"width":"height"]}const en=e=>"function"==typeof e&&"brokenSpec"in e;function tn(e,t,n){if(!Array.isArray(e)||!e.length)return[];const i=(Array.isArray(e[0])?e:[e]).filter(e=>Array.isArray(e)&&2===e.length).map(e=>e.map(Number)).filter(e=>e.every(Number.isFinite)&&e[0]!==e[1]).map(e=>e[0]<e[1]?[e[0],e[1]]:[e[1],e[0]]).sort((e,t)=>e[0]-t[0]),o=[];for(const e of i){const t=o[o.length-1];t&&e[0]<=t[1]?t[1]=Math.max(t[1],e[1]):o.push([e[0],e[1]])}return o.filter(([e,i])=>e>t&&i<n)}function nn(e){const[t,n]=e.domain,i=Math.min(t,n),o=Math.max(t,n),a=t<=n?e.range[0]:e.range[1],r=t<=n?e.range[1]:e.range[0],s=Math.sign(r-a)||1,c=e.breaks.reduce((e,[t,n])=>e+n-t,0),l=(Math.abs(r-a)-e.breaks.length*e.space)/(o-i-c),h=[i],u=[a];let d=i;for(const[t,n]of e.breaks){const i=u[u.length-1]+s*l*(t-d);h.push(t,n),u.push(i,i+s*e.space),d=n}return h.push(o),u.push(r),{values:h,pixels:u}}function on(e){let{values:t,pixels:n}=nn(e),i=s.scaleLinear().domain(t).range(n);const o=t=>{const n=+t,o=(t=>{const n=e.edge;if(!n)return;const i=(t-n.value)/(n.edge-n.value);return i<1?i<=0?n.position:n.position+i*(n.edgePosition-n.position):void 0})(n);return void 0!==o?o:i(n)},a=()=>{({values:t,pixels:n}=nn(e)),i=s.scaleLinear().domain(t).range(n)};return o.brokenSpec=e,o.domain=t=>void 0===t?e.domain.slice():(e.domain=Array.from(t,Number),a(),o),o.range=t=>void 0===t?e.range.slice():(e.range=Array.from(t,Number),a(),o),o.copy=()=>on({...e,breaks:e.breaks.map(e=>[e[0],e[1]])}),o.invert=t=>{const n=e.edge;if(n){const e=(t-n.position)/(n.edgePosition-n.position);if(e<=0)return n.value;if(e<1)return n.value+e*(n.edge-n.value)}return i.invert(t)},o.segments=()=>{const i=[];for(let e=0;e<t.length;e+=2)i.push({domain:[t[e],t[e+1]],range:[n[e],n[e+1]]});return e.domain[0]>e.domain[1]?i.reverse().map(e=>({domain:[e.domain[1],e.domain[0]],range:[e.range[1],e.range[0]]})):i},o.ticks=n=>s.scaleLinear().domain([t[0],t[t.length-1]]).ticks(n).filter(t=>!e.breaks.some(([e,n])=>t>e&&t<n)),o}function an(e,t,n){const i=new Set,o=[],a=e=>{const t=Number(e);i.has(t)||(i.add(t),o.push(e))},r=new Set(e.brokenSpec.breaks.flat());for(const i of e.segments()){const e=s.scaleLinear().domain(i.domain).range(i.range),o=t(e);o.forEach(a);const c=o.map(Number);i.domain.filter(e=>r.has(e)&&!c.includes(e)).forEach(t=>{n&&!n(t,c,e)||a(t)})}return o}const rn=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t;function sn(e,t="breakConfig"){const n=e.schema[t]||{};return{angle:rn(n.angle,30),gap:Math.max(0,rn(n.gap,5)),size:Math.max(0,rn(n.size,10)),space:Math.max(0,rn(n.space,36)),mask:!1!==n.mask,lines:!1!==n.lines}}const cn=e=>sn(e,"baselineBreakConfig");function ln(e,t){const{baseline:n,baselineBreak:i,scale:o}=e.schema;if(!i||"linear"!==o||!e._d3Scale)return null;if("number"!=typeof n||!Number.isFinite(n))return null;const a=e._d3Scale.domain().map(Number);if(2!==a.length||a.some(e=>!Number.isFinite(e)))return null;const r=Math.min(a[0],a[1]),s=Math.max(a[0],a[1]);if(r===s||n>=r&&n<=s)return null;const c=n<r?r:s,l=a[0]===c?0:1,h=t[l],u=t[1-l],{space:d}=cn(e);if(!d||Math.abs(u-h)<=2*d)return null;return{value:n,position:h,edge:c,edgePosition:h+Math.sign(u-h)*d}}function hn(e,t){if(e._baselineBreak=ln(e,t),e._breaks=[],"linear"!==e.schema.scale||!e._d3Scale)return;const n=e._baselineBreak,i=e._d3Scale.domain().map(Number),o=t.slice(0,2).map(e=>n&&e===n.position?n.edgePosition:e),{space:a,mask:r}=sn(e);let s=tn(e.schema.break,Math.min(...i),Math.max(...i));if(Math.abs(o[1]-o[0])-s.length*a<2*a&&(s=[]),!n&&!s.length)return;const c=on({domain:i,range:o,breaks:s,space:a,edge:n});e._d3Scale=c;const l="number"==typeof e.schema.baseline?e.schema.baseline:0;n&&e._breaks.push({start:n.value,end:n.edge,startPosition:n.position,endPosition:n.edgePosition,baseline:!0,mask:cn(e).mask}),s.forEach(([t,n])=>{const[i,o]=Math.abs(n-l)<Math.abs(t-l)?[n,t]:[t,n];e._breaks.push({start:i,end:o,startPosition:c(i),endPosition:c(o),baseline:!1,mask:r})})}function un(e,t,n=!0){const i=t.filter(t=>{const n=Number(t);return!e.some(e=>n>Math.min(e.start,e.end)&&n<Math.max(e.start,e.end))});return n&&e.forEach(e=>{e.baseline&&!i.some(t=>Number(t)===e.start)&&i.push(e.start)}),i}function dn(e,t){const{gap:n}=sn(e,t.baseline?"baselineBreakConfig":"breakConfig"),i=(t.startPosition+t.endPosition)/2;return[i-n/2,i+n/2]}function fn(e,t,n){const i=n(e.schema.barConfig),o=e._breaks||[];return o.length?mn(e,o,t,i,n):[{type:"line",key:"bar",points:t,paint:i}]}function mn(e,t,n,i,o){const a=e._position.horizontal,r=a?0:1,s=n[0][1-r],c=(e,t)=>a?[e,t]:[t,e],l=n.map(e=>e[r]),h=t.find(e=>e.baseline);h&&l.push(h.startPosition);const u=Math.min(...l),d=Math.max(...l),f=["top","left"].includes(e.schema.orient)?-1:1,m=t.map(t=>dn(e,t)).sort((e,t)=>e[0]-t[0]),p=[];let g=u;m.forEach(([e,t])=>{p.push([g,e]),g=t}),p.push([g,d]);const y=h?h.startPosition<=u?0:p.length-1:-1,x=y>0;let b=0;const _=p.map(([e,t],n)=>{const o=n===y?"bar-baseline":b++?"bar-"+(b-1):"bar",a=[c(e,s),c(t,s)];return{type:"line",key:o,points:x?a.reverse():a,paint:i}});y>0&&_.unshift(..._.splice(y,1));let k=0;return t.forEach(t=>{const n=t.baseline?"baselineBreakConfig":"breakConfig",{angle:i,size:a}=sn(e,n),r=o(e.schema[n]),l=Math.sign(t.endPosition-t.startPosition),h=i*Math.PI/180,u=Math.sin(h)*a,d=Math.cos(h)*a,m=e=>[c(e,s),c(e-l*u,s+f*d)],p=t.baseline?"baseline-break":"break-"+k++,[g,y]=dn(e,t),[x,b]=l<0?[y,g]:[g,y];_.push({type:"line",key:`${p}-0`,points:m(x),paint:r},{type:"line",key:`${p}-1`,points:m(b),paint:r})}),_}function pn(e){if(null==e)return;const t=n.date(e);return t instanceof Date&&!isNaN(+t)?t:void 0}function gn(e){return e.map(pn).filter(e=>void 0!==e)}function yn(e,t){const[n,i]=h.extent(t.domain()).map(Number);return e.filter(e=>+e>=n&&+e<=i)}function xn(e){return e.schema.timeLocale||c.locale[e.schema.locale]||c.locale["en-US"]}function bn(e){const{_scaleData:t,schema:{domain:n}}=e;return $n(e,"timeReference",[t,n],()=>gn(t.length?t:n).sort((e,t)=>+e-+t))}function _n(e,t){const n=xn(e),i=function(e){return"time"===e.schema.scale?bn(e):Sn(e)}(e);return(i.length?$n(e,"dateLabel",[i,n],()=>d.dateFullFormatter(i,kn(n)))(t):d.formatDateFull(t,[t],kn(n))).replace(/^Q/,n.quarter)}function kn(e){let t=vn.get(e);return t||vn.set(e,t=g.timeFormatLocale(e).format),t}const vn=new WeakMap,wn=e=>e instanceof Date&&!isNaN(+e);function Sn(e){const{_scaleData:t,schema:{domain:n}}=e;return $n(e,"dateCategories",[n,t],()=>{const e=e=>Array.isArray(e)?e.filter(wn):[],i=e(n),o=i.length?i:e(t),a=new Set;return o.filter(e=>!a.has(+e)&&!!a.add(+e)).sort((e,t)=>+e-+t)})}function Cn(e){const t=e._shownLabels;if(!t)return;const n=Mn.get(e);if(n&&n[0]===t)return n[1];const i=gn(t).sort((e,t)=>+e-+t);return Mn.set(e,[t,i]),i}const Mn=new WeakMap;function $n(e,t,n,i){const o=n.flatMap(e=>Array.isArray(e)?[e,e.length]:[e]);let a=An.get(e);a||An.set(e,a=new Map);const r=a.get(t);if(r&&r.fingerprint.length===o.length&&r.fingerprint.every((e,t)=>e===o[t]))return r.value;const s=i();return a.set(t,{fingerprint:o,value:s}),s}const An=new WeakMap,zn=e=>"number"==typeof e&&e>=1e3&&e<=2999;function Dn(e){return e.length>0&&e.every(e=>zn(e)&&Number.isInteger(e))}function Fn(e){const t=e.schema.domain??[];return!(!t.length||!t.every(zn))&&Dn(e._scaleData.length?e._scaleData:t)}function Bn(e,t="en-US"){return d.formatAbbreviate(e,t,"~f")}const Ln=e=>e<0||Object.is(e,-0),Pn=e=>Math.pow(10,Math.floor(Math.log10(Math.abs(e))))*Math.pow(-1,Ln(e)?1:0),Rn=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,Ln(e)?1:0),En=e=>{const t=`${e}`;if(t.includes("e-")||"0"===t)return 0;const n=t.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(n)return+`${n[1]}${+n[2]+1}`;const i=t.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return i?+`${i[1]}${+i[2]}`:e};function Nn(e,t,n){const i=e=>{if(o){if(!e)return 0;const t=`${e}`.match(/0\.(0*)/);if(t)return+`0.${Array(t[1].length+1).fill(0).join("")}1`}return`${Math.round(Math.abs(e))}`.length},o=e.every(e=>Math.abs(e)<1),a=[i(e[0]),i(e[1])].filter(Boolean).sort();if(!a.length)return;const r=e.some(e=>Ln(e))&&e.some(e=>e>0),s=1===a.length?a[0]:a[0]>1&&a[0]===a[1]?a[0]-1:"outside"!==t&&r?h.max(a):a[0]+(a[1]-a[0])/2;let c=s<1?En(s):+`1${Array(Math.floor(En(s))-1).fill(0).join("")}`;c>=Math.abs(e[1]-e[0])&&(c/=2);const l=e[1]<e[0],u=[Math["outside"===t?l?"ceil":"floor":l?"floor":"ceil"](e[0]/c)*c,Math["outside"===t?l?"floor":"ceil":l?"ceil":"floor"](e[1]/c)*c];return"log"===n&&(0===u[0]&&(u[0]=e[0]),0===u[1]&&(u[1]=e[1])),u.map(En)}const Tn=["linear","log","pow","sqrt"];function On(e,t,n){if(["linear","pow","sqrt"].includes(n))return Nn(e,t,n);if("log"===n){const i=[],o=e[1]<e[0];i[0]=("outside"===t?Ln(e[0])?o?Pn:Rn:o?Rn:Pn:Ln(e[0])?o?Rn:Pn:o?Pn:Rn)(e[0]),i[1]=("inside"===t?Ln(e[1])?o?Pn:Rn:o?Rn:Pn:(Ln(e[1]),o?Pn:Rn))(e[1]);const a=i[1]<i[0];return i[0]!==i[1]&&i.some(e=>Math.abs(e)>10)&&a===o?i:Nn(e,t,n)}}const Wn=(e,t)=>e<0?-Math.pow(-e,t):Math.pow(e,t);function jn(e,t){return e.map(e=>{const n=Math.min(...t.map(t=>Math.abs(t-e)).filter(e=>e>0));return function(e,t){if(!(t>0&&Number.isFinite(t)))return e;let n=Math.floor(Math.log10(Math.max(Math.abs(e),t)))+1;for(;n>-30;n--)for(const i of[5,2,1]){const o=i*Math.pow(10,n),a=Math.round(e/o)*o;if(Math.abs(a-e)<=t)return+a.toPrecision(12)}return e}(e,n/3)})}function Hn(e,t,n){let i,o,a;const r=(n,i)=>(a&&a.dates===n&&a.format===g.timeFormat||(a={dates:n,format:g.timeFormat,label:d.dateFormatter(n,g.timeFormat)}),a.label(i,Cn(e)).replace(/^Q/g,t.quarter)),s=e.schema.tickFormat;return s?t=>s.call(e,t):t=>{if(wn(t)&&(e=>["band","ordinal","point"].includes(e.schema.scale))(e))return r(o??(o=Sn(e)),t);if(isNaN(t)||["band","ordinal","point"].includes(e.schema.scale))return t;if("time"===e.schema.scale)return r(bn(e),t);if("linear"===e.schema.scale&&"smallest"===e.schema.tickSuffix){const n="object"==typeof e.schema.locale?e.schema.locale:c.formatLocale[e.schema.locale],{separator:i,suffixes:o}=n,a=t>=1e3?o[e._tickUnit+8]:"",r=t/Math.pow(10,3*e._tickUnit);return`${d.formatAbbreviate(r,n,`,.${r.toString().length}r`)}${i}${a}`}{const o=n(),a=o[1]<o[0],r=a?o.length-1:0,s=a?0:o.length-1,c="inside"===e.schema.rounding?o.indexOf(t)===r?e.schema.roundingInsideMinPrefix:o.indexOf(t)===s?e.schema.roundingInsideMaxPrefix:"":"",l="inside"===e.schema.rounding?o.indexOf(t)===r?e.schema.roundingInsideMinSuffix:o.indexOf(t)===s?e.schema.roundingInsideMaxSuffix:"":"";i??(i=Fn(e));return`${c}${i?Bn(t,e.schema.locale):d.formatAbbreviate(t,e.schema.locale)}${l}`}}}function In(e){const{labels:t}=e.schema;return Array.isArray(t)&&t.length&&t.every(Array.isArray)?t:void 0}function Gn(e,t,n,i){const o=function(e,t,n){let i=n?n.slice():[],[o,a]=t;e.schema.range&&(void 0!==e.schema.range[0]&&(o=e.schema.range[0]),void 0!==e.schema.range[e.schema.range.length-1]&&(a=e.schema.range[e.schema.range.length-1])),(void 0===i[0]||i[0]<o)&&(i[0]=o),(void 0===i[1]||i[1]>a)&&(i[1]=a);const r=a-o;if("ordinal"===e.schema.scale&&e.schema.domain.length>i.length)if(n===e.schema.range){const t=e.schema.domain.length+1;i=h.range(t).map(e=>i[0]+r*(e/(t-1))).slice(1,t),i=i.map(e=>e-i[0]/2)}else{const t=e.schema.domain.length,n=i[1]-i[0];i=h.range(t).map(e=>i[0]+n*(e/(t-1)))}return i}(e,t,void 0!==i?i:e.schema.range),a=`scale${e.schema.scale.charAt(0).toUpperCase()}${e.schema.scale.slice(1)}`,r=e.schema.domain.slice();var s;if(e._d3Scale=B[a]().domain("time"===e.schema.scale?function(e){const t=e.schema.domain.map(pn),n=e._scaleData;return t.some(e=>void 0===e)&&n.length?h.extent(n):t}(e):r).range(o),"pow"===e.schema.scale&&e._d3Scale.exponent&&e._d3Scale.exponent("number"==typeof(s=e.schema.exponent)&&Number.isFinite(s)&&s>0?s:1),"none"!==e.schema.rounding){const t=On(r,e.schema.rounding,e.schema.scale);t&&e._d3Scale.domain(t)}e.schema.reverse&&e._d3Scale.domain(e._d3Scale.domain().slice().reverse()),e._d3Scale.padding&&e._d3Scale.padding(e.schema.scalePadding),e._d3Scale.align&&e._d3Scale.align(e.schema.scaleAlign),e._d3Scale.paddingInner&&e._d3Scale.paddingInner(e.schema.paddingInner),e._d3Scale.paddingOuter&&e._d3Scale.paddingOuter(e.schema.paddingOuter),e._d3ScaleNegative=null,"log"===e.schema.scale&&function(e){const t=e._d3Scale.domain(),n=e._scaleData;if(0===t[0]){const e=h.min([h.min(n),Math.abs(t[1])]);t[0]=0===e||1===e?1e-6:e<=1?Pn(e):1,Ln(t[1])&&(t[0]*=-1)}else if(0===t[t.length-1]){const e=h.min([h.min(n),Math.abs(t[0])]);t[t.length-1]=0===e||1===e?1e-6:e<=1?Pn(e):1,Ln(t[0])&&(t[t.length-1]*=-1)}const i=e._d3Scale.range();if(Ln(t[0])&&Ln(t[t.length-1]))e._d3ScaleNegative=e._d3Scale.copy().domain(t).range(i),e._d3Scale=null;else if(t[0]>0&&t[t.length-1]>0)e._d3Scale.domain(t).range(i);else{const o=t.map(e=>Math.log10(Math.abs(e))).map(e=>e||-1e-6),a=o[0]/h.sum(o)*(i[1]-i[0]);let r=h.min([h.min(n.filter(e=>e>=0)),Math.abs(t[1])]);1===r&&(r=1e-6);let s=h.min([h.min(n.filter(Ln)),Math.abs(t[0])]);1===s&&(s=1e-6);const c=0===r?1e-6:r<=1?Pn(r):1,l=0===s?-1e-6:s<=1?Pn(s):1,u=h.min([Math.abs(c),Math.abs(l)]);e._d3ScaleNegative=e._d3Scale.copy(),(Ln(t[0])?e._d3Scale:e._d3ScaleNegative).domain([Ln(t[0])?u:-u,t[1]]).range([i[0]+a,i[1]]),(Ln(t[0])?e._d3ScaleNegative:e._d3Scale).domain([t[0],Ln(t[0])?-u:u]).range([i[0],i[0]+a])}}(e),hn(e,o);const{ticks:c,labels:l}=function(e){const t=In(e),n=t?t[Math.min(e._labelSet??0,t.length-1)]:e.schema.labels,i=e.schema.ticks||(t?n:void 0);let o=(i?"time"===e.schema.scale?gn(i):i:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getTicks():e.schema.domain).slice(),a=(n?"time"===e.schema.scale?gn(n):n:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getLabels():o).slice();return"time"===e.schema.scale&&(o=o.map(Number),a=a.map(Number)),e._breaks.length&&(o=un(e._breaks,o),a=un(e._breaks,a,!n)),o=o.sort((t,n)=>e._getPosition(t)-e._getPosition(n)),a=a.sort((t,n)=>e._getPosition(t)-e._getPosition(n)),{ticks:o,labels:a}}(e);!function(e,t){if("linear"===e.schema.scale&&"smallest"===e.schema.tickSuffix){const n=t.filter(e=>e>=1e3);if(n.length>0){const t=Math.min(...n);let i=1;for(;i&&i<7&&t/Math.pow(10,3*i)>=1;)e._tickUnit=i,i+=1}}}(e,l);const u=function(e,t,n){const i=[];return e._availableTicks=t,t.forEach((t,o)=>{let a=n({id:t,tick:!0},o);"Circle"===e.schema.shape&&(a*=2);const r=e._getPosition(t);!i.length||Math.abs(f.closest(r,i.filter(e=>!1!==e))-r)>2*a?i.push(r):i.push(!1)}),t=t.filter((e,t)=>!1!==i[t]),e._visibleTicks=t,t}(e,c,n);return{range:o,ticks:u,labels:l}}function Vn(e){const t=xn(e);g.timeFormatDefaultLocale(t);const{width:n,height:i,x:o,y:r,horizontal:s,opposite:c}=e._position,l=e.schema.padding,u=[l,e.schema[n]-l],d="Circle"===e.schema.shape?e.schema.shapeConfig.r:"Rect"===e.schema.shape?e.schema.shapeConfig[n]:e.schema.shapeConfig.strokeWidth,f="function"!=typeof d?()=>d:d,m=e._margin={top:0,right:0,bottom:0,left:0};!function(e){An.delete(e)}(e),e._scaleData=function(e){if("time"!==e.schema.scale)return e._data??[];const t=gn(e._data??[]),n=(e.schema.domain??[]).map(pn);if(n.length<2||n.some(e=>void 0===e))return t;const[i,o]=h.extent(n);return t.filter(e=>e>=i&&e<=o)}(e);let p=[],y=[],x=[];const b=function(e,t,n){const i=Hn(e,t,n),o=e.schema.rotatedTickFormat;return o?t=>(e._labelRotation?o:i)(t):i}(e,t,()=>x);e._labelFormat=b;const _=t=>({range:y,ticks:x,labels:p}=Gn(e,u,f,t));e._labelSet=0,_(),function(e,t){if(!e.schema.title)return;const{range:n,p:i,height:o,margin:r}=t,{fontFamily:s,fontSize:c,lineHeight:l}=e.schema.titleConfig,h=a.textWrap().fontFamily("function"==typeof s?s():s).fontSize("function"==typeof c?c():c).lineHeight("function"==typeof l?l():l).width(n[n.length-1]-n[0]-2*i).height(e.schema[o]-e.schema.tickSize-2*i),u=h(e.schema.title).lines.length;r[e.schema.orient]=u*h.lineHeight()+i}(e,{range:y,p:l,height:i,margin:m});const{hBuff:k,wBuff:v}=function(e,t,n,i){let o="Circle"===e.schema.shape?"function"==typeof e.schema.shapeConfig.r?e.schema.shapeConfig.r({tick:!0}):e.schema.shapeConfig.r:"Rect"===e.schema.shape?"function"==typeof e.schema.shapeConfig[i]?e.schema.shapeConfig[i]({tick:!0}):e.schema.shapeConfig[i]:e.schema.tickSize,a=n({tick:!0});return"Rect"===e.schema.shape&&(o/=2),"Circle"!==e.schema.shape&&(a/=2),{hBuff:o,wBuff:a}}(e,0,f,i),w=s&&!Zt(e.schema.scale)&&Xn(e,p,b),S={rangeOuter:u,horizontal:s,hBuff:k,p:l,tickFormat:b,rescale:_,ownSpace:w},C=e._labelRotationSetting;Yn(e,function(e,t){return Et(e)?{rotate:!0,angle:Lt(e),slant:Nt(e,t)}:Pt}(C,s));let M=Kn(e,{range:y,labels:p},S);const $=In(e)?.length??0;for(let t=1;t<$&&Qn(M);t++)e._labelSet=t,M=Kn(e,_(),S);void 0===C&&s&&(M=function(e,t,n){const{labels:i,tickFormat:o,ownSpace:a,rangeOuter:r,relayout:s}=n,c=Qt(e,i),l=Xn(e,i,o)?e=>Qn(e):c?e=>e.length&&!e[0].fits?1:0:void 0,h=l?l(t):0;if(!l||!h||a&&2*h<t.length)return t;let u={turn:Pt,misses:h,data:t},d=Pt;for(const t of[{rotate:!0,angle:Rt(e.schema.orient),slant:!0},{rotate:!0,angle:-90,slant:!1}]){Yn(e,d=t);const n=s(),i=l(n)+(c&&n[0]?.truncated?1:0)+(t.slant&&qn(e,n,r).some(e=>e>1)?1:0);if(i<u.misses&&(u={turn:t,misses:i,data:n}),!i)break}return u.turn===d?u.data:(Yn(e,u.turn),s())}(e,M,{labels:p,tickFormat:b,ownSpace:w,rangeOuter:u,relayout:()=>Kn(e,_(),S)})),function(e,t,n){const i=new Set(t.filter(e=>e.truncated).map(e=>e.d));i.size&&(e._visibleTicks=n.filter(e=>!i.has(e)))}(e,M,x),e._labelOverflow=qn(e,M,y);const A=h.max(M,e=>e.height)||0;!function(e,t){const n=e.schema.labelOffset?h.max(t,e=>e.offset||0):0;t.forEach(e=>e.offset=e.offset?n:0)}(e,M);const z=function(e,t){const{textData:n,rangeOuter:i,hBuff:o,horizontal:a,p:r,width:s,height:c,x:l,y:u,opposite:d,margin:f}=t,m="Line"===e.schema.shape?0:o,p=e._outerBounds={[c]:(h.max(n,e=>Math.ceil(Jt(e,a)+(e.offset??0)))||0)+(n.length?r:0),[s]:i[i.length-1]-i[0],[l]:i[0]};return p[c]="number"==typeof e.schema.fixedSize?e.schema.fixedSize:h.max([e.schema.minSize,p[c]]),e._labelSpace=p[c],f[e.schema.orient]+=o,f[d]=void 0!==e.schema.gridSize?h.max([e.schema.gridSize,m]):e.schema[c]-f[e.schema.orient]-p[c]-r,p[c]+=f[d]+f[e.schema.orient],p[u]="start"===e.schema.align?e.schema.padding:"end"===e.schema.align?e.schema[c]-p[c]-e.schema.padding:e.schema[c]/2-p[c]/2,p}(e,{textData:M,rangeOuter:u,hBuff:k,horizontal:s,p:l,width:n,height:i,x:o,y:r,opposite:c,margin:m});return{ticks:x,labels:p,range:y,textData:M,tickFormat:b,hBuff:k,wBuff:v,tickGet:f,labelHeight:A,bounds:z}}function qn(e,t,n){const i=t.filter(e=>!e.truncated&&e.slant);if(!i.length)return[0,0];const o=Math.min(n[0],n[n.length-1]),a=Math.max(n[0],n[n.length-1]),r=t=>Ht(e.schema.orient,t.angle,t.width,t.height-t.fP),s=i[0],c=i[i.length-1];return[Math.max(0,r(s)[0]-(s.position-o)),Math.max(0,r(c)[1]-(a-c.position))]}function Yn(e,t){e._labelRotation=t.rotate,e._labelAngle=t.angle,e._labelSlant=t.slant}function Kn(e,t,n){const{rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,rescale:c,ownSpace:l}=n;let{labels:h}=t,u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l});const d=e.schema.labelOffset&&u.some(e=>e.truncated);d&&(u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l,offset:2}));let[f,m]=t.range;for(let t=0;t<3;t++){const t=u.filter(e=>!e.truncated),n=[0,1].map(n=>{const a=t[n?t.length-1:0];if(!a)return 0;const{height:r,position:s,rotate:c,width:l}=a,h=n?i[1]:i[0],u=a.slant?Ht(e.schema.orient,a.angle,l,r-a.fP)[n]:(c||!o?r:l)/2,d=n?h-s:s-h;return d>=u?0:u-d}),p=m-f-(i[1]-i[0])/2,g=n[0]+n[1],y=g>p&&t.some(e=>e.slant)?Math.max(0,p)/g:1,x=[f+n[0]*y,m-n[1]*y];if(e.schema.range&&(void 0!==e.schema.range[0]&&(x[0]=e.schema.range[0]),void 0!==e.schema.range[e.schema.range.length-1]&&(x[1]=e.schema.range[e.schema.range.length-1])),x[0]===f&&x[1]===m)break;const b=Un(u);if([f,m]=x,({labels:h}=c(x)),u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l,offset:d?2:1}),Un(u)===b&&!u.some(e=>e.slant))break}return u}function Un(e){const t=e.filter(e=>!e.truncated);return[t[0],t[t.length-1]].map(e=>e?`${e.d instanceof Date?+e.d:e.d}`:"").join(",")}function Xn(e,t,n){const i=e=>!(e instanceof Date)&&isNaN(e);return Zt(e.schema.scale)?t.some(i):Array.isArray(e.schema.labels)&&!!n&&t.some(e=>i(n(e)))}function Qn(e){return e.filter(e=>!e.fits||e.truncated).length}function Zn(e,t){const i=e?n.backgroundColor(e):"rgb(255, 255, 255)";return r.colorContrast(i,t)===t.dark?r.colorGray[200]:r.colorGray[800]}function Jn(e){return()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)}}function ei(e){return{angle:30,gap:5,lineConfig:{},lines:!0,mask:!0,size:10,space:36,stroke:Jn(e),"stroke-width":1}}function ti(e,t,n,i=0){const o=t=>{if("function"==typeof t)try{return t.call(e,n,i)}catch{return}return t},a={},r=o(t.stroke);null!=r&&(a.stroke=String(r));const s=o(t["stroke-width"]);null!=s&&(a.strokeWidth=Number(s));const c=o(t["stroke-opacity"]);null!=c&&(a.strokeOpacity=Number(c));const l=o(t["stroke-linecap"]);null!=l&&(a.strokeLinecap=l);const h=o(t["stroke-dasharray"]);if(null!=h){const e=String(h).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));e.length&&(a.strokeDasharray=e)}const u=o(t.opacity);null!=u&&(a.opacity=Number(u));const d=o(t.fill);return null!=d&&(a.fill=String(d)),a}function ni(e){if(!e._d3Scale&&!e._d3ScaleNegative)return null;const{height:t,x:n,y:i,opposite:o}=e._position,a=e._margin[o],r=["top","left"].includes(e.schema.orient)?e._outerBounds[i]+e._outerBounds[t]-a:e._outerBounds[i]+a,s="point"===e.schema.scale&&e._d3Scale.align?e._d3Scale.align():.5,c="band"===e.schema.scale?e._d3Scale.step()-e._d3Scale.bandwidth():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding()*2*s:0,l="band"===e.schema.scale?e._d3Scale.step():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding()*2*(1-s):0,h=(e._d3ScaleNegative?e._d3ScaleNegative.domain():[]).concat(e._d3Scale?e._d3Scale.domain():[]).sort((e,t)=>e-t);if(!h.length)return null;const u=e._getPosition(h[0])-c,d=e._getPosition(h[h.length-1])+l;return{points:"x"===n?[[u,r],[d,r]]:[[r,u],[r,d]]}}function ii(e,t,n,i=.5){if(t.length<3)return!1;const o=t.map(n).sort((e,t)=>e-t),a=n(e);if(![a,...o].every(Number.isFinite))return!1;const r=o.length-1,s=Math.abs(a-o[0])<=Math.abs(a-o[r]),c=s?o[0]:o[r],l=s?o[1]:o[r-1],h=Math.abs(c-l);return!!h&&Math.abs(a-c)-h*i<=1e-9*h}const oi=936e5;function ai(e,t,n){const i=B.scaleLinear().domain([200,1200]).range([8,28]),o=e.range(),a=Math.abs(o[1]-o[0]);let r=Math.floor(i(a));if("time"===this.schema.scale)if(n.length){const e=h.extent(n),i=n.reduce((e,t,n,i)=>{if(n){const o=Math.abs(t-i[n-1]);o<e&&(e=o)}return e},1/0),o=Math.round((e[1]-e[0])/i);r=h.min([r*(t?2:.5),o])}else r=t?2*r:r/2;return Math.floor(r)}function ri(e,t=!1){if(en(e))return an(e,e=>ri.call(this,e,t),t?void 0:(e,t,n)=>!ii(e,t,e=>n(e)));let i;const o=e.copy(),a="time"===this.schema.scale?yn(this._scaleData,e):[];if(a.length){const t=h.extent(a),n=t.map(t=>e(t));o.domain(t).range(n)}const r=o.domain(),s=r[1]<r[0],c=ai.call(this,o,t,a);if(t||"log"!==this.schema.scale){if(o.exponent&&1!==o.exponent())i=function(e,t,n,i=!1){const[o,a]=e.map(Number),r=Math.min(o,a),s=Math.max(o,a);if(!Number.isFinite(r)||!Number.isFinite(s)||r===s||!t)return r===s&&Number.isFinite(r)?[r]:[];const c=Math.max(1,Math.round(n)),l=Wn(r,t),h=Wn(s,t),u=e=>Array.from({length:e+1},(n,i)=>Wn(l+(h-l)*i/e,1/t)),d=u(c),f=jn(d,d);let m=f;if(i){const e=u(2*c),t=e.filter((e,t)=>t%2);m=f.concat(jn(t,e))}const p=Array.from(new Set(m)).filter(e=>e>=r&&e<=s).sort((e,t)=>e-t);return a<o?p.reverse():p}(r,o.exponent(),Math.max(1,c/2),t);else if(i=o.ticks(c),!t&&!["log","time"].includes(this.schema.scale)&&i.length>1){const e=Math.abs(2*En(i[1]-i[0]));i=i.filter(t=>{const n=Math.abs(t)%e,i=En(n);return i!==n?!i||i===e:0===n})}}else{const e=r.map(e=>Math.log10(e)%1==0?e:(s?Rn:Pn)(e)),t=e[1]<e[0],n=e.map(e=>(Ln(e)?-1:1)*([-1,1].includes(e)||Math.abs(e)<1?1:Math.log10(Math.abs(e)))),a=Math.ceil((Math.abs(n[1]-n[0])+1)/(.65*c));i=a<=1&&n[0]===n[1]||t!==s?o.ticks(c).filter(e=>+`${e}`.replace("0.","")%2==0):h.range(n[0],n[1],n[1]<n[0]?-1:1).concat([n[1]]).filter(e=>Math.abs(e)%a===0).map(e=>+(""+(Ln(e)?-1:1)*(e?Math.pow(10,Math.abs(e)):Math.sign(1/e)>0?1:-1)).replace(/9+/g,"1"))}if("time"===this.schema.scale&&this._scaleData.length){const e=this._scaleData.map(Number);i=i.filter(t=>{const n=+t;return e.find(e=>e>=n-oi&&e<=n+oi)})}return function(e,t,i,o,a){if(!1===e.schema.domainTicks)return t;const r=i[1]<i[0],s=t.map(Number),c=(e.schema.ticks??[]).map(t=>Number("time"===e.schema.scale?n.date(t):t)),l=e=>!t.map(Number).includes(Number(e))&&(!a||c.includes(Number(e))||!ii(Number(e),s,e=>o(e))),h=n=>!e._d3ScaleNegative||Ln(n)===t.some(e=>Ln(e));return h(i[r?1:0])&&l(i[0])&&t.unshift(i[0]),h(i[r?0:1])&&l(i[1])&&t.push(i[1]),t}(this,i,r,o,!t)}function si(e,t,n){const{x:i,y:o,width:a,height:r}=jt(e.schema.orient,t.angle,t.width,t.height-t.fP,t.height,n);return{x:i,y:o,width:a,height:r}}function ci(e,t,n){const{fP:i,fS:o,lineHeight:a,lines:r,width:s}=t,c=a*r.length;return{x:-s/2+((t.angle??-90)>0?-1:1)*(o/4),y:"bottom"===e.schema.orient?n+(s-c)/2+i:n-(s+c)/2-2*i,width:s,height:t.height}}const li=[{key:"align",coerce:"identity",default:"middle"},{key:"baseline",coerce:"identity",default:0},{key:"baselineBreak",coerce:"identity",default:!1},{key:"break",coerce:"identity",default:!1},{key:"domain",coerce:"identity",default:[0,10]},{key:"domainTicks",coerce:"identity",default:!0},{key:"duration",coerce:"identity",default:600},{key:"exponent",coerce:"identity",default:1},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"fixedSize",coerce:"identity"},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"renderMode",coerce:"identity",default:"full"},{key:"reverse",coerce:"identity",default:!1},{key:"rotatedTickFormat",coerce:"identity"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scaleAlign",coerce:"identity",default:.5},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"width",coerce:"identity",default:400}];class hi extends $e{_getDomain(){let e=[];this._d3ScaleNegative&&(e=this._d3ScaleNegative.domain()),this._d3Scale&&(e=e.concat(this._d3Scale.domain())),this._baselineBreak&&(e=e.concat([this._baselineBreak.value]));const t=["band","ordinal","point"].includes(this.schema.scale)?e:h.extent(e);return e[0]>e[1]?t.reverse():t}_givenDomain(e=!1){const t=(e?this._d3ScaleNegative:this._d3Scale).domain();return this.schema.reverse?t.slice().reverse():t}_getPosition(e){if("log"===this.schema.scale){if(0===e)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const t=Ln(e)?this._d3ScaleNegative:this._d3Scale;return t?t(e):0}return this._d3Scale?this._d3Scale(e):0}_getRange(){let e=[];return this._d3ScaleNegative&&(e=this._d3ScaleNegative.range()),this._d3Scale&&(e=e.concat(this._d3Scale.range())),this._baselineBreak&&e.push(this._baselineBreak.position),e[0]>e[1]?h.extent(e).reverse():h.extent(e)}_getLabels(){let e=[];if(this._d3ScaleNegative&&(e=e.concat(ri.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(e=e.concat(ri.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(e.some(e=>Ln(e))&&e.some(e=>e>0)){const t=h.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);e.includes(t)||e.splice(e.findIndex(e=>e>t),0,t),e.includes(-t)&&e.includes(t)&&e.splice(e.indexOf(-t),1)}}return e}_getTicks(){const e="time"===this.schema.scale&&this._d3Scale?yn(this._scaleData,this._d3Scale):this._scaleData;if(["band","ordinal","point","time"].includes(this.schema.scale)&&e.length&&e.length<this.schema.width/4)return e;let t=[];return this._d3ScaleNegative&&(t=t.concat(ri.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(t=t.concat(ri.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&t.includes(-1)&&t.includes(1)&&t.splice(t.indexOf(-1),1),t}toScene(){return function(e){const t=[],n=e._gridLineData??[];(function(e){if(!e._gridLineData||!e._gridLineData.length)return[];const{height:t,x:n,y:i,opposite:o}=e._position,a=e._margin[o],r=["top","left"].includes(e.schema.orient)?e._outerBounds[i]+e._outerBounds[t]-a:e._outerBounds[i]+a,s=["top","left"].includes(e.schema.orient)?a:-a,c="band"===e.schema.scale?e._d3Scale.bandwidth()/2:0,l="x"===n;return(e._gridLineData??[]).map(t=>{const n=e._getPosition(t.id)+c;return{points:[l?[n,r]:[r,n],l?[n,r+s]:[r+s,n]]}})})(e).forEach((i,o)=>{const a=ti(e,e.schema.gridConfig,n[o],o);t.push({type:"line",key:`grid-${o}`,points:i.points,paint:a})});const i=e._tickShape&&"function"==typeof e._tickShape.toScene?e._tickShape.toScene():null;if(i&&t.push(i),e._tickShape){const n=e._tickShape._labelClass;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){const e=n.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}const o=ni(e);let a;o&&t.push(...fn(e,o.points,t=>ti(e,t))),e._titleClass&&"function"==typeof e._titleClass.toScene&&e._titleClass._data&&e._titleClass._data.length&&t.push(e._titleClass.toScene());const r=e._select&&"function"==typeof e._select.node?e._select.node():null;if(r&&"function"==typeof r.getAttribute){const e=r.getAttribute("transform");if(e){const t=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);t&&(a={x:Number(t[1]),y:Number(t[2])})}}return{type:"group",key:`Axis-${e._uuid.slice(0,8)}`,...a?{transform:a}:{},children:t}}(this)}render(e){if(void 0===this._select&&"compute"!==this.schema.renderMode)if(this._managesOwnScenePaint){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",`${this.schema.width}px`),e.setAttribute("height",`${this.schema.height}px`),document.body.appendChild(e),this.select(e)}else{const e=document.createElement("div");document.body.appendChild(e),this.select(e)}const t=Vn(this),{ticks:i,labels:o}=t,a=this._select,r="compute"===this.schema.renderMode&&(void 0===this._select||null===this._select||"function"==typeof this._select.node&&null===this._select.node())?null:n.elem(`g#d3plus-Axis-${this._uuid}`,{parent:a});this._group=r;const s=(0!==this.schema.gridSize?this.schema.grid||"log"===this.schema.scale&&!this.schema.gridLog?o:i:[]).map(e=>({id:e}));this._gridLineData=s;const c=function(e,t){const{ticks:n,labels:i,textData:o,tickFormat:a,hBuff:r,labelHeight:s}=t,{height:c,x:l,y:h,horizontal:u,opposite:d}=e._position,f=["top","left"].includes(e.schema.orient),m=e.schema.padding,p=e._margin,g=e._outerBounds,y=i.filter((e,t)=>o[t].lines.length&&!n.includes(e)),x=o.some(e=>e.rotate);let b=n.concat(y).map(t=>{const y=o.find(e=>e.d===t),b=e._getPosition(t),_=y?y.space:0,k=y?y.fP:0,v=y&&e.schema.labelOffset?y.offset??0:0,w=u?_:g.width-p[e._position.opposite]-r-p[e.schema.orient]+m,S=!u&&y&&"number"==typeof e.schema.fixedSize?Math.max(w,Math.ceil(y.width)+m):w,C=p[d],M=(r+v)*(f?-1:1),$=f?g[h]+g[c]-C:g[h]+C;return{id:t,labelBounds:y?.slant?si(e,y,Math.abs(M)+(u?k:m)):x&&y?ci(e,y,M):{x:u?-_/2:"left"===e.schema.orient?-S-m+M:M+m,y:u?"bottom"===e.schema.orient?M+k:M-s-k:-_/2,width:u?_:S,height:u?s:_},rotate:!!y&&y.rotate,angle:y?y.angle:0,size:i.includes(t)||"log"===e.schema.scale&&Math.log10(Math.abs(t))%1==0?M:n.includes(t)?Math.ceil(M/2):e._scaleData.find(e=>+e===t)?Math.ceil(M/4):0,text:!(y?.truncated||!i.includes(t))&&a(t),tick:n.includes(t),[l]:b+("band"===e.schema.scale?e._d3Scale.bandwidth()/2:0),[h]:$}});return"Line"===e.schema.shape&&(b=b.concat(b.map(e=>{const t=Object.assign({},e);return t[h]=t[h]+e.size,t}))),b}(this,t);return function(e,t){e._tickShape=(new E[e.schema.shape]).renderMode("compute").select(null).data(t).duration(e.schema.duration).labelConfig({ellipsis:e=>e&&e.length?`${e}...`:"",...e._labelRotation&&e._labelSlant?{split:Dt}:{},rotate:e=>{const t=void 0!==e.rotate?e:e.data;return t?.rotate?Number(t.angle??-90):0}}),e._tickShape.config(Ae.bind(e)(e.schema.shapeConfig)).labelConfig({padding:0}).render()}(this,c),function(e,t,i){const{range:o}=t,{horizontal:a}=e._position,r=e._margin,s=e._outerBounds;e._titleClass.renderMode("compute").data(e.schema.title?[{text:e.schema.title}]:[]).duration(e.schema.duration).height(r[e.schema.orient]).rotate("left"===e.schema.orient?-90:"right"===e.schema.orient?90:0).select(i?n.elem("g.d3plus-Axis-title",{parent:i}).node():null).text(e=>e.text).verticalAlign("middle").width(o[o.length-1]-o[0]).x(a?o[0]:"left"===e.schema.orient?s.x+r.left/2-(o[o.length-1]-o[0])/2:s.x+s.width-r.right/2-(o[o.length-1]-o[0])/2).y(a?"bottom"===e.schema.orient?s.y+s.height-r.bottom:s.y:o[0]+(o[o.length-1]-o[0])/2-r[e.schema.orient]/2).config(Ae.bind(e)(e.schema.titleConfig)).render()}(this,t,r),this._lastScale=this._getPosition.bind(this),"compute"===this.schema.renderMode||this._managesOwnScenePaint||De(this),e&&setTimeout(e,this.schema.duration+100),this}barConfig(e){return arguments.length?(this.schema.barConfig=Y(this,"barConfig",e),this):this.schema.barConfig}breakConfig(e){return arguments.length?(this.schema.breakConfig=Y(this,"breakConfig",e),this):this.schema.breakConfig}baselineBreakConfig(e){return arguments.length?(this.schema.baselineBreakConfig=Y(this,"baselineBreakConfig",e),this):this.schema.baselineBreakConfig}data(e){return arguments.length?(this._data=e,this):this._data}gridConfig(e){return arguments.length?(this.schema.gridConfig=Y(this,"gridConfig",e),this):this.schema.gridConfig}labelRotation(e){return arguments.length?(this._labelRotationSetting=e,this):this._labelRotationSetting}orient(e){if(arguments.length){const t=["top","bottom"].includes(e),n={top:"bottom",right:"left",bottom:"top",left:"right"};return this._position={horizontal:t,width:t?"width":"height",height:t?"height":"width",x:t?"x":"y",y:t?"y":"x",opposite:n[e]},this.schema.orient=e,this}return this.schema.orient}outerBounds(){return this._outerBounds}measure(){return Vn(this),this}select(e){return arguments.length?(this._select=null==e?void 0:t.select(e),this):this._select}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}constructor(){super(),this._scaleData=[],this._labelAngle=0,this._labelSlant=!1,this._labelOverflow=[0,0],this._d3Scale=null,this._d3ScaleNegative=null,this._baselineBreak=null,this._breaks=[],ee(this,li),this._data=[],this._labelRotation=!1,this._labelRotationSetting=void 0,this.schema.barConfig={stroke:Jn(this),"stroke-width":1},this.schema.baselineBreakConfig=ei(this),this.schema.breakConfig=ei(this),this.schema.gridConfig=function(e){return{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),"stroke-width":1}}(this),this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig=function(e){return{fill:Jn(e),height:e=>e.tick?8:0,label:e=>e.text,labelBounds:e=>e.labelBounds,labelConfig:{fontColor:Jn(e),fontResize:!1,fontSize:N(12),padding:5,textAnchor:()=>{if(e._labelRotation&&e._labelSlant)return Wt(e.schema.orient,e._labelAngle);const t=n.rtl();return"left"===e.schema.orient?t?"start":"end":"right"===e.schema.orient?t?"end":"start":e._labelRotation?Wt(e.schema.orient,e._labelAngle):"middle"},verticalAlign:()=>"bottom"===e.schema.orient?"top":"top"===e.schema.orient?e._labelRotation?"top":"bottom":"middle"},r:e=>e.tick?4:0,stroke:Jn(e),strokeWidth:1,width:e=>e.tick?8:0}}(this),this._tickUnit=0,this._titleClass=new ro,this.schema.titleConfig=function(e){return{fontColor:Jn(e),fontSize:12,textAnchor:"middle"}}(this),this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}K(hi.prototype,"barConfig","breakConfig","baselineBreakConfig","gridConfig","shapeConfig","titleConfig");class ui extends hi{constructor(){super(),this.orient("bottom")}}class di extends hi{constructor(){super(),this.orient("left")}}class fi extends hi{constructor(){super(),this.orient("right")}}class mi extends hi{constructor(){super(),this.orient("top")}}const pi=new WeakMap;function gi(e){const t=e._lineData,{align:n,direction:i,padding:o}=e.schema,a=e._outerBounds,r=[t,e._data,a.x,a.y,a.width,e._titleHeight,e._rtl,n,i,o],s=pi.get(e);if(s&&s.deps.every((e,t)=>e===r[t]))return s;const c=new Map;t.forEach(e=>{const t=c.get(e.y);t?t.push(e):c.set(e.y,[e])});const l=new Map,u=new Map;c.forEach((t,n)=>{l.set(n,e._rowWidth(t)),u.set(n,h.max(t.map(e=>e.height)))});const d=h.max(e._data.map((t,n)=>e._fetchConfig("height",t,n))),f=new Map,m=[],p=[];t.forEach(t=>{const r=t.y,s=l.get(r),c="left"===n||"right"===n&&"column"===i?0:"center"===n?(a.width-s)/2:a.width-s,g=f.get(r)||{widths:0,pads:0,last:0,count:0},y=g.count?g.widths+o*(g.pads-g.last):0,x=e._rtl?t.width+o:0;m.push(y+o*(g.count?t.sentence?2:1:0)+a.x+t.shapeWidth/2+c+x),p.push(r+e._titleHeight+a.y+h.max([u.get(r),d])/2);const b=t.width?2:1;f.set(r,{widths:g.widths+t.shapeWidth+t.width,pads:g.pads+b,last:b,count:g.count+1})});const g={deps:r,x:m,y:p};return pi.set(e,g),g}function yi(e,t,i){const o={lines:1,newRows:[],maxLines:h.max(e._lineData.map(e=>e.words.length))};if(e._wrapLines=()=>function(e,t,i,o){if(t.lines++,t.lines>t.maxLines)return;const r=1===t.lines?e._lineData.slice():e._lineData.filter(n=>n.width+n.shapeWidth+e.schema.padding*(n.width?2:1)>i&&n.words.length>=t.lines).sort((e,t)=>t.sentence.length-e.sentence.length);if(r.length&&o>r[0].height*t.lines){let i=!1;for(let e=0;e<r.length;e++){const o=r[e],s=o.og,c=s.height*t.lines,l=s.width*(1/t.lines*1.5),u=a.textWrap().fontFamily(o.f).fontSize(o.s).lineHeight(o.lh).width(l).height(c)(o.sentence);if(u.truncated){i=!0;break}o.width=Math.ceil(h.max(u.lines.map(e=>n.textWidth(e,{"font-family":o.f,"font-size":o.s}))))+o.s,o.height=u.lines.length*(o.lh+1)}i||e._wrapRows()}else t.newRows=[]}(e,o,t,i),e._wrapRows=()=>function(e,t,n,i){t.newRows=[];let o=1,a=0;for(let r=0;r<e._lineData.length;r++){const s=e._lineData[r],c=s.width+e.schema.padding*(s.width?2:1)+s.shapeWidth;if(h.sum(t.newRows.map(e=>h.max(e,e=>h.max([e.height,e.shapeHeight]))))>i){t.newRows=[];break}if(c>n){t.newRows=[],e._wrapLines();break}a+c<n?a+=c:"column"!==e.schema.direction&&(a=c,o++),t.newRows[o-1]||(t.newRows[o-1]=[]),t.newRows[o-1].push(s),"column"===e.schema.direction&&(a=0,o++)}}(e,o,t,i),e._wrapRows(),!o.newRows.length||h.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding>i){for(let t=0;t<e._lineData.length;t++)e._lineData[t].width=0,e._lineData[t].height=0;e._wrapRows()}return!(!o.newRows.length||h.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding>i)&&(o.newRows.forEach((t,n)=>{t.forEach(t=>{n&&(t.y=h.sum(o.newRows.slice(0,n),e._rowHeight.bind(e)))})}),h.max(o.newRows,e._rowWidth.bind(e)))}const xi=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:T("id")},{key:"label",coerce:"const",default:T("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:N("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class bi extends $e{_fetchConfig(e,t,n){const i=this.schema.shapeConfig.labelConfig,o=void 0!==this.schema.shapeConfig[e]?this.schema.shapeConfig[e]:i?.[e];return o||"lineHeight"!==e?"function"==typeof o?o(t,n):o:1.4*this._fetchConfig("fontSize",t,n)}_rowHeight(e){return h.max(e.map(e=>e.height).concat(e.map(e=>e.shapeHeight)))+this.schema.padding}_rowWidth(e){return h.sum(e.map((t,n)=>{const i=this.schema.padding*(n===e.length-1?0:t.width?2:1);return t.shapeWidth+t.width+i}))}toScene(){const e=[];let t;this._titleClass&&"function"==typeof this._titleClass.toScene&&this._titleClass._data&&this._titleClass._data.length&&e.push(this._titleClass.toScene()),(this._shapes||[]).forEach(t=>{const n=t;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){e.push(n.toScene());const t=n._labelClass;if(t&&"function"==typeof t.toScene&&t._data&&t._data.length){const n=t.toScene();n&&Array.isArray(n.children)&&e.push(...n.children)}}});const n=this._select&&"function"==typeof this._select.node?this._select.node():null;if(n&&"function"==typeof n.getAttribute){const e=n.getAttribute("transform");if(e){const n=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);n&&(t={x:Number(n[1]),y:Number(n[2])})}}return{type:"group",key:`Legend-${this._uuid.slice(0,8)}`,...t?{transform:t}:{},children:e}}render(e){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(t.select("body").append("div").node()),this._group=n.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=n.elem("g.d3plus-Legend-title",{parent:this._group}),this._shapeGroup=n.elem("g.d3plus-Legend-shape",{parent:this._group}),function(e){if(e._titleHeight=0,e._titleWidth=0,e.schema.title){const t=e.schema.titleConfig.fontFamily||e._titleClass.fontFamily()(),n=e.schema.titleConfig.fontSize||e._titleClass.fontSize()();let i=e.schema.titleConfig.lineHeight||e._titleClass.lineHeight();i="function"==typeof i?i():i??1.4*n;const o=a.textWrap().fontFamily(t).fontSize(n).lineHeight(i).width(e.schema.width).height(e.schema.height)(e.schema.title);e._titleHeight=i+o.lines.length+e.schema.padding,e._titleWidth=h.max(o.widths)}}(this);const i=this.schema.height-this._titleHeight;this._lineData=function(e,t){return e._data.map((i,o)=>{const r=e.schema.label(i,o),s=e.schema.shape(i,o),c=e._fetchConfig("r",i,o),l=e._fetchConfig("height",i,o);let u={data:i,i:o,id:e.schema.id(i,o),shape:s,shapeR:c,shapeWidth:"Circle"===s?2*c:"Line"===s?l:e._fetchConfig("width",i,o),shapeHeight:"Circle"===s?2*c:l,y:0};if(!r)return u.sentence=!1,u.words=[],u.height=0,u.width=0,u;const d=e._fetchConfig("fontFamily",i,o),f=e._fetchConfig("lineHeight",i,o),m=e._fetchConfig("fontSize",i,o),p=t-(e._data.length+1)*e.schema.padding,g=e.schema.width,y=a.textWrap().fontFamily(d).fontSize(m).lineHeight(f).width(g).height(p)(r);return u=Object.assign(u,y),u.width=u.lines.length?Math.ceil(h.max(u.lines.map(e=>n.textWidth(e,{"font-family":d,"font-size":m}))))+10:0,u.height=Math.ceil(u.lines.length*(f+1)),u.og={height:u.height,width:u.width},u.f=d,u.s=m,u.lh=f,u})}(this,i);let o=this._rowWidth(this._lineData);const r=this.schema.width-2*this.schema.padding;var s;return("column"===this.schema.direction||o>r)&&(o=yi(this,r,i)),!1===o?((s=this)._titleClass.data([]),s._shapes=[],Object.assign(s._outerBounds,{width:0,height:0,x:0,y:0})):(function(e,t){const n=h.max(e._lineData,(t,n)=>h.max([t.height,e._fetchConfig("height",t.data,n)])+t.y)+e._titleHeight,i=h.max([t,e._titleWidth]);e._outerBounds.width=i,e._outerBounds.height=n;let o=e.schema.padding,a=e.schema.padding;"center"===e.schema.align?o=(e.schema.width-i)/2:"right"===e.schema.align&&(o=e.schema.width-e.schema.padding-i),"middle"===e.schema.verticalAlign?a=(e.schema.height-n)/2:"bottom"===e.schema.verticalAlign&&(a=e.schema.height-e.schema.padding-n),e._outerBounds.x=o,e._outerBounds.y=a}(this,o),function(e){e._titleClass.renderMode("compute").data(e.schema.title?[{text:e.schema.title}]:[]).duration(e.schema.duration).select(e._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[e.schema.align]).width(e.schema.width-2*e.schema.padding).x(e.schema.padding).y(e._outerBounds.y).config(e.schema.titleConfig).render()}(this),function(e){e._shapes=[];const t=Ae.bind(e)(e.schema.shapeConfig,"legend"),n={id:e=>e.id,label:e=>e.label},i=e._data.map((t,n)=>({__d3plus__:!0,data:t,i:n,id:e.schema.id(t,n),label:!!e._lineData[n].width&&e.schema.label(t,n),shape:e.schema.shape(t,n)}));e._shapes=[],["Circle","Rect"].forEach(o=>{e._shapes.push((new E[o]).renderMode("compute").parent(e).data(i.filter(e=>e.shape===o||"Line"===e.shape)).duration(e.schema.duration).labelConfig({padding:0}).select(e._shapeGroup.node()).verticalAlign("top").config(t).config(n).config(function(e,t){const n=e=>"Line"===e.shape,i=(t,n)=>e._fetchConfig(t,n.data,n.i),o=t=>e._lineData[t.i];return"Rect"===t?{width:e=>n(e)?o(e).shapeWidth:i("width",e),height:e=>n(e)?2:i("height",e)}:{r:e=>n(e)?.3*o(e).shapeHeight:i("r",e),label:e=>!n(e)&&e.label,hitArea:e=>n(e)?null:i("hitArea",e)}}(e,o)).render())})}(this)),"compute"!==this.schema.renderMode&&De(this),e&&setTimeout(e,this.schema.duration+100),this}active(e){return this._shapes.forEach(t=>t.active(e)),this}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return this._shapes.forEach(t=>t.hover(e)),this}outerBounds(){return this._outerBounds}select(e){return arguments.length?(this._select=t.select(e),this._rtl=n.rtl(),this):this._select}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}constructor(){var e;super(),ee(this,xi),this._titleClass=new ro,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(e=this,{fill:T("color"),height:N(12),hitArea:(t,n)=>{const i=e._lineData[n],o=h.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:o,x:-i.shapeWidth/2,y:-o/2}},labelBounds:(t,n)=>{const i=e._lineData[n],o=i.shapeWidth/2,a=h.max([i.shapeHeight,i.height]),r=e._rtl?i.shapeWidth+i.width+2*e.schema.padding:0;return{width:i.width,height:a,x:o+5-r,y:-a/2}},labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},fontFamily:e._titleClass.fontFamily(),fontResize:!1,fontSize:N(10),pointerEvents:N("none"),textAnchor:"start",verticalAlign:"middle"},opacity:1,r:N(6),width:N(12),x:(t,n)=>gi(e).x[n],y:(t,n)=>gi(e).y[n]}),this.schema.titleConfig={fontSize:12},this._rtl=!1,this._titleHeight=0,this._titleWidth=0}}function _i(e){const[t,n]=e.toExponential(14).split("e"),i=t.split(".")[1].replace(/0+$/,"");return Math.max(0,i.length-Number(n))}K(bi.prototype,"shapeConfig","titleConfig");const ki=(e,t)=>+(e*10**t).toPrecision(15),vi=(e,t)=>+(e/10**t).toPrecision(15);const wi=["buckets","jenks","linear","log","quantile"],Si=e=>"buckets"===e||"jenks"===e||"quantile"===e;const Ci=e=>e.schema.colorMin??e.schema.colorDefaults.off,Mi=e=>e.schema.colorMid??e.schema.colorDefaults.light,$i=e=>e.schema.colorMax??e.schema.colorDefaults.sequential;function Ai(e,t){const{scale:n}=t;let i=e.schema.buckets instanceof Array?e.schema.buckets:void 0;const o=t.diverging&&!t.colors?function(e,t,n){const{domain:i,numBuckets:o}=t,a=Math.floor(o/2),r=x.interpolateRgb.gamma(2.2)(Ci(e),Mi(e)),s=h.range(0,a,1).map(e=>r(e/a)),c=(o%2?[0]:[]).map(()=>Mi(e)),l=x.interpolateRgb.gamma(2.2)($i(e),Mi(e)),u=h.range(0,a,1).map(e=>l(e/a)).reverse(),d=s.concat(c).concat(u);if(!n){const t=(d.length-1)/2;n=h.range(i[0],e.schema.midpoint,-(i[0]-e.schema.midpoint)/t).concat(h.range(e.schema.midpoint,i[1],(i[1]-e.schema.midpoint)/t)).concat([i[1]])}return{colors:d,buckets:n}}(e,t,i):function(e,t,n){const{allValues:i,domain:o,negative:a,positive:s,diverging:c,numBuckets:l,scale:u}=t;let{colors:d}=t;if(!d){const t=a?Ci(e):$i(e);if("buckets"===u||"quantile"===u){const e=r.colorRamp(t,l);d=s?e:e.slice().reverse()}else{const e=r.colorRamp(t,2);d=a?e.slice().reverse():e}}if(!n)if("quantile"===u){const e=1/(d.length-1);n=h.range(0,1+e/2,e).map(e=>h.quantile(i,e))}else if(c&&e.schema.color&&e.schema.centered){const t=d.indexOf(Mi(e)),i=(e.schema.midpoint-o[0])/t,a=(o[1]-e.schema.midpoint)/(d.length-t),r=h.range(o[0],e.schema.midpoint,i),s=h.range(e.schema.midpoint,o[1]+a/2,a);n=r.concat(s)}else{const e=(o[1]-o[0])/(d.length-1);n=h.range(o[0],o[1]+e/2,e)}return{colors:d,buckets:n}}(e,t,i);let a,{colors:c}=o;if(i=o.buckets,"buckets"===n||"quantile"===n)a=i,c=[c[0]].concat(c);else if("log"===n){const e=i.filter(e=>e<0);if(e.length){const t=e[0],n=e.map(e=>-Math.pow(Math.abs(t),e/t));e.forEach((e,t)=>{i[i.indexOf(e)]=n[t]})}const t=i.filter(e=>e>0);if(t.length){const e=t[t.length-1],n=t.map(t=>Math.pow(e,t/e));t.forEach((e,t)=>{i[i.indexOf(e)]=n[t]})}i.includes(0)&&(i[i.indexOf(0)]=1)}const l="buckets"===n||"quantile"===n?s.scaleThreshold:s.scaleLinear;return e._colorScale=l().domain(i).range(c),{colors:c,ticks:a,labels:void 0}}function zi(e){const t=["bottom","top"].includes(e.schema.orient),n=t?"height":"width",i=t?"width":"height",a=t?"x":"y",c=t?"y":"x",l=e._data.map(e.schema.value).filter(e=>"number"==typeof e&&!Number.isNaN(e)).sort((e,t)=>e-t),u=function(e,t,n){const i=t.length?[t[0],t[t.length-1]]:[void 0,void 0],o="function"==typeof e?e.call(n,t.slice(),i):e;return wi.includes(o)?o:(pe(`ColorScale received unknown scale ${JSON.stringify(o)??String(o)}; using "linear". Use one of ${wi.map(e=>`"${e}"`).join(", ")}, or a function returning one.`),"linear")}(e.schema.scale,l,e);e._scaleType=u;const d=e.schema.domain||h.extent(l),m=d[0]<e.schema.midpoint,p=d[1]>e.schema.midpoint,g=m&&p,y=h.min([e.schema.buckets instanceof Array?e.schema.buckets.length:e.schema.buckets,g&&"jenks"!==u?2*Math.floor(o.unique(l).length/2)-1:o.unique(l).length]);let x=g&&(!e.schema.color||e.schema.color instanceof Array&&!e.schema.color.includes(Mi(e)))?void 0:e.schema.color;!x||x instanceof Array||(x=r.colorRamp(x,y));const b={scale:u,allValues:l,domain:d,negative:m,positive:p,diverging:g,numBuckets:y,colors:x},_="jenks"===u?function(e,t){const{allValues:n,diverging:i,numBuckets:o}=t;let a,c,{colors:l}=t;const u=h.min([l?l.length:o,o,n.length]);let d;if(e.schema.buckets instanceof Array)a=e.schema.buckets;else{if(i&&e.schema.centered){const t=Math.floor(u/2),i=u%2,o=n.filter(t=>t<e.schema.midpoint),a=h.deviation(o),r=n.concat(e.schema.midpoint).filter(t=>t>=e.schema.midpoint),s=h.deviation(r),c=a>s?1:0,l=s>a?1:0,m=f.ckmeans(o,h.min([t+i*c,o.length])),p=f.ckmeans(r,h.min([t+i*l,r.length]));d=m.concat(p)}else d=f.ckmeans(n,u);a=d.map(e=>e[0])}const m=new Set(a);if(a.length!==m.size&&(c=Array.from(m)),!l)if(i){const t=[Ci(e),Mi(e),$i(e)],n=a.slice(0,u).filter((t,n)=>t<e.schema.midpoint&&a[n+1]<=e.schema.midpoint),i=a.slice(0,u).filter((t,n)=>t<=e.schema.midpoint&&a[n+1]>e.schema.midpoint),o=a.slice(0,u).filter(t=>t>e.schema.midpoint),s=n.map((e,i)=>i?r.colorLighter(t[0],i/n.length):t[0]),c=i.map(()=>t[1]),h=o.map((e,n)=>n===o.length-1?t[2]:r.colorLighter(t[2],1-(n+1)/o.length));l=s.concat(c).concat(h)}else l=r.colorRamp($i(e),o);return a.length<=u&&(l=l.slice(-a.length)),l=[l[0]].concat(l),e._colorScale=s.scaleThreshold().domain(a).range(l),{colors:l,ticks:a,labels:c}}(e,b):Ai(e,b);return e._colorScale.clamp&&e._colorScale.clamp(!0),{scale:u,allValues:l,domain:d,ticks:_.ticks,labels:_.labels,colors:_.colors,horizontal:t,height:n,width:i,x:a,y:c}}function Di(e,t,o){const a={x:0,y:0},{axisConfig:r,labelConfig:c,axisDomain:l,labelData:h}=function(e,t,i){const{horizontal:o,height:a,width:r,domain:s,labels:c,ticks:l}=t,h=s.slice();if(e.schema.bucketAxis){const e=h[h.length-1],t=h[h.length-2],n=e?e/10:t/10,i=n>=1||n<=-1?Math.round(n).toString().length-1:-1*n.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,o=Math.pow(10,i);h[h.length-1]=e+o}const u=n.assign({domain:o?h:h.slice().reverse(),duration:e.schema.duration,height:e.schema.height,labels:c||l,orient:e.schema.orient,padding:e.schema.padding,scale:"log"===t.scale?"log":"linear",ticks:l,width:e.schema.width},e.schema.axisConfig),d=n.assign({height:e.schema[a]/2,width:e.schema[r]/2},e.schema.labelConfig);e._labelClass.config(d);const f=[];if(o&&e._labelMin){const t={"font-family":e._labelClass.fontFamily()(e._labelMin),"font-size":e._labelClass.fontSize()(e._labelMin),"font-weight":e._labelClass.fontWeight()(e._labelMin)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMin,t);a&&a<e.schema[r]/2&&(f.push(e._labelMin),a+=e.schema.padding,o&&(i.x+=a),u[r]=u[r]-a)}if(o&&e._labelMax){const t={"font-family":e._labelClass.fontFamily()(e._labelMax),"font-size":e._labelClass.fontSize()(e._labelMax),"font-weight":e._labelClass.fontWeight()(e._labelMax)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMax,t);a&&a<e.schema[r]/2&&(f.push(e._labelMax),a+=e.schema.padding,o||(i.y+=a),u[r]=u[r]-a)}return{axisConfig:u,labelConfig:d,axisDomain:h,labelData:f}}(e,t,a),{axisBounds:u,axisScale:d,scaleRange:f}=function(e,t,i,o,a){const{horizontal:r,height:s,width:c,x:l,y:h}=t;e._axisTest.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:e._group}).node()).config(o).duration(0).render();const u=e._axisTest.outerBounds();e._outerBounds[c]=e.schema[c]-2*e.schema.padding,e._outerBounds[s]=u[s]+e.schema.size,e._outerBounds[l]=e.schema.padding,e._outerBounds[h]=e.schema.padding,"middle"===e.schema.align?e._outerBounds[h]=(e.schema[s]-e._outerBounds[s])/2:"end"===e.schema.align&&(e._outerBounds[h]=e.schema[s]-e.schema.padding-e._outerBounds[s]);const d=e._outerBounds[h]+(["bottom","right"].includes(e.schema.orient)?e.schema.size:0)-(o.padding||e._axisClass.padding()),f=`translate(${a.x+(r?0:d)}, ${a.y+(r?d:0)})`;return e._axisClass.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axis",n.assign(i.groupParams,{condition:!0,enter:{transform:f},update:{transform:f}})).node()).config(o).align("start").render(),{axisBounds:u,axisScale:e._axisTest._getPosition.bind(e._axisTest),scaleRange:e._axisTest._getRange()}}(e,t,o,r,a);!function(e,t,n,o){const{horizontal:a,colors:r}=t,c=e._colorScale.domain(),l=s.scaleLinear().domain(o).range(a?[0,100]:[100,0]),h=r.map((e,t)=>({offset:(t<=c.length-1?l(n(c[t])):100)/100,color:String(e)})).sort((e,t)=>e.offset-t.offset),u={type:"linear",from:a?[0,0]:[0,1],to:a?[1,0]:[0,0],stops:h};e._gradientFill=i.gradientToken(u)}(e,t,d,f);const m=function(e,t,i,o){const{height:a,width:r,x:s,y:c,ticks:l}=t,{axisScale:h,scaleRange:u,axisDomain:d,axisBounds:f,offsets:m}=o,p=(e,t)=>{const n=l[t+1]||d[d.length-1];return Math.abs(h(n)-h(e))},g=n.assign({duration:e.schema.duration,fill:l?t=>e._colorScale(t):e._gradientFill,[s]:l?(t,n)=>h(t)+p(t,n)/2-(["left","right"].includes(e.schema.orient)?p(t,n):0):u[0]+(u[1]-u[0])/2+m[s],[c]:e._outerBounds[c]+(["top","left"].includes(e.schema.orient)?f[a]:0)+e.schema.size/2+m[c],[r]:l?p:u[1]-u[0],[a]:e.schema.size},e.schema.rectConfig),y=e._outerBounds[c]+(["top","left"].includes(e.schema.orient)?f[a]:0)+m[c];return e._barGeometry={orient:e.schema.orient,position:e=>h(e)+m[s],range:[u[0]+m[s],u[1]+m[s]],cross:[y,y+e.schema.size],domain:[d[0],d[d.length-1]],...l?{ticks:l}:{}},e._rectClass.renderMode("compute").data(l||[0]).id((e,t)=>t).select(i.rectGroup.node()).config(g).render(),g}(e,t,o,{axisScale:d,scaleRange:f,axisDomain:l,axisBounds:u,offsets:a});!function(e,t,n,i,o,a){const{horizontal:r,height:s,width:c}=t;i.height=e._outerBounds[s],i.width=e._outerBounds[c],e._labelClass.renderMode("compute"),e._labelClass.config(i).data(a).select(n.labelGroup.node()).x(t=>t===e._labelMax?o.x+o.width/2+e.schema.padding:e._outerBounds.x).y(t=>o.y-e._labelClass.fontSize()(t)/2).text(e=>e).rotate(r?0:"right"===e.schema.orient?90:-90).render()}(e,t,o,c,m,h)}const Fi=e=>"bottom"===e||"top"===e;function Bi(e,[t,n]){const i=Math.min(t,n),o=Math.max(t,n);return Math.min(o,Math.max(i,e))}function Li(e,t){if("number"!=typeof t||!Number.isFinite(t))return null;const n=e.position(Bi(t,e.domain));return Number.isFinite(n)?Bi(n,e.range):null}function Pi(e,t,n,i){return"bottom"===e?[[t,n[1]],[t,n[1]+i]]:"top"===e?[[t,n[0]],[t,n[0]-i]]:"right"===e?[[n[1],t],[n[1]+i,t]]:[[n[0],t],[n[0]-i,t]]}function Ri(e,t){return"function"==typeof e?e(t):e}function Ei(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",e}function Ni(e){const t=Ri(e.config.tickConfig?.length,e.value),n=e.cs._axisClass.schema.tickSize;return"number"==typeof t?t:"number"==typeof n?n:8}function Ti(e,t,n,i){const o=e.config.tickConfig||{};return Ei({type:"line",key:`${e.key}-tick`,points:Pi(t,n,i,Ni(e)),paint:{fill:"none",stroke:Ri(o.stroke,e.value)??e.tickPaint.stroke??e.ink,strokeWidth:Ri(o.strokeWidth,e.value)??e.tickPaint.strokeWidth??1}})}function Oi(e,t,i,o){const{cs:a,value:s}=e,c=e.config.badgeConfig||{},l=Ri(c.fontSize,s)??11,h=Ri(c.fontFamily,s)||`${a._labelClass.fontFamily()(o)}`,u=Ri(c.fontWeight,s)??400,d=Ri(c.padding,s)??3,f=Ri(c.fill,s)??e.color,m=Ri(c.fontColor,s)??r.colorContrast(f,a.schema.colorDefaults),p=n.textWidth(o,{"font-family":h,"font-size":l,"font-weight":u}),g=Fi(t.orient)?a.schema.width:a.schema.height,y=Ni(e),x=a._axisClass.schema,b=("number"==typeof x.tickSize?x.tickSize:8)+("number"==typeof x.padding?x.padding:0),_=Math.max(d,b-y),k=function(e,t,n,i,o,a){const{width:r,height:s}=i;if(Fi(e))return{x:Bi(t-r/2,[0,Math.max(0,o-r)]),y:"bottom"===e?n[1]+a:n[0]-a-s,width:r,height:s};const c=Bi(t-s/2,[0,Math.max(0,o-s)]);return{x:"right"===e?n[1]+a:n[0]-a-r,y:c,width:r,height:s}}(t.orient,i,t.cross,Fi(t.orient)?{width:p+2*d,height:l+2*_}:{width:p+2*_,height:l+2*d},g,y),v=`${e.key}-badge`;return Ei({type:"group",key:v,children:[Ei({type:"rect",key:`${v}-box`,...k,rx:Ri(c.rx,s)??0,paint:{fill:f,stroke:Ri(c.stroke,s)??e.ink,strokeWidth:Ri(c.strokeWidth,s)??1}}),Ei({type:"text",key:`${v}-text`,x:0,y:0,transform:{x:k.x+k.width/2,y:k.y+k.height/2},lines:[{text:o,x:0,y:0,width:p}],font:{family:h,size:l,weight:u,anchor:"middle",baseline:"middle"},paint:{fill:m}})]})}function Wi(e,t){if(!t.ticks)return[];const n=function(e,t,n){let i=-1;return e.forEach((e,n)=>{t>=e&&(i=n)}),i<0?e.length?[e[0],e[1]??n]:null:[e[i],e[i+1]??n]}(t.ticks,e.value,t.domain[1]);if(!n)return[];const[i,o]=n.map(e=>Li(t,e));if(null===i||null===o)return[];const a=e.config.outlineConfig||{},r=Math.min(i,o),s=Math.abs(o-i),[c,l]=t.cross,h=Fi(t.orient)?{x:r,y:c,width:s,height:l-c}:{x:c,y:r,width:l-c,height:s};return[Ei({type:"rect",key:`${e.key}-outline`,...h,paint:{fill:"none",stroke:Ri(a.stroke,e.value)??e.ink,strokeWidth:Ri(a.strokeWidth,e.value)??2}})]}function ji(e){let t;const n=(e,i)=>{if(t)return;const o=i||String(e.key).startsWith("Axis-");"group"===e.type?e.children.forEach(e=>n(e,o)):o&&"path"===e.type&&!String(e.key).endsWith("::hit")&&(t={stroke:e.paint?.stroke,strokeWidth:e.paint?.strokeWidth})};return e.children.forEach(e=>n(e,!1)),t??{}}function Hi(e,t){const i=e._hoverValue,o=e._barGeometry;if(!1===e.schema.hoverMark||"number"!=typeof i||!Number.isFinite(i)||!e._colorScale||!o)return;const a=e._select&&"function"==typeof e._select.node?e._select.node():null,s=r.colorContrast(a?n.backgroundColor(a):"rgb(255, 255, 255)",e.schema.colorDefaults),c={cs:e,key:`${t.key}-hover`,value:i,color:String(e._colorScale(i)),ink:s,config:e.schema.hoverMarkConfig||{},tickPaint:ji(t)};t.children.push(...function(e,t){const n=Li(t,e.value);if(null===n)return[];const i=function(e,t){const n=e._axisClass._labelFormat??e.schema.axisConfig.tickFormat;return`${(n?n(t):`${t}`)??""}`.replace(/<[^>]*>/g,"").trim()}(e.cs,e.value);return[...Wi(e,t),Ti(e,t.orient,n,t.cross),...i?[Oi(e,t,n,i)]:[]]}(c,o))}const Ii=[{key:"align",coerce:"identity",default:"middle"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(e,t)=>e!==t?`${e} - ${t}`:`${e}`},{key:"centered",coerce:"identity",default:!0},{key:"color",coerce:"identity"},{key:"colorMax",coerce:"identity"},{key:"colorMid",coerce:"identity"},{key:"colorMin",coerce:"identity"},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"hoverMark",coerce:"identity",default:!0},{key:"hoverMarkConfig",merge:!0,factory:function(){return{tickConfig:{},badgeConfig:{fontSize:11,fontWeight:400,padding:3,rx:2},outlineConfig:{strokeWidth:2}}}},{key:"midpoint",coerce:"identity",default:0},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:T("value")},{key:"width",coerce:"identity",default:400}];class Gi extends $e{render(e){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(t.select("body").append("div").node()),this._group=n.elem("g.d3plus-ColorScale",{parent:this._select});const i=zi(this),o=this.schema.bucketAxis||!Si(i.scale),a=u.transition().duration(this.schema.duration),r={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:a,update:{opacity:1}},s={labelGroup:n.elem("g.d3plus-ColorScale-labels",Object.assign({condition:o},r)),rectGroup:n.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:o},r)),legendGroup:n.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!o},r)),groupParams:r,gradient:o};return o?Di(this,i,s):function(e,t,i){const{horizontal:o,allValues:a,ticks:r,colors:s}=t;e._barGeometry=void 0,n.elem("g.d3plus-ColorScale-axis",Object.assign({condition:i.gradient},i.groupParams));let c=r.reduce((t,n,i)=>{const o=e.schema.bucketFormat.bind(e)(n,i,r,a);return t.push({color:s[i+1],id:o,_isColorScaleBucket:!0}),t},[]);o||(c=c.reverse());const l=n.assign({align:o?"center":{start:"left",middle:"center",end:"right"}[e.schema.align],direction:o?"row":"column",duration:e.schema.duration,height:e.schema.height,padding:e.schema.padding,shapeConfig:n.assign({duration:e.schema.duration},e.schema.axisConfig.shapeConfig||{}),title:e.schema.axisConfig.title,titleConfig:e.schema.axisConfig.titleConfig||{},width:e.schema.width,verticalAlign:o?{start:"top",middle:"middle",end:"bottom"}[e.schema.align]:"middle"},e.schema.legendConfig);e._legendClass.renderMode("compute").data(c).select(i.legendGroup.node()).config(l).render(),e._outerBounds=e._legendClass.outerBounds()}(this,i,s),"compute"!==this.schema.renderMode&&De(this),e&&setTimeout(e,this.schema.duration+100),this}toScene(){const e=[],t=t=>{if(t&&"function"==typeof t.toScene){const n=t.toScene();n&&e.push(n)}};let n;this.schema.bucketAxis||!Si(this._scaleType)?(t(this._rectClass),t(this._axisClass),t(this._labelClass)):t(this._legendClass);const i=this._select&&"function"==typeof this._select.node?this._select.node():null;if(i&&"function"==typeof i.getAttribute){const e=i.getAttribute("transform");if(e){const t=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);t&&(n={x:Number(t[1]),y:Number(t[2])})}}const o={type:"group",key:`ColorScale-${this._uuid.slice(0,8)}`,...n?{transform:n}:{},children:e};return Hi(this,o),o}axisConfig(e){return arguments.length?(this.schema.axisConfig=Y(this,"axisConfig",e),this):this.schema.axisConfig}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return arguments.length?(this._hoverValue=e,this):this._hoverValue}labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}labelMin(e){return arguments.length?(this._labelMin=e,this):this._labelMin}labelMax(e){return arguments.length?(this._labelMax=e,this):this._labelMax}legendConfig(e){return arguments.length?(this.schema.legendConfig=Y(this,"legendConfig",e),this):this.schema.legendConfig}outerBounds(){return this._outerBounds}rectConfig(e){return arguments.length?(this.schema.rectConfig=Y(this,"rectConfig",e),this):this.schema.rectConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){super(),this._scaleType="linear",ee(this,Ii),this._axisClass=new hi,this.schema.axisConfig={gridSize:0},this._axisTest=new hi,this.schema.bucketFormat=(e,t,n,i)=>{const o=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:Dn(i)?e=>Bn(e,this.schema.locale):d.formatAbbreviate,a=t===n.length-1;if(e===n[t+1]||a){const t=a&&e<h.max(i)?"+":"";return`${o(e)}${t}`}const[r,s]=function(e,t,n,i,o){const a=n[t+1],r=h.max(i.filter(Number.isFinite).map(_i))??0,s=ki(e,r),c=vi(1===t&&n[0]===e?Math.floor(s)+1:Math.ceil(s),r),l=e=>vi(Math.ceil(ki(a,e))-1,e),u=o(vi(Math.ceil(ki(a,r)),r));let d=r,f=l(d);for(;o(f)===u&&l(d-1)>=c;)f=l(--d);return[c,f]}(e,t,n,i,o);return this.schema.bucketJoiner(o(r),o(s))},this._data=[],this._labelClass=new ro,this.schema.labelConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return r.colorContrast(e,this.schema.colorDefaults)},fontSize:12},this._legendClass=new bi,this.schema.legendConfig={shapeConfig:{stroke:()=>this.schema.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new Yo).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}function Vi(e,t,n){return n.width<=n.availableWidth/3&&n.height<=n.availableHeight/3}K(Gi.prototype,"axisConfig","labelConfig","legendConfig","rectConfig");function qi(e){for(let t=1;t<15;t++)if(Number(e.toPrecision(t))===e)return t;return 15}function Yi(e,t=3){const[n,i]=e;if(t<=1)return[i];if(2===t)return[n,i];const o=h.ticks(n,i,4*t).filter(e=>e>n&&e<i),a=.15*(i-n),r=[];for(let e=1;e<t-1;e++){const s=n+(i-n)*e/(t-1),c=o.filter(e=>!r.includes(e)&&Math.abs(e-s)<=a);c.sort((e,t)=>qi(e)-qi(t)||Math.abs(e-s)-Math.abs(t-s)),c.length&&r.push(c[0])}return[n,...r.sort((e,t)=>e-t),i]}function Ki(e){const t=e.scale.domain();if(t.length<2||!Number.isFinite(t[0])||!Number.isFinite(t[1])||t[0]===t[1])return{circles:[],lines:[],labels:[],width:0,height:0};const i=e.maxRadius??1/0,o=function(e,t){const n="function"==typeof e?e(t):Array.isArray(e)?e:Yi(t,e??3);return Array.from(new Set(n.filter(e=>Number.isFinite(e)))).sort((e,t)=>t-e)}(e.values,t).filter(t=>e.scale(t)<=i+.5),a=o.map(t=>Math.max(0,e.scale(t)||0)),r=Math.max(0,...a);if(!o.length||!r)return{circles:[],lines:[],labels:[],width:0,height:0};const{padding:s,fontSize:c}=e,l=1.2*c,h=o.map(t=>e.tickFormat(t)),u=h.map(t=>n.textWidth(t,{"font-family":e.fontFamily,"font-size":c})),d=e.title?String(e.title):"",f=d?n.textWidth(d,{"font-family":e.titleFontFamily,"font-size":e.titleFontSize,"font-weight":e.titleFontWeight}):0,m=d?1.2*e.titleFontSize+2:0,p=2*r+e.lineLength+e.labelPadding+Math.max(...u),g=Math.max(p,f),y=Math.min(s+g/2,s+g-p+r),x=s+m+l/2+2*r,b=o.map((e,t)=>({value:e,cx:y,cy:x-a[t],r:a[t]})),_=y+r+e.lineLength+e.labelPadding,k=[],v=[];let w,S=-1/0;if(b.forEach((t,n)=>{const i=t.cy-t.r,o=Math.max(i,S+l);S=o,k.push({value:t.value,text:h[n],x:_,y:o,width:u[n]});const a=[[t.cx,i],[t.cx+r,i]];o!==i&&a.push([t.cx+r+e.lineLength/2,o]),a.push([_-e.labelPadding,o]),v.push({value:t.value,points:a})}),d){w={text:d,x:Math.min(Math.max(y,s+f/2),s+g-f/2),y:s+e.titleFontSize,width:f}}const C=Math.max(x,S+l/2)+s;return{circles:b,lines:v,labels:k,title:w,width:Math.ceil(g+2*s),height:Math.ceil(C)}}function Ui(e,t){if(1===t||!Number.isFinite(t)||t<=0)return e;const[n,i]=e.domain(),o=e.invert?Math.max(n,Math.min(i,e.invert(e(i)/t))):i,a=(o<i?h.ticks(n,o,4).filter(e=>e>n&&e<=o).pop():void 0)??o,r=n=>e(n)*t;return r.domain=()=>[n,a],r}const Xi=[{key:"labelPadding",coerce:"identity",default:4},{key:"lineLength",coerce:"identity",default:6},{key:"padding",coerce:"identity",default:4},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity"},{key:"tickFormat",coerce:"identity"},{key:"title",coerce:"identity"},{key:"values",coerce:"identity"}],Qi=e=>a.fontFamilyStringify(void 0===e?a.fontFamily:Array.isArray(e)?e:[e]);class Zi extends $e{labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}lineConfig(e){return arguments.length?(this.schema.lineConfig=Y(this,"lineConfig",e),this):this.schema.lineConfig}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}layout(){const e=this.schema.scale;if(!e||"function"!=typeof e.domain)return this._layout={circles:[],lines:[],labels:[],width:0,height:0};const t=this.schema.labelConfig,n=this.schema.titleConfig,i=this.schema.locale;return this._layout=Ki({scale:e,values:this.schema.values,tickFormat:this.schema.tickFormat??(e=>d.formatAbbreviate(e,i)),fontFamily:Qi(t.fontFamily),fontSize:t.fontSize??10,title:this.schema.title,titleFontFamily:Qi(n.fontFamily),titleFontSize:n.fontSize??11,titleFontWeight:n.fontWeight??600,lineLength:this.schema.lineLength,labelPadding:this.schema.labelPadding,padding:this.schema.padding,maxRadius:this._maxRadius}),this._layout}outerBounds(){return{width:this._layout.width,height:this._layout.height}}toScene(e=0,t=0){const n=this._layout,i=this.schema.shapeConfig,o=this.schema.lineConfig,a=this.schema.labelConfig,r=this.schema.titleConfig,s=Qi(a.fontFamily),c=[];return n.circles.forEach(e=>c.push({type:"circle",key:`circle-${e.value}`,interactive:!1,cx:e.cx,cy:e.cy,r:e.r,paint:{...i}})),n.lines.forEach(e=>c.push({type:"line",key:`line-${e.value}`,interactive:!1,points:e.points,paint:{fill:"none",...o}})),n.labels.forEach(e=>c.push({type:"text",key:`label-${e.value}`,interactive:!1,x:0,y:0,transform:{x:e.x,y:e.y},lines:[{text:e.text,x:0,y:0,width:e.width}],font:{family:s,size:a.fontSize??10,anchor:"start",baseline:"middle"},paint:{fill:a.fontColor}})),n.title&&c.push({type:"text",key:"title",interactive:!1,x:0,y:0,transform:{x:n.title.x,y:n.title.y},lines:[{text:n.title.text,x:0,y:0,width:n.title.width}],font:{family:Qi(r.fontFamily),size:r.fontSize??11,weight:r.fontWeight??600,anchor:"middle",baseline:"alphabetic"},paint:{fill:r.fontColor}}),{type:"group",key:`SizeLegend-${this._uuid.slice(0,8)}`,transform:{x:e,y:t},children:c}}render(e){return this.layout(),"compute"!==this.schema.renderMode&&(void 0===this._select&&this.select(t.select("body").append("div").node()),this.schema.width=this._layout.width,this.schema.height=this._layout.height,De(this)),e&&setTimeout(e,0),this}constructor(){super(),ee(this,Xi),this._layout={circles:[],lines:[],labels:[],width:0,height:0},this.schema.labelConfig={fontColor:r.colorDefaults.dark,fontSize:10},this.schema.lineConfig={stroke:r.colorDefaults.dark,strokeOpacity:.5,strokeWidth:1},this.schema.shapeConfig={fill:r.colorDefaults.dark,fillOpacity:.05,stroke:r.colorDefaults.dark,strokeOpacity:.6,strokeWidth:1},this.schema.titleConfig={fontColor:r.colorDefaults.dark,fontSize:11,fontWeight:600}}}K(Zi.prototype,"labelConfig","lineConfig","shapeConfig","titleConfig");class Ji{exit(e,t){e.transition().duration(t).style("opacity",0).transition().remove(),this._isVisible=!1}hide({duration:e=600,callback:t}={}){return this.mask.call(this.exit.bind(this),e),this.elem.call(this.exit.bind(this),e),t&&setTimeout(t,e+100),this._isVisible=!1,this}render({callback:e,container:i="body",duration:o=600,html:a="Please Wait",mask:r="rgba(0, 0, 0, 0.05)",style:s={}}={}){const c=t.select(i);return this.mask=c.selectAll("div.d3plus-Mask").data(r?[r]:[]),this.mask=this.mask.enter().append("div").attr("class","d3plus-Mask").style("opacity",1).merge(this.mask),this.mask.exit().call(this.exit.bind(this),o),n.stylize(this.mask,{"background-color":"transparent",bottom:"0px",left:"0px",position:"absolute",right:"0px",top:"0px"}),this.elem=c.selectAll("div.d3plus-Message").data([a]),this.elem=this.elem.enter().append("div").attr("class","d3plus-Message").style("opacity",1).merge(this.elem).html(String),n.stylize(this.elem,s),e&&setTimeout(e,100),this._isVisible=!0,this}constructor(){this._isVisible=!1}}function eo(e){const t={};for(const n of e.split(";")){const[e,i]=n.split(":").map(e=>e.trim());e&&i&&("font-weight"===e?t.weight=/^\d+$/.test(i)?Number(i):i:"font-style"===e&&(t.style="italic"===i?"italic":"normal"))}return void 0===t.weight&&void 0===t.style?void 0:t}function to(e,t,n){let i=e.trimEnd().replace(/&([^;&]*)/g,(e,t)=>"amp"===t?e:`&${t}`).replace(/<([^A-z^/]+)/g,(e,t)=>`<${t}`).replace(/<$/g,"<").replace(/(<[^>^/]+>)([^<^>]+)$/g,(e,t,n)=>`${t}${n}${t.replace("<","</")}`).replace(/^([^<^>]+)(<\/[^>]+>)/g,(e,t,n)=>`${n.replace("</","<")}${t}${n}`),o=n;o&&!i.startsWith("<")&&(i=`<${o}>${i}`,i.includes(`</${o}>`)||(i+=`</${o}>`));const a=/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g,r=[];let s,c=0;for(;null!==(s=a.exec(i));){s.index>c&&r.push({text:i.slice(c,s.index)});const n=s[1],a=s[2],l=t[n];l?(o=!e.includes(`</${n}>`)&&n,r.push({text:a,style:eo(l)})):r.push({text:a}),c=s.index+s[0].length}return c<i.length&&r.push({text:i.slice(c)}),!r.length&&i&&r.push({text:i}),{runs:r,openTag:o}}function no(e,t,n,i){const{lineData:o,line:a,fS:r,lH:s,w:c,h:l,vA:h,style:u,widths:d,truncated:f,padding:m}=i,p=a*s,g=e.schema.rotate(t,n);let y=0===g?"top"===h?0:"middle"===h?l/2-p/2:l-p:0;y-=.1*s;const x=function(e,t){let n=null;if(e.schema.html){const i=e.schema.html;let o=!1;const a=[];let r=!1;for(const e of t){const{runs:t,openTag:n}=to(e,i,o);a.push(t),o=n,t.some(e=>e.style)&&(r=!0)}r&&(n=a)}return n}(e,o);return{aH:e.schema.ariaHidden(t,n),data:t,i:n,lines:o,lineRuns:x,fC:e.schema.fontColor(t,n),fStroke:e.schema.fontStroke(t,n),fSW:e.schema.fontStrokeWidth(t,n),fF:u["font-family"],fO:e.schema.fontOpacity(t,n),fW:u["font-weight"],id:e.schema.id(t,n),pE:e.schema.pointerEvents(t,n),tA:e.schema.textAnchor(t,n),vA:e.schema.verticalAlign(t,n),widths:d,truncated:f,fS:r,lH:s,w:c,h:l,r:g,x:e.schema.x(t,n)+m.left,y:e.schema.y(t,n)+y+m.top}}function io(e,t,i){const o=e;let r=e.schema.text(t,i);if(void 0===r)return null;r=`${r}`.trim();const s=e.schema.fontResize(t,i),c=e.schema.lineHeight(t,i)/e.schema.fontSize(t,i);let l=s?e.schema.fontMax(t,i):e.schema.fontSize(t,i),u=s?l*c:e.schema.lineHeight(t,i),d=1,f=[],m={lines:[],truncated:!1,widths:[]};const p={"font-family":n.fontExists(e.schema.fontFamily(t,i)),"font-size":l,"font-weight":e.schema.fontWeight(t,i),"line-height":u},g=n.parseSides(e.schema.padding(t,i)),y=e.schema.height(t,i)-(g.top+g.bottom),x=e.schema.width(t,i)-(g.left+g.right),b=e.schema.shape(t,i),_=a.textWrap().fontFamily(p["font-family"]).fontSize(l).fontWeight(p["font-weight"]).lineHeight(u).maxLines(e.schema.maxLines(t,i)).height(y).overflow(e.schema.overflow(t,i)).shape(b).width(x).split(e.schema.split),k=e.schema.fontMax(t,i),v=e.schema.fontMin(t,i),w=e.schema.verticalAlign(t,i),S=e.schema.split(r,i);return x>(s?v:0)&&(y>u||s&&y>v*c)&&(s&&(l=function(e,t,i,o,a,r,s){const c=n.textWidth(a,r),l=1.165+t/i*.1,u=t*i*("circle"===s?Math.PI/4:1),d=h.max(c),f=h.sum(c,e=>e*o)*l;if(d>t||f>u){const n=Math.sqrt(u/f),i=t/d,o=h.min([n,i]);e=Math.floor(e*o)}const m=Math.floor(.8*i);return e>m&&(e=m),e}(l,x,y,u,S,p,b)),function e(){const t=()=>{d<1?f=[o.schema.ellipsis("",d)]:f[d-1]=o.schema.ellipsis(f[d-1],d)};if(s&&(l=h.max([l,v]),l=h.min([l,k]),u=l*c,_.fontSize(l).lineHeight(u),p["font-size"]=l,p["line-height"]=u),m=_(r),f=m.lines.filter(e=>""!==e),d=f.length,m.truncated)if(s){if(l--,l<v)return l=v,void t();e()}else t()}()),f.length?no(e,t,i,{lineData:f,line:d,fS:l,lH:u,w:x,h:y,vA:w,style:p,widths:m.widths,truncated:m.truncated,padding:g}):null}const oo={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"},ao=[{key:"ariaHidden",coerce:"const",default:N("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:N("black")},{key:"fontFamily",coerce:"const",default:N(a.fontFamily)},{key:"fontMax",coerce:"const",default:N(50)},{key:"fontMin",coerce:"const",default:N(8)},{key:"fontOpacity",coerce:"const",default:N(1)},{key:"fontResize",coerce:"const",default:N(!1)},{key:"fontSize",coerce:"const",default:N(10)},{key:"fontStroke",coerce:"const",default:N("transparent")},{key:"fontStrokeWidth",coerce:"const",default:N(0)},{key:"fontWeight",coerce:"const",default:N(400)},{key:"height",coerce:"const",default:T("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:N(null)},{key:"overflow",coerce:"const",default:N(!1)},{key:"padding",coerce:"const",default:N(0)},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:N(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},{key:"shape",coerce:"const",default:e=>e.__d3plusWrapShape__??"square"},{key:"split",coerce:"identity",default:a.textSplit},{key:"text",coerce:"const",default:T("text")},{key:"textAnchor",coerce:"const",default:N("start")},{key:"verticalAlign",coerce:"const",default:N("top")},{key:"width",coerce:"const",default:T("width",200)},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class ro extends $e{_textData(){return this._data.reduce((e,t,n)=>{const i=io(this,t,n);return i&&e.push(i),e},[])}toScene(){const e=n.rtl();return{type:"group",key:"textBox-group",children:this._textData().map(t=>{const n="middle"===t.tA?"middle":"end"===t.tA?"end":"start",i="middle"===t.tA?t.w/2:e?"start"===t.tA?t.w:0:"end"===t.tA?t.w:2*Math.sin(Math.PI*t.r/180),o=t.lines.map((e,n)=>{const o=0===t.r||"top"===t.vA?(n+1)*t.lH-(t.lH-t.fS):"middle"===t.vA?(t.h+t.fS)/2-(t.lH-t.fS)+(n-t.lines.length/2+.5)*t.lH:t.h-2*(t.lH-t.fS)-(t.lines.length-(n+1))*t.lH+2*Math.cos(Math.PI*t.r/180),a=t.widths?t.widths[n]??0:0,r=t.lineRuns?t.lineRuns[n]:void 0;return r?{text:e,x:i,y:o,width:a,runs:r}:{text:e,x:i,y:o,width:a}}),r=this.schema.rotateAnchor(t,t.i),s="true"===t.aH||!0===t.aH,c="none"!==t.pE;return{type:"text",key:t.id,id:`d3plus-textBox-${a.strip(t.id)}`,datum:t.data,index:t.i,x:0,y:0,width:t.w,height:t.h,lines:o,font:{family:t.fF,size:t.fS,weight:t.fW,anchor:n,baseline:"alphabetic",dir:e?"rtl":"ltr"},paint:{fill:t.fC,opacity:t.fO,...t.fStroke&&"transparent"!==t.fStroke?{stroke:t.fStroke}:{},...t.fSW?{strokeWidth:t.fSW}:{}},transform:{x:t.x,y:t.y,rotate:t.r,rotateAnchor:r},aria:s?{hidden:!0}:void 0,interactive:c}})}}render(e){if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;if(void 0===this._select&&"undefined"!=typeof document){const e=t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;if(t){const e=this.toScene(),n=e.children.reduce((e,t)=>Math.max(e,(t.transform?.x??0)+(t.width??0)),0),o=e.children.reduce((e,t)=>Math.max(e,(t.transform?.y??0)+(t.height??0)),0),a="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null,r=a&&a.width||Number(t.getAttribute("width"))||t.clientWidth||0,s=a&&a.height||Number(t.getAttribute("height"))||t.clientHeight||0,c=Math.max(r,n)||400,l=Math.max(s,o)||300;for(;t.firstChild;)t.removeChild(t.firstChild);const h={root:e,width:c,height:l},u=new i.SvgRenderer;u.mount({container:t,width:c,height:l}),u.drawScene(h),this._sceneRenderer=u,ve(this)}}return e&&setTimeout(e,0),this}data(e){return arguments.length?(this._data=e,this):this._data}html(e){return arguments.length?(this.schema.html="boolean"==typeof e?!!e&&oo:e,this):this.schema.html}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){super(),ee(this,ao),this.schema.lineHeight=(e,t)=>1.2*this.schema.fontSize(e,t),this.schema.html=oo}}const so=e=>"function"==typeof e?e():e;function co(e,t){const n=so(e),i="number"==typeof n&&Number.isFinite(n)?n:1,o=so(t);return{min:i,max:"number"==typeof o&&Number.isFinite(o)?Math.max(Math.floor(o),Math.ceil(i),1):1/0}}function lo(e,t,n,i,o="hi",a="lo"){const r=i.min-1;Math.abs(t-e)<r&&("lo"===a?(t=Math.min(n-1,e+r),e=Math.max(0,t-r)):(e=Math.max(0,t-r),t=Math.min(n-1,e+r)));const s=i.max-1;return t-e>s&&("lo"===o?t=e+s:e=t-s),[e,t]}function ho(e){const t=co(e.brushMin,e.brushMax);return!1===e.brushing?{...t,min:1}:t}const uo="#bbb";function fo(e){return e.slice().sort((e,t)=>Number(e)-Number(t))}function mo(e){e.schema.brushFilter=e=>{const t=e;return!t.button&&t.detail<2},e.schema.domain=[2001,2010],e.schema.gridSize=0,e.schema.handleConfig={fill:()=>e.schema.colorDefaults.light,stroke:"#228be6","stroke-width":2,rx:2,ry:2},e.schema.height=100,e.schema.labelOffset=!1,e._labelRotationSetting=!1,e.schema.on={},e.orient("bottom"),e._playButtonClass=new ro,e.schema.playButtonConfig={fontColor:()=>e.schema.colorDefaults.dark,fontSize:15,text:()=>e._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},e.schema.selectionConfig={fill:"#228be6","fill-opacity":()=>"buttons"===e._buttonBehaviorCurrent?.3:1,"stroke-width":0},e.schema.shape="Rect",e.schema.barConfig=n.assign({},e.schema.barConfig,{stroke:()=>"buttons"===e._buttonBehaviorCurrent?"transparent":uo,"stroke-width":()=>"buttons"===e._buttonBehaviorCurrent?0:1}),e.schema.shapeConfig=n.assign({},e.schema.shapeConfig,function(e){return{labelBounds:t=>"buttons"===e._buttonBehaviorCurrent?{x:t.labelBounds.x,y:-e.schema.buttonHeight/2+1,width:t.labelBounds.width,height:e.schema.buttonHeight}:t.labelBounds,labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},fontSize:()=>12,verticalAlign:()=>"buttons"===e._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===e._buttonBehaviorCurrent?"#fff":uo,stroke:()=>"buttons"===e._buttonBehaviorCurrent?uo:"transparent",height:t=>"buttons"===e._buttonBehaviorCurrent?e.schema.buttonHeight:t.tick?e.schema.handleSize:0,width:t=>"buttons"===e._buttonBehaviorCurrent?e._ticksWidth/e._availableTicks.length:t.tick?e.schema.domain.map(Number).includes(t.id)?2:1:0,y:t=>"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2:"start"===e.schema.align?e._margin.top+e.schema.buttonHeight/2:e.schema.height-e.schema.buttonHeight/2-e._margin.bottom:t.y,rx:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0,ry:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0}}(e)),e._buttonBehaviorCurrent="auto",e._hiddenHandles=!1,e._paddingLeft=0,e._ticksWidth=0}function po(e,t,i,o=i){const a=ho(e.schema);if(a.min<=1&&a.max===1/0||!i.length)return;const r=i.map(Number),s=[t[0],t[t.length-1]].map(e=>function(e,t){let n=-1;return e.forEach((i,o)=>{(n<0||Math.abs(i-t)<Math.abs(e[n]-t))&&(n=o)}),n}(r,Number(e))),c=Math.min(...s),l=Math.max(...s),[h,u]=lo(c,l,r.length,a,"hi","hi");h===c&&u===l||([t[0],t[t.length-1]]=fo([i[h],i[u]]),e.schema.selection=[o[h],o[u]].map(e=>n.date(e)))}const go=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMax",coerce:"const"},{key:"brushMin",coerce:"const",default:N(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class yo extends hi{_brushBrush(e){if(!e.sourceEvent||null===e.selection||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render()),this._updateDomain(e)),this._brushStyle(),e.sourceEvent&&!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const n=t.pointers(e,this._select.node());n.length&&this._brushGroup.selectAll(".handle").filter(e=>"e"===e.type).attr("x",n[0][0]-this.schema.handleSize/2)}this.schema.on.brush&&this.schema.on.brush(this.schema.selection)}_snapBrushVisual(e){const t=this._hiddenHandles?0:this.schema.handleSize;this._brushGroup.selectAll(".selection").attr("x",e[0]).attr("width",e[1]-e[0]),this._brushGroup.selectAll(".handle").attr("x",n=>("e"===n.type[n.type.length-1]?e[1]:e[0])-t/2)}_brushEnd(e){if(!e.sourceEvent)return;const t=this._updateDomain(e);this._brushStyle();const n=this._brushGroup.transition(this._transition);this.schema.brushing||n.duration(0),n.call(this._brush.move,this._updateBrushLimit(t)),this.schema.on.end&&this.schema.on.end(this.schema.selection)}_brushStart(e){null===e.sourceEvent||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),null!==e.selection&&this._snapBrushVisual(this._updateBrushLimit(this._updateDomain(e)))),this._brushStyle(),this.schema.on.start&&this.schema.on.start(e)}_brushStyle(){const{height:e}=this._position,t="Circle"===this.schema.shape?"function"==typeof this.schema.shapeConfig.r?2*this.schema.shapeConfig.r({tick:!0}):this.schema.shapeConfig.r:"Rect"===this.schema.shape?"function"==typeof this.schema.shapeConfig[e]?this.schema.shapeConfig[e]({tick:!0}):this.schema.shapeConfig[e]:this.schema.tickSize,i=this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.selectionConfig).attr("transform","translate(0,-1)").attr("height",t+2).style("display",()=>this.schema.brushing||this._hiddenHandles?null:"none"),o=this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.handleConfig).style("display",e=>this._hiddenHandles||!this.schema.brushing&&"w"===e.type?"none":null).attr("transform",e=>"buttons"===this._buttonBehaviorCurrent?`translate(${"w"===e.type?-this.schema.handleSize/2:0},-1)`:"").attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight+2:t+this.schema.handleSize);if(!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const e=+i.attr("x")||0,t=+i.attr("width")||0;o.filter(e=>"e"===e.type).attr("x",e+t/2-this.schema.handleSize/2)}if(this._brushGroup.selectAll(".overlay").attr("x",this._paddingLeft).attr("cursor","pointer").attr("transform",`translate(0,${"buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight/2:-this.schema.handleSize})`).attr("width","buttons"===this._buttonBehaviorCurrent?this._ticksWidth:this.schema.width).attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight:2*this.schema.handleSize),"buttons"===this._buttonBehaviorCurrent){const e="middle"===this.schema.align?this.schema.height/2-this.schema.buttonHeight/2:"start"===this.schema.align?this._margin.top:this.schema.height-this.schema.buttonHeight-this._margin.bottom;o.attr("y",e),i.attr("y",e)}}_updateDomain(e){const i=t.pointers(e,this._select.node()),o=(e.selection&&this.schema.brushing||!i.length?e.selection:[i[0][0],i[0][0]]).map(Number),a="ticks"===this._buttonBehaviorCurrent,r=fo(this._availableTicks).map(Number),s=this._d3Scale.range(),c=this._availableTicks.map(Number),l=e=>r.indexOf(a?f.closest(+this._d3Scale.invert(e),r):c[s.indexOf(f.closest(e,s))]),h=a?r:s,u=e.selection,d=i.length?i[0][0]:NaN,m=u&&Math.abs(d-u[0])<Math.abs(d-u[1])?"lo":"hi",[p,g]=function(e,t,n,i,o=!1){const a=Math.min(...e),r=Math.max(...e),s=e["lo"===i?0:1]===a?"lo":"hi",c=o?((e,t,n)=>e===t?"lo":n)(a,r,s):"lo";return lo(a,r,t,n,s,c)}([l(o[0]),l(o[1])],r.length,ho(this.schema),m,!a),y=e=>s[c.indexOf(r[e])],x=a?[n.date(r[p]),n.date(r[g])]:fo([y(p),y(g)]),b=+x[0]===+x[1];return"brush"!==e.type&&"end"!==e.type||(this.schema.selection="ticks"===this._buttonBehaviorCurrent?b?x[0]:x:b?n.date(this._availableTicks[h.indexOf(x[0])]):fo([n.date(this._availableTicks[h.indexOf(x[0])]),n.date(this._availableTicks[h.indexOf(x[1])])])),x}_updateBrushLimit(e){const t="ticks"===this._buttonBehaviorCurrent?fo(e.map(n.date).map(e=>this._d3Scale(e))):e;if(t[0]===t[1]&&(t[0]-=.1,t[1]+=.1),"buttons"===this._buttonBehaviorCurrent){const e=this._hiddenHandles?0:this.schema.handleSize,n=.5*(this._ticksWidth/this._availableTicks.length-e);t[0]-=n,t[1]+=n}return t}_togglePlay(){if(this._playTimer)return clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),void this._onPlayToggle?.();const e=e=>{this.selection(e).render(),this.schema.on.end&&this.schema.on.end(this.schema.selection)};let t=!0;const i=()=>{const i=fo(("ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks)||[]);if(!i.length)return;let o=this.schema.selection||[this.schema.domain[this.schema.domain.length-1]];o instanceof Array||(o=[o]),o=o.map(n.date).map(Number),1===o.length&&o.push(o[0]);const a=i.map(Number),r=a.indexOf(o[0]),s=a.indexOf(o[o.length-1]);s===a.length-1?t?e([i[0],i[s-r]]):(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),this._onPlayToggle?.()):(s+1===a.length-1&&(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1),e([i[r+1],i[s+1]])),t=!1},o=Number(this.schema.duration)||0,a=o>0?o:this.schema.playButtonInterval;this._playTimer=setInterval(i,a),i(),this._onPlayToggle?.()}_isFullRangeSelected(){const e="ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks;if(!e||e.length<2)return!1;if(null==this.schema.selection)return!1;const t=(this.schema.selection instanceof Array?this.schema.selection:[this.schema.selection]).map(n.date).map(Number),i=e.map(Number);return Math.min(...t)<=Math.min(...i)&&Math.max(...t)>=Math.max(...i)}toScene(){const e=super.toScene(),t=this._playButtonClass;return this.schema.playButton&&t&&"function"==typeof t.toScene&&t._data&&t._data.length&&e.children.push(t.toScene()),e}render(e){const{height:t,y:o}=this._position,{ticks:r,tickFormat:l}=function(e){e.schema.ticks&&(e.schema.ticks=gn(e.schema.ticks)),e._data&&(e._data=gn(e._data));let t=e.schema.ticks?e.schema.ticks:e.schema.domain.map(n.date);if(!e.schema.ticks){const n=s.scaleTime().domain(t).range([0,e.schema.width]);t=n.ticks()}const i=e.schema.timeLocale||c.locale[e.schema.locale]||c.locale["en-US"];let o;void 0===e._userFormat&&(e._userFormat=e.schema.tickFormat||!1);const a=e.schema.tickFormat=e._userFormat?e._userFormat:e=>(o&&o.format===g.timeFormat||(o={format:g.timeFormat,label:d.dateFormatter(t,g.timeFormat)}),o.label(e).replace(/^Q/g,i.quarter));return{ticks:t,tickFormat:a}}(this);!function(e,t,i){if(e._ticksWidth=e.schema.width,["auto","buttons"].includes(e.schema.buttonBehavior)){let o=0;t.forEach((t,r)=>{const{fontFamily:s,fontSize:c}=e.schema.shapeConfig.labelConfig,l="function"==typeof s?s(t,r):s,u="function"==typeof c?c(t,r):c,d=a.textWrap().fontFamily(l).fontSize(u).lineHeight(e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t,r):void 0)(i(t));let f=d.lines.length?Math.ceil(h.max(d.lines.map(e=>n.textWidth(e,{"font-family":l,"font-size":u}))))+u/4:0;f%2&&f++,o<f&&(o=f+2*e.schema.buttonPadding)}),e._ticksWidth=o*t.length}}(this,r,l);const u=this.schema.playButton?this.schema.playButtonConfig.width||this.schema.buttonHeight:0,f=function(e,t,i){const o=e.schema.width-i;e._buttonBehaviorCurrent="auto"===e.schema.buttonBehavior?e._ticksWidth<o?"buttons":"ticks":e.schema.buttonBehavior;const a=e._hiddenHandles="buttons"===e._buttonBehaviorCurrent&&!e.schema.brushing;if("buttons"===e._buttonBehaviorCurrent){e.schema.scale="ordinal";const t=s.scaleTime().domain(e.schema.domain.map(n.date)).ticks().map(Number);e.schema.domain=e.schema.ticks?e.schema.ticks:Array.from(Array(t[t.length-1]-t[0]+1),(e,n)=>t[0]+n).map(n.date),e.schema.ticks=e.schema.domain;const o=.5*e._ticksWidth/e.schema.ticks.length,a=e.schema.width-e._ticksWidth-i;e._paddingLeft="middle"===e.schema.buttonAlign?a/2+i:"end"===e.schema.buttonAlign?a+i:i,e.schema.range=[e._paddingLeft+o,e._paddingLeft+e._ticksWidth-o]}else e.schema.scale="time",e.schema.domain=h.extent(t),e.schema.range=[i?1.5*i:void 0,void 0],e._paddingLeft=i;return a}(this,r,u);if(super.render(e),function(e,t,i,o){const a=e._outerBounds[o],r=e._d3Scale.range(),[s,c]="buttons"===e._buttonBehaviorCurrent?[e._paddingLeft,e._paddingLeft+e._ticksWidth]:[r[0],r[r.length-1]],l=e._brush=p.brushX().extent([[s,a],[c,a+e._outerBounds[i]]]).filter(e.schema.brushFilter).handleSize(t?0:e.schema.handleSize).on("start",e._brushStart.bind(e)).on("brush",e._brushBrush.bind(e)).on("end",e._brushEnd.bind(e)),h=fo(("ticks"===e._buttonBehaviorCurrent?e._availableTicks:e.schema.ticks)||[]),u=t=>{const n=h[h.map(Number).indexOf(+t)];return void 0===n?void 0:e._d3Scale(n)},d="ticks"===e._buttonBehaviorCurrent?h:h.map(u),f=fo([e.schema.brushMin()>d.length?d[0]:d[d.length-e.schema.brushMin()],d[d.length-1]]),m=void 0===e.schema.selection?f:e.schema.selection instanceof Array?"buttons"===e._buttonBehaviorCurrent?fo(e.schema.selection.map(n.date).map(u)):e.schema.selection.map(n.date):"buttons"===e._buttonBehaviorCurrent?[u(n.date(e.schema.selection))]:[e.schema.selection];1===m.length&&m.push(m[0]),po(e,m,d,h),e._updateBrushLimit(m),e._brushGroup=n.elem("g.brushGroup",{parent:e._group}),e._brushGroup.call(l).transition(e._transition).call(l.move,"ticks"===e._buttonBehaviorCurrent?e._updateBrushLimit(m):m),e._outerBounds.y-=e.schema.handleSize/2,e._outerBounds.height+=e.schema.handleSize/2}(this,f,t,o),function(e,t){const i=n.elem("g.d3plus-Timeline-play",{parent:e._group}),o=e.schema.playButton?[{x:e._paddingLeft-t,y:"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2-e.schema.buttonHeight/2:"start"===e.schema.align?e._margin.top:e.schema.height-e.schema.buttonHeight-e._margin.bottom:e._outerBounds.y,width:t,height:e.schema.buttonHeight}]:[],a=e._isFullRangeSelected();e._playButtonClass.renderMode("compute").data(o).select(i.node()).config(Ae.bind(e)(e.schema.playButtonConfig)),a&&e._playButtonClass.config({fontColor:e.schema.colorDefaults.missing}),e._playButtonClass.render();const r=n.elem("rect.d3plus-Timeline-play-hit",{parent:i,condition:o.length>0});if(o.length){const t=o[0];r.attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height).attr("fill","transparent").attr("cursor",a?"default":"pointer").style("pointer-events",a?"none":"all").on("click",()=>{e._isFullRangeSelected()||e._togglePlay()})}}(this,u),"compute"!==this.schema.renderMode&&this._select&&(function(e,t){const n=e._select,o=n&&"function"==typeof n.node?n.node():null;if(!(o instanceof Element))return;const a=o,r=e.schema.width??400,s=e.schema.height??100,c=e;c._sceneRenderer?c._sceneRenderer.resize(r,s):(c._sceneRenderer=new i.SvgRenderer,c._sceneRenderer.mount({container:a,width:r,height:s})),c._sceneRenderer.drawScene({root:{type:"group",key:"root",children:[t]},width:r,height:s},{duration:0}),ve(e)}(this,this.toScene()),this._group)){const e=this._select.node(),t=this._group.node();e instanceof Element&&t instanceof Element&&t.parentNode===e&&e.appendChild(t)}return this}handleConfig(e){return arguments.length?(this.schema.handleConfig=Y(this,"handleConfig",e),this):this.schema.handleConfig}on(e,t){return 2===arguments.length?(this.schema.on[e]=t,this):arguments.length?"string"==typeof e?this.schema.on[e]:(this.schema.on=n.assign({},this.schema.on,e),this):this.schema.on}playButtonConfig(e){return arguments.length?(this.schema.playButtonConfig=Y(this,"playButtonConfig",e),this):this.schema.playButtonConfig}selectionConfig(e){return arguments.length?(this.schema.selectionConfig=Y(this,"selectionConfig",e),this):this.schema.selectionConfig}constructor(){super(),ee(this,go),mo(this),this._managesOwnScenePaint=!0}}function xo(e=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:e[0],y:e[1],top:e[1],right:e[0],bottom:e[1],left:e[0]})}}async function bo(e,t,n,i,o,a){const{x:r,y:s,placement:c,middlewareData:l}=await m.computePosition(e,t,{strategy:"fixed",placement:"top",middleware:[m.offset(i+o),m.flip({fallbackPlacements:["bottom"],padding:5}),m.shift({padding:5}),m.arrow({element:n})]});Object.assign(t.style,{position:"fixed",left:`${r}px`,top:`${s}px`,visibility:"visible"});const h="bottom"===c,u=parseFloat(n.style.borderRightWidth)||0;h?(n.style.transform="rotate(225deg)",n.style.top=`-${a/2+u}px`,n.style.bottom=""):(n.style.transform="rotate(45deg)",n.style.bottom=`-${a/2+u}px`,n.style.top=""),n.style.left=null!=l.arrow?.x?`${l.arrow.x}px`:""}K(yo.prototype,"handleConfig","playButtonConfig","selectionConfig");const _o=['[id="d3plus-portal"]',".d3plus-tooltip-portal",".d3plus-tooltip",".d3plus-tooltip-title",".d3plus-tooltip-body",".d3plus-tooltip-footer",".d3plus-tooltip-arrow",".d3plus-tooltip-table",".d3plus-tooltip-thead",".d3plus-tooltip-tbody"];function ko(e,t,n,i){return`${i?`d3plus-tooltip-${i}`:"d3plus-tooltip"}-${e._uuid}-${t?e.schema.id(t,n):""}`}function vo(e,t,i,o){t.append("div").attr("class",`d3plus-tooltip-${o}`).attr("id",(t,n)=>ko(e,t,n,o));const a=i.select(`.d3plus-tooltip-${o}`).html((t,n)=>e.schema[o](t,n)).style("display",(t,n)=>{const i=e.schema[o](t,n);return!1!==i&&null!=i?"block":"none"});n.stylize(a,e.schema[`${o}Style`])}function wo(e,t){t.style("background",e.schema.background).style("border-radius",e.schema.borderRadius).style("pointer-events",e.schema.pointerEvents).style("padding",e.schema.padding).style("max-width",e.schema.maxWidth).style("min-width",e.schema.minWidth).style("width",e.schema.width).style("height",e.schema.height).style("border",e.schema.border)}const So="d3plus-tooltip",Co=[{key:"arrow",coerce:"const",default:T("arrow","")},{key:"background",coerce:"const",factory:e=>()=>e.schema.colorDefaults.light},{key:"body",coerce:"const",default:T("body","")},{key:"border",coerce:"const",default:N("1px solid rgba(0, 0, 0, 0.25)")},{key:"borderRadius",coerce:"const",default:N("4px")},{key:"footer",coerce:"const",default:T("footer","")},{key:"height",coerce:"const",default:N("auto")},{key:"id",coerce:"const",default:(e,t)=>`${t}`},{key:"offset",coerce:"const",default:N(5)},{key:"padding",coerce:"const",default:N("10px")},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:T("title","")},{key:"titleSwatch",coerce:"identity",default:!0},{key:"maxWidth",coerce:"const",default:N("300px")},{key:"minWidth",coerce:"const",default:N("200px")},{key:"width",coerce:"const",default:N("auto")}];class Mo extends $e{render(e){const o=this,a=`d3plus-tooltip-${this._uuid}-`,r=function(e){if(!e._parentEl)return n.elem("div#d3plus-portal");let i=e._portalEl??null;return i&&i.isConnected||(i=document.createElement("div"),i.setAttribute("class","d3plus-tooltip-portal"),i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.width="0",i.style.height="0",i.style.pointerEvents="none",document.body.appendChild(i),e._portalEl=i),t.select(i)}(this);i.resetInjectedBoxes(r.node(),_o);const s=r.selectAll(`.${So}`).filter(function(){return this.id.startsWith(a)}).data(this._data,this.schema.id),c=s.enter().append("div").attr("class",So),l=s.merge(c);return l.each(function(){this instanceof Element&&ke(this,o.schema.className,[So])}),n.stylize(l,this.schema.tooltipStyle),vo(this,c,l,"title"),vo(this,c,l,"body"),function(e,t,i,o){const a=t.append("table").attr("class","d3plus-tooltip-table"),r=i.select(".d3plus-tooltip-table");n.stylize(r,e.schema.tableStyle),a.append("thead").attr("class","d3plus-tooltip-thead");const s=i.select(".d3plus-tooltip-thead");n.stylize(s,e.schema.theadStyle);const c=s.selectAll("tr").data([0]),l=c.enter().append("tr");c.exit().remove();const h=c.merge(l);n.stylize(h,e.schema.trStyle);const u=h.selectAll("th").data(e.schema.thead),d=u.enter().append("th").merge(u).html(o);n.stylize(d,e.schema.thStyle),u.exit().remove(),a.append("tbody").attr("class","d3plus-tooltip-tbody");const f=i.select(".d3plus-tooltip-tbody");n.stylize(f,e.schema.tbodyStyle);const m=f.selectAll("tr").data(e.schema.tbody),p=m.enter().append("tr");m.exit().remove();const g=m.merge(p);n.stylize(g,e.schema.trStyle);const y=g.selectAll("td").data(e=>e),x=y.enter().append("td").merge(y).html(o);n.stylize(x,e.schema.tdStyle)}(this,c,l,function(e){if("function"==typeof e){const n=t.select(this.parentNode.parentNode).datum();return e(n,o._data.indexOf(n),n)}return e}),vo(this,c,l,"footer"),vo(this,c,l,"arrow"),function(e,t,n,i){t.attr("id",(t,n)=>ko(e,t,n)).style("visibility","hidden").call(t=>wo(e,t)).each(function(t,n){const i=e.schema.id(t,n),o=this,a=o.querySelector(".d3plus-tooltip-arrow"),r=a.offsetHeight,s=a.getBoundingClientRect().height/2;a.style.bottom=`-${r/2}px`;const c=e.schema.position(t,n),l=Array.isArray(c)?xo(c):c;e._tooltipRefs[i]={reference:l,arrowEl:a,tooltip:o,arrowHeight:r,arrowDistance:s},bo(l,o,a,e.schema.offset(t,n),s,r)}),n.each(function(t,n){const i=e.schema.id(t,n),o=e.schema.position(t,n),a=e._tooltipRefs[i];a&&(a.reference=Array.isArray(o)?xo(o):o,bo(a.reference,a.tooltip,a.arrowEl,e.schema.offset(t,n),a.arrowDistance,a.arrowHeight))}).call(t=>wo(e,t)),i.exit().each(function(t,n){const i=e.schema.id(t,n);delete e._tooltipRefs[i]}).remove()}(this,c,l,s),e&&setTimeout(e,100),this}className(e){return arguments.length?super.className(e):super.className()}arrowStyle(e){return arguments.length?(this.schema.arrowStyle=Y(this,"arrowStyle",e),this):this.schema.arrowStyle}bodyStyle(e){return arguments.length?(this.schema.bodyStyle=Y(this,"bodyStyle",e),this):this.schema.bodyStyle}parent(e){if(!arguments.length)return this._parentEl;const t=this._parentEl,n=e||void 0;return t&&t!==n&&this._portalEl&&(this._portalEl.remove(),this._portalEl=void 0),this._parentEl=n,this}data(e){return arguments.length?(this._data=e,this):this._data}footerStyle(e){return arguments.length?(this.schema.footerStyle=Y(this,"footerStyle",e),this):this.schema.footerStyle}position(e){return arguments.length?(this.schema.position="string"==typeof e?N(t.select(e).node()||[0,0]):"function"==typeof e?e:N(e),this):this.schema.position}tableStyle(e){return arguments.length?(this.schema.tableStyle=Y(this,"tableStyle",e),this):this.schema.tableStyle}tbodyStyle(e){return arguments.length?(this.schema.tbodyStyle=Y(this,"tbodyStyle",e),this):this.schema.tbodyStyle}theadStyle(e){return arguments.length?(this.schema.theadStyle=Y(this,"theadStyle",e),this):this.schema.theadStyle}titleStyle(e){return arguments.length?(this.schema.titleStyle=Y(this,"titleStyle",e),this):this.schema.titleStyle}tooltipStyle(e){return arguments.length?(this.schema.tooltipStyle=Y(this,"tooltipStyle",e),this):this.schema.tooltipStyle}trStyle(e){return arguments.length?(this.schema.trStyle=Y(this,"trStyle",e),this):this.schema.trStyle}tdStyle(e){return arguments.length?(this.schema.tdStyle=Y(this,"tdStyle",e),this):this.schema.tdStyle}thStyle(e){return arguments.length?(this.schema.thStyle=Y(this,"thStyle",e),this):this.schema.thStyle}constructor(){super(),ee(this,Co),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=e=>[e.x,e.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":"0 1px 5px rgba(0, 0, 0, 0.25)",color:(e,t)=>r.colorContrast(this.schema.background(e,t),this.schema.colorDefaults),"font-family":a.fontFamilyStringify(a.fontFamily)},this.schema.trStyle={"border-top":(e,t)=>t?"1px solid rgba(0, 0, 0, 0.1)":"none"};const e=(e,t)=>t?"right":"left";this.schema.tdStyle={"text-align":e},this.schema.thStyle={"text-align":e}}}function $o(e){const{data:t,dataFilter:n,label:i,labelBounds:o,x:a,y:r,aes:s,rotate:c,id:l,datum:h}=e,u=[];return(n?n(t):t).forEach((e,n)=>{let d=e;e.nested&&void 0!==e.key&&e.values&&(d=e.values[0],n=t.indexOf(d));let f=i(d,n);if(o&&!1!==f&&null!=f){const t=o(d,n,s(e,n));if(!t)return;f.constructor!==Array&&(f=[f]);const i=d.__d3plusShape__?d.translate?d.translate[0]:a(d.data,d.i):a(d,n),m=d.__d3plusShape__?d.translate?d.translate[1]:r(d.data,d.i):r(d,n);d.__d3plusShape__&&(d=d.data,n=d.i);for(let e=0;e<f.length;e++){const o=t.constructor===Array?t[e]:Object.assign({},t),a=c(d,n),r=d.labelConfig;let s=r&&r.rotate?r.rotate:void 0!==t.angle?t.angle:0;s+=a;const p=0!==a?[-1*o.x||0,-1*o.y||0]:[o.width/2,o.height/2];u.push({__d3plus__:!0,data:h?h(d,n):d,height:o.height,l:e,id:`${l(d,n)}_${e}`,r:s,rotateAnchor:p,...o.shape?{__d3plusWrapShape__:o.shape}:{},text:f[e],width:o.width,x:i+o.x,y:m+o.y})}}}),u}K(Mo.prototype,"arrowStyle","bodyStyle","footerStyle","tableStyle","tbodyStyle","theadStyle","titleStyle","tooltipStyle","trStyle","tdStyle","thStyle");const Ao=["squares","nylon","waves","woven","crosses","caps","hexagons"],zo=["background","fill","stroke"];function Do(e,t,i,o={}){if(!e)return!1;const a=t();if("none"===a)return!1;const r=n.isObject(e)?{...e}:{texture:e};r.background||(r.background=a),r.stroke||o.stroke||(r.stroke=i()),Ao.includes(r.texture)||"function"==typeof r.texture?(r.d=r.texture,r.texture="paths"):"grid"===r.texture&&(r.orientation||o.orientation||(r.orientation=["vertical","horizontal"]),r.texture="lines"),r.fill||"paths"===r.texture||(r.fill=r.stroke);for(const e of zo){const t=r[e];t&&"object"==typeof t&&(r[e]=String(t))}const s=n.assign({},o,r);return"function"==typeof s.d&&(s.d=s.d(s.size||20)),JSON.stringify(s)}function Fo(e){let t=e;for(;t.__d3plus__&&t.data;)t=t.data;return t.__d3plusShape__?t.data:t}function Bo(e,t){if("number"==typeof e.width&&"number"==typeof e.height){return{x:"number"==typeof e.x?e.x:-e.width/2,y:"number"==typeof e.y?e.y:-e.height/2,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0;return{x:t-e.r,y:n-e.r,width:2*e.r,height:2*e.r}}if("string"==typeof e.d){const t=f.pathBounds(e.d);return t.width>0&&t.height>0?t:null}return function(e){if(!e.length)return null;let t=1/0,n=1/0,i=-1/0,o=-1/0;for(const[a,r]of e)a<t&&(t=a),r<n&&(n=r),a>i&&(i=a),r>o&&(o=r);return!Number.isFinite(t)||i<=t||o<=n?null:{x:t,y:n,width:i-t,height:o-n}}(t)}function Lo(e,t,n,i,o,a){return`M${e+(o=Math.min(o,n/2))},${t}h${n-2*o}a${o},${a=Math.min(a,i/2)} 0 0 1 ${o},${a}v${i-2*a}a${o},${a} 0 0 1 ${-o},${a}h${-(n-2*o)}a${o},${a} 0 0 1 ${-o},${-a}v${-(i-2*a)}a${o},${a} 0 0 1 ${o},${-a}Z`}function Po(e,t){if("string"==typeof e.d)return{type:"path",d:e.d};if("number"==typeof e.width&&"number"==typeof e.height){const t="number"==typeof e.x?e.x:-e.width/2,n="number"==typeof e.y?e.y:-e.height/2,i="number"==typeof e.rx?e.rx:0,o="number"==typeof e.ry?e.ry:0;return i>0||o>0?{type:"path",d:Lo(t,n,e.width,e.height,i||o,o||i)}:{type:"rect",x:t,y:n,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0,i=e.r;return{type:"path",d:`M${t-i},${n}a${i},${i} 0 1,0 ${2*i},0a${i},${i} 0 1,0 ${-2*i},0Z`}}if(t.length>2){return{type:"path",d:`M${t.map(([e,t])=>`${e},${t}`).join("L")}Z`}}}function Ro(e,t,n){if("contain"!==n){const n=Bo(e,t);return n?{box:n,clip:Po(e,t),preserveAspectRatio:"xMidYMid slice"}:null}let i;if("number"==typeof e.width&&"number"==typeof e.height)i=Bo(e,t);else if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0,o=e.r/Math.SQRT2;i={x:t-o,y:n-o,width:2*o,height:2*o}}else{const n=function(e,t){return"string"==typeof e.d?f.path2polygon(e.d):t}(e,t),o=n.length>2?f.largestRect(n,{angle:0}):null;i=o?{x:o.cx-o.width/2,y:o.cy-o.height/2,width:o.width,height:o.height}:Bo(e,t)}return i?{box:i,preserveAspectRatio:"xMidYMid meet"}:null}function Eo(e,t,n){return e.map((e,i)=>{const o={type:"image",key:`${e.key}-bgimage-img`,x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,href:e.url,preserveAspectRatio:e.preserveAspectRatio,interactive:!1};return{type:"group",key:`${e.key}-bgimage`,children:[o],datum:e.datum,index:e.index,interactive:!1,paint:{opacity:e.opacity??1},...e.transform?{transform:e.transform}:{},...e.clip?{clip:e.clip}:{},...t?{z:n+i}:{}}})}function No(e){const t=Number(e);return Number.isFinite(t)?t:void 0}function To(e){return null==e||""===e?void 0:String(e)}function Oo(e){if(null==e||"none"===e||""===e)return;if("number"==typeof e)return[e];const t=String(e).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));return t.length?t:void 0}const Wo=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:N("")},{key:"backgroundImage",coerce:"const",default:N(!1)},{key:"backgroundImageFit",coerce:"const",default:N("cover")},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:N("black")},{key:"fillOpacity",coerce:"const",default:N(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(e,t)=>void 0!==e.id?e.id:t},{key:"label",coerce:"const",default:N(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:N(1)},{key:"pointerEvents",coerce:"const",default:N("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:N("presentation")},{key:"rotate",coerce:"const",default:N(0)},{key:"rx",coerce:"const",default:N(0)},{key:"ry",coerce:"const",default:N(0)},{key:"scale",coerce:"const",default:N(1)},{key:"shapeRendering",coerce:"const",default:N("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:N("0")},{key:"strokeLinecap",coerce:"const",default:N("butt")},{key:"strokeOpacity",coerce:"const",default:N(1)},{key:"strokeWidth",coerce:"const",default:N(0)},{key:"textAnchor",coerce:"const",default:N("start")},{key:"texture",coerce:"const",default:N(!1)},{key:"vectorEffect",coerce:"const",default:N("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:N("top")},{key:"x",coerce:"accessor",default:T("x",0)},{key:"y",coerce:"accessor",default:T("y",0)}];class jo extends $e{_aes(e,t){return{}}_getTextureKey(e,t){const n=this._styleVal(this.schema.texture,e,t);return!!n&&Do(n,()=>this._styleVal(this.schema.fill,e,t),()=>this._styleVal(this.schema.stroke,e,t),this.schema.textureDefault)}_nestWrapper(e){return(t,n)=>e(t.__d3plusShape__?t.data:t,t.__d3plusShape__?t.i:n)}_buildLabelData(){return $o({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(this):void 0,label:this.schema.label,labelBounds:this.schema.labelBounds?this.schema.labelBounds.bind(this):void 0,x:this.schema.x,y:this.schema.y,aes:this._aes.bind(this),rotate:this.schema.rotate,id:this.schema.id})}_styleVal(e,t,n){return"function"!=typeof e?e:t.nested&&void 0!==t.key&&t.values?e(t.data,t.i):e(t,n)}_sceneTransform(e,t){const n=Boolean(e.__d3plusShape__),i=n?e.data:e,o=n?e.i:t;let a,r;if(n&&e.translate){const[t,n]=String(e.translate).split(",").map(Number);a=t,r=n}else a=Number(this.schema.x(i,o)),r=Number(this.schema.y(i,o));return{x:a,y:r,scale:n&&void 0!==e.scale?Number(e.scale):Number(this.schema.scale(i,o)),rotate:n&&void 0!==e.rotate?Number(e.rotate):Number(this.schema.rotate(e.data||e,o))}}_scenePaint(e,t){const n=this._getTextureKey(e,t);return{fill:n?`pattern:${n}`:To(this._styleVal(this.schema.fill,e,t)),fillOpacity:No(this._styleVal(this.schema.fillOpacity,e,t)),stroke:To(this._styleVal(this.schema.stroke,e,t)),strokeWidth:No(this._styleVal(this.schema.strokeWidth,e,t)),strokeOpacity:No(this._styleVal(this.schema.strokeOpacity,e,t)),strokeDasharray:Oo(this._styleVal(this.schema.strokeDasharray,e,t)),strokeLinecap:To(this._styleVal(this.schema.strokeLinecap,e,t)),vectorEffect:To(this._styleVal(this.schema.vectorEffect,e,t)),shapeRendering:To(this._nestWrapper(this.schema.shapeRendering)(e,t)),opacity:No(this._nestWrapper(this.schema.opacity)(e,t))}}_sceneGeometry(e,t){return null}toScene(){let e=this._data;this._dataFilter&&(e=this._dataFilter(e));const t=[],n=[],i=function(e,t){if(!t||e.length<2)return null;const n=e.map((e,t)=>t);n.sort((n,i)=>t(Fo(e[n]),Fo(e[i])));const i=new Array(e.length);return n.forEach((e,t)=>i[e]=t),i}(e,this.schema.sort);return e.forEach((e,o)=>{const a=this._sceneGeometry(e,o);if(!a)return;const r=this._nestWrapper(this.schema.id)(e,o),s=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,o),l=this._scenePaint(e,o),h=function(e,t,n,i){if(!e.__d3plusShape__||!Array.isArray(e.values))return{};const o=e.values,a=[];return o.forEach((e,o)=>{if("function"==typeof i&&!1===i(e,o))return;const r=Number(t(e,o)),s=Number(n(e,o));Number.isFinite(r)&&Number.isFinite(s)&&a.push({x:r,y:s,datum:e,index:"number"==typeof e.i?e.i:o})}),a.length?{interactionPoints:a}:{}}(e,this.schema.x,this.schema.y,this.schema.defined);if(this.schema.hitArea){const n=function(e,t,n,i,o,a,r,s,c){const l="function"==typeof e?e(t,n,i):e;if(!l)return null;if("number"!=typeof l.width&&"string"==typeof c)return{type:"path",d:c,key:`${o}::hit`,datum:a,index:n,shapeType:r,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof l["stroke-width"]?l["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:s,aria:{hidden:!0}};return"number"!=typeof l.width||"number"!=typeof l.height?null:{type:"rect",x:"number"==typeof l.x?l.x:-l.width/2,y:"number"==typeof l.y?l.y:-l.height/2,width:l.width,height:l.height,key:`${o}::hit`,datum:a,index:n,shapeType:r,paint:{fill:"transparent"},transform:s,aria:{hidden:!0}}}(this.schema.hitArea,e,o,this._aes(e,o),r,s,this._name,c,a.d);n&&t.push(i?{...n,...h,z:i[o]}:{...n,...h})}t.push({...a,key:r,datum:s,index:o,shapeType:this._name,paint:l,transform:c,aria:{role:To(this._nestWrapper(this.schema.role)(e,o)),label:To(this._nestWrapper(this.schema.ariaLabel)(e,o))},...h,...i?{z:i[o]}:{}});const u="none"!==l.fill&&this._nestWrapper(this.schema.backgroundImage)(e,o);if(u){const t=a,i=Ro(t,"string"!=typeof t.d&&"number"!=typeof t.width&&"number"!=typeof t.r?this._aes(e,o).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(e,o)?"contain":"cover");i&&n.push({key:r,index:o,datum:s,url:u,box:i.box,clip:i.clip,preserveAspectRatio:i.preserveAspectRatio,opacity:No(this._nestWrapper(this.schema.opacity)(e,o)),transform:c})}}),n.length&&t.push(...Eo(n,i,e.length)),{type:"group",key:`${this._name}-group`,children:t}}render(e){const t=this._labelClass;if(t&&"function"==typeof t.renderMode&&t.renderMode("compute"),this._labelClass.config(this.schema.labelConfig),this._labelClass.data(this._buildLabelData()),"compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;if(void 0===this._select&&"undefined"!=typeof document){const e=document.createElement("div");e.style.cssText="display:block;",document.body.appendChild(e),this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;t&&function(e,t){const o="svg"===(t.tagName||"").toLowerCase(),a=o?Number(t.getAttribute("width")):t.clientWidth,r=o?Number(t.getAttribute("height")):t.clientHeight,[s,c]=a&&r?[a,r]:n.getSize(t),l=a||s||400,h=r||c||300,u=e.toScene(),d=[];e._labelClass&&"function"==typeof e._labelClass.toScene&&e._labelClass._data&&e._labelClass._data.length&&d.push(...e._labelClass.toScene().children);const f={root:{...u,children:[...u.children,...d]},width:l,height:h},m=e._sceneRenderer;if(m&&"function"==typeof m.destroy&&m.destroy(),!m)for(;t.firstChild;)t.removeChild(t.firstChild);const p=new i.SvgRenderer;p.mount({container:t,width:l,height:h}),p.drawScene(f),e._sceneRenderer=p,ve(e)}(this,t)}return e&&setTimeout(e,0),this}active(e){return arguments.length&&void 0!==e?(this.schema.active=e,this):this.schema.active}activeStyle(e){return arguments.length?(this.schema.activeStyle=Y(this,"activeStyle",e),this):this.schema.activeStyle}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return arguments.length&&void 0!==e?(this.schema.hover=e,this):this.schema.hover}hoverStyle(e){return arguments.length?(this.schema.hoverStyle=Y(this,"hoverStyle",e),this):this.schema.hoverStyle}labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}sort(e){return arguments.length?(this.schema.sort=e??null,this):this.schema.sort}textureDefault(e){return arguments.length?(this.schema.textureDefault=Y(this,"textureDefault",e),this):this.schema.textureDefault}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(e="g"){super(),ee(this,Wo),this._data=[],this._labelClass=new ro,this._name="Shape",this._tagName=e,this._textureDefs={},this.schema.stroke=(e,t)=>{const n=l.color(this.schema.fill(e,t));return n?n.darker(1).formatHex():this.schema.fill(e,t)},this.schema.activeStyle={stroke:(e,t)=>{let n=this.schema.fill(e,t);["transparent","none"].includes(n)&&(n=this.schema.stroke(e,t));const i=l.color(n);return i?i.darker(1).toString():n},"stroke-width":(e,t)=>3*(this.schema.strokeWidth(e,t)||1)},this.schema.hoverStyle={stroke:(e,t)=>{let n=this.schema.fill(e,t);["transparent","none"].includes(n)&&(n=this.schema.stroke(e,t));const i=l.color(n);return i?i.darker(.5).toString():n},"stroke-width":(e,t)=>2*(this.schema.strokeWidth(e,t)||1)},this.schema.labelConfig={fontColor:(e,t)=>r.colorContrast(this.schema.fill(e,t),this.schema.colorDefaults),fontOpacity:(e,t)=>this.schema.opacity(e,t),fontResize:!0,fontMax:50,fontMin:8,fontSize:12,padding:5,textAnchor:"start",verticalAlign:"top"},this.schema.textureDefault={}}}K(jo.prototype,"activeStyle","hoverStyle","labelConfig","textureDefault");const Ho=[{key:"curve",coerce:"const",default:N("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class Io extends jo{_sceneGeometry(e){const t=Number(e.x),n=Number(e.y),i=String(this.schema.curve.bind(this)(this.config())),o=L[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`],a=e=>(n,i)=>e(n,i)-t,r=e=>(t,i)=>e(t,i)-n,s=L.area().defined(this.schema.defined).curve(o).x(a(this.schema.x)).x0(a(this.schema.x0)).y(r(this.schema.y)).y0(r(this.schema.y0));return this.schema.x1?s.x1(a(this.schema.x1)):s.x1(null),this.schema.y1?s.y1(r(this.schema.y1)):s.y1(null),{type:"path",d:s(e.values)||""}}_aes(e){const t=e.values.slice().sort((e,t)=>this.schema.y1?this.schema.x(e)-this.schema.x(t):this.schema.y(e)-this.schema.y(t)),n=t.map((e,t)=>[this.schema.x0(e,t),this.schema.y0(e,t)]),i=t.reverse().map((e,t)=>this.schema.y1?[this.schema.x(e,t),this.schema.y1(e,t)]:[this.schema.x1(e,t),this.schema.y(e,t)]);let o=n.concat(i);return n[0][1]>i[0][1]&&(o=o.reverse()),o.push(o[0]),{points:o}}_dataFilter(e){const t=h.groups(e,this.schema.id).map(([t,n])=>{const i={key:t,values:n};i.data=o.merge(i.values),i.i=e.indexOf(i.values[0]);const a=h.extent(i.values.map(this.schema.x).concat(i.values.map(this.schema.x0)).concat(this.schema.x1?i.values.map(this.schema.x1):[]));i.xR=a,i.width=a[1]-a[0],i.x=a[0]+i.width/2;const r=h.extent(i.values.map(this.schema.y).concat(i.values.map(this.schema.y0)).concat(this.schema.y1?i.values.map(this.schema.y1):[]));return i.yR=r,i.height=r[1]-r[0],i.y=r[0]+i.height/2,i.nested=!0,i.translate=[i.x,i.y],i.__d3plusShape__=!0,i});return t.key=e=>e.key,t}x(e){return arguments.length?(this.schema.x="function"==typeof e?e:N(e),this.schema.x0=this.schema.x,this):this.schema.x}x0(e){return arguments.length?(this.schema.x0="function"==typeof e?e:N(e),this.schema.x=this.schema.x0,this):this.schema.x0}x1(e){return arguments.length?(this.schema.x1="function"==typeof e?e:null===e?null:N(e),this):this.schema.x1}y(e){return arguments.length?(this.schema.y="function"==typeof e?e:N(e),this.schema.y0=this.schema.y,this):this.schema.y}y0(e){return arguments.length?(this.schema.y0="function"==typeof e?e:N(e),this.schema.y=this.schema.y0,this):this.schema.y0}y1(e){return arguments.length?(this.schema.y1="function"==typeof e?e:null===e?null:N(e),this):this.schema.y1}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,Ho),this._name="Area",this.schema.labelBounds=(e,t,n)=>{const i=f.largestRect(n.points);return i?{angle:i.angle,width:i.width,height:i.height,x:i.cx-i.width/2-this.schema.x(e,t),y:i.cy-i.height/2-this.schema.y(e,t)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=T("x"),this.schema.x0=T("x"),this.schema.x1=null,this.schema.y=N(0),this.schema.y0=N(0),this.schema.y1=T("y")}}const Go=[{key:"height",coerce:"accessor",default:N(10)},{key:"width",coerce:"accessor",default:N(10)}];class Vo extends jo{_sceneGeometry(e,t){const n=this._getWidth(e,t),i=this._getHeight(e,t);return{type:"rect",x:null!==this.schema.x1?this._getX(e,t):-n/2,y:null===this.schema.x1?this._getY(e,t):-i/2,width:n,height:i}}_aes(e,t){return{height:this._getHeight(e,t),width:this._getWidth(e,t)}}_applyPosition(e){e.attr("width",(e,t)=>this._getWidth(e,t)).attr("height",(e,t)=>this._getHeight(e,t)).attr("x",(e,t)=>null!==this.schema.x1?this._getX(e,t):-this._getWidth(e,t)/2).attr("y",(e,t)=>null===this.schema.x1?this._getY(e,t):-this._getHeight(e,t)/2)}_getHeight(e,t){return null!==this.schema.x1?this.schema.height(e,t):Math.abs(this.schema.y1(e,t)-this.schema.y(e,t))}_getWidth(e,t){return null===this.schema.x1?this.schema.width(e,t):Math.abs(this.schema.x1(e,t)-this.schema.x(e,t))}_getX(e,t){const n=null===this.schema.x1?this.schema.x(e,t):this.schema.x1(e,t)-this.schema.x(e,t);return n<0?n:0}_getY(e,t){const n=null!==this.schema.x1?this.schema.y(e,t):this.schema.y1(e,t)-this.schema.y(e,t);return n<0?n:0}x0(e){return arguments.length?(this.schema.x0="function"==typeof e?e:N(e),this.schema.x=this.schema.x0,this):this.schema.x0}x1(e){return arguments.length?(this.schema.x1="function"==typeof e?e:null===e?null:N(e),this):this.schema.x1}y0(e){return arguments.length?(this.schema.y0="function"==typeof e?e:N(e),this.schema.y=this.schema.y0,this):this.schema.y0}y1(e){return arguments.length?(this.schema.y1="function"==typeof e?e:null===e?null:N(e),this):this.schema.y1}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("rect"),ee(this,Go),this._name="Bar",this.schema.labelBounds=(e,t,n)=>({width:n.width,height:n.height,x:null!==this.schema.x1?this._getX(e,t):-n.width/2,y:null===this.schema.x1?this._getY(e,t):-n.height/2}),Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=T("x"),this.schema.x0=T("x"),this.schema.x1=null,this.schema.y=N(0),this.schema.y0=N(0),this.schema.y1=T("y")}}const qo=[{key:"height",coerce:"accessor",default:T("height")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:T("width")}];class Yo extends jo{_sceneGeometry(e,t){const n=Number(this.schema.width(e,t)),i=Number(this.schema.height(e,t)),o=this._styleVal(this.schema.rx,e,t),a=this._styleVal(this.schema.ry,e,t);return{type:"rect",x:-n/2,y:-i/2,width:n,height:i,...null==o?{}:{rx:Number(o)},...null==a?{}:{ry:Number(a)},...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(e,t){return{width:this.schema.width(e,t),height:this.schema.height(e,t)}}_applyPosition(e){e.attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>-this.schema.width(e,t)/2).attr("y",(e,t)=>-this.schema.height(e,t)/2)}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("rect"),ee(this,qo),this._name="Rect",this.schema.labelBounds=(e,t,n)=>({width:n.width,height:n.height,x:-n.width/2,y:-n.height/2})}}const Ko=[{key:"r",coerce:"accessor",default:T("r")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0}];class Uo extends jo{_applyPosition(e){e.attr("r",(e,t)=>this.schema.r(e,t)).attr("x",(e,t)=>-this.schema.r(e,t)/2).attr("y",(e,t)=>-this.schema.r(e,t)/2)}_sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(e,t){return{r:this.schema.r(e,t)}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("circle"),ee(this,Ko),this._name="Circle",this.schema.labelBounds=(e,t,n)=>({width:2*n.r,height:2*n.r,x:-n.r,y:-n.r,shape:"circle"}),this.schema.labelConfig=n.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}const Xo=new Map([["Circle",Uo],["Rect",Yo]]);const Qo=e=>Xo.has(e);function Zo(e){return Array.isArray(e)?e:[e,e]}function Jo(e,t){const n=h.quantile(e,.25),i=h.quantile(e,.5),o=h.quantile(e,.75),a=i=>function(e,t,n,i,o){const a=h.min(e),r=h.max(e);if("tukey"===t){const e=n?o+1.5*(o-i):i-1.5*(o-i);return n?e>r?r:e:e<a?a:e}return"extent"===t?n?r:a:"number"==typeof t?h.quantile(e,t):void 0}(e,t[i],i,n,o);return{first:n,median:i,third:o,lowerLimit:a(0),upperLimit:a(1)}}const ea=["fill","stroke","backgroundImage","backgroundImageFit","texture","textureDefault"],ta={fill:"white",stroke:"black"};function na(e,t){return fe(e)?de(t):t}function ia(e){return"function"==typeof e?t=>e(t.data,t.i):e}function oa(e){const t="string"==typeof e?l.color(e):null;return t&&t.opacity?r.colorContrast(t.formatRgb(),{dark:"black",light:"white"}):"black"}function aa(e){const t=new Set(e),n=new Set;return e.map(e=>{if(!n.has(e))return n.add(e),e;let i=1;for(;t.has(`${e}~${i}`);)i++;const o=`${e}~${i}`;return t.add(o),o})}const ra=["boxMin","boxQ1","boxMedian","boxQ3","boxMax"];function sa(e){if(null!=e&&!1!==e)return"function"==typeof e?e:"string"==typeof e?Be(e):N(e)}function ca(e){return ra.some(t=>"function"==typeof e[t])}function la(e,t){const n=function(e){return ca(e)?ra.filter(t=>"function"!=typeof e[t]):[]}(t);n.length&&pe(`${e} draws precomputed boxes only when ${ra.join(", ")} are all set; missing ${n.join(", ")}.`)}const ha=e=>"number"==typeof e&&Number.isFinite(e),ua=e=>"number"==typeof e||e instanceof Date?+e:NaN;function da(e,t,n){const i="function"==typeof e.boxOutliers?e.boxOutliers(t,n):void 0;return(Array.isArray(i)?i:[i]).map(ua).filter(ha)}function fa(e,t,n){const i=[];for(const o of ra){const a=e[o];if("function"!=typeof a)return null;const r=ua(a(t,n));if(!ha(r))return null;i.push(r)}i.sort((e,t)=>e-t);const o=da(e,t,n),[a,r,s,c,l]=i;return{min:a,q1:r,median:s,q3:c,max:l,outliers:o}}function ma(e,t,n){const i=e,o=e.first,a=e.third-o;"vertical"===e.orient?(i.height=a,i.width=n,i.x=t,i.y=o+a/2):"horizontal"===e.orient&&(i.height=n,i.width=a,i.x=o+a/2,i.y=t)}function pa(e,t,n){const i=e=>{const o={...e},a=function(e,t){const n=new Set;for(let i=e;i&&"object"==typeof i&&!n.has(i);i=i.data){const e=t.get(i);if(e)return e;n.add(i)}}(e.datum,n);return a&&(o.owners=[...e.owners??[],{shapeType:t,...a}]),"group"===e.type&&(o.children=e.children.map(i)),o};return e.map(i)}const ga=[{key:"curve",coerce:"const",default:N("linear")},{key:"defined",coerce:"identity",default:e=>e}];class ya extends jo{_dataFilter(e){const t=h.groups(e,this.schema.id).map(([t,n])=>{const i={key:t,values:n};i.data=o.merge(i.values),i.i=e.indexOf(i.values[0]);const a=h.extent(i.values,this.schema.x);i.xR=a,i.width=a[1]-a[0],i.x=a[0]+i.width/2;const r=h.extent(i.values,this.schema.y);return i.yR=r,i.height=r[1]-r[0],i.y=r[0]+i.height/2,i.nested=!0,i.translate=[i.x,i.y],i.__d3plusShape__=!0,i});return t.key=e=>e.key,t}_sceneGeometry(e){const t=Number(e.x),n=Number(e.y),i=String(this.schema.curve.bind(this)(this.config())),o=L[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`];return{type:"path",d:L.line().curve(o).defined(this.schema.defined).x((e,n)=>this.schema.x(e,n)-t).y((e,t)=>this.schema.y(e,t)-n)(e.values)||""}}_aes(e,t){return{points:e.values.map(e=>[this.schema.x(e,t),this.schema.y(e,t)])}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,ga),this._name="Line",this._path=L.line(),this.schema.fill=N("none"),this.schema.stroke=N("black"),this.schema.strokeWidth=N(1),this.schema.hitArea=N({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const xa={Circle:Uo,Rect:Yo},ba=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:T("endpoint","Rect")},{key:"length",coerce:"const",default:T("length",25)},{key:"orient",coerce:"const",default:T("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class _a extends $e{render(e){const i="compute"===this.schema.renderMode;void 0!==this._select||i||this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const o=e=>i?null:n.elem(e,{parent:this._select}).node();this._owned=new Map(this._data.map((e,t)=>[e,{datum:e,index:t}]));const a=aa(this._data.map((e,t)=>`${e.id??t}`)),r=function(e,t){const n=[];return e._data.forEach((i,o)=>{const a=e.schema.orient(i,o),r=e.schema.x(i,o),s=e.schema.y(i,o);let c=r;"left"===a?c-=e.schema.length(i,o):"right"===a&&(c+=e.schema.length(i,o));let l=s;"top"===a?l-=e.schema.length(i,o):"bottom"===a&&(l+=e.schema.length(i,o)),n.push({__d3plus__:!0,data:i,i:o,id:t[o],x:r,y:s}),n.push({__d3plus__:!0,data:i,i:o,id:t[o],x:c,y:l})}),n}(this,a);this._line=(new ya).data(r).renderMode(i?"compute":"full").select(o("g.d3plus-Whisker")).config(Ae.bind(this)(this.schema.lineConfig,"shape")).render();const s=function(e,t){return e._data.map((n,i)=>{const o={__d3plus__:!0};o.data=n,o.i=i,o.id=`${t[i]}-end`,o.endpoint=e.schema.endpoint(n,i),o.length=e.schema.length(n,i),o.orient=e.schema.orient(n,i);let a=e.schema.x(n,i);"left"===o.orient?a-=o.length:"right"===o.orient&&(a+=o.length);let r=e.schema.y(n,i);return"top"===o.orient?r-=o.length:"bottom"===o.orient&&(r+=o.length),o.x=a,o.y=r,o})}(this,a);return this._whiskerEndpoint=[],h.groups(s,e=>e.endpoint).forEach(([e,t])=>{this._whiskerEndpoint.push((new xa[e]).data(t).renderMode(i?"compute":"full").select(o(`g.d3plus-Whisker-Endpoint-${e}`)).config(de({height:e=>"top"===e.orient||"bottom"===e.orient?5:20,width:e=>"top"===e.orient||"bottom"===e.orient?20:5})).config(Ae.bind(this)(this.schema.endpointConfig,"shape",e)).render())}),e&&setTimeout(e,this.schema.duration+100),this}toScene(){const e=[],t=t=>{const n=t&&"function"==typeof t.toScene?t.toScene():null;n&&Array.isArray(n.children)&&e.push(...n.children)};if(t(this._line),Array.isArray(this._whiskerEndpoint))for(const e of this._whiskerEndpoint)t(e);return{type:"group",key:"d3plus-Whisker-scene",children:pa(e,"Whisker",this._owned)}}active(e){this._line&&this._line.active(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.active(e))}data(e){return arguments.length?(this._data=e,this):this._data}endpointConfig(e){return arguments.length?(this.schema.endpointConfig=Y(this,"endpointConfig",e),this):this.schema.endpointConfig}hover(e){this._line&&this._line.hover(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.hover(e))}lineConfig(e){return arguments.length?(this.schema.lineConfig=Y(this,"lineConfig",e),this):this.schema.lineConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,ba),this.schema.endpointConfig={Circle:{r:T("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[],this._owned=new Map}}K(_a.prototype,"endpointConfig","lineConfig");const ka=e=>"function"==typeof e?e:T(e),va=[{key:"backgroundImage",coerce:"const"},{key:"backgroundImageFit",coerce:"const"},{key:"boxMax",coerce:sa},{key:"boxMedian",coerce:sa},{key:"boxMin",coerce:sa},{key:"boxOutliers",coerce:sa},{key:"boxQ1",coerce:sa},{key:"boxQ3",coerce:sa},{key:"fill",coerce:"const"},{key:"id",coerce:"accessor"},{key:"orient",coerce:"const",default:T("orient","vertical")},{key:"outlier",coerce:"const",default:T("outlier","Circle")},{key:"rectWidth",coerce:"const",default:N(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"stroke",coerce:"const"},{key:"texture",coerce:"const"},{key:"textureDefault",coerce:"identity"},{key:"whiskerMode",coerce:Zo,default:["tukey","tukey"]},{key:"x",coerce:ka,default:T("x",250)},{key:"y",coerce:ka,default:T("y",250)}];function wa(e,[t,n],i,a){const r={key:t,values:n};r.data=o.merge(r.values),r.i=e._data.indexOf(r.values[0]),r.id=i,r.orient=e.schema.orient(r.data,r.i);const s=r.values.map("vertical"===r.orient?e.schema.y:e.schema.x);s.sort((e,t)=>e-t);const{first:c,median:l,third:h,lowerLimit:u,upperLimit:d}=Jo(s,e.schema.whiskerMode);return Object.assign(r,{first:c,median:l,third:h}),void 0!==u&&Object.assign(r,{lowerLimit:u}),void 0!==d&&Object.assign(r,{upperLimit:d}),ma(r,t,e.schema.rectWidth(r.data,r.i)),function(e,t,n){t.values.forEach((i,o)=>{const a="vertical"===t.orient?e.schema.y(i,o):e.schema.x(i,o);if(a<t.lowerLimit||a>t.upperLimit){const r=e.schema.outlier(i,o);if(!Qo(r))return;const s={__d3plus__:!0};s.data=i,s.i=o,s.id=`${t.id}-outlier-${o}`,s.outlier=r,"vertical"===t.orient?(s.x=t.x,s.y=a,n.push(s)):"horizontal"===t.orient&&(s.y=t.y,s.x=a,n.push(s))}})}(e,r,a),r.__d3plus__=!0,r}class Sa extends $e{render(){const e="compute"===this.schema.renderMode;void 0!==this._select||e||this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const i=t=>e?null:n.elem(t,{parent:this._select}).node(),o=[],a=ca(this.schema)?function(e,t){const{schema:n}=e;la("Box",n);const i=e._data.map((e,t)=>({row:e,i:t,stats:fa(n,e,t)})).filter(e=>e.stats),o=n.orient,a=i.map(({row:e,i:t})=>"vertical"===o(e,t)?n.x(e,t):n.y(e,t)),r=aa(i.map(({row:e,i:t},i)=>`${(n.id?n.id(e,t):void 0)??a[i]}`));return e._owned=new Map,i.map(({row:i,i:s,stats:c},l)=>{const h=c,u={__d3plus__:!0,key:a[l],values:[i],data:i,i:s,id:r[l],orient:o(i,s),first:h.q1,median:h.median,third:h.q3,lowerLimit:h.min,upperLimit:h.max};ma(u,a[l],n.rectWidth(i,s));const d=t.length,f=n.outlier(i,s);Qo(f)&&h.outliers.forEach((e,n)=>t.push(function(e,t,n,i){const o="vertical"===e.orient;return{__d3plus__:!0,data:e.data,i:e.i,id:`${e.id}-outlier-${i}`,outlier:t,x:o?e.x:n,y:o?n:e.y}}(u,f,e,n)));const m={datum:u,index:l};for(const n of[u,...t.slice(d)])e._owned.set(n,m);return u})}(this,o):function(e,t){const n=h.groups(e._data,(t,n)=>"vertical"===e.schema.orient(t,n)?e.schema.x(t,n):e.schema.y(t,n)),i=aa(n.map(([t,n])=>{const i=n[0];return`${(e.schema.id?e.schema.id(i,e._data.indexOf(i)):void 0)??t}`}));return e._owned=new Map,n.map((n,o)=>{const a=t.length,r=wa(e,n,i[o],t),s={datum:r,index:o};for(const n of[r,...t.slice(a)])e._owned.set(n,s);return r})}(this,o),r=function(e,t){const n={...ta};for(const i of ea){const o=e[i];void 0===o||i in t||(n[i]=ia(o))}return na(t,{...n,...t})}(this.schema,Ae.bind(this)(this.schema.rectConfig,"shape"));this._box=(new Yo).data(a).id(e=>`${e.id}-box`).x(e=>e.x).y(e=>e.y).renderMode(e?"compute":"full").select(i("g.d3plus-Box")).config(r).render(),this._median=(new Yo).data(a).id(e=>`${e.id}-median`).x(e=>"vertical"===e.orient?e.x:e.median).y(e=>"vertical"===e.orient?e.median:e.y).height(e=>"vertical"===e.orient?1:e.height).width(e=>"vertical"===e.orient?e.width:1).renderMode(e?"compute":"full").select(i("g.d3plus-Box-Median")).config(function(e,t){if("fill"in t)return t;const n="function"==typeof e?(t,n)=>oa(e(t,n)):()=>oa(e);return na(t,{...t,fill:n})}(r.fill,Ae.bind(this)(this.schema.medianConfig,"shape"))).render();const s=function(e){const t=[];return e.forEach((e,n)=>{const i=e.x,o=e.y,a=e.first-e.lowerLimit,r=e.upperLimit-e.third;if("vertical"===e.orient){const s=o-e.height/2,c=o+e.height/2;t.push({__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-top`,x:i,y:s,length:a,orient:"top"},{__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-bottom`,x:i,y:c,length:r,orient:"bottom"})}else if("horizontal"===e.orient){const s=i+e.width/2,c=i-e.width/2;t.push({__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-right`,x:s,y:o,length:r,orient:"right"},{__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-left`,x:c,y:o,length:a,orient:"left"})}}),t}(a);return this._whisker=(new _a).data(s).renderMode(e?"compute":"full").select(i("g.d3plus-Box-Whisker")).config(Ae.bind(this)(this.schema.whiskerConfig,"shape")).render(),this._whiskerEndpoint=[],h.groups(o,e=>e.outlier).forEach(([t,n])=>{const o=function(e){return Xo.get(e)}(t);var a,r;this._whiskerEndpoint.push((new o).data(n).renderMode(e?"compute":"full").select(i(`g.d3plus-Box-Outlier-${t}`)).config((a=this.schema,r=Ae.bind(this)(this.schema.outlierConfig,"shape",t),void 0===a.fill||"fill"in r?r:na(r,{...r,fill:ia(a.fill)}))).render())}),this}toScene(){const e=[],t=t=>{const n=t&&"function"==typeof t.toScene?t.toScene():null;n&&Array.isArray(n.children)&&e.push(...n.children)};if(t(this._box),t(this._median),t(this._whisker),Array.isArray(this._whiskerEndpoint))for(const e of this._whiskerEndpoint)t(e);return{type:"group",key:"d3plus-Box-scene",children:pa(e,"Box",this._owned)}}active(e){this._box&&this._box.active(e),this._median&&this._median.active(e),this._whisker&&this._whisker.active(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.active(e))}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){this._box&&this._box.hover(e),this._median&&this._median.hover(e),this._whisker&&this._whisker.hover(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.hover(e))}medianConfig(e){return arguments.length?(this.schema.medianConfig=Y(this,"medianConfig",e),this):this.schema.medianConfig}outlierConfig(e){return arguments.length?(this.schema.outlierConfig=Y(this,"outlierConfig",e),this):this.schema.outlierConfig}rectConfig(e){return arguments.length?(this.schema.rectConfig=Y(this,"rectConfig",e),this):this.schema.rectConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}whiskerConfig(e){return arguments.length?(this.schema.whiskerConfig=Y(this,"whiskerConfig",e),this):this.schema.whiskerConfig}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,va),this.schema.medianConfig={},this.schema.outlierConfig={Circle:{r:T("r",5)},Rect:{height:(e,t)=>"vertical"===this.schema.orient(e,t)?5:20,width:(e,t)=>"vertical"===this.schema.orient(e,t)?20:5}},this.schema.rectConfig={strokeWidth:N(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[],this._owned=new Map}}K(Sa.prototype,"medianConfig","outlierConfig","rectConfig","whiskerConfig");const Ca=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:T("height")},{key:"id",coerce:"identity",default:T("id")},{key:"opacity",coerce:"const",default:N(1)},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:T("url")},{key:"width",coerce:"accessor",default:T("width")},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class Ma{config(e){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const t=e;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("function"==typeof this[e]?this[e](t[e]):this.schema[e]=t[e]);return this}render(e){if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;void 0===this._select&&this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const n=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),i=n.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(e,t)=>this.schema.x(e,t)+this.schema.width(e,t)/2).attr("y",(e,t)=>this.schema.y(e,t)+this.schema.height(e,t)/2),o=u.transition().duration(this.schema.duration),a=this;return i.merge(n).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(o).attr("opacity",this.schema.opacity).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).each(function(e,n){const i=t.select(this),o=a.schema.url(e,n);if(!(0===o.indexOf("http://")||0===o.indexOf("https://"))||0===o.indexOf(window.location.hostname)){const e=new window.Image;e.src=o,e.crossOrigin="Anonymous",e.onload=function(){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;t.getContext("2d").drawImage(e,0,0),i.attr("xlink:href",t.toDataURL("image/png"))}}}),n.exit().transition(o).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).attr("opacity",0).remove(),e&&setTimeout(e,this.schema.duration+100),this}data(e){return arguments.length?(this._data=e,this):this._data}toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((e,t)=>({type:"image",key:`${this.schema.id(e,t)}`,x:this.schema.x(e,t),y:this.schema.y(e,t),width:this.schema.width(e,t),height:this.schema.height(e,t),href:this.schema.url(e,t),paint:{opacity:this.schema.opacity(e,t)},datum:e,index:t}))}}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){ee(this,Ca)}}const $a=[{key:"d",coerce:"const",default:T("path")}];class Aa extends jo{_sceneGeometry(e,t){return{type:"path",d:String(this.schema.d(e,t))}}_aes(e,t){return{points:f.path2polygon(this.schema.d(e,t))}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("path"),ee(this,$a),this._name="Path",this.schema.labelBounds=(e,t,n)=>{const i=this.schema.labelConfig.rotate,o=f.largestRect(n.points,{angle:i?i(e,t):0});return!!o&&{angle:o.angle,width:o.width,height:o.height,x:o.cx-o.width/2,y:o.cy-o.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}const za=E;let Da;function Fa(e,t,i={}){const o=`${e}.${i.method??"shapeConfig"}()`,a=function(){if(!Da){Da={};for(const[e,t]of Object.entries(za))Da[e]=new t}return Da}(),r=i.shapes??Object.fromEntries(Object.keys(a).map(e=>[e,e])),s=i.extra??{},c=Object.values(r).map(e=>a[e]);for(const e of Object.keys(t)){const i=r[e]&&a[r[e]];if(i){if(!n.isObject(t[e]))continue;for(const n of Object.keys(t[e]))n in i||s[e]?.includes(n)||me(o,`${e}.${n}`)}else s[""]?.includes(e)||c.some(t=>e in t)||me(o,e)}}class Ba extends $e{active(e){return arguments.length?(this._active=e,1!==this.schema.shapeConfig.activeOpacity&&(this.schema.legend&&this._legendClass.active(e),this._sceneRenderer&&this._scheduleSceneRepaint()),dt(this,"active",e),this):this._active}data(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"data"),this._hidden=[],this._solo=[],this._userData&&JSON.stringify(e)!==JSON.stringify(this._userData)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userData=e,this._userDataFormat=t,this._dataSignature=void 0,Ct(this),this):this._data}facet(e){return arguments.length?(this.schema.facet=Ee(e),this):this.schema.facet}facetConfig(e){return arguments.length?(this.schema.facetConfig=Y(this,"facetConfig",e),this):this.schema.facetConfig}fontFamily(e){if(arguments.length){const t={fontFamily:e},n={titleConfig:t,shapeConfig:{labelConfig:t}};return this.shapeConfig({labelConfig:t}),this.colorScaleConfig({axisConfig:n}),["axis","column","row","timeline","x","y","x2","y2"].forEach(e=>{const t=`${e}Config`;this[t]&&this[t](n)}),["back","title","total","subtitle"].forEach(e=>{const n=`${e}Config`;this[n]&&this[n](t)}),this.tooltipConfig({tooltipStyle:{"font-family":a.fontFamilyStringify(e)}}),this.schema.fontFamily=e,this}return this.schema.fontFamily}groupBy(e){if(!arguments.length)return this.schema.groupBy;this._groupByRaw=e;const t=e instanceof Array?e:[e];return this.schema.groupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=o.unique(e.map(t));return 1===n.length?n[0]:n}),Be(e))),this}hover(e){if(!arguments.length)return this._hover;let t=this._hover=e;if(1!==this.schema.shapeConfig.hoverOpacity&&void 0!==e){if("function"==typeof e){const n=[...this._filteredData??[],...this._legendClass.data()??[]].filter(e),i=new Set;n.map(this._ids).forEach(e=>{for(let t=1;t<=e.length;t++)i.add(JSON.stringify(e.slice(0,t)))}),i.size&&(t=(e,t)=>{const n=this._ids(e,t),o=Ye(e);return i.has(JSON.stringify(void 0===o?n:n.slice(0,o+1)))})}this.schema.legend&&this._legendClass.hover(t)}return this._sceneRenderer&&void 0!==e&&(gt(this)||this._hoverBucket)&&this._scheduleSceneRepaint(),dt(this,"hover",e),this}highlight(e){return arguments.length?(this._highlight=e,this._sceneRenderer&&this._scheduleSceneRepaint(),dt(this,"highlight",e),this):this._highlight}select(e){return arguments.length?(this._select=t.select(e),this):this._select}shapeConfig(e){return arguments.length?(W(e)&&Fa(this.constructor.name,e),this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}threshold(e){return arguments.length?("function"==typeof e?this.schema.threshold=e:isFinite(e)&&!isNaN(e)&&(this.schema.threshold=N(1*e)),this):this.schema.threshold}thresholdKey(e){return arguments.length?(this.schema.thresholdKey="function"==typeof e?e:Be(e),this):this.schema.thresholdKey}time(e){return arguments.length?("function"==typeof e?this.schema.time=e:e?(this.schema.time=Be(e),this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=o.unique(e.map(t));return 1===n.length?n[0]:n}),this._userTime&&JSON.stringify(e)!==JSON.stringify(this._userTime)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userTime=e):(this.schema.time=void 0,this._userTime=void 0,this.schema.timeFilter=!1,this._timelineSelection=!1),this):this.schema.time}timelineDefault(e){return arguments.length?(e instanceof Array||(e=[e,e]),this.schema.timelineDefault=e.map(e=>n.date(e)).filter(e=>!1!==e),this):this.schema.timelineDefault}total(e){return arguments.length?(this.schema.total="function"==typeof e?e:!!e&&Be(e),this):this.schema.total}}function La(e){const t=e._colorScaleClass,n=e.schema.colorScale;if(!t||"function"!=typeof t._colorScale||!n)return null;const i=t._colorScale;return{rows:Array.isArray(t._data)?t._data:[],colorOf:(e,t)=>{let o=e;for(;o&&o.__d3plus__&&o.data;)o=o.data;return o&&o._isColorScaleBucket?o.color:i(n(o,t))}}}function Pa(e,t,n){const i=La(e);if(!i)return null;let o=0,a=0;return i.rows.forEach((e,r)=>{const s=n(e,r);Number.isFinite(s)&&(o+=s,i.colorOf(e,r)===t&&(a+=s))}),o?a/o:null}function Ra(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t&&t._isColorScaleBucket?t:null}function Ea(e,t){const n=e._colorScaleClass;if(!n||!e.schema.colorScale)return;let i=!1;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;if(!1===n.hoverMark())return;i=function(e,t){const n=e.schema.colorScale;if(!t||"function"!=typeof n)return null;if(t.interactionGroup)return null;if(Ra(t.datum))return null;let i=t.datum,o="number"==typeof t.index?t.index:0;for(;i&&i.__d3plus__&&i.data;)i=i.data,"number"==typeof i.i&&(o=i.i);if(!i||"object"!=typeof i)return null;const a=n(i,o);if(null==a||""===a)return null;if("number"!=typeof a&&"string"!=typeof a)return null;const r=+a;return Number.isFinite(r)?r:null}(e,t.pick?.node)??!1}else if("mouseleave"!==t.type)return;(n.hover()??!1)!==i&&(n.hover(i),e._scheduleSceneRepaint())}K(Ba.prototype,"facetConfig","shapeConfig");function Na(e,t,n){const i={...e.paint??{}};let o="string"==typeof i.fill?i.fill:void 0;if(o&&"transparent"!==o&&"none"!==o||(o="string"==typeof i.stroke?i.stroke:void 0),!o||"transparent"===o||"none"===o)return e;const a=l.color(o);a&&(i.stroke=a.darker(t).formatHex());const r="number"==typeof i.strokeWidth&&i.strokeWidth?i.strokeWidth:1;return i.strokeWidth=r*n,{...e,paint:i}}function Ta(e){const t="function"==typeof e._hover?e._hover:null,n="function"==typeof e._active?e._active:null,i="function"==typeof e._highlight?e._highlight:null;if(!t&&!n&&!i)return null;const o=e.schema.shapeConfig??{};let a="number"==typeof o.hoverOpacity?o.hoverOpacity:.5;const r="number"==typeof o.activeOpacity?o.activeOpacity:.25,s=!t&&!n;return t&&e._hoverBucket&&a>=1&&(a=.5),{predicate:t??n??i,dimOpacity:t?a:n?r:1,isHover:!!t,gray:s,kind:t?"hover":n?"active":"highlight",activePredicate:n}}function Oa(e,t){const n=function(e){const t=e._colorScaleClass;if(!t||"function"==typeof e._hover)return null;const n=t.hover();if("number"!=typeof n||!Number.isFinite(n)||!1===t.hoverMark()||t._barGeometry||"function"!=typeof t._colorScale)return null;const i=e.schema.shapeConfig,o=i?.hoverOpacity;return{color:t._colorScale(n),dimOpacity:"number"==typeof o&&o<1?o:.5}}(t);let i,o;if(n)i=new Set([n.color]),o=n.dimOpacity;else{const n=Ta(t);if(!n)return e;i=function(e,t){const n=La(e);if(!n)return null;const i=new Set;return n.rows.forEach((e,o)=>{t(e,o)&&i.add(n.colorOf(e,o))}),i}(t,n.predicate),o=n.dimOpacity}if(!i)return e;const a=e=>{let t=e,n=e.datum;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(n&&n._isColorScaleBucket&&!i.has(n.color)){const n=e.paint&&"number"==typeof e.paint.opacity?e.paint.opacity:1;t={...e,paint:{...e.paint??{},opacity:n*o}}}const r=t.children;return r&&r.length&&(t={...t,children:r.map(a)}),t};return e.map(a)}function Wa(e,t,n){let i=t;if(e(i,n))return!0;for(;i&&i.__d3plus__&&i.data;)if(i=i.data,e(i,n))return!0;return!1}function ja(e,t){const n=e.datum;if(n){const i=n.data??n,o="number"==typeof e.index?e.index:"number"==typeof i.i?i.i:0;return Wa(t,i,o)}const i=e.interactionPoints;return i&&i.length?i.some((e,n)=>{const i=e.datum;return Wa(t,i,"number"==typeof i.i?i.i:n)}):null}function Ha(e,t){const n=Ta(t);if(!n)return e;const{predicate:i,dimOpacity:o,isHover:a,gray:s,kind:c,activePredicate:l}=n,h=e=>{const t=e.interactionGroup;if("axis"===t||"timeline"===t)return e;let n=e;const u=ja(e,i);if(null!==u)if(u){if("highlight"!==c&&Qe.has(e.type)){n="active"===c||!!l&&!0===ja(e,l)?Na(e,1,3):Na(e,.5,2)}a&&(n={...n,z:1e6})}else{const t=e.paint??{};if(s){const i={...t};"string"==typeof t.fill&&(i.fill=r.colorGrayscale(t.fill)),"string"==typeof t.stroke&&(i.stroke=r.colorGrayscale(t.stroke)),n={...e,paint:i}}else{const i="number"==typeof t.opacity?t.opacity:1;n={...e,paint:{...t,opacity:i*o}}}}const d=n.children;return d&&d.length&&(n={...n,children:d.map(h)}),n};return e.map(h)}function Ia(e){const t=e._select&&"function"==typeof e._select.node?e._select.node():null;return t?n.backgroundColor(t):"rgb(255, 255, 255)"}function Ga(e){return r.colorContrast(Ia(e),e.schema.colorDefaults)}const Va=["sizeLegend","legend","colorScale"];function qa(e){return{padding:10,margin:6,fillOpacity:.85,strokeWidth:1,rx:4,...e.schema.legendInsetConfig||{}}}function Ya(e,t){return Boolean(e._insetPending&&e._insetPending.has(t))}function Ka(e,t){const n=e._insetPlacement;return n&&n.key===t?n:null}function Ua(e,t){return Ka(e,t)?.orient??"column"}function Xa(e,t){return"column"===e?{width:.4*t.width,height:.6*t.height}:{width:.6*t.width,height:.4*t.height}}function Qa(e,t){const n=qa(e),i=n.fill??Ia(e);return{type:"rect",key:"viz-inset-background",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.rx,ry:n.rx,paint:{fill:i,fillOpacity:n.fillOpacity,stroke:n.stroke??r.colorContrast(i,e.schema.colorDefaults),strokeOpacity:n.stroke?1:.15,strokeWidth:n.strokeWidth}}}function Za(e,t,n,i){const o=Ja(e,t,i);return o?[Qa(e,Ka(e,t)),{...n,transform:o}]:[n]}function Ja(e,t,n){const i=Ka(e,t);if(!i)return null;const{margin:o}=qa(e);return{x:i.x+o-(n.x??0),y:i.y+o-(n.y??0)}}function er(e){let t=e._select?.node()?.parentNode??null;for(;t&&!(t instanceof HTMLElement);)t=t.parentNode;return t instanceof HTMLElement?t:null}function tr(e,n){const{kind:i,width:o,height:a,duration:r,ocean:s}=n,c=`d3plus-${"generic"===i?"zoom":i}`,l="geomap"===i&&s||"transparent",h=function(e,n){const i="geomap"!==n||"canvas"!==e._renderer||e._ssr?null:er(e);if(!i)return e._select;i.style.isolation="isolate";const o=t.select(i).selectAll(":scope > svg.d3plus-geomap-underlay").data([0]);return o.enter().insert("svg",":first-child").attr("class","d3plus-geomap-underlay").style("position","absolute").style("top","0").style("left","0").style("z-index","-1").style("overflow","hidden").style("pointer-events","none").merge(o).attr("width",e.schema.width).attr("height",e.schema.height)}(e,i),u=e._container&&e._container.classed(c)?e._container.node():null;u&&u.parentNode!==h.node()&&h.node().insertBefore(u,h.node().firstChild),h!==e._select?e._select.selectAll(":scope > svg.d3plus-geomap").remove():function(e){const t=er(e);t&&t.querySelector(":scope > svg.d3plus-geomap-underlay")?.remove()}(e);let d=h.selectAll(`:scope > svg.${c}`).data([0]);if(d=d.enter().insert("svg",":first-child").attr("class",c).attr("opacity",0).attr("width",o).attr("height",a).attr("x",e._margin.left).attr("y",e._margin.top).style("background-color",l).merge(d),e._container=d,d.transition().duration(r).attr("opacity",1).attr("width",o).attr("height",a).attr("x",e._margin.left).attr("y",e._margin.top),"generic"===i){let t=d.selectAll(`g.${c}-zoomGroup`).data([0]);t=t.enter().append("g").attr("class",`${c}-zoomGroup`).merge(t),e._zoomGroup=t}else if("network"===i){const t=d.selectAll(`rect.${c}-hitArea`).data([0]);t.enter().append("rect").attr("class",`${c}-hitArea`).merge(t).attr("width",o).attr("height",a).attr("fill","transparent").on("click",()=>{e._focus&&(e.active(!1),e._focus=void 0,e._zoomToBounds(null))});let n=d.selectAll(`g.${c}-zoomGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-zoomGroup`).merge(n),e._zoomGroup=n}else{const t=d.selectAll(`rect.${c}-ocean`).data([0]);t.enter().append("rect").attr("class",`${c}-ocean`).merge(t).attr("width",o).attr("height",a).attr("fill",s||"transparent");let n=d.selectAll(`g.${c}-tileGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-tileGroup`).merge(n),e._tileGroup=n;let i=d.selectAll(`g.${c}-zoomGroup`).data([0]);i=i.enter().append("g").attr("class",`${c}-zoomGroup`).merge(i),e._zoomGroup=i}}function nr(e){const t=e.interactionPoints;if(t&&t.length>1){const e=[];for(let n=1;n<t.length;n++)e.push([Math.abs(t[n].x-t[n-1].x),Math.abs(t[n].y-t[n-1].y)]);return e}const n=function(e){switch(e.type){case"rect":case"image":return[e.width,e.height];case"circle":return[2*e.r,2*e.r];case"path":{const t=f.pathBounds(e.d);return[t.width,t.height]}case"line":{const t=f.pathBounds(i.linePath(e));return[t.width,t.height]}case"area":{const t=f.pathBounds(i.areaPath(e));return[t.width,t.height]}default:return null}}(e);return n?[n]:[]}const ir=new WeakSet;function or(e){return ir.add(e),e}function ar(e){return"function"==typeof e&&ir.has(e)}const rr=e=>e&&"function"!=typeof e?Be(e):e,sr={aggs:{merge:!0},ariaHidden:{},attribution:{},attributionIcon:{},attributionStyle:{merge:!0},backControlClassName:{},backControlStyle:{},cache:{},color:{coerce:rr},colorOrdinal:{default:!1},colorScale:{coerce:rr},colorScaleConfig:{merge:!0},colorScaleMaxSize:{},colorScalePadding:{coerce:"const"},colorScalePosition:{coerce:"const"},dataCutoff:{},dataPollingInterval:{onSet:e=>function(e){(e._dataPollStop||e._sceneRenderer)&&(e._queue?.some(e=>"data"===e[3])||At(e))}(e)},depth:{},detectResize:{},detectResizeDelay:{},detectVisible:{},detectVisibleInterval:{},detectVisibleUnload:{},discrete:{},duration:{},filter:{},height:{},hiddenColor:{coerce:"const"},hiddenOpacity:{coerce:"const"},label:{coerce:"const"},legend:{coerce:"const"},legendConfig:{merge:!0},legendFilterInvert:{coerce:"const"},legendInset:{},legendInsetConfig:{merge:!0},legendPadding:{coerce:"const"},legendPosition:{coerce:"const"},legendSort:{},legendTooltip:{merge:!0},link:{onSet:e=>ot(e)},loadingHTML:{coerce:"const"},loadingMessage:{},messageMask:{},messageStyle:{merge:!0},minimap:{},minimapClassName:{},minimapLabelStyle:{},minimapStyle:{},minimapViewportStyle:{},minimapViewportStyleActive:{},noDataHTML:{coerce:"const"},noDataMessage:{},saveControl:{},saveControlClassName:{},saveControlConfig:{merge:!0},saveControlMenuClassName:{},saveControlMenuItemStyle:{},saveControlMenuItemStyleHover:{},saveControlMenuStyle:{},saveControlStyle:{},saveControlStyleActive:{},saveControlStyleHover:{},scrollContainer:{},search:{},searchAccessor:{},searchControlClassName:{},searchControlStyle:{},searchControlStyleActive:{},searchControlStyleHover:{},shape:{coerce:"const"},sizeLegend:{coerce:"const"},sizeLegendConfig:{merge:!0},sizeLegendPosition:{},subtitle:{coerce:"const"},subtitleConfig:{merge:!0},subtitlePadding:{coerce:"const"},svgDesc:{},svgTitle:{},tableView:{},tableViewClassName:{},tableViewControlClassName:{},tableViewControlStyle:{},tableViewControlStyleActive:{},tableViewControlStyleHover:{},tableViewDownload:{},tableViewPageSize:{},tableViewSort:{},thresholdName:{coerce:"const"},timeFilter:{},timeline:{},timelineConfig:{merge:!0},timelinePadding:{coerce:"const"},title:{coerce:"const"},titleConfig:{merge:!0},titlePadding:{coerce:"const"},tooltip:{coerce:"const"},tooltipConfig:{merge:!0},totalConfig:{merge:!0},totalFormat:{},totalPadding:{coerce:"const"},width:{},zoom:{},zoomBrushHandleSize:{},zoomBrushHandleStyle:{},zoomBrushSelectionStyle:{},zoomControlClassName:{},zoomControlIcons:{},zoomControlStyle:{},zoomControlStyleActive:{},zoomControlStyleHover:{},zoomFactor:{},zoomMax:{},zoomPadding:{},zoomPan:{},zoomScroll:{}},cr=Object.entries(sr).map(([e,t])=>({key:e,...t}));function lr(e){if(!["string","number","boolean"].includes(typeof e))return;const t=`${e}`;return""===t||l.color(t)?void 0:t}function hr(e,t){if(e._legendCategories&&t){for(;t.__d3plus__&&t.data;)t=t.data;return e._legendCategories.get(t)}}function ur(e,t){return hr(this,e)??this._drawLabel(e,t,this._legendDepth)}function dr(e){return i.isFlipEligible(e)?"rect"===e.type?{x:e.x,y:e.y,width:e.width,height:e.height}:"circle"===e.type?{x:e.cx-e.r,y:e.cy-e.r,width:2*e.r,height:2*e.r}:"area"===e.type?f.pathBounds(i.areaPath(e)):"path"===e.type?f.pathBounds(e.d):null:null}function fr(e,t){for(const n of e){if(i.isFlipEligible(n)&&t(n))return n;if("group"===n.type&&n.children.length){const e=fr(n.children,t);if(e)return e}}}function mr(e){const t=e._pendingEnterOrigin;if(e._pendingEnterOrigin=void 0,t&&e._bodyRect){const n=e._bodyRect;e._resolvedEnterFrom={x:n.x+t.fx*n.width,y:n.y+t.fy*n.height,width:t.fw*n.width,height:t.fh*n.height},e._resolvedEnterFromBody=n,e._resolvedInstantExitKey=t.key}else e._resolvedEnterFrom=void 0,e._resolvedEnterFromBody=void 0,e._resolvedInstantExitKey=void 0;const n=e._pendingExitReunion;if(e._pendingExitReunion=void 0,n&&e._chartScene){const t=e.schema.groupBy?.[n.groupDepth],i=t?fr(e._chartScene,e=>{const i=function(e){const t=e;return t&&t.data?t.data:t}(e.datum);return void 0!==i&&t(i,function(e,t){const n=e;return n&&"number"==typeof n.i?n.i:t??0}(e.datum,e.index))===n.groupId}):void 0;e._resolvedExitTo=i?dr(i)??void 0:void 0,e._resolvedExitToBody=n.body,e._resolvedReunionEnterKey=i?.key,e._resolvedReunionEnterFrom=i?n.body:void 0,e._resolvedInstantExitAll=Boolean(i)}else e._resolvedExitTo=void 0,e._resolvedExitToBody=void 0,e._resolvedReunionEnterKey=void 0,e._resolvedReunionEnterFrom=void 0,e._resolvedInstantExitAll=void 0}function pr(e,t,n,i){i.stopPropagation();const o=Ye(e);if(void 0===o){if(this._drawDepth<this.schema.groupBy.length-1){this._select.style("cursor","auto");const n=this.schema.groupBy[this._drawDepth],i=n(e,t);this.hover(!1),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();const o=this.schema.filter,a=this._lastScenePick?.node,r=a&&dr(a);if(r&&this._bodyRect&&this._bodyRect.width&&this._bodyRect.height){const e=this._bodyRect;this._pendingEnterOrigin={fx:(r.x-e.x)/e.width,fy:(r.y-e.y)/e.height,fw:r.width/e.width,fh:r.height/e.height,key:a.key,parentStartAngle:a.startAngle,parentEndAngle:a.endAngle}}this._history.push({depth:this.schema.depth,filter:o,groupId:i,groupDepth:this._drawDepth});const s=Array.isArray(i)?e=>i.includes(e):e=>e===i;this.config({depth:this._drawDepth+1,filter:(e,t)=>(!o||o(e,t))&&s(n(e,t))}).render()}}else!function(e,t,n){const i=e.schema.groupBy,o=Ke(i,t,n);if(!Xe(i,o,e._filteredData??[]))return;e._select.style("cursor","auto"),e.hover(!1),e._tooltipClass.data([]).render();const a=e.schema.filter;e._history.push({depth:e.schema.depth,filter:a}),e.config({filter:(e,t)=>(!a||a(e,t))&&Ue(i,o,e,t)}).render()}(this,e,o)}function gr(e,t,n,i){this._select.style("cursor","auto"),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();let o=this._id(e,t);o instanceof Array||(o=[o]);const a=this._hidden.indexOf(o[0]),r=this._solo.indexOf(o[0]),s=h.merge(this._legendClass.data().map((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),n})).length,c=()=>{pt(this),this.render()};this.schema.legendFilterInvert.bind(this)(this)?i.shiftKey?a<0&&!this._solo.length?(this._hidden=this._hidden.concat(o),r>=0&&(this._solo=[]),this._hidden.length===s&&(this._hidden=[]),c()):r>=0&&(this._solo=[],this._hidden=[],c()):(r<0&&this._hidden.length<s-1?(this._solo=o,this._hidden=[]):(this._solo=[],this._hidden=[]),c()):i.shiftKey&&r<0?(this._solo=o,this._hidden=[],c()):i.shiftKey||(a>=0?this._hidden=this._hidden.filter(e=>!o.includes(e)):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(o),this._solo.length===s&&(this._solo=[])):(this._hidden=this._hidden.concat(o),this._hidden.length===s&&(this._hidden=[])),c())}function yr(e,t){if(this._sharedHoverActive&&"shared"===this._sharedHoverState?.mode)return;const n=Ra(e);if(n){const e=function(e,t){const n=La(e);return n?(e,i)=>n.colorOf(e,i)===t:null}(this,n.color);return void(e&&(this._hoverBucket=!0,this.hover(e)))}if(this._hoverBucket=!1,(!this._sharedHoverActive||!this._plotColumnHighlight)&>(this)){const n=Ye(e);if(void 0!==n){const t=this.schema.groupBy,i=Ke(t,e,n);return void this.hover((e,n)=>Ue(t,i,e,n))}let i=this._id(e,t);i instanceof Array||(i=[i]),this.hover((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),i.some(e=>n.includes(e))})}}function xr(e,t){if(!Array.isArray(e)&&!Array.isArray(t))return e===t;const n=new Set([].concat(e)),i=new Set([].concat(t));return n.size===i.size&&[...n].every(e=>i.has(e))}function br(e,t){setTimeout(()=>{let n=e;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(!n)return;let i=this._hoverDatum;for(;i&&i.__d3plus__&&i.data;)i=i.data;if(i&&xr(this._id(i),this._id(n)))return;if(this._sharedHoverActive)return;gt(this)&&this._hover&&!this._hover(e,t)||this.hover(!1);const o=this._tooltipClass.data();if(o.length&&this.schema.tooltip(e,t)){let e=o[0];for(;e.__d3plus__&&e.data;)e=e.data;xr(this._id(e),this._id(n))&&this._tooltipClass.data([]).render()}},0),this._select.style("cursor","auto")}const _r="__d3plusShare",kr="__d3plus",vr=new WeakSet;function wr(e,t){e[_r]=t,(void 0===e.share||vr.has(e))&&(e.share=t,vr.add(e))}function Sr(e){return e?e[_r]:void 0}function Cr(e){const t=Sr(e);return Array.isArray(t)?t.reduce((e,t)=>e+t,0):"number"==typeof t?t:NaN}function Mr(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function $r(e,t,n){let i=0;for(const e of t)i+=Math.abs(+n(e))||0;return i>0?Math.abs(+n(e))/i:NaN}function Ar(e){return e.startsWith(kr)}const zr=`${kr}Members`;function Dr(e,t,n,i){const o=new Map;return e.forEach((e,a)=>{const r=`${t(e,a)}`,s=+i(e,a)||0,c=o.get(r);c?c.value+=s:o.set(r,{label:`${n(e,a)}`,value:s})}),Array.from(o.values()).sort((e,t)=>t.value-e.value)}const Fr=e=>`<span class="d3plus-tooltip-member" style="padding-left: 12px">${e}</span>`;function Br(e,t,n=10){const i=function(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;const n=t?t[zr]:void 0;return n?Array.isArray(n)?n:[n]:[]}(t);if(!i.length)return[];const o=e._thresholdMemberFormat??(t=>d.formatAbbreviate(t,e.schema.locale)),a=i.slice(0,n).map(e=>[Fr(e.label),o(e.value)]),r=i.slice(n);return r.length&&a.push([Fr(`+${d.formatAbbreviate(r.length,e.schema.locale)} ${e.schema.translate("more")}`),o(r.reduce((e,t)=>e+t.value,0))]),a}function Lr(e,t,n){const i=Br(t,n);if(!i.length)return e;const o=e.tbody();return e.tbody((e,t)=>{const n="function"==typeof o?o(e,t):o;return[...Array.isArray(n)?n:[],...i]}),e}const Pr=10,Rr="display: inline-block; flex: none; margin-right: 6px; width: 10px; height: 10px;";function Er(e,t){if(!e)return"";if("Line"===t){const t=6;return`<span class="d3plus-tooltip-swatch d3plus-tooltip-swatch-line" style="${Rr} position: relative"><span style="position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: ${e}"></span><span style="position: absolute; left: ${(Pr-t)/2}px; top: ${(Pr-t)/2}px; width: ${t}px; height: ${t}px; border-radius: 50%; background: ${e}"></span></span>`}return`<span class="d3plus-tooltip-swatch" style="${Rr} border-radius: ${"Circle"===t?"50%":"1px"}; background: ${e}"></span>`}function Nr(e,t){return e?null==t||!1===t||""===t?"":`<span style="display: inline-flex; align-items: center">${e}<span>${t}</span></span>`:`${t}`}const Tr=e=>"string"==typeof e&&"none"!==e&&"transparent"!==e?e:void 0;function Or(e,t){for(const n of e){if(n.key===t)return n;const e=n.children&&Or(n.children,t);if(e)return e}}const Wr=["::hit","::confidence","::stem"];function jr(e,t){const n=t&&t.key;if("string"!=typeof n)return t;let i=n;for(const e of Wr)for(;i.endsWith(e);)i=i.slice(0,-e.length);return i===n?t:Or(e._chartScene||[],i)||t}function Hr(e,t){const n=jr(e,t);return n&&Ir(n)}function Ir(e){const t=e.paint;if(t)return"Line"===e.shapeType?Tr(t.stroke)??Tr(t.fill):Tr(t.fill)??Tr(t.stroke)}const Gr=e=>!!e.paint&&"Label"!==e.shapeType&&"text"!==e.type,Vr=e=>e.shapeType??("circle"===e.type?"Circle":void 0);function qr(e){let t=e;for(;t&&"object"==typeof t&&t.data&&"object"==typeof t.data&&!Array.isArray(t.data);)t=t.data;return t}function Yr(e,t,n){for(const i of e){if(Gr(i)&&!`${i.key}`.endsWith("::hit")&&"legend"===i.interactionGroup===n&&qr(i.datum)===t&&Ir(i))return i;const e=i.children&&Yr(i.children,t,n);if(e)return e}}function Kr(e,t){if(!t||!t.node)return"";const n=t.node,i=Gr(n)?Hr(e,n):void 0;if(i&&!t.isLegend)return Er(i,Vr(n));const o=e._paintedScene?.root,a=i?n:o&&Yr([o],qr(t.d),!!t.isLegend);if(!a)return"";const r=a.datum?.shape;return Er(Hr(e,a),t.isLegend&&"string"==typeof r?r:Vr(a))}function Ur(e,t){if(!t||!1===e.schema.titleSwatch)return e;const n=e.schema.title;return e.title((e,i)=>Nr(t,n(e,i)))}function Xr(e,t,n,i){const o=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY],a=h.merge(this._legendClass.data().map((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),n})).length;if(e&&this.schema.tooltip(e,t)){let i=this._id(e,t);i instanceof Array&&(i=i[0]);const r=this.schema.translate,s=gr.bind(this).toString(),c=Object.keys(this.schema.on).some(e=>["click","click.legend"].includes(e)&&this.schema.on[e]&&this.schema.on[e].toString()!==s),l=this.schema.on["click.legend"]&&this.schema.on["click.legend"].toString()===s,h=this._drawDepth<this.schema.groupBy.length-1;this._select.style("cursor",c||l&&h?"pointer":"auto");const u=this.schema.legendFilterInvert.bind(this)(this),d=this._solo.includes(i),f=this._hidden.includes(i);this._tooltipClass.data([n||e]).footer(!!l&&(u?this._solo.length&&!d||f?r("Click to Highlight"):1===this._solo.length&&d||this._hidden.length===a-1?r("Click to Show All"):`${r("Click to Highlight")}<br />${r("Shift+Click to Hide")}`:this._solo.length&&!d||f?`${r("Click to Show")}<br />${r("Shift+Click to Highlight")}`:1===this._solo.length&&d||this._hidden.length===a-1?r("Click to Show All"):`${r("Click to Hide")}<br />${r("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():ur.bind(this)).titleSwatch(!0).position(o).config(Ae.bind(this)(this.schema.tooltipConfig)).config(Ae.bind(this)(this.schema.legendTooltip)),Lr(this._tooltipClass,this,e),Ur(this._tooltipClass,Kr(this,this._lastScenePick)).render()}}function Qr(e,t,n,i){if(e&&this.schema.tooltip(e,t)){const t=pr.bind(this).toString(),o=Object.keys(this.schema.on).some(e=>["click","click.shape"].includes(e)&&this.schema.on[e]&&this.schema.on[e].toString()!==t),a=this.schema.on["click.shape"]&&this.schema.on["click.shape"].toString()===t,r=Ye(e),s=void 0===r?this._drawDepth<this.schema.groupBy.length-1:Xe(this.schema.groupBy,Ke(this.schema.groupBy,e,r),this._filteredData??[]);if(this._select.style("cursor",o||a&&s?"pointer":"auto"),this._sharedHoverActive)return;const c=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY];let l=n||e;for(;l&&l.__d3plus__&&l.data;)l=l.data;this._tooltipClass.data([l]).footer(!(!a||!s)&&this.schema.translate("Click to Expand")).title((e,t)=>this._drawLabel(e,t)).titleSwatch(!0).position(c).config(Ae.bind(this)(this.schema.tooltipConfig)),Lr(this._tooltipClass,this,l),Ur(this._tooltipClass,Kr(this,this._lastScenePick)).render()}}function Zr(){return"undefined"==typeof window||window.innerWidth>600}class Jr{get(e){if(!this._map.has(e))return;const t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){this._map.delete(e),this._map.size>=this._cap&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}constructor(e){this._cap=e,this._map=new Map}}const es={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`400 12px/1 ${a.fontFamilyStringify(a.fontFamily)}`,gap:"4px",height:"20px","justify-content":"center",margin:0,padding:"0 6px",width:"auto"};function ts(e){e.schema.on={"click.shape":pr.bind(e),"click.legend":gr.bind(e),mouseenter:yr.bind(e),mouseleave:br.bind(e),"mousemove.shape":Qr.bind(e),"mousemove.legend":Xr.bind(e)},e._queue=[];const t=t=>{const{width:n,height:i}=t[0].contentRect;(n!==e.schema.width&&e._autoWidth||i!==e.schema.height&&e._autoHeight)&&n&&i&&(e._setSVGSize(n,i),e._callback||e.render())},n=function(e,t){let n;return function(...i){const o=this;clearTimeout(n),n=setTimeout(()=>e.apply(o,i),t)}}(t,e.schema.detectResizeDelay);e._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(i=>{const{width:o,height:a}=i[0].contentRect;if(e._resizeSettled)n(i);else{if(!o||!a)return;e._resizeSettled=!0,t(i)}}),e.schema.scrollContainer="undefined"==typeof window?"":window}const ns="rgba(255, 255, 255, 0.7)",is="rgba(24, 25, 28, 0.7)",os={"border-radius":"3px 0 0 0",display:"flex","align-items":"center",gap:"4px",font:`400 10px/1.4 ${a.fontFamilyStringify(a.fontFamily)}`},as={...os,background:ns,color:r.colorContrast(ns)},rs={...os,background:is,color:r.colorContrast(is)},ss={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},cs={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},ls=!1,hs={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},us={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},ds=!1;const fs={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)","border-radius":"2px","box-sizing":"border-box"},ms={background:"rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.5)","border-radius":"2px",cursor:"grab"},ps={background:"rgba(0, 0, 0, 0.25)",cursor:"grabbing"},gs={bottom:"2px",right:"3px",color:"rgba(0, 0, 0, 0.75)",font:`400 9px/1 ${a.fontFamilyStringify(a.fontFamily)}`,"pointer-events":"none"};const ys={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},xs={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},bs=!1;const _s={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},ks={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},vs=!1,ws={background:"Canvas",border:"1px solid rgba(128, 128, 128, 0.5)","border-radius":"3px","box-shadow":"0 2px 6px rgba(0, 0, 0, 0.2)",color:"CanvasText","margin-top":"4px",padding:"2px 0"},Ss={background:"none",border:"none",color:"inherit",font:`12px/1.2 ${a.fontFamilyStringify(a.fontFamily)}`,margin:0,padding:"4px 10px"},Cs={background:"rgba(128, 128, 128, 0.2)"};function Ms(e){e.schema.aggs={},ee(e,cr),function(e){e._renderer="svg",e.schema.ariaHidden=!0,e.schema.attribution=!1,e.schema.attributionIcon=void 0,e.schema.attributionStyle=as,e.schema.cache=!0}(e),function(e){e.schema.color=(t,n)=>e.schema.groupBy[0](t,n);const t=s.scaleOrdinal().range(r.colorDefaults.scale.range());e.schema.colorDefaults={...r.colorDefaults,scale:t},e._autoColorScale=t,e._colorScaleClass=new Gi,e.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},e.schema.colorScalePadding=Zr,e.schema.colorScalePosition=N("auto"),e.schema.colorScaleMaxSize=600}(e),function(e){e._data=[],e.schema.dataCutoff=100,e.schema.dataPollingInterval=!1,e.schema.detectResize=!0,e.schema.detectResizeDelay=400,e.schema.detectVisible=!0,e.schema.detectVisibleInterval=1e3,e.schema.detectVisibleUnload=!0,e.schema.duration=600,e.schema.fontFamily=a.fontFamily,e._hidden=[],e.schema.hiddenColor=N("#aaa"),e.schema.hiddenOpacity=N(.5),e._history=[],e.schema.groupBy=[T("id")],e.schema.facetConfig={}}(e),function(e){e.schema.legend=(t,n)=>{if(e._legendCategories)return n.length>1;const i=h.max(n,(t,n)=>{if(t._isAggregation)return 1;const i=e.schema.groupBy[e._legendDepth].bind(e)(t,n);return i instanceof Array?i.length:1});return n.length>1&&(i??0)<=2},e._legendClass=new bi,e.schema.legendConfig={label:ur.bind(e),shapeConfig:{ariaLabel:ur.bind(e),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0}}},e.schema.legendFilterInvert=N(!1),e.schema.legendPadding=Zr,e.schema.legendPosition=N("auto");const t=t=>hr(e,t)??e._drawLabel(t);e.schema.legendSort=(e,n)=>t(e).localeCompare(t(n)),e.schema.legendTooltip={},e._sizeLegendClass=new Zi,Object.assign(e.schema,{sizeLegend:Vi,sizeLegendConfig:{},sizeLegendPosition:"right"})}(e),function(e){e.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${e.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,e.schema.loadingMessage=!0,e._lrucache=new Jr(10),e._messageClass=new Ji,e.schema.messageMask="rgba(0, 0, 0, 0.05)",e.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},e.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("No Data Available")}</strong>\n </div>`,e.schema.noDataMessage=!0}(e),ts(e),function(e){e.schema.shape=N("Rect"),e.schema.shapeConfig={ariaLabel:(t,n)=>e._drawLabel(t,n),fill:(t,n)=>{for(;t.__d3plus__&&t.data;)n=(t=t.data).i;if(e.schema.colorScale){const i=e.schema.colorScale(t,n);if(null!=i){const t=e._colorScaleClass._colorScale,n=e._colorScaleClass.color();return t?t.domain().length?t(i):t.range()[t.range().length-1]:n instanceof Array?n[n.length-1]:n}}const i=e.schema.color(t,n);if(l.color(i))return i;const o="string"==typeof i?i:JSON.stringify(i);return e.schema.colorOrdinal&&e._ordinalColorScale?e._ordinalColorScale(o):r.colorAssign(o,rt(e))},labelConfig:{fontColor:or((t,n)=>{const i="function"==typeof e.schema.shapeConfig.fill?e.schema.shapeConfig.fill(t,n):e.schema.shapeConfig.fill;return r.colorContrast(i,e.schema.colorDefaults)})},opacity:N(1),stroke:(t,n)=>{const i="function"==typeof e.schema.shapeConfig.fill?e.schema.shapeConfig.fill(t,n):e.schema.shapeConfig.fill,o=l.color(i);return o?o.darker(.25).toString():i},role:"presentation",strokeWidth:N(0)},e._solo=[]}(e),function(e){e._subtitleClass=new ro,e.schema.subtitleConfig={ariaHidden:!0,fontColor:()=>Ga(e),fontSize:12,padding:5,textAnchor:"middle"},e.schema.subtitlePadding=Zr,e.schema.svgDesc="",e.schema.svgTitle="",e.schema.timeline=!0,e._timelineClass=(new yo).align("end"),e.schema.timelineConfig={padding:5},e.schema.timelinePadding=Zr,e.schema.threshold=N(1e-4),e.schema.thresholdKey=void 0,e.schema.thresholdName=()=>e.schema.translate("Values"),e._titleClass=new ro,e.schema.titleConfig={ariaHidden:!0,fontColor:()=>Ga(e),fontSize:16,padding:5,textAnchor:"middle"},e.schema.titlePadding=Zr,e.schema.tooltip=N(!0),e._tooltipClass=new Mo,e.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},e._totalClass=new ro,e.schema.totalConfig={fontColor:()=>Ga(e),fontSize:10,padding:5,textAnchor:"middle"},e.schema.totalFormat=t=>`${e.schema.translate("Total")}: ${d.formatAbbreviate(t,e.schema.locale)}`,e.schema.totalPadding=Zr}(e),function(e){e.schema.zoom=!0,e._zoomBehavior=b.zoom(),e._zoomBrush=p.brush(),e.schema.zoomBrushHandleSize=1,e.schema.zoomBrushHandleStyle={fill:"#444"},e.schema.zoomBrushSelectionStyle={fill:"#777","stroke-width":0},e.schema.zoomControlClassName=void 0,e.schema.zoomControlIcons=void 0,e.schema.zoomControlStyle=ss,e.schema.zoomControlStyleActive=cs,e.schema.zoomControlStyleHover=ls,e.schema.zoomFactor=2,e.schema.zoomMax=void 0,e.schema.zoomPadding=20,e.schema.zoomPan=!0,e.schema.zoomScroll="modifier"}(e),function(e){e.schema.tableView=!0,e.schema.tableViewClassName=void 0,e.schema.tableViewControlClassName=void 0,e.schema.tableViewControlStyle=hs,e.schema.tableViewControlStyleActive=us,e.schema.tableViewControlStyleHover=ds,e.schema.tableViewDownload=!0,e.schema.tableViewPageSize=50,e.schema.tableViewSort=!0}(e),function(e){e.schema.minimap=!0,e.schema.minimapClassName=void 0,e.schema.minimapStyle=fs,e.schema.minimapViewportStyle=ms,e.schema.minimapViewportStyleActive=ps,e.schema.minimapLabelStyle=gs}(e),function(e){e.schema.backControlClassName=void 0,e.schema.backControlStyle=es}(e),function(e){e.schema.search=!0,e.schema.searchAccessor=(t,n)=>e._drawLabel(t,n),e.schema.searchControlClassName=void 0,e.schema.searchControlStyle=ys,e.schema.searchControlStyleActive=xs,e.schema.searchControlStyleHover=bs}(e),function(e){e.schema.saveControl=!0,e.schema.saveControlClassName=void 0,e.schema.saveControlConfig={},e.schema.saveControlMenuClassName=void 0,e.schema.saveControlMenuItemStyle=Ss,e.schema.saveControlMenuItemStyleHover=Cs,e.schema.saveControlMenuStyle=ws,e.schema.saveControlStyle=_s,e.schema.saveControlStyleActive=ks,e.schema.saveControlStyleHover=vs}(e)}const $s=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),As={AccentColor:"Highlight",AccentColorText:"HighlightText"};function zs(e,t,n){const i=$s(t);e.style.setProperty(i,n);const o=As[n];o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}function Ds(e,t,n){return n&&e===t?{}:e||{}}function Fs(e,t,n,i){const{base:o,active:a={},hover:r={}}=t;for(const t of new Set([...Object.keys(o),...Object.keys(a),...Object.keys(r)]))e.style.removeProperty($s(t));for(const t of[o,n?r:{},i?a:{}])for(const n in t){const i=t[n];null!=i&&!1!==i&&zs(e,n,String(i))}}function Bs(e,t,n){const i=Boolean(e[`${t}ClassName`]),o=(n,o)=>Ds(e[`${t}Style${n}`],o,i);return{base:o("",n.base),active:o("Active",n.active),hover:o("Hover",n.hover)}}function Ls(e){return String(e??"").replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e]))}function Ps(e){return Boolean(e._brushing)}function Rs(e){return Bs(e.schema,"zoomControl",{base:ss,active:cs,hover:ls})}function Es(e,t,n=!1){Fs(t,Rs(e),n,t.classList.contains("active"))}const Ns='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Ts=`<svg ${Ns}><line x1="12" y1="4" x2="12" y2="20"/><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Os=`<svg ${Ns}><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Ws=`<svg ${Ns}><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>`,js=`<svg ${Ns} stroke-dasharray="4 3"><rect x="4" y="4" width="16" height="16" rx="1"/></svg>`;function Hs(e,t,n){const i=e.schema.zoomControlIcons?.[t];return"string"==typeof i?i:"function"==typeof i?(e=>`<span class="zoom-control-icon" data-icon="${e}" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>`)(t):n}const Is={zoomIn:"zoom-in",zoomOut:"zoom-out",zoomReset:"zoom-reset",zoomBrush:"zoom-brush"},Gs={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"4px",boxSizing:"border-box",paddingTop:"4px",paddingRight:"4px"};function Vs(e){const t=e.schema.zoomControlClassName?` ${e.schema.zoomControlClassName}`:"",n=(n,i,o,a)=>`<button type="button" class="zoom-control ${n}${a?" active":""}${t}" aria-label="${e.schema.translate(i)}"${void 0===a?"":` aria-pressed="${a}"`}>${o}</button>`;return n("zoom-in","Zoom In",Hs(e,"zoomIn",Ts))+n("zoom-out","Zoom Out",Hs(e,"zoomOut",Os))+n("zoom-reset","Reset Zoom",Hs(e,"zoomReset",Ws))+n("zoom-brush","Brush Zoom",Hs(e,"zoomBrush",js),Ps(e))}function qs(e){let t=e._select&&e._select.node()?e._select.node().parentNode:null;for(;t&&!(t instanceof HTMLElement);)t=t.parentNode;return t instanceof HTMLElement?t:null}function Ys(e){return Boolean(e.schema.zoom)&&!e._ssr}const Ks={width:96,height:24};function Us(e){if(!Ys(e))return null;const t=Vs(e),{base:n}=Rs(e),i=`${t}|${JSON.stringify(n)}`,o=e._zoomControlsBox;if(o&&o.signature===i)return o;let a=Ks;const r=qs(e);if(r){const n=document.createElement("div");n.className="d3plus-zoom-control";for(const e in Gs)n.style.setProperty($s(e),Gs[e]);n.style.setProperty("display","inline-flex"),n.style.setProperty("position","absolute"),n.style.setProperty("visibility","hidden"),n.style.setProperty("pointer-events","none"),n.innerHTML=t,n.querySelectorAll(".zoom-control").forEach(t=>Es(e,t)),r.appendChild(n);const i=n.getBoundingClientRect();r.removeChild(n),i.width&&i.height&&(a={width:Math.ceil(i.width),height:Math.ceil(i.height)})}return e._zoomControlsBox={...a,signature:i},e._zoomControlsBox}function Xs(e){const t=Us(e);return t&&t.height?t.height+4:0}function Qs(e){return{width:e.reduce((e,t,n)=>e+t.width+(n?6:0),0),height:Math.max(0,...e.map(e=>e.height))}}function Zs(e){const t=e._bottomRightBox;return t&&t.width&&t.height?t:null}function Js(e){const t=Zs(e);return t&&!t.inset?t:null}function ec(e,t,n){const i=Js(e);if(!i||"right"===i.side||t>=i.bottom+i.height)return 0;const o=i.width-n;return o>0?o+6:0}function tc(e,t){const n=Js(e);return n?Math.max(0,n.bottom+n.height-t):0}function nc(e,t,n,i){return{inset:"bottom"===t?ec(e,n,i):0,drop:"left"===t||"right"===t?tc(e,n):0}}function ic(e,t){const n=Js(e);return n&&"bottom"===n.side?Math.max(0,n.bottom+n.height-t):0}function oc(e,t){const n=Js(e);return n&&"right"===n.side?Math.max(0,n.width+6-t):0}function ac(e,t){const n=e._zoomTransform?.scale??1;if(t.inset)return function(e,t,n){const i=Ka(e,"sizeLegend");if(!i)return null;const{margin:o}=qa(e),a=t.items.map(e=>({item:e,paint:e.paint(n)})).filter(e=>Boolean(e.paint));if(!a.length)return null;const r=a.reduce((e,t,n)=>e+t.paint.width+(n?6:0),0)+2*o,s=Math.max(...a.map(e=>e.paint.height))+2*o,c="left"===i.alignX?i.x:"center"===i.alignX?i.x+(i.width-r)/2:i.x+i.width-r,l="top"===i.alignY?i.y:"middle"===i.alignY?i.y+(i.height-s)/2:i.y+i.height-s,h=[Qa(e,{...i,x:c,y:l,width:r,height:s})];let u=c+r-o;const d=l+s-o;for(const{item:e,paint:t}of a)h.push({type:"group",key:e.key,transform:{x:u-t.width,y:d-t.height},children:[t.node]}),u-=t.width+6;return{type:"group",key:"viz-bottomRight",children:h}}(e,t,n);const i=[];let o=e.schema.width;const a=e.schema.height-t.bottom;return t.items.forEach(e=>{const t=e.paint(n);t&&i.push({type:"group",key:e.key,transform:{x:o-t.width,y:a-t.height},children:[t.node]}),o-=e.width+6}),i.length?{type:"group",key:"viz-bottomRight",children:i}:null}const rc=new WeakMap;function sc(e){rc.delete(e)}function cc(e){return{type:"htmlOverlay",key:"viz-zoom-controls",x:0,y:0,width:e.schema.width,style:Gs,className:"d3plus-zoom-control",html:Vs(e),events:{".zoom-in":{click:()=>bc.bind(e)(e.schema.zoomFactor)},".zoom-out":{click:()=>bc.bind(e)(1/e.schema.zoomFactor)},".zoom-reset":{click:()=>bc.bind(e)(0)},".zoom-brush":{click:t=>{const n=t.target.closest(".zoom-brush");if(!n)return;const i=!Ps(e);n.classList.toggle("active",i),n.setAttribute("aria-pressed",String(i)),Es(e,n,n.matches(":hover")),mc.bind(e)(i)}}},onUpdate:t=>{t.querySelectorAll(".zoom-control").forEach(t=>{t.dataset.zoomBound||(t.dataset.zoomBound="1",Es(e,t),t.addEventListener("mouseenter",()=>Es(e,t,!0)),t.addEventListener("mouseleave",()=>Es(e,t)),function(e,t){var n;const i=e.schema.zoomControlIcons;if(!i)return;const o=Object.keys(Is).find(e=>t.classList.contains(Is[e])),a=o&&i[o];if(!o||"function"!=typeof a)return;const r=t.querySelector(".zoom-control-icon");if(!r)return;const s=(n=e)._zoomIconCleanup||(n._zoomIconCleanup={});s[o]?.(),s[o]=a(r)||void 0}(e,t))})}}}const lc={name:"zoom",layout:({viz:e})=>{if(e.schema.zoom?function(e){if(!e._select)return;if(!e._ssr&&(!e._container||e._container.classed("d3plus-zoom"))){const{width:t,height:n}=ie(e);tr(e,{kind:"generic",width:t,height:n,duration:e.schema.duration})}"canvas"!==e._renderer&&uc(e,e._select)}(e):function(e){e._zoomTransform=void 0,sc(e);const t=e._zoomEventTarget||e._container;t&&t.node()&&t.property("__zoom",b.zoomIdentity)}(e),!e._container||!e._zoomGroup)return{panel:null,margin:{}};const t=ie(e),n=e._zoomHeight||t.height,i=e._zoomWidth||t.width,{left:o,top:a}=e._margin,r=[[o,a],[o+i,a+n]];e._zoomBehavior.filter(t=>function(e,t){const n="modifier"===e.schema.zoomScroll;return"wheel"===t.type?!n||t.ctrlKey||t.metaKey:!function(e){const t=e.target;return Boolean(t&&"function"==typeof t.closest&&t.closest("g.d3plus-viz-timeline, g.d3plus-zoom-brush"))}(t)&&("touchstart"===t.type&&n?(t.touches?.length??0)>1||pc(e):!t.ctrlKey&&!t.button)}(e,t)).wheelDelta(gc).extent(r).scaleExtent([1,hc(e,i,n)]).translateExtent(r).on("zoom",t=>{(function(e,t){const n=t;if(!n||"object"!=typeof n||"number"!=typeof n.k)return!1;const i=rc.get(e)??{k:1,x:0,y:0};return n.k===i.k&&(n.x??0)===i.x&&(n.y??0)===i.y})(e,t.transform)||xc.bind(e)(t.transform)}),e._zoomToBounds=kc.bind(e);const s=Ys(e)?cc(e):null;e._zoomBrush.extent([[0,0],[i,n]]).filter(e=>!e.button&&e.detail<2).handleSize(e.schema.zoomBrushHandleSize).on("start",Sc.bind(e)).on("brush",vc.bind(e)).on("end",wc.bind(e));const c=e._select.selectAll(":scope > g.d3plus-zoom-brush").data([0]);return e._brushGroup=c.enter().append("g").attr("class","d3plus-zoom-brush").merge(c).attr("transform",`translate(${o}, ${a})`).call(e._zoomBrush),mc.bind(e)(Ps(e)),e._renderTiles&&e._renderTiles(fc(e),0),{panel:s,margin:{}}}};function hc(e,t,n){return"number"==typeof e.schema.zoomMax?e.schema.zoomMax:function(e,t,n,i,o=1){const a=Math.max(1,t-2*i),r=Math.max(1,n-2*i);let s=1;for(const t of e){if(void 0===t.datum||"group"===t.type||"text"===t.type)continue;if(String(t.key).endsWith("::hit"))continue;const e=o*(t.transform?.scale??1);for(const[n,i]of nr(t)){const t=Math.min(n>0?a/(n*e):1/0,i>0?r/(i*e):1/0);Number.isFinite(t)&&t>s&&(s=t)}}return s}(e._zoomShapes||e._chartScene||[],t,n,e.schema.zoomPadding,e._chartTransform?.scale??1)}function uc(e,t){const n=e._zoomEventTarget;n&&n.node()===t.node()||(n&&n.on(".zoom",null),e._container&&e._container.on(".zoom",null),e._zoomEventTarget=t)}function dc(e){const t="canvas"===e._renderer,n=Ps(e);e._select&&e._select.style("pointer-events",t||n?"none":null),e._container&&e._container.style("pointer-events",t?"none":null),e._brushGroup&&e._brushGroup.style("pointer-events",n?"all":null)}function fc(e){const t=b.zoomTransform((e._zoomEventTarget||e._container).node()),{left:n,top:i}=e._margin;return b.zoomIdentity.translate(t.x+(t.k-1)*n,t.y+(t.k-1)*i).scale(t.k)}function mc(e=!1){!function(e,t){e._brushing=t}(this,e),e?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none"),dc(this);const t=this._zoomEventTarget||this._container;!e&&this.schema.zoom?(t.call(this._zoomBehavior),this.schema.zoomScroll||t.on("wheel.zoom",null),yc(this),this.schema.zoomPan||t.on("mousedown.zoom mousemove.zoom",null).on("touchstart.zoom touchmove.zoom touchend.zoom touchcancel.zoom",null)):t.on(".zoom",null)}function pc(e){const t=e._zoomEventTarget||e._container;return Boolean(t&&t.node()&&b.zoomTransform(t.node()).k>1)}function gc(e){const t=e.ctrlKey&&0===e.deltaMode&&Math.abs(e.deltaY)<50;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(t?10:1)}function yc(e){const t=e._zoomEventTarget||e._container;if(!t)return;const n="modifier"===e.schema.zoomScroll&&e.schema.zoomPan;t.style("touch-action",n?pc(e)?"none":"pan-x pan-y":null)}function xc(e=!1,t=0){this._zoomGroup&&(t?this._zoomGroup.transition().duration(t).attr("transform",e):this._zoomGroup.attr("transform",e));const n=e;if(n&&"object"==typeof n&&"k"in n){const e={k:n.k??1,x:n.x??0,y:n.y??0};!function(e,t){rc.set(e,{k:t.k,x:t.x,y:t.y})}(this,e),this._zoomRescale&&this._zoomRescale(e,t)?this._zoomTransform=void 0:this._zoomTransform={x:e.x,y:e.y,scale:e.k}}else!1===n&&(this._zoomTransform=void 0,sc(this));!function(e){const t=Zs(e);if(!t||!e._featurePanels)return;const n=e._featurePanels.filter(e=>"viz-bottomRight"!==e.key),i=ac(e,t);e._featurePanels=i?[...n,i]:n}(this),this._drawSceneToTarget&&this._sceneRenderer&&this._drawSceneToTarget(t),yc(this),this._renderTiles&&this._renderTiles(fc(this),t)}function bc(e=0){if(!this._container)return;const[[t,n],[i,o]]=this._zoomBehavior.extent().bind(document)(),a=(t+i)/2,r=(n+o)/2,s=b.zoomTransform((this._zoomEventTarget||this._container).node());if(!e)return _c(this,1,0,0);const c=s.k*e;_c(this,c,a-(a-s.x)/s.k*c,r-(r-s.y)/s.k*c)}function _c(e,t,n,i,o=e.schema.duration){const[a,r]=e._zoomBehavior.scaleExtent(),[[s,c],[l,h]]=e._zoomBehavior.translateExtent(),u=Math.max(a,Math.min(r,t)),d=Math.max(l*(1-u),Math.min(s*(1-u),n)),f=Math.max(h*(1-u),Math.min(c*(1-u),i)),m=b.zoomIdentity.translate(d,f).scale(u);(e._zoomEventTarget||e._container).property("__zoom",m),xc.bind(e)(m,o)}function kc(e,t=this.schema.duration){if(!e)return _c(this,1,0,0,t);const[[n,i],[o,a]]=this._zoomBehavior.translateExtent(),r=this.schema.zoomPadding,s=b.zoomTransform((this._zoomEventTarget||this._container).node()),c=(e[0][0]-s.x)/s.k,l=(e[0][1]-s.y)/s.k,h=(e[1][0]-s.x)/s.k,u=(e[1][1]-s.y)/s.k,d=Math.min((o-n-2*r)/(h-c),(a-i-2*r)/(u-l));_c(this,d,(n+o)/2-d*(c+h)/2,(i+a)/2-d*(l+u)/2,t)}function vc(){Cc.bind(this)()}function wc(e){if(!e.selection)return;this._brushGroup.call(this._zoomBrush.move,null),mc.bind(this)(!1),function(e){const t=qs(e)?.querySelector(".d3plus-zoom-control .zoom-brush");if(!t)return;const n=Ps(e);t.classList.toggle("active",n),t.setAttribute("aria-pressed",String(n)),Es(e,t,t.matches(":hover"))}(this);const{left:t,top:n}=this._margin;kc.bind(this)(e.selection.map(([e,i])=>[e+t,i+n]))}function Sc(){Cc.bind(this)()}function Cc(){this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.zoomBrushHandleStyle||{})}function Mc(e,t){const n=e._facetPanels;if(!n||!n.length||!t)return;const i=e._zoomTransform,o=i&&i.scale?i.scale:1,a=(t[0]-(i?.x??0))/o,r=(t[1]-(i?.y??0))/o;return n.find(e=>{const t=e.cell;return a>=t.x&&a<=t.x+t.width&&r>=t.y&&r<=t.y+t.height})}function $c(e,t,n){if(!t)return n();const i=e,o=function(e){return{_chartScene:e.scene,_chartTransform:e.chartTransform,...e.state}}(t),a={};for(const e of Object.keys(o))a[e]=i[e],i[e]=o[e];try{return n()}finally{for(const e of Object.keys(o))i[e]===o[e]&&(i[e]=a[e])}}function Ac(e,t){const n=e;for(const e of t)for(const t of Object.keys(e.state))n[t]=void 0}function zc(e){const t=Boolean(e.schema.backControlClassName);return Ds(e.schema.backControlStyle,es,t)}const Dc=`<svg ${Ns}><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>`;function Fc(e){const t=e.schema.backControlClassName?` ${e.schema.backControlClassName}`:"",n=e.schema.translate("Back");return`<button type="button" class="back-control${t}">${Dc}${n}</button>`}function Bc(e){return function(e){return Boolean(e._history&&e._history.length)&&!e._ssr}(e)?{key:"back",html:Fc(e),styleSignature:JSON.stringify(zc(e)),events:{".back-control":{click:()=>function(e){const t=e._history.pop();t?(void 0!==t.groupId&&void 0!==t.groupDepth&&(e._pendingExitReunion={groupId:t.groupId,groupDepth:t.groupDepth,body:e._bodyRect}),e.config({depth:t.depth,filter:t.filter}).render()):e.depth(e._drawDepth-1).filter(!1).render()}(e)}},onUpdate:t=>{const n=t.querySelector(".back-control");n&&!n.dataset.backBound&&(n.dataset.backBound="1",function(e,t){Fs(t,{base:zc(e)},!1,!1)}(e,n))}}:null}function Lc(e){return Boolean(e._tableView)}function Pc(e){return e._tableViewPage||0}function Rc(e,t){e._tableViewPage=t}function Ec(e){return e._tableViewSort}function Nc(e){return"raw"===e._tableViewDataSource?"raw":"aggregate"}function Tc(e){const t=e._data,n=e._filteredData||t;return!(!t||!n||t===n)&&t.length!==n.length}function Oc(e){return Bs(e.schema,"tableViewControl",{base:hs,active:us,hover:ds})}function Wc(e,t,n=!1){Fs(t,Oc(e),n,t.classList.contains("active"))}function jc(e){return JSON.stringify(Oc(e))}const Hc='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Ic=`<svg ${Hc}><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="12" y1="3" x2="12" y2="21"/></svg>`,Gc=`<svg ${Hc}><path d="M12 3v12"/><polyline points="7 11 12 16 17 11"/><path d="M4 18v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"/></svg>`,Vc=`<svg ${Hc}><polyline points="14 4 19 9 14 14"/><line x1="4" y1="9" x2="19" y2="9"/><polyline points="10 20 5 15 10 10"/><line x1="20" y1="15" x2="5" y2="15"/></svg>`,qc='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;vertical-align:middle;margin-left:4px;flex-shrink:0"',Yc=`<svg ${qc}><polyline points="6 15 12 9 18 15"/></svg>`,Kc=`<svg ${qc}><polyline points="6 9 12 15 18 9"/></svg>`;function Uc(e){const t=Lc(e);return`<button type="button" class="table-view-control table-view-toggle${t?" active":""}${e.schema.tableViewControlClassName?` ${e.schema.tableViewControlClassName}`:""}" aria-label="${e.schema.translate(t?"Show Chart":"Show Data Table")}" aria-pressed="${t}">${Ic}</button>`}function Xc(e){const t=function(e){return null==e?"":e instanceof Date?e.toISOString():String(e)}(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Qc(e,t,n){const i=e.schema.groupBy;return i&&i.length?i.map(e=>String(e(t,n))).join("\0"):""}function Zc(e,t){const n=e._data;if(!n||!n.length)return t;const{exact:i,group:o}=function(e){const t=e._data||[],n=e._tableViewGroupOrder;if(n&&n.data===t)return n;const i=new Map,o=new Map;t.forEach((t,n)=>{const a=JSON.stringify(t);i.has(a)||i.set(a,n);const r=Qc(e,t,n);o.has(r)||o.set(r,n)});const a={data:t,exact:i,group:o};return e._tableViewGroupOrder=a,a}(e);return t.map((t,n)=>({row:t,order:i.get(JSON.stringify(t))??o.get(Qc(e,t,n))??Number.MAX_SAFE_INTEGER})).sort((e,t)=>e.order-t.order).map(e=>e.row)}function Jc(e){const t="raw"===Nc(e)&&Tc(e);let n=((t?e._data:e._filteredData||e._data)||[]).slice();const i=function(e){const t=[],n=new Set;for(const i of e)for(const e of Object.keys(i))n.has(e)||Ar(e)||(n.add(e),t.push(e));return t}(n),o=Ec(e);if(o&&i.includes(o.column)){const t="desc"===o.direction?-1:1,{column:i}=o;n.sort((n,o)=>t*function(e,t,n){const i=null==e,o=null==t;return i||o?i&&o?0:i?1:-1:"number"==typeof e&&"number"==typeof t?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t),n,{numeric:!0})}(n[i],o[i],e.schema.locale))}else t||(n=Zc(e,n));return{rows:n,columns:i}}function el(e,t){const n=t.length,i=e.schema.tableViewPageSize,o="number"==typeof i&&i>0?i:n||1,a=Math.max(1,Math.ceil(n/o)),r=Math.min(Math.max(0,Pc(e)),a-1);Rc(e,r);const s=r*o,c=Math.min(s+o,n);return{slice:t.slice(s,c),page:r,totalPages:a,start:s,end:c,total:n}}function tl(e,t,n){return t.map(t=>`<td style="padding:6px 10px;border-bottom:1px solid #e0e0e0;"><div class="d3plus-table-view-cell" style="max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${Ls(function(e,t){return null==e?"":e instanceof Date?e.toLocaleDateString(t):"number"==typeof e?e.toLocaleString(t):String(e)}(n[t],e.schema.locale))}</div></td>`).join("")}function nl(e,t){return e?`<tr aria-hidden="true" style="height:${e}px;padding:0;border:0;"><td style="padding:0;border:0;" colspan="${t}"></td></tr>`:""}function il(e,t,n,i,o,a){const r=Math.max(t.length,1);return nl(30*i,r)+n.slice(i,o).map(n=>function(e,t,n){return`<tr style="height:30px;">${tl(e,t,n)}</tr>`}(e,t,n)).join("")+nl(30*(a-o),r)}function ol(e){const t=Ec(e),{rows:n,columns:i}=Jc(e),{slice:o,page:r,totalPages:s,start:c,end:l,total:h}=el(e,n),u=o.length,d=u>300,f=h?il(e,i,o,0,d?Math.min(u,60):u,u):`<tr><td style="padding:12px;color:#767676;" colspan="${Math.max(i.length,1)}">${e.schema.translate("No Data Available")}</td></tr>`,m=i.map(n=>function(e,t,n){const i=Ls(t);if(!function(e){return!1!==e.schema.tableViewSort}(e))return`<th style="position:sticky;top:0;background:#fff;text-align:left;padding:6px 10px;border-bottom:2px solid #ccc;white-space:nowrap;">${i}</th>`;const o=n?.column===t,a=o?"desc"===n.direction?"descending":"ascending":"none",r=o?"desc"===n.direction?Kc:Yc:"";return`<th class="tableview-sort-header" data-column="${Ls(t)}" role="button" tabindex="0" aria-sort="${a}" style="position:sticky;top:0;background:#fff;text-align:left;padding:6px 10px;border-bottom:2px solid #ccc;white-space:nowrap;cursor:pointer;user-select:none;">${i}${r}</th>`}(e,n,t)).join(""),p=s>1?`<div class="d3plus-table-view-pagination" style="display:flex;align-items:center;gap:8px;padding:6px 10px;border-top:1px solid #e0e0e0;font-size:12px;flex:0 0 auto;">\n <button type="button" class="tableview-page-prev"${r<=0?" disabled":""}>‹ ${e.schema.translate("Previous")}</button>\n <span>${h?c+1:0}–${l} / ${h}</span>\n <button type="button" class="tableview-page-next"${r>=s-1?" disabled":""}>${e.schema.translate("Next")} ›</button>\n </div>`:"",g=e.schema.tableViewClassName?` ${e.schema.tableViewClassName}`:"",y=Uc(e)+(function(e){return!1!==e.schema.tableViewDownload}(e)?function(e){const t=e.schema.translate("Download");return`<button type="button" class="table-view-control tableview-download-csv" aria-label="${t}" title="${t} CSV">${Gc}</button>`}(e):"")+(Tc(e)?function(e){const t="raw"===Nc(e),n=e.schema.tableViewControlClassName?` ${e.schema.tableViewControlClassName}`:"",i=e.schema.translate(t?"Show Aggregate Data":"Show Raw Data");return`<button type="button" class="table-view-control tableview-source-toggle${t?" active":""}${n}" aria-label="${i}" title="${i}" aria-pressed="${t}">${Vc}</button>`}(e):""),x=d?"table-layout:fixed;":"";return`\n <div class="d3plus-table-view-frame" style="display:flex;flex-direction:column;width:100%;height:100%;box-sizing:border-box;background:#fff;font:12px/1.4 ${a.fontFamilyStringify(e.schema.fontFamily||"sans-serif")};">\n <div class="d3plus-table-view-toolbar" style="flex:0 0 auto;display:flex;gap:4px;padding:4px;">${y}</div>\n <div class="d3plus-table-view-scroll"${d?' data-tableview-virtual="1"':""} style="flex:1 1 auto;min-height:0;overflow:auto;">\n <table class="d3plus-table-view-table${g}" style="border-collapse:collapse;width:100%;${x}">\n <thead><tr>${m}</tr></thead>\n <tbody>${f}</tbody>\n </table>\n </div>\n ${p}\n </div>`}function al(e){const{rows:t,columns:n}=Jc(e),i=function(e,t){const n=[e.map(Xc).join(",")];for(const i of t)n.push(e.map(e=>Xc(i[e])).join(","));return n.join("\r\n")}(n,t),o=new Blob([i],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(o),r=document.createElement("a");r.href=a,r.download="table-view.csv",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)}function rl(e,t){e.querySelectorAll(".table-view-control").forEach(e=>{e.dataset.tableViewBound||(e.dataset.tableViewBound="1",Wc(t,e),e.addEventListener("mouseenter",()=>Wc(t,e,!0)),e.addEventListener("mouseleave",()=>Wc(t,e)))})}function sl(e,t){const n=e.querySelector(".d3plus-table-view-scroll[data-tableview-virtual]");if(!n||n.dataset.tableviewVirtualBound)return;const i=n.querySelector("tbody");if(!i)return;n.dataset.tableviewVirtualBound="1";const{rows:o,columns:a}=Jc(t),{slice:r}=el(t,o);let s=0;const c=()=>{s=0,function(e,t,n,i,o){const a=i.length,r=Math.max(1,Math.ceil(t.clientHeight/30)),s=Math.max(0,Math.floor(t.scrollTop/30)-10),c=Math.min(a,s+r+20);n.innerHTML=il(e,o,i,s,c,a)}(t,n,i,r,a)};n.addEventListener("scroll",()=>{s||(s=requestAnimationFrame(c))},{passive:!0}),c()}const cl="viz-table-view-overlay";function ll(e){const t=e.target.closest(".tableview-sort-header");return t?.dataset.column}function hl(e){return{type:"htmlOverlay",key:cl,x:0,y:0,width:e.schema.width,height:e.schema.height,className:"d3plus-table-view",html:ol(e),events:{".table-view-toggle":{click:()=>dl(e)},".tableview-page-prev":{click:()=>fl(e,-1)},".tableview-page-next":{click:()=>fl(e,1)},".tableview-download-csv":{click:()=>al(e)},".tableview-source-toggle":{click:()=>function(e){(function(e,t){e._tableViewDataSource=t})(e,"raw"===Nc(e)?"aggregate":"raw"),Rc(e,0),ul(e)}(e)},".tableview-sort-header":{click:t=>{const n=ll(t);n&&ml(e,n)},keydown:t=>{const n=t.key;if("Enter"!==n&&" "!==n)return;const i=ll(t);i&&(t.preventDefault(),ml(e,i))}}},onUpdate:t=>function(e,t){rl(e,t),sl(e,t)}(t,e)}}function ul(e){const t=(e._featurePanels||[]).slice(),n=t.findIndex(e=>e.key===cl);if(Lc(e)){const i=hl(e);n>=0?t[n]=i:t.push(i)}else n>=0&&t.splice(n,1);e._featurePanels=t,function(e){const t=qs(e)?.querySelector(".d3plus-top-left-controls-item .table-view-toggle");if(!t)return;const n=Lc(e);t.classList.toggle("active",n),t.setAttribute("aria-pressed",String(n)),Wc(e,t,t.matches(":hover"))}(e),e._drawSceneToTarget&&e._sceneRenderer&&e._drawSceneToTarget(0)}function dl(e){!function(e,t){e._tableView=t}(e,!Lc(e)),Rc(e,0),ul(e)}function fl(e,t){Rc(e,Math.max(0,Pc(e)+t)),ul(e)}function ml(e,t){const n=Ec(e);!function(e,t){e._tableViewSort=t}(e,{column:t,direction:n?.column===t&&"asc"===n.direction?"desc":"asc"}),Rc(e,0),ul(e)}const pl={name:"tableView",layout:({viz:e})=>Lc(e)?{panel:hl(e),margin:{}}:{panel:null,margin:{}}};function gl(e){return function(e){return Boolean(e.schema.tableView)&&!e._ssr}(e)?{key:"table-view",html:Uc(e),styleSignature:jc(e),events:{".table-view-toggle":{click:()=>dl(e)}},onUpdate:t=>rl(t,e)}:null}const yl=["png","svg","jpg"];function xl(e){if(!Array.isArray(e))return yl.slice();const t=[];for(const n of e){const e=String(n).toLowerCase().replace("jpeg","jpg");yl.includes(e)&&!t.includes(e)&&t.push(e)}return t}function bl(e){return("string"==typeof e||"number"==typeof e?String(e).replace(/<[^>]*>/g,"").replace(/[\\/:*?"<>|\p{Cc}]/gu,"").replace(/\s+/g," ").trim().slice(0,100).trim():"")||"download"}function _l(e){return Ia({_select:e._select})}function kl(e){const t=e.schema.title;return"function"==typeof t?t(e._filteredData||[]):void 0}function vl(e){const{filename:t,formats:n,background:i,callback:o,...a}=e.schema.saveControlConfig||{};return{filename:"string"==typeof t&&t.trim()?bl(t):bl(kl(e)),formats:xl(n),background:!1!==i&&("string"==typeof i&&i?i:_l(e)),callback:"function"==typeof o?o:void 0,renderOptions:a}}function wl(e){const t="canvas"===e._renderer?e.toCanvas():e._select?.node?.(),n="canvas"===e._renderer?"canvas":"svg";return t?.localName===n?t:null}const Sl=["position","top","left","content-visibility","touch-action"];function Cl(e,t){let n=null;if("canvas"===e._renderer){const t=e.toSVGString();if(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml");n=e.querySelector("parsererror")?null:e.documentElement}}else{const t=wl(e);n=t?t.cloneNode(!0):null,n&&function(e){e.removeAttribute("aria-hidden");for(const t of Sl)e.style?.removeProperty(t)}(n)}if(!n||"svg"!==n.localName)return null;if(t){const e=n.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("class","d3plus-save-background"),e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("fill",t),n.insertBefore(e,n.firstChild)}return n}function Ml(e){const t=e.pixelRatio;return"number"==typeof t&&t>0?t:"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1}function $l(e,t){const n=e.getBoundingClientRect().width;return n>0&&e.width/n<t-.01}function Al(e,t){const{filename:n,background:i,callback:o,renderOptions:a}=vl(e),r=e=>{o?o(e):e&&console.error(e)},s=()=>r(new Error("The chart has not been rendered, so it cannot be saved."));if("svg"===t){const t=Cl(e,i);return t?void _.saveElement(t,{filename:n,type:"svg",callback:r}):s()}const c=wl(e);if(!c)return s();const l={...a,backgroundColor:i||("jpg"===t?_l(e):void 0)},h={filename:n,type:t};"canvas"===e._renderer&&$l(c,Ml(l))&&function(e,t,n,i,o){const a=i.backgroundColor,r=Cl(e,"string"==typeof a&&a),s=t.ownerDocument;if(!r||!s.body)return!1;const c=s.createElement("div");c.setAttribute("aria-hidden","true"),c.style.cssText="position:fixed;left:-100000px;top:0;";const l=s.importNode(r,!0);return c.appendChild(l),s.body.appendChild(c),_.saveElement(l,{...n,callback:e=>{c.remove(),o(e)}},i),!0}(e,c,h,l,r)||_.saveElement(c,{...h,callback:r},l)}const zl={png:"PNG image",svg:"SVG vector",jpg:"JPG image"};function Dl(e){return xl(e.schema.saveControlConfig?.formats)}function Fl(e){return Bs(e.schema,"saveControl",{base:_s,active:ks,hover:vs})}function Bl(e,t,n=!1){Fs(t,Fl(e),n,t.classList.contains("active"))}const Ll={position:"relative",display:"inline-flex","align-items":"center"},Pl={position:"absolute",top:"100%",left:"0","z-index":"1",display:"none","flex-direction":"column","min-width":"max-content"},Rl={display:"flex"},El={display:"block",width:"100%","text-align":"start","white-space":"nowrap",cursor:"pointer"};function Nl(e){const t=Boolean(e.schema.saveControlMenuClassName),n=(n,i)=>Ds(e.schema[n],i,t);return{menu:n("saveControlMenuStyle",ws),item:n("saveControlMenuItemStyle",Ss),itemHover:n("saveControlMenuItemStyleHover",Cs)}}function Tl(...e){return e.flatMap(e=>Object.entries(e)).filter(([,e])=>null!=e&&!1!==e).map(([e,t])=>`${$s(e)}:${Ls(t)}`).join(";")}function Ol(e){const t=Dl(e),n=t=>e.schema.translate(t),i=n("Download"),o=e.schema.saveControlClassName?` ${Ls(e.schema.saveControlClassName)}`:"",a=(e,t)=>`<button type="button" class="save-control save-toggle${o}" aria-label="${Ls(e)}" title="${Ls(e)}"${t}>${Gc}</button>`;if(1===t.length){const e=`${i} (${n(zl[t[0]])})`;return`<span class="save-root" style="${Tl(Ll)}">${a(e,` data-format="${t[0]}"`)}</span>`}const r=Nl(e),s=Tl(r.item,El),c=e.schema.saveControlMenuClassName?` ${Ls(e.schema.saveControlMenuClassName)}`:"",l=t.map(e=>`<button type="button" role="menuitem" tabindex="-1" class="save-menu-item" data-format="${e}" style="${s}">${Ls(n(zl[e]))}</button>`).join("");return`<span class="save-root" style="${Tl(Ll)}">`+a(i,' aria-haspopup="menu" aria-expanded="false"')+`<span class="d3plus-save-menu${c}" role="menu" aria-label="${Ls(i)}" style="${Tl(r.menu,Pl)}">${l}</span></span>`}const Wl=new WeakMap;function jl(e){return e instanceof Element?e.closest(".save-root"):null}function Hl(e){return e.querySelector(".save-toggle")}function Il(e){return Array.from(e.querySelectorAll(".save-menu-item"))}function Gl(e){return"true"===Hl(e)?.getAttribute("aria-expanded")}function Vl(e,t,n){const i=Hl(t),o=t.querySelector(".d3plus-save-menu");if(!i||!o)return;i.setAttribute("aria-expanded",String(n)),i.classList.toggle("active",n),Bl(e,i,i.matches(":hover"));const a=n?Rl:Pl;o.style.setProperty("display",String(a.display))}function ql(e,t,n=!1){Wl.get(t)?.(),Wl.delete(t),Vl(e,t,!1),n&&Hl(t)?.focus()}function Yl(e,t,n="first"){Vl(e,t,!0);const i=t.ownerDocument,o=n=>{t.isConnected&&t.contains(n.target)||ql(e,t)};Wl.get(t)?.(),i.addEventListener("pointerdown",o,!0),Wl.set(t,()=>i.removeEventListener("pointerdown",o,!0));const a=Il(t);a["last"===n?a.length-1:0]?.focus()}function Kl(e,t,n){const i=t.target.closest(".save-menu-item");i&&function(e,t,n){const{item:i,itemHover:o}=Nl(e);Fs(t,{base:{...i,...El},hover:o},n,!1)}(e,i,n)}function Ul(e){return function(e){return Boolean(e.schema.saveControl)&&!e._ssr&&Dl(e).length>0}(e)?{key:"save",html:Ol(e),styleSignature:JSON.stringify(Fl(e)),events:{".save-toggle":{click:t=>function(e,t){const n=jl(t.target),i=n&&Hl(n);if(!n||!i)return;const o=i.dataset.format;o?Al(e,o):Gl(n)?ql(e,n,!0):Yl(e,n)}(e,t),keydown:t=>function(e,t){const n=t.key,i=jl(t.target);i&&i.querySelector(".d3plus-save-menu")&&("ArrowDown"===n||"ArrowUp"===n?(t.preventDefault(),Yl(e,i,"ArrowUp"===n?"last":"first")):"Escape"===n&&Gl(i)&&(t.stopPropagation(),ql(e,i,!0)))}(e,t)},".d3plus-save-menu":{keydown:t=>function(e,t){const n=t.key,i=jl(t.target);if(!i)return;const o=Il(i),a=o.indexOf(t.target),r=e=>{t.preventDefault(),o[(e+o.length)%o.length]?.focus()};"ArrowDown"===n?r(a+1):"ArrowUp"===n?r(a-1):"Home"===n?r(0):"End"===n?r(o.length-1):"Escape"===n?(t.preventDefault(),t.stopPropagation(),ql(e,i,!0)):"Tab"===n&&ql(e,i)}(e,t)},".save-menu-item":{click:t=>function(e,t){const n=jl(t.target),i=t.target.closest(".save-menu-item");n&&i&&(ql(e,n,!0),Al(e,i.dataset.format))}(e,t),mouseover:e=>function(e){e.target.closest(".save-menu-item")?.focus()}(e),focusin:t=>Kl(e,t,!0),focusout:t=>Kl(e,t,!1)},".save-root":{focusout:t=>function(e,t){const n=jl(t.target),i=t.relatedTarget;n&&i&&!n.contains(i)&&Gl(n)&&ql(e,n)}(e,t)}},onUpdate:t=>{const n=t.querySelector(".save-toggle");n&&!n.dataset.saveBound&&(n.dataset.saveBound="1",Bl(e,n),n.addEventListener("mouseenter",()=>Bl(e,n,!0)),n.addEventListener("mouseleave",()=>Bl(e,n)))}}:null}function Xl(e){return Boolean(e._searchOpen)}function Ql(e){return Bs(e.schema,"searchControl",{base:ys,active:xs,hover:bs})}function Zl(e,t,n=!1){Fs(t,Ql(e),n,t.classList.contains("active"))}const Jl=`<svg ${Ns}><circle cx="10" cy="9" r="7"/><line x1="21" y1="20" x2="15" y2="14"/></svg>`,eh=`<svg ${Ns}><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>`,th={width:"0",padding:"0",border:"none",opacity:"0","pointer-events":"none"},nh={width:"120px",padding:"0 22px 0 6px",border:"1px solid #ccc","border-radius":"3px",opacity:"1","pointer-events":"auto"},ih={height:"20px","box-sizing":"border-box",margin:"0",font:`12px/1 ${a.fontFamilyStringify(a.fontFamily)}`,transition:"width 0.15s ease, opacity 0.15s ease"},oh={position:"relative",display:"inline-block"},ah={display:"inline-flex","align-items":"center"},rh={position:"absolute",top:"50%",right:"2px",transform:"translateY(-50%)",display:"inline-flex","align-items":"center","justify-content":"center",visibility:"visible",width:"16px",height:"16px",margin:"0",padding:"0",border:"none",background:"none",cursor:"pointer"},sh={...rh,visibility:"hidden",cursor:"default"},ch={position:"absolute",top:"100%",left:"0","margin-top":"4px",width:"100%","box-sizing":"border-box",display:"block",visibility:"visible",background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)","font-size":"11px","text-align":"center",padding:"2px 4px","white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis","pointer-events":"none"},lh={...ch,visibility:"hidden"};function hh(e){return Object.entries(e).map(([e,t])=>`${$s(e)}:${t}`).join(";")}function uh(e,t){const n=t?nh:th;for(const t in n)e.style.setProperty($s(t),n[t])}function dh(e){const t=e.schema.searchControlClassName?` ${e.schema.searchControlClassName}`:"",n=e.schema.translate("Search"),i=Xl(e),o=e._searchTerm||"",a=o.trim().length>0,r=hh({...ih,...i?nh:th}),s=hh(a?rh:sh),c=hh(oh);return`<span class="search-root" style="${hh(ah)}"><button type="button" class="search-control search-toggle${i?" active":""}${t}" aria-label="${n}" aria-pressed="${i}">${Jl}</button><span class="search-input-wrap" style="${c}"><input type="text" class="search-control search-input" placeholder="${n}" aria-label="${n}" value="${Ls(o)}" style="${r}"${i?"":' tabindex="-1"'}/><button type="button" class="search-control search-clear" aria-label="${e.schema.translate("Clear")}" style="${s}"${a?"":' tabindex="-1"'}>${eh}</button><span class="search-count" aria-live="polite"></span></span></span>`}function fh(e,t,n,i){const o=e.schema.searchAccessor(t,n);if("string"==typeof o&&o.toLowerCase().includes(i))return!0;return e._ids(t,n).some(e=>"string"==typeof e&&e.toLowerCase().includes(i))}function mh(e,t){const n=t.trim().toLowerCase();if(!n)return[];const i=[];return Ze(e._chartScene||[],(t,o,a)=>{fh(e,t,o,n)&&i.push({node:a,row:t,index:o})}),i}function ph(e,t){const n=dh(e),o=function(e){const t=e._featurePanels??[];for(const e of t){if("viz-top-left-controls"!==e?.key||!e.children)continue;const t=e.children.find(e=>"viz-top-left-controls-search"===e.key);if(t)return t}return null}(e);o&&(o.html=n),i.markOverlayHtmlSynced(t,n)}function gh(e,t){const n=t.querySelector(".search-count");if(!n)return;const i=e._searchTerm||"",o=i.trim().length>0,a=o?mh(e,i).length:0;"number"==typeof e._searchMatchIndex&&e._searchMatchIndex>=a&&(e._searchMatchIndex=void 0),function(e,t,n,i,o){const a=n?ch:lh;for(const e in a)t.style.setProperty($s(e),a[e]);const{text:r,label:s}=function(e,t,n){let i;return i=0===n?e.schema.translate("No Matches"):"number"!=typeof t?`${n} ${e.schema.translate(1===n?"Match":"Matches")}`:`${e.schema.translate("Match")} ${t+1}/${n}`,{text:i,label:i}}(e,i,o);t.textContent=n?r:"",t.setAttribute("aria-label",s)}(e,n,o,e._searchMatchIndex,a)}function yh(e,t,n){const i=n.trim().length>0;e._searchMatchIndex=void 0;const o=t.querySelector(".search-clear");o&&function(e,t){const n=t?rh:sh;for(const t in n)e.style.setProperty($s(t),n[t]);e.tabIndex=t?0:-1}(o,i),gh(e,t)}function xh(e,t){e._searchOpen=!1,e._searchTerm="",e.highlight(e._searchPrevHighlight??!1),e._searchPrevHighlight=void 0,ph(e,t),yh(e,t,"");const n=t.querySelector(".search-toggle");n&&(n.classList.remove("active"),n.setAttribute("aria-pressed","false"),Zl(e,n,n.matches(":hover")));const i=t.querySelector(".search-input");i&&(i.value="",i.setAttribute("tabindex","-1"),uh(i,!1))}function bh(e,t){const n=t.currentTarget;Xl(e)?xh(e,n):function(e,t){e._searchOpen=!0,e._searchPrevHighlight=e._highlight,ph(e,t);const n=t.querySelector(".search-toggle");n&&(n.classList.add("active"),n.setAttribute("aria-pressed","true"),Zl(e,n,n.matches(":hover")));const i=t.querySelector(".search-input");i&&(i.removeAttribute("tabindex"),uh(i,!0),i.focus())}(e,n)}function _h(e,t,n){e._searchTerm=n,e.highlight(function(e,t){const n=t.trim().toLowerCase();return n?(t,i)=>fh(e,t,i,n):e._searchPrevHighlight??!1}(e,n)),ph(e,t),yh(e,t,n)}function kh(e,t,n){if("canvas"===e._renderer||"function"!=typeof e._zoomToBounds)return;const i=t.parentElement?.parentElement,o=i?.querySelector("svg");if(!i||!o)return;const a=function(e,t){const n=e.querySelectorAll("[data-key]");for(const e of n)if(e.getAttribute("data-key")===String(t))return e;return null}(i,n);if(!a)return;const r=a.getBoundingClientRect(),s=o.getBoundingClientRect();(r.width||r.height)&&e._zoomToBounds([[r.left-s.left,r.top-s.top],[r.right-s.left,r.bottom-s.top]],e.schema.duration)}function vh(e,t){const n=t,i=t.currentTarget;"Escape"===n.key?xh(e,i):"Enter"===n.key&&(n.preventDefault(),function(e,t,n){const i=e._searchTerm||"";if(!i.trim())return;const o=mh(e,i);if(!o.length)return;const a=o.length,r=e._searchMatchIndex,s=(("number"==typeof r?r:1===n?-1:0)+n+a)%a;e._searchMatchIndex=s,gh(e,t),kh(e,t,o[s].node.key)}(e,i,n.shiftKey?-1:1))}function wh(e){return function(e){return Boolean(e.schema.search)&&!e._ssr}(e)?{key:"search",html:dh(e),styleSignature:JSON.stringify(Ql(e)),events:{".search-toggle":{click:t=>bh(e,t)},".search-clear":{click:t=>function(e,t){const n=t.currentTarget,i=n.querySelector(".search-input");i&&(i.value=""),_h(e,n,""),i?.focus()}(e,t)},".search-input":{input:t=>function(e,t){const n=t.target;_h(e,t.currentTarget,n.value)}(e,t),keydown:t=>vh(e,t)}},onUpdate:t=>{gh(e,t);const n=t.querySelector(".search-toggle");n&&!n.dataset.searchBound&&(n.dataset.searchBound="1",Zl(e,n),n.addEventListener("mouseenter",()=>Zl(e,n,!0)),n.addEventListener("mouseleave",()=>Zl(e,n)));const i=t.querySelector(".search-input");i&&!i.dataset.searchBlurBound&&(i.dataset.searchBlurBound="1",i.addEventListener("blur",n=>function(e,t,n){if((e._searchTerm||"").trim().length>0)return;const i=n.relatedTarget;i&&t.contains(i)||xh(e,t)}(e,t,n)))}}:null}function Sh(e,t){if(!t.length)return null;const n=t.map(e=>`${e.key}:${e.html}|${e.styleSignature??""}`).join("||"),i=e._topLeftControlsBox;if(i&&i.signature===n)return i.measurement;const o=function(e,t){const n=qs(e);if(!n){let e=0;return{items:t.map(t=>{const n={...t,x:e};return e+=32,n}),width:Math.max(0,e-4),height:20}}const i=document.createElement("div");i.className="d3plus-top-left-controls",i.style.setProperty("display","inline-flex"),i.style.setProperty("align-items","center"),i.style.setProperty("gap","4px"),i.style.setProperty("position","absolute"),i.style.setProperty("visibility","hidden"),i.style.setProperty("pointer-events","none"),i.innerHTML=t.map(e=>`<span class="tlc-item" data-tlc-key="${e.key}" style="display:inline-flex;align-items:center;">${e.html}</span>`).join("");for(const e of t)e.onUpdate?.(i);n.appendChild(i);const o=i.getBoundingClientRect(),a=Array.from(i.querySelectorAll(":scope > .tlc-item")),r=t.map((e,t)=>{const n=a[t]?.getBoundingClientRect();return{...e,x:n?Math.round(n.left-o.left):0}});return n.removeChild(i),{items:r,width:o.width?Math.ceil(o.width):0,height:o.height?Math.ceil(o.height):0}}(e,t);return e._topLeftControlsBox={width:o.width,height:o.height,signature:n,measurement:o},o}function Ch(e,t){const n=Sh(e,t);return n?{type:"group",key:"viz-top-left-controls",children:n.items.map(e=>({type:"htmlOverlay",key:`viz-top-left-controls-${e.key}`,x:4+e.x,y:4,className:"d3plus-top-left-controls-item",html:e.html,events:e.events,onUpdate:e.onUpdate}))}:null}function Mh(e,t){const n=Sh(e,t);return n?{width:n.width?n.width+4:0,height:n.height?n.height+4:0}:null}function $h(e,t){const n=Mh(e,t);return n&&n.height?n.height+4:0}const Ah=[Bc,gl,Ul,wh];function zh(e){const t=[];for(const n of Ah){const i=n(e);i&&t.push(i)}return t}const Dh={name:"topLeftControls",layout:({viz:e})=>{const t=zh(e);return t.length?{panel:Ch(e,t),margin:{}}:{panel:null,margin:{}}}};function Fh(e){const t="function"==typeof e.config?e.config():{};return Object.freeze(t)}function Bh(e){const t=e._legendData||[],n=(t,n,i)=>{const o=e.schema.shape(t,n);"fill"===i&&"Line"===o&&(i="stroke");const a=e.schema.shapeConfig[o]&&e.schema.shapeConfig[o][i]?e.schema.shapeConfig[o][i]:e.schema.shapeConfig[i];return"function"==typeof a?a.bind(e)(t,n):a},i=(t,n)=>"function"==typeof e.schema.color?e.schema.color(t,n):void 0,a=(e,t,i)=>[null==i?n(e,t,"fill"):"string"==typeof i?i:JSON.stringify(i),n(e,t,"opacity"),n(e,t,"texture")].join("_"),r=e.schema.colorScale?t.filter((t,n)=>void 0===e.schema.colorScale(t,n)):t,s=new Map;r.forEach((e,t)=>{const n=i(e,t),o=a(e,t,n),r=s.get(o);r?r.leaves.push(e):s.set(o,{leaves:[e],color:n})});const c=Array.from(s.values(),({leaves:t,color:n})=>({datum:o.merge(t,e.schema.aggs),color:n})),l=c.map(e=>e.datum),h=l.map((t,n)=>e._ids(t,n).slice(0,e._drawDepth+1));e._legendDepth=0;for(let t=0;t<=e._drawDepth;t++){const n=h.map(e=>e[t]);if(!n.some(e=>Array.isArray(e))&&Array.from(new Set(n)).length===l.length){e._legendDepth=t;break}}e._legendCategories=function(e,t){const n=e.schema.groupBy?.[e._legendDepth??0];return"function"==typeof n&&t.some((t,i)=>{const o=n.bind(e)(t,i);return Array.isArray(o)&&o.length>1})}(e,l)?function(e){const t=new WeakMap,n=new Set;for(const{datum:i,color:o}of e){const e=lr(o);if(void 0===e||n.has(e))return;n.add(e),t.set(i,e)}return t}(c):void 0;const u=e=>e._isAggregation?1:0;return l.sort((t,n)=>u(t)-u(n)||e.schema.legendSort(t,n)),{legendData:l,legendKey:(e,t)=>a(e,t,i(e,t)),getAttr:n}}function Lh(e,t,i){const{legendData:o,legendKey:a,getAttr:r}=t,s=(t,n)=>{let i=e._id(t,n);return Array.isArray(i)&&(i=i[0]),e._hidden.includes(i)||e._solo.length>0&&!e._solo.includes(i)},c={transform:`translate(${i.x}, ${i.y})`},l=n.elem("g.d3plus-viz-legend",{condition:i.visible&&!e.schema.legendConfig.select,enter:c,parent:e._select,duration:0,update:c}).node();e._legendClass.renderMode("compute").id(a).align(i.align).direction(i.direction).duration(e.schema.duration).data(i.visible?o:[]).height(i.height).locale(e.schema.locale).parent(e).select(l).shape((t,n)=>{const i=e.schema.shape(t,n);return"Circle"===i||"Line"===i?i:"Rect"}).verticalAlign(i.verticalAlign).width(i.width).shapeConfig(Ae.bind(e)(e.schema.shapeConfig,"legend")).shapeConfig({fill:(t,n)=>s(t,n)?e.schema.hiddenColor(t,n):r(t,n,"fill"),labelConfig:{fontOpacity:(t,n)=>s(t,n)?e.schema.hiddenOpacity(t,n):1}}).config(e.schema.legendConfig).render()}function Ph(e){const{width:t,height:n}=e.outerBounds();return!(!t||!n)&&(e._lineData||[]).every(e=>{if(!e.sentence)return!0;const t=e.lines.length;return e.width>0&&!e.truncated&&t<=`${e.sentence}`.split("\n").length&&e.height<=e.og.height})}function Rh(e,t){const n=Fh(e);return!1!==yu(e.schema.legendPosition.bind(e)(n),e)&&Boolean(e.schema.legend.bind(e)(n,t.legendData))}function Eh(e,t,n,i=Bh(e)){const o=Rh(e,i)&&!e.schema.legendConfig.select;if(Lh(e,i,{x:0,y:0,...Xa(t,n),align:"left",direction:t,verticalAlign:"top",visible:o}),!o)return null;const a=e._legendClass,r=(a._lineData||[]).every(e=>e.width>0),{width:s,height:c}=a.outerBounds();return r&&s&&c?{width:s,height:c}:null}function Nh(e,t,n){if(Ya(e,"legend"))return Eh(e,Ua(e,"legend"),{width:e.schema.width-n.left-n.right,height:e.schema.height-n.top-n.bottom},t),{panel:null,margin:{}};const i=Fh(e),o=yu(e.schema.legendPosition.bind(e)(i),e),a=["top","bottom"].includes(o),r=e.schema.legendPadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},{drop:s,insetRight:c,shorten:l}=function(e,t,n,i){const o=vu(e,t,n.top,"left"===t?n.left:n.right),a=nc(e,t,n.bottom+i.bottom,n.right+i.right);return{drop:o,insetRight:a.inset,shorten:a.drop}}(e,o,n,r),h={x:a?n.left+r.left:n.left,y:(a?n.top:n.top+r.top)+s,width:(a?e.schema.width-(n.left+n.right+r.left+r.right):e.schema.width-(n.left+n.right))-c,height:(a?e.schema.height-(n.bottom+n.top):e.schema.height-(n.bottom+n.top+r.bottom+r.top))-s-l,align:a?"center":o,direction:a?"row":"column",verticalAlign:a?o:"middle",visible:Rh(e,t)};let u=0;"top"===o?u=function(e,t,n,i,o){const a=n.visible&&!e.schema.legendConfig.select?Su(e,i,n.x,o,!0):[{left:0,right:0,drop:0}];for(const[i,{left:o,right:r,drop:s}]of a.entries())if(Lh(e,t,{...n,x:n.x+o,y:n.y+s,width:n.width-o-r,height:n.height-s}),i===a.length-1||Ph(e._legendClass))return s;return 0}(e,t,h,n.top,n.right+r.right):Lh(e,t,h);const d=e._legendClass.outerBounds(),f={};return!e.schema.legendConfig.select&&d.height&&(f[o]=a?u+d.height+2*e._legendClass.padding():d.width+2*e._legendClass.padding()),{panel:null,margin:f}}const Th={name:"legend",configFields:["legend","legendConfig","legendPadding","legendPosition","legendSort"],layout:({viz:e,layoutMargin:t})=>Nh(e,Bh(e),t)};function Oh(e){const t=e.schema.filter,n=e._filterApplied;return t&&n?(e,i)=>n(e)||t(e,i):t}function Wh(e){if(!e.schema.timeline)return{min:1,max:1/0};const t=e.schema.timelineConfig||{},n=co(t.brushMin,t.brushMax);return!1===t.brushing?{...n,min:1}:n}function jh(e,t,i){const o=[...new Set(t.map(Number))].sort((e,t)=>e-t);if(o.length<=i)return()=>!0;const a=o[o.length-i],r=e.schema.time;return(e,t)=>+n.date(r(e,t))>=a}function Hh(e){let t;if(e.schema.time&&!e.schema.timeFilter&&e._data.length){const i=e._data.map(e.schema.time).map(e=>n.date(e)),o=e._data[0],a=0;t=e.schema.discrete&&`_${e.schema.discrete}`in e&&e[`_${e.schema.discrete}`](o,a)===e.schema.time(o,a)?jh(e,i,Wh(e).max):jh(e,i,Math.max(1,Math.ceil(Wh(e).min)))}return t}function Ih(e,t,n,i,a,r=e._data){const s=[],c=[];if(r.length){const l=e.schema.timeFilter||a;let u=l?r.filter(l):r;const d=Oh(e);d&&(u=u.filter(d));const f=[];for(let t=0;t<=n;t++)f.push(e.schema.groupBy[t]);f.push(...function(e){const t=e.schema.discrete;if(!t)return[];const n=[],i=e;for(const o of[t,`${t}2`])`_${o}`in e?n.push(i[`_${o}`]):"function"==typeof e.schema[o]&&n.push(e.schema[o]);return n}(e));const m=h.rollup(u,t=>{const n=e._data.indexOf(t[0]),a=e.schema.shape(t[0],n),r=i(t[0],n),l=e._mergeRows?e._mergeRows(t):o.merge(t,e.schema.aggs);e._hidden.includes(r)||e._solo.length&&!e._solo.includes(r)||(e.schema.discrete||"Line"!==a?s.push(l):s.push(...t)),c.push(l)},...f);t.filteredData=s,t._thresholdTree=m}else t.filteredData=s;t.legendData=c}function Gh(e){return e instanceof Date?""+ +e:`${e}`}function Vh(e){if(null!=e&&""!==e)return e instanceof Date||"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e:`${e}`}function qh(e,t){const n=e instanceof Date?+e:e,i=t instanceof Date?+t:t;return"number"==typeof n&&"number"==typeof i?n-i:`${e}`.localeCompare(`${t}`,void 0,{numeric:!0})}function Yh(e,t){const n=e.slice();if(Array.isArray(t)){const e=new Map(t.map((e,t)=>[Gh(e),t])),i=t=>e.get(Gh(t))??1/0;return n.sort((e,t)=>i(e)-i(t))}return"function"==typeof t?n.sort(t):"data"===t?n:(n.sort(qh),"descending"===t?n.reverse():n)}function Kh(e,t,n){const i=new Map;e.forEach((e,n)=>{const o=Vh(t(e,n));if(void 0===o)return;const a=Gh(o);let r=i.get(a);r||i.set(a,r={key:a,value:o,rows:[]}),r.rows.push(e)});const o=new Map(Array.from(i.values()).map(e=>[e.key,e]));return Yh(Array.from(i.values()).map(e=>e.value),n).map(e=>o.get(Gh(e)))}function Uh(e,t){const n=e.schema.facet;if(!n)return[];const i=e._data||[],o=Oh(e);return Kh(o?i.filter(o):i,n,t)}function Xh(e,t,n){const i={};Ih(e,i,e._drawDepth,e._id,n,t);let o=i.filteredData??[];return t.length&&i._thresholdTree&&e._thresholdFunction&&(o=e._thresholdFunction(o,i._thresholdTree,e._thresholdRows??i.legendData)),o}function Qh(e){return Hh(e)}function Zh(e,t){if(e instanceof Date){const n=t.filter(e=>e instanceof Date).sort((e,t)=>+e-+t);return d.formatDate(e,n)}return`${e}`}const Jh=E,eu=e=>new Jh[e];function tu(e,t,n){return"function"==typeof e?e(t,n):e}function nu(e,t,n,i){const o=Do(tu(e.texture,t,n),()=>i,()=>tu(e.stroke,t,n),e.textureDefault);return o?`pattern:${o}`:"string"==typeof i?i:void 0}function iu(e,t,n){const i=tu(e.fill,t,n),o=tu(e.stroke,t,n),a=tu(e.strokeWidth,t,n),r=tu(e.opacity,t,n),s=tu(e.vectorEffect,t,n);return{fill:nu(e,t,n,i),stroke:o,strokeWidth:a,opacity:r,vectorEffect:"none"===s||"non-scaling-stroke"===s?s:void 0}}function ou(e,t,n){return e._drawLabel(t.data??t,t.i??n)}function au(e,t,n,i="shape"){return Ae.bind(e)(n??e.schema.shapeConfig,i,t)}function ru(e,t){const n=e.schema.shapeConfig??{},i=e=>e&&"object"==typeof e?e.labelConfig:void 0,o={...i(n),...i(n[t])};for(const e in o)ar(o[e])&&delete o[e];const{labelConfig:a}=au(e,t,{labelConfig:o});return a??{}}function su(e,t={}){if(!e)return[];const n=!1!==t.shape,i=!1!==t.labels;try{e.render();const t=[];if(n&&"function"==typeof e.toScene){const n=e.toScene();n&&Array.isArray(n.children)&&t.push(...n.children)}if(i){const n=e._labelClass;if(n&&"function"==typeof n.toScene){const e=n.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}return t}catch{return[]}}const cu=["fillOpacity","opacity","stroke","strokeDasharray","strokeLinecap","strokeOpacity","strokeWidth"];function lu(e){let t;const n=new Map,i=(i,o)=>{void 0===t&&(t=function(e){const t=La(e);if(!t)return null;const n=new Map;return t.rows.forEach((e,i)=>{const o=t.colorOf(e,i);n.has(o)||n.set(o,{row:e,i:i})}),n}(e));const a=t?.get(i.color)??t?.values().next().value;if(!a)return;const{row:r,i:s}=a,c=e._colorScaleShape(r,s),l="Line"===c?"":c;return n.has(l)||n.set(l,au(e,l)),tu(n.get(l)[o],r,s)};return Object.fromEntries(cu.map(e=>[e,t=>i(t,e)]))}function hu(e,t,i){const a={opacity:t.orient?1:0,transform:`translate(${t.x}, ${t.y})`},r=n.elem("g.d3plus-viz-colorScale",{condition:i&&!e.schema.colorScaleConfig.select,enter:a,parent:e._select,duration:0,update:a}).node();e.schema.colorScale&&e._colorScaleClass.renderMode("compute").align(t.align).duration(e.schema.duration).data(function(e){const t=e.schema.facet;return Array.from(h.rollup(e._data,t=>o.merge(t,e.schema.aggs),(n,i)=>`${e.schema.time?e.schema.time(n,i):"all"}-${t?Gh(t(n,i)):"all"}-${e._ids(n,i).join("_")}`).values()).filter((t,n)=>null!=e.schema.colorScale(t,n))}(e)).height(t.height).locale(e.schema.locale).orient(t.orient).select(r).value(e.schema.colorScale).width(t.width).legendConfig({shapeConfig:lu(e)}).config(e.schema.colorScaleConfig).hover(!1).render()}function uu(e){return yu(e.schema.colorScalePosition.bind(e)(Fh(e)),e)}function du(e,t,n){const i=Boolean(e.schema.colorScale)&&!1!==uu(e)&&!e.schema.colorScaleConfig.select,o=Xa(t,n),a=e.schema.colorScaleMaxSize;if(hu(e,{x:0,y:0,width:"row"===t?h.min([a,o.width]):o.width,height:"column"===t?h.min([a,o.height]):o.height,orient:"column"===t?"right":"bottom",align:"start"},i),!i)return null;const{width:r,height:s}=e._colorScaleClass.outerBounds();return r&&s?{width:r,height:s}:null}const fu={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:t})=>{if(Ya(e,"colorScale"))return du(e,Ua(e,"colorScale"),{width:e.schema.width-t.left-t.right,height:e.schema.height-t.top-t.bottom}),{panel:null,margin:{}};const n=uu(e),i=["top","bottom"].includes(n),o=e.schema.colorScale&&n,a=e.schema.colorScalePadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},r=vu(e,n,t.top,"left"===n?t.left:t.right),s=nc(e,n,t.bottom+a.bottom,t.right+a.right),c=e.schema.width-(t.left+t.right+a.left+a.right)-s.inset,l=i?h.min([e.schema.colorScaleMaxSize,c]):e.schema.width-(t.left+t.right),u=e.schema.height-(t.bottom+t.top+a.bottom+a.top)-r-s.drop,d=i?e.schema.height-(t.bottom+t.top):h.min([e.schema.colorScaleMaxSize,u]);hu(e,{x:i?t.left+a.left+(c-l)/2:t.left,y:i?t.top:t.top+a.top+r+(u-d)/2,width:l,height:d,orient:n,align:{bottom:"end",left:"start",right:"end",top:"start"}[n]||"bottom"},Boolean(o));const f={};if(o){const t=e._colorScaleClass.outerBounds();if(!e.schema.colorScaleConfig.select&&t.height){const o="function"==typeof e._colorScaleClass.padding?e._colorScaleClass.padding():e._legendClass.padding();f[n]=i?t.height+2*o:t.width+2*o}}return{panel:null,margin:f}}};function mu(e,t){const n=e.querySelector(".d3plus-attribution-text"),i=e.querySelector(".d3plus-attribution-toggle");n&&(n.style.display=t?"":"none"),i&&i.setAttribute("aria-expanded",String(t)),e.style.borderRadius="3px 0 0 0",e.style.padding=t?"4px 6px":"2px"}const pu={name:"attribution",configFields:["attribution","attributionIcon","attributionStyle"],layout:({viz:e})=>{let i=t.select(e._select.node().parentNode).selectAll("div.d3plus-attribution").data(e.schema.attribution?[0]:[]);const o=i.enter().append("div").attr("class","d3plus-attribution");i.exit().remove();const a=e._basemapDark?function(e){const t=as,n=rs,i={...e};for(const e of Object.keys(n))i[e]===t[e]&&(i[e]=n[e]);return i}(e.schema.attributionStyle):e.schema.attributionStyle;i=i.merge(o).style("position","absolute").style("right",`${e._margin.right}px`).style("bottom",`${e._margin.bottom}px`).call(n.stylize,a);const r=`<span class="d3plus-attribution-text">${e.schema.attribution}</span><button type="button" class="d3plus-attribution-toggle" aria-label="${e.schema.translate("Attribution")}" aria-expanded="true">${function(e){const t=e.schema.attributionIcon;return"string"==typeof t?t:"function"==typeof t?'<span class="d3plus-attribution-icon" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="width:12px;height:12px;display:block"><circle cx="12" cy="12" r="10"/><line x1="12" y1="11" x2="12" y2="17"/><line x1="12" y1="7" x2="12" y2="7.01"/></svg>'}(e)}</button>`,s=i.node();if(s&&s.__d3plusHTML!==r){s.innerHTML=r,s.__d3plusHTML=r,s.querySelectorAll("a").forEach(e=>{e.style.color="inherit",e.style.textDecoration="none"});const t=s.querySelector(".d3plus-attribution-toggle");t&&(t.style.border="0",t.style.background="transparent",t.style.color="inherit",t.style.margin="0",t.style.padding="0",t.style.flexShrink="0"),function(e,t){const n=e.schema.attributionIcon;if("function"!=typeof n)return;const i=t.querySelector(".d3plus-attribution-icon");i&&(e._attributionIconCleanup?.(),e._attributionIconCleanup=n(i)||void 0)}(e,s)}const c=i.node();if(!c)return{panel:null,margin:{}};const{width:l}=ie(e);c.style.maxWidth=`${Math.min(280,l)}px`;const h=c.querySelector(".d3plus-attribution-text");h.style.whiteSpace="nowrap";const u=h.getBoundingClientRect().width>.5*l;h.style.whiteSpace="";const d=t.select(c).select(".d3plus-attribution-toggle").style("display",u?"":"none");if(!u)return t.select(c).on(".compact",null),mu(c,!0),{panel:null,margin:{}};const f=()=>mu(c,Boolean(e._attributionPinned||c.matches(":hover, :focus-within")));return t.select(c).on("mouseenter.compact focusin.compact",()=>mu(c,!0)).on("mouseleave.compact focusout.compact",()=>window.setTimeout(f,0)),d.on("click.compact",()=>{e._attributionPinned=!e._attributionPinned,mu(c,e._attributionPinned)}),mu(c,Boolean(e._attributionPinned)),{panel:null,margin:{}}}},gu=new Set([!1,"top","right","bottom","left"]);function yu(e,t){return"auto"===e?function(e){return e.schema.width>1.5*e.schema.height?"right":"bottom"}(t):gu.has(e)?e:"bottom"}function xu(e,t,n={top:0,right:0,bottom:0,left:0}){const i={top:0,right:0,bottom:0,left:0},o=[];for(const a of t){if(!a.layout)continue;const t={top:n.top+i.top,right:n.right+i.right,bottom:n.bottom+i.bottom,left:n.left+i.left},r=a.layout({...e,layoutMargin:t}),{panel:s,margin:c,vizUpdate:l}=r;if(s&&o.push(s),i.top+=c.top??0,i.right+=c.right??0,i.bottom+=c.bottom??0,i.left+=c.left??0,l&&e.viz){const t=e.viz;for(const e of Object.keys(l)){t[e.startsWith("_")?e:`_${e}`]=l[e]}}}return{panels:o,margin:i}}const bu=6;function _u(e,t,n){const i=Us(e);if(!i||t>=Xs(e))return 0;const o=i.width-n;return o>0?o+bu:0}function ku(e,t,n){const i=function(e,t,n,i){const o=Mh(e,i);return!o||t>=$h(e,i)?0:Math.max(0,o.width-n)}(e,t,n,zh(e));return i>0?i+bu:0}function vu(e,t,n,i){return"right"===t&&_u(e,n,i)?Xs(e)-n:"left"===t&&ku(e,n,i)?$h(e,zh(e))-n:0}function wu(e){return Math.max(Xs(e),$h(e,zh(e)))}function Su(e,t,n,i,o){const a=function(e,t,n,i){const o=ku(e,t,n),a=_u(e,t,i);return{left:o,right:a,symmetric:Math.max(o,a)}}(e,t,n,i);if(!a.left&&!a.right)return[{left:0,right:0,drop:0}];const r=[];return o&&a.left!==a.right&&r.push({left:a.symmetric,right:a.symmetric,drop:0}),r.push({left:a.left,right:a.right,drop:0}),r.push({left:0,right:0,drop:Math.max(0,wu(e)-t)}),r}function Cu(e,t){const{viz:n,layoutMargin:i}=e,o=t.getText(n);if(!o)return{panel:null,margin:{}};const a=n.schema[t.paddingMethod](n)?n._padding:{right:0,left:0},r=n[t.textClassKey];r.data([{text:o}]).locale(n.schema.locale).config(n.schema[t.configKey]);const{x:s,width:c,drop:l,boxes:h}=function(e,t,n,i,o,a){const r=t.split(),s=(e,n,i)=>{t.width(n);const o=()=>{const o=t._textData();return{x:e,width:n,drop:i,boxes:o,lines:o[0]?.lines??[],truncated:!o.length||o[0].truncated}};return Ft(o(),()=>{t.split(zt(r));const e=o();return t.split(r),e})},c=s(i,a,0).result;if(!c.boxes.length)return c;const l=Su(e,n,i,o,"middle"===c.boxes[0].tA);if(1===l.length)return c;for(const[e,{left:t,right:n,drop:o}]of l.entries()){const{fits:r,result:c}=s(i+t,a-t-n,o);if(r||e===l.length-1)return c}return c}(n,r,i.top,i.left+a.left,i.right+a.right,n.schema.width-(i.left+i.right+a.left+a.right));if(!h.length)return{panel:null,margin:{}};const u=h[0],d=u.lH,f=n.schema[t.configKey]?.padding??0,m=u.lines.length*d+2*f,p=i.top+l+f,g=u.lines.map((e,t)=>({text:e,x:"middle"===u.tA?c/2:"end"===u.tA?c:0,y:(t+1)*d-(d-u.fS),width:u.widths?.[t]??0}));return{panel:{type:"text",key:t.panelKey,x:0,y:0,lines:g,font:{family:u.fF,size:u.fS,anchor:"middle"===u.tA||"end"===u.tA||"start"===u.tA?u.tA:"start",baseline:"alphabetic"},paint:{fill:u.fC,opacity:u.fO},transform:{x:s,y:p}},margin:{top:l+m}}}const Mu={name:"title",configFields:["title","titleConfig","titlePadding"],layout:e=>Cu(e,{panelKey:"viz-title",getText:e=>!!e.schema.title&&e.schema.title(e._filteredData||[]),textClassKey:"_titleClass",configKey:"titleConfig",paddingMethod:"titlePadding"})},$u={name:"subtitle",configFields:["subtitle","subtitleConfig","subtitlePadding"],layout:e=>Cu(e,{panelKey:"viz-subtitle",getText:e=>!!e.schema.subtitle&&e.schema.subtitle(e._filteredData||[]),textClassKey:"_subtitleClass",configKey:"subtitleConfig",paddingMethod:"subtitlePadding"})};const Au={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:e,layoutMargin:t})=>{let i=e.schema.time&&e.schema.timeline;const a=i?o.unique(e._data.map(e.schema.time)).map(e=>n.date(e)):[];i=i&&a.length>1;const r=e.schema.timelinePadding(e)?e._padding:{right:0,left:0},s={transform:`translate(${t.left+r.left}, 0)`},c=n.elem("g.d3plus-viz-timeline",{condition:i,enter:s,parent:e._select,duration:e.schema.duration,update:s}).node();if(!i)return{panel:null,margin:{}};const l=e._timelineClass.renderMode("compute").domain(h.extent(a)).duration(e.schema.duration).height(e.schema.height-t.bottom).locale(e.schema.locale).select(c).ticks(a.sort((e,t)=>+e-+t)).width(e.schema.width-(t.left+t.right+r.left+r.right)),u=h.extent(a);if(e._timelineSelection)e._timelineSelection[0]<u[0]&&(e._timelineSelection[0]=u[0]),e._timelineSelection[1]>u[1]&&(e._timelineSelection[1]=u[1]);else{const t=h.extent((e._filteredData||[]).flatMap((t,n)=>e.schema.time(t,n)).map(e=>n.date(e)));e._timelineSelection=e.schema.timelineDefault||(t[0]?t:u)}l.selection(e._timelineSelection),l._onPlayToggle=()=>e._scheduleSceneRepaint();const d=e.schema.timelineConfig;return l.config(d).on("brush",e=>{d.on&&d.on.brush&&d.on.brush(e)}).on("end",t=>{!function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const o=n.date(e.schema.time(t)).getTime();return o>=i[0]&&o<=i[1]}).render()}}(e,t),d.on&&d.on.end&&d.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},zu={name:"total",configFields:["total","totalConfig","totalFormat","totalPadding"],layout:e=>Cu(e,{panelKey:"viz-total",getText:e=>{const t=e._filteredData||[],n="function"==typeof e.schema.total?h.sum(t.map(e.schema.total)):!(!0!==e.schema.total||!e._size)&&h.sum(t.map(e._size));return!!n&&e.schema.totalFormat(n)},textClassKey:"_totalClass",configKey:"totalConfig",paddingMethod:"totalPadding"})};function Du(e,t,n){return e.schema.minimapClassName&&t===n?{}:t||{}}function Fu(e,...t){const n=new Set;for(const e of t)for(const t of Object.keys(e))n.add(t);for(const t of n)e.style.removeProperty($s(t));for(const n of t)for(const t in n){const i=n[t];null!=i&&!1!==i&&e.style.setProperty($s(t),String(i))}}function Bu(e){const t=e.schema.minimapClassName?` ${e.schema.minimapClassName}`:"";return`<div class="d3plus-minimap-viewport${t}" tabindex="0" aria-label="${e.schema.translate("Pan viewport — drag or use arrow keys")}"></div><div class="d3plus-minimap-label${t}"></div>`}function Lu(e){const t=function(e){return e._zoomEventTarget||e._container}(e)?.node();return t?b.zoomTransform(t):b.zoomIdentity}function Pu(e){const t=e._plotZoomBase?.scales;return t?{x:Boolean(t.x||t.x2),y:Boolean(t.y||t.y2)}:{x:!0,y:!0}}const Ru={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function Eu(e,t,n,i,o){const[[a,r],[s,c]]=e._zoomBehavior.translateExtent(),l=Pu(e),h=Lu(e);_c(e,i,l.x?(a+s)/2-t*i:h.x,l.y?(r+c)/2-n*i:h.y,o)}function Nu(e,t,n,i,o){const[[a,r],[s,c]]=e._zoomBehavior.translateExtent();return[a+i/t*(s-a),r+o/n*(c-r)]}function Tu(e,t,n,i,o,a){const r=a.parentElement,s=r?.querySelector(".d3plus-minimap-label");if(!r||!s)return;const c=Lu(e),l=c.k>1;if(Fu(r,i.outer),Fu(r,{position:"absolute","box-sizing":"border-box",overflow:"hidden",opacity:l?"1":"0","pointer-events":l?"auto":"none",transition:`opacity ${e.schema.duration}ms`}),!l)return;const[[h,u],[d,f]]=e._zoomBehavior.translateExtent(),m=d-h,p=f-u,g=Math.min(1,1/c.k),y=Pu(e),x=y.x?g:1,b=y.y?g:1,_=(h-c.x)/c.k,k=(u-c.y)/c.k,v=Math.max(0,Math.min(1-x,m?(_-h)/m:0)),w=Math.max(0,Math.min(1-b,p?(k-u)/p:0));Fu(a,i.viewport,o.dragging?i.viewportActive:{}),Fu(a,{position:"absolute","box-sizing":"border-box","touch-action":"none",left:v*t+"px",top:w*n+"px",width:`${Math.max(1,x*t)}px`,height:`${Math.max(1,b*n)}px`}),Fu(s,i.label),Fu(s,{position:"absolute"}),s.textContent=function(e){const t=Math.round(10*e)/10;return`${t%1==0?t.toFixed(0):t.toFixed(1)}x`}(c.k)}function Ou(e,t,n,i,o){const a=e=>e.target?.closest(".d3plus-minimap-viewport"),r=e=>{if(e.pointerId!==i.dragPointerId)return;i.dragging=!1;const t=a(e);t&&o(t)};return{pointerdown:t=>{const n=t,r=a(t);if(!r)return;try{r.setPointerCapture(n.pointerId)}catch{}i.dragging=!0,i.dragPointerId=n.pointerId;const s=Lu(e);i.dragStart={x:n.clientX,y:n.clientY,tx:s.x,ty:s.y,k:s.k},o(r),t.preventDefault()},pointermove:n=>{const o=n;if(!i.dragging||o.pointerId!==i.dragPointerId)return;const[[a],[r]]=e._zoomBehavior.translateExtent(),s=(r-a)/t,c=Pu(e),l=c.x?(o.clientX-i.dragStart.x)*s*i.dragStart.k:0,h=c.y?(o.clientY-i.dragStart.y)*s*i.dragStart.k:0;_c(e,i.dragStart.k,i.dragStart.tx-l,i.dragStart.ty-h,0)},pointerup:r,pointercancel:r,keydown:n=>{const i=n,o=Ru[i.key];if(!o)return;i.preventDefault();const[[a],[r]]=e._zoomBehavior.translateExtent(),s=(r-a)/t,c=i.shiftKey?40:10,l=Lu(e),h=Pu(e),u=h.x?o[0]*c*s*l.k:0,d=h.y?o[1]*c*s*l.k:0;_c(e,l.k,l.x-u,l.y-d,e.schema.duration)}}}function Wu(e,t,n){return{click:i=>{const o=i.target;if(o?.closest(".d3plus-minimap-viewport"))return;const a=o?.closest(".d3plus-minimap");if(!a)return;const r=i,s=a.getBoundingClientRect(),[c,l]=Nu(e,t,n,r.clientX-s.left,r.clientY-s.top);Eu(e,c,l,Lu(e).k,e.schema.duration)},dblclick:t=>{t.preventDefault(),_c(e,1,0,0)},wheel:i=>{const o=i;if(!o.ctrlKey&&!o.metaKey)return;o.preventDefault();const a=i.target?.closest(".d3plus-minimap");if(!a)return;const r=a.getBoundingClientRect(),[s,c]=Nu(e,t,n,o.clientX-r.left,o.clientY-r.top),l=o.deltaY<0?e.schema.zoomFactor:1/e.schema.zoomFactor;Eu(e,s,c,Lu(e).k*l,0)}}}function ju(e,t,n,i){const o=function(e){return{outer:Du(e,e.schema.minimapStyle,fs),viewport:Du(e,e.schema.minimapViewportStyle,ms),viewportActive:Du(e,e.schema.minimapViewportStyleActive,ps),label:Du(e,e.schema.minimapLabelStyle,gs)}}(e),a={dragging:!1,dragPointerId:null,dragStart:{x:0,y:0,tx:0,ty:0,k:1}},r=i=>Tu(e,t,n,o,a,i),s=e.schema.minimapClassName?` ${e.schema.minimapClassName}`:"";return{type:"htmlOverlay",key:"viz-minimap",x:e.schema.width-4-t,y:i+4,width:t,height:n,className:`d3plus-minimap${s}`,html:Bu(e),events:{".d3plus-minimap-viewport":Ou(e,t,0,a,r),".d3plus-minimap":Wu(e,t,n)},onUpdate:e=>{const t=e.querySelector(".d3plus-minimap-viewport");t&&r(t)}}}const Hu={name:"minimap",layout:({viz:e})=>{if(!(e.schema.zoom&&e.schema.minimap&&e._container&&e._zoomBehavior&&Ys(e)))return{panel:null,margin:{}};const t=Us(e);if(!t)return{panel:null,margin:{}};const n=ie(e),i=e._zoomHeight||n.height,o=e._zoomWidth||n.width;if(!o||!i)return{panel:null,margin:{}};const a=t.width-4;return{panel:ju(e,a,a*(i/o),t.height),margin:{}}}};function Iu([e,t],n){if(!n)return[e,t];let i=e,o=t;if(n.rotate){const[e,t]=n.rotateAnchor??[0,0],a=n.rotate*Math.PI/180,r=Math.cos(a),s=Math.sin(a),c=i-e,l=o-t;i=e+c*r-l*s,o=t+c*s+l*r}const a=n.scale??1;return[i*a+(n.x??0),o*a+(n.y??0)]}const Gu=([e,t])=>({x:e,y:t,width:0,height:0});function Vu(e){switch(e.type){case"rect":case"image":return[{x:e.x,y:e.y,width:e.width,height:e.height}];case"circle":return[{x:e.cx-e.r,y:e.cy-e.r,width:2*e.r,height:2*e.r}];case"path":{const t=f.path2polygon(e.d,10);return t.length?t.map(Gu):[f.pathBounds(e.d)]}case"line":return e.points.map(Gu);case"area":return[...e.topline,...e.baseline].map(Gu);case"text":return function(e){const t=e.font?.size??0,n=e.font?.anchor??"start",i=e.font?.baseline??"alphabetic",o="hanging"===i?0:"middle"===i?t/2:.8*t;return(e.lines||[]).filter(e=>e.text&&e.width).map(i=>{const a="middle"===n?i.width/2:"end"===n?i.width:0;return{x:e.x+i.x-a,y:e.y+i.y-o,width:i.width,height:t}})}(e);default:return[]}}function qu(e){return t=>e.reduceRight((e,t)=>Iu(e,t),t)}function Yu(e,t){const n=[t([e.x,e.y]),t([e.x+e.width,e.y]),t([e.x,e.y+e.height]),t([e.x+e.width,e.y+e.height])],i=n.map(e=>e[0]),o=n.map(e=>e[1]),a=Math.min(...i),r=Math.min(...o);return{x:a,y:r,width:Math.max(...i)-a,height:Math.max(...o)-r}}function Ku(e,t,n,i=!1){const o=[],a=(e,t)=>{for(const r of e){if(String(r.key).endsWith("::hit")||n&&n(r))continue;const e=r.transform?[...t,r.transform]:t;if("group"===r.type){a(r.children,e);continue}if(!i&&void 0===r.datum)continue;const s=qu(e);for(const e of Vu(r))[e.x,e.y,e.width,e.height].every(Number.isFinite)&&o.push(Yu(e,s))}};return a(e,t?[t]:[]),o}function Uu(e,t,n){const{width:i,height:o}=ie(e);return{bounds:t??{x:e._margin.left,y:e._margin.top,width:i,height:o},obstacles:Ku(e._chartScene||[],e._chartTransform,n)}}const Xu=12*1.4+5;function Qu(e,t){return"auto"===t.bind(e)(Fh(e))}function Zu(e){return Va.filter(t=>"legend"===t?Qu(e,e.schema.legendPosition)&&function(e){const t=Xa("column",{width:e.schema.width||0,height:e.schema.height||0});return Bh(e).legendData.length*Xu*Xu<=t.width*t.height}(e):"colorScale"!==t||Qu(e,e.schema.colorScalePosition))}const Ju={sizeLegend:["column"],legend:["column","row"],colorScale:["column","row"]};function ed(e,t,n,i){if("sizeLegend"===t){const t=Zs(e);return t?{width:t.width,height:t.height}:null}return"legend"===t?Eh(e,n,i):du(e,n,i)}const td=[{alignX:"right",alignY:"bottom"},{alignX:"right",alignY:"top"},{alignX:"left",alignY:"bottom"},{alignX:"left",alignY:"top"}];function nd(e,t,n,i){const o=.5,a=e.filter(e=>e.width>=n&&e.height>=i);if(!a.length)return null;const r=e=>({right:Math.abs(e.x+e.width-(t.x+t.width))<o,left:Math.abs(e.x-t.x)<o,bottom:Math.abs(e.y+e.height-(t.y+t.height))<o,top:Math.abs(e.y-t.y)<o}),s=(e,t,o)=>({x:"right"===t?e.x+e.width-n:"left"===t?e.x:e.x+(e.width-n)/2,y:"bottom"===o?e.y+e.height-i:"top"===o?e.y:e.y+(e.height-i)/2,width:n,height:i,alignX:t,alignY:o});for(const{alignX:e,alignY:t}of td){const n=a.find(n=>{const i=r(n);return i[e]&&i[t]});if(n)return s(n,e,t)}const c=a[0],l=r(c);return s(c,l.right?"right":l.left?"left":"center",l.bottom?"bottom":l.top?"top":"middle")}function id(e){const t=e._insetRegion?.();if(!t)return null;const{padding:n}=qa(e),i=t.bounds,o={x:i.x+n,y:i.y+n,width:i.width-2*n,height:i.height-2*n};if(o.width<=0||o.height<=0)return null;const a=function(e){const t=[],{width:n,height:i}=ie(e),o=Us(e);if(o){const a=e.schema.minimap?(o.width-4)*(i/Math.max(1,n)):0;t.push({x:e.schema.width-o.width,y:0,width:o.width,height:o.height+a})}const a=Mh(e,zh(e));if(a&&t.push({x:0,y:0,width:a.width,height:a.height}),e.schema.attribution){const i=e._select?.node?.()?.parentNode,o=i?.querySelector?.("div.d3plus-attribution"),a=String(e.schema.attribution).replace(/<[^>]*>/g,""),r=Math.min(o?.offsetWidth||6*a.length+30,n/2),s=o?.offsetHeight||22,c=e.schema.width-e._margin.right,l=e.schema.height-e._margin.bottom;t.push({x:c-r,y:l-s,width:r,height:s})}return t}(e);return{rects:f.negativeSpace(o,t.obstacles,{padding:n,exclude:a}),bounds:o,area:i}}function od(e,t){const n=t.filter(t=>function(e,t){return"sizeLegend"===t?Boolean(Zs(e)?.inset):"legend"===t?Boolean(e._legendClass?._data?.length):Boolean(e.schema.colorScale)&&!1!==yu(e.schema.colorScalePosition.bind(e)(Fh(e)),e)&&!e.schema.colorScaleConfig.select}(e,t)),i=n.length?id(e):null;if(!i||!i.rects.length)return{placement:null,showing:n};const{margin:o}=qa(e);for(const t of n)for(const a of Ju[t]){const r=ed(e,t,a,i.area),s=r&&nd(i.rects,i.bounds,r.width+2*o,r.height+2*o);if(s)return{placement:{key:t,orient:a,...s},showing:n}}return{placement:null,showing:n}}function ad(e,t){e._margin={...t.margin},e._padding={...t.padding},e._draw()}function rd(e){e._insetPlacement=null;const t="function"==typeof e._insetRegion&&function(e){const t=e.schema.legendInset;return"function"==typeof t?Boolean(t.bind(e)(Fh(e))):Boolean(t)}(e)?Zu(e):[];if(!t.length)return e._insetPending=null,void e._draw();const n={margin:{...e._margin},padding:{...e._padding}};e._insetPending=new Set(t),e._draw();const i=od(e,t),{showing:o}=i;let{placement:a}=i;if(o.length){if(a&&o.some(e=>e!==a.key)&&(e._insetPending=new Set([a.key]),ad(e,n),a=od(e,[a.key]).placement),!a)return e._insetPending=new Set,void ad(e,n);e._insetPlacement=a}}function sd(e,t,n){if(e<=0||t<=0)return 0;const i=Math.min(e,t*n);return i*(i/n)}function cd(e,t,n){if(e<=0)return{columns:0,rows:0};const{columns:i,rows:o}=n;if(i)return{columns:Math.min(i,e),rows:Math.max(o??0,Math.ceil(e/i))};if(o){const t=Math.ceil(e/o);return{columns:t,rows:Math.ceil(e/t)}}const a=n.gutter??{left:0,right:0,bottom:0};let r={columns:1,rows:e},s=-1,c=1/0,l=1/0;for(let i=1;i<=e;i++){const o=Math.ceil(e/i),h=(t.width-a.left-a.right-(i-1)*(n.columnPadding??n.padding))/i,u=(t.height-a.bottom-(o-1)*n.padding)/o-n.titleHeight,d=sd(h,u,n.aspect),f=i*o-e,m=u>0?Math.abs(Math.log(h/u/n.aspect)):1/0;(d>1.01*s||d>=.99*s&&(f<c||f===c&&m<l))&&(r={columns:i,rows:o},s=Math.max(d,s),c=f,l=m)}return r}function ld(e,t,n){const{columns:i,rows:o}=cd(e,t,n);if(!i)return[];const a=n.gutter??{left:0,right:0,bottom:0},r=n.padding,s=n.columnPadding??r,c=Math.max(0,(t.width-a.left-a.right-(i-1)*s)/i),l=Math.max(0,(t.height-a.bottom-(o-1)*r)/o),h=[];for(let n=0;n<e;n++){const o=Math.floor(n/i),u=n%i,d=n+i<e,f=t.x+u*(c+s)+(u?a.left:0),m=t.y+o*(l+r);h.push({index:n,row:o,column:u,x:f,y:m,width:c+(u?0:a.left)+(u===i-1?a.right:0),height:l+(d?0:a.bottom),edges:{top:0===o,right:u===i-1||n===e-1,bottom:!d,left:0===u}})}return h}const hd={top:0,right:0,bottom:0,left:0},ud=[{x:!0,y:!0},{x:!0,y:!1},{x:!1,y:!0},{x:!1,y:!1}];function dd(e){return`${e.x?"x":""}${e.y?"y":""}`}function fd(e,t={x:!1,y:!1}){const n=e[dd(t)]??hd,i={};for(const[t,o]of Object.entries(e))i[t]={top:Math.max(0,o.top-n.top),right:Math.max(0,o.right-n.right),bottom:Math.max(0,o.bottom-n.bottom),left:Math.max(0,o.left-n.left)};return i}function md(e){const t=Object.values(e),n=(t,n)=>Math.max(0,...ud.filter(n).map(n=>e[dd(n)]?.[t]??0));return{top:Math.max(0,...t.map(e=>e.top)),right:Math.max(0,...t.map(e=>e.right)),bottom:n("bottom",e=>e.x),left:n("left",e=>e.y)}}function pd(e,t,n,i){const o=0===e.column?n.left:0,a=e.column===i-1?n.right:0,r=t+n.top,s=e.edges.bottom?n.bottom:0;return{x:e.x+o,y:e.y+r,width:Math.max(0,e.width-o-a),height:Math.max(0,e.height-r-s)}}function gd(e){const t=Object.fromEntries(["top","right","bottom","left"].map(t=>[t,Math.max(...e.map(e=>e[t]))]));return e.map(e=>({top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}))}function yd(e,t){return{x:e.x-t.left,y:e.y-t.top,width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}}function xd(e){const t=(t,n)=>Math.max(0,...ud.filter(n).map(n=>e[dd(n)]?.[t]??0));return t("left",e=>e.x&&!e.y)+t("right",e=>e.x)}function bd(e,t){const n="function"==typeof t?t:e=>`${t}/${e}`;return e.map(e=>{const t=e.children,i={...e,key:n(`${e.key}`)};return t&&(i.children=bd(t,n)),i})}function _d(e,t,n){const i=(new ro).data(e.map((e,t)=>({id:`facet-title-${t}`,text:e.text}))).x((t,n)=>e[n].x).y((t,n)=>e[n].y).width((t,n)=>e[n].width).height(()=>1e4).verticalAlign("top").config(t);return n&&i.locale(n),i}function kd(e,t,n){if(!e.length)return 0;const i="number"==typeof t.padding?t.padding:0,o=_d(e,{...t,padding:0},n)._textData(),a=Math.max(0,...o.map(e=>e.lines.length*e.lH));return a?a+2*i:0}function vd(e,t,n){if(!e.length)return[];const i="number"==typeof t.padding?t.padding:0;return _d(e.map(e=>({...e,x:e.x+i,y:e.y+i,width:e.width-2*i})),{...t,padding:0},n).toScene().children.map(e=>{const t={...e,interactive:!1,interactionGroup:"facet"};return delete t.datum,delete t.index,t})}function wd(e,t,n,i){return{type:"group",key:`${e}/cells`,...i?{clip:i}:{},children:[{type:"group",key:`${e}/body`,...n?{transform:n}:{},children:t}]}}function Sd(e,t,n,i){const o=[];return n&&o.push(n),t&&o.push(t),{type:"group",key:e,children:o,...i?{aria:{role:"group",label:i}}:{}}}function Cd(e,t){return{top:t.y,left:t.x,right:e.schema.width-t.x-t.width,bottom:e.schema.height-t.y-t.height}}function Md(e,t){const{x:n,y:i}="boolean"==typeof t?{x:t,y:t}:t;return{x:!n||e.edges.bottom,y:!i||e.edges.left}}function $d(e,t,n,i,o){if(e._filteredData=n,e._margin=Cd(e,i),e._padding={...t.padding},e._chartScene=[],e._chartTransform=void 0,e._chartClip=void 0,e._zoomShapes=void 0,!n.length||i.width<=0||i.height<=0)return{scene:[],zoomShapes:[],state:{}};const a=t.hooks.panel?t.hooks.panel(e,o):void 0;let r,s;e._facetStep="panel";try{e._draw(),r=e._chartScene||[],s=t.hooks.scene?t.hooks.scene(e,r):r}finally{e._facetStep=void 0,a&&a()}return{scene:s,zoomShapes:e._zoomShapes||r,chartTransform:e._chartTransform,chartClip:e._chartClip,state:t.hooks.capture?t.hooks.capture(e):{}}}function Ad(e,t){return void 0!==t.titleConfig.fontColor?t.titleConfig:{...t.titleConfig,fontColor:Ga(e)}}function zd(e,t){const{title:n}=e,i=t.map(e=>e.value);return t.map(e=>!1===n?"":n?`${n(e.value,e.data)}`:Zh(e.value,i))}function Dd(e,t,n,i){const o=t.map((e,t)=>({text:e,x:0,y:0,width:n[t]?n[t].width:0})).filter(e=>e.text&&e.width>0);return kd(o,i,e.schema.locale)}function Fd(e,t,n,i){const{config:o,hooks:a,panels:r,area:s}=t,c={columns:o.columns,rows:o.rows,padding:o.padding,titleHeight:0,aspect:a.aspect??Re},l=Dd(e,n,ld(r.length,s,c),i);c.titleHeight=l;const h=ld(r.length,s,c)[0],u=pd(h,l,hd,1);t.shared&&a.share&&(e._margin=Cd(e,u),t.scales=a.share(e,r.map(e=>e.data)));const d=je(e,o,a,t.shared),f=d.x||d.y?function(e,t,n,i,o){const a=t.panels.find(e=>e.data.length)?.data,r=t.hooks.insets;if(!a||!r)return{};const s={};for(const c of ud.filter(e=>(o.x||e.x)&&(o.y||e.y)))$d(e,t,a,i,{cell:n,shared:t.shared,labels:c,scales:t.scales}),s[dd(c)]=r(e);return fd(s,function(e){return{x:!e.x,y:!e.y}}(o))}(e,t,h,u,d):{},m=md(f);c.gutter=m,c.columnPadding=o.padding+xd(f),c.titleHeight=l+m.top;const p=ld(r.length,s,c),g=Math.max(1,...p.map(e=>e.column+1));return{cells:p,columns:g,titleHeight:l,outer:d,gutter:m,expansions:f}}function Bd(e,t,n){return{text:e,x:n.x,y:t.y,width:n.width}}function Ld(e,t){const n=Ad(e,t.config),i=zd(t.config,t.panels),o=Fd(e,t,i,n),{cells:a,expansions:r}=o,s=a.map(e=>pd(e,o.titleHeight,o.gutter,o.columns)),c=vd(a.map((e,t)=>Bd(i[t],e,s[t])).filter(e=>e.text),n,e.schema.locale),l=a.map(e=>Md(e,o.outer)),h=a.map((e,t)=>yd(s[t],r[dd(l[t])]??hd)),u=function(e,t,n,i,o,a){const r=t.hooks.insets,{outer:s,expansions:c}=a;if(!r||s.x===s.y)return[];const l=t.panels.map((a,s)=>{if(!a.data.length)return;$d(e,t,a.data,i[s],{cell:n[s],shared:t.shared,labels:o[s],scales:t.scales});const l=c[dd(o[s])]??hd,h=r(e);return{top:h.top-l.top,right:h.right-l.right,bottom:h.bottom-l.bottom,left:h.left-l.left}}),h=gd(l.filter(e=>!!e));let u=0;return l.map(e=>e?h[u++]:hd)}(e,t,a,h,l,o);let d=0;const f=[],m=[],p=[];return t.panels.forEach((n,o)=>{const r=a[o],s=u[o]?yd(h[o],u[o]):h[o],g=$d(e,t,n.data,s,{cell:r,shared:t.shared,labels:l[o],scales:t.scales}),y=`facet-${n.key}`,x=i[o]?c[d++]:void 0,b=g.scene.length?wd(y,bd(g.scene,y),g.chartTransform,g.chartClip):void 0;m.push(Sd(y,x?{...x,key:`${y}/title`}:void 0,b,i[o])),p.push(...g.zoomShapes),f.push({key:y,value:n.value,cell:r,area:s,chartTransform:g.chartTransform,scene:g.scene,state:g.state})}),e._chartScene=m,{states:f,zoomShapes:p}}function Pd(e){const t=Ne(e.schema.facetConfig),n=Uh(e,t.sort);if(!n.length||!(e._filteredData||[]).length)return!1;const i=Qh(e),o=n.map(t=>({...t,data:Xh(e,t.rows,i)})),a=o.flatMap(e=>e.data);if(!a.length)return!1;e._filteredData=a,e._insetPending=null,e._insetPlacement=null,e._facetStep="chrome";try{e._draw()}finally{e._facetStep=void 0}const r={...e._margin},s={...e._padding},c={x:r.left,y:r.top,width:e.schema.width-r.left-r.right,height:e.schema.height-r.top-r.bottom},l=e._facetHooks?e._facetHooks():{},h=He(t,l),{states:u,zoomShapes:d}=Ld(e,{config:t,hooks:l,panels:o,area:c,shared:h,scales:void 0,padding:s});return e._filteredData=a,e._margin=r,e._padding=s,e._chartTransform=void 0,e._chartClip=void 0,e._bodyRect={...c},e._zoomShapes=d,e._facetPanels=u,e._pendingEnterOrigin=void 0,e._pendingExitReunion=void 0,Ac(e,u),!0}function Rd(e){e._facetPanels=void 0,Ie(e)&&Pd(e)||rd(e)}function Ed(e,t){const n=Ga(e),i=e._sizeLegendClass;i.renderMode("compute").locale(e.schema.locale).title(e._sizeKey).labelConfig({fontColor:n,fontFamily:e.schema.fontFamily}).titleConfig({fontColor:n,fontFamily:e.schema.fontFamily}).lineConfig({stroke:n}).shapeConfig({fill:n,stroke:n}).config(e.schema.sizeLegendConfig).scale(t);const{width:o,height:a}=i.layout();return{width:o,height:a}}function Nd(e,t){if(!e._sizeLegendClass||"function"!=typeof e._sizeLegendScale)return null;const n=e._sizeLegendScale(t);if(!n)return null;e._sizeLegendClass._maxRadius=void 0;const{width:i,height:o}=Ed(e,n);if(!i||!o)return null;const a={width:i,height:o,availableWidth:t.width,availableHeight:t.height};return e.schema.sizeLegend.bind(e)(Fh(e),n,a)?{key:"sizeLegend",width:i,height:o,paint:t=>{const n=e._sizeLegendFinal;if(!n)return null;e._sizeLegendClass._maxRadius=1===t?void 0:n(n.domain()[1]);const i=Ed(e,Ui(n,t));return i.width&&i.height?{node:e._sizeLegendClass.toScene(),...i}:null}}:null}const Td=[Nd];function Od(e,t,n){const i=[];for(const t of Td){const o=t(e,n);o&&i.push(o)}const o="bottom"===e.schema.sizeLegendPosition?"bottom":"right",a=Ya(e,"sizeLegend");e._bottomRightBox=i.length?{...Qs(i),bottom:t,side:o,inset:a,items:i}:null}const Wd={name:"bottomRightControls",configFields:["sizeLegend","sizeLegendConfig","sizeLegendPosition"],layout:({viz:e})=>{const t=Zs(e);return{panel:t?ac(e,t):null,margin:{}}}};function jd(e){e._preDraw(),Rd(e),Hd(e),mr(e),e._drawSceneToTarget()}function Hd(e){const t=xu({viz:e},[lc,Hu,Dh,Wd,pu,pl]);t.panels.length&&(e._featurePanels=[...e._featurePanels||[],...t.panels])}function Id(){this._tooltipClass.data([]).render()}const Gd="d3plus-viz-spacer";function Vd(e,t){return void 0===e||t?void 0:e}function qd(e){const t=e._select?.node(),n=t?.parentNode;if(!t||!n||"http://www.w3.org/1999/xhtml"!==n.namespaceURI)return;let i=Array.from(n.children).find(e=>e.classList.contains(Gd));const o=Vd(e.schema.width,e._autoWidth),a=Vd(e.schema.height,e._autoHeight);if("canvas"===e._renderer||void 0===o&&void 0===a)i?.remove();else{if(!i){i=n.ownerDocument.createElement("div"),i.className=Gd,i.setAttribute("aria-hidden","true");const e=i.style;e.display="block",e.flex="none",e.boxSizing="content-box",e.margin="0",e.padding="0",e.border="0",e.visibility="hidden",e.pointerEvents="none",n.insertBefore(i,t.nextSibling)}i.style.width=`${o??0}px`,i.style.height=`${a??0}px`}}const Yd="d3plus-viz";const Kd=":where(.d3plus-render-overlays, .d3plus-zoom-control, .d3plus-top-left-controls)",Ud=[".d3plus-zoom-control",".d3plus-top-left-controls",".d3plus-top-left-controls-item",`${Kd} .tlc-item`,`${Kd} .zoom-control-icon`,`${Kd} .search-root`,`${Kd} .search-input-wrap`,`${Kd} .search-count`,".d3plus-minimap",".d3plus-minimap-viewport",".d3plus-minimap-label",".d3plus-table-view",".d3plus-table-view-frame",".d3plus-table-view-toolbar",".d3plus-table-view-scroll",".d3plus-table-view-table",".d3plus-table-view-cell",".d3plus-table-view-pagination",".d3plus-attribution",".d3plus-attribution-text",".d3plus-attribution-icon",".d3plus-Mask",".d3plus-Message"];function Xd(e){return!!e._forceVisible||n.inViewport(e._select.node())}function Qd(e){const t=[];return e._queue.forEach(n=>{const i=e.schema.cache?e._lrucache.get(`${n[3]}_${n[1]}`):void 0;if(i){const t=n[2]?n[2](i):i;`_${n[3]}`in e?e[`_${n[3]}`]=t:e.schema[n[3]]=t}else t.push(new Promise(t=>{n[0](n[1],n[2],n[3],(i,o)=>{i?console.error(i):"data"===n[3]&&function(e,t){e._dataSignature=e.schema.dataPollingInterval?wt(t):void 0}(e,o),t()})}))}),e._queue=[],t}function Zd(e,t){var i;if(e._unloaded)return;let o;!function(e){const t=e._data instanceof Array&&e._data.length>0?Object.keys(e._data[0]):[],n=e._select.selectAll("g.data-table").data(!e.schema.ariaHidden&&e._data instanceof Array&&e._data.length?[0]:[]),i=n.enter().append("g").attr("class","data-table").attr("role","table");n.exit().remove();const o=n.merge(i).selectAll("text").data(e._data instanceof Array?h.range(0,e._data.length+1):[]);o.exit().remove();const a=o.merge(o.enter().append("text").attr("role","row")).selectAll("tspan").data((n,i)=>t.map(t=>({role:i?"cell":"columnheader",text:i?e._data[i-1][t]:t})));a.exit().remove(),a.merge(a.enter().append("tspan")).attr("role",e=>e.role).attr("dy","-1000px").html(e=>e.text)}(e),jd(e),e._instantNextDraw=!1,kt(e),At(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1));const a=()=>{if(o=void 0,!e._fontsUnsubscribe)return;const t=e._callback?e.schema.duration:(e._transitionEndsAt??0)-Date.now();t>0?o=setTimeout(a,t):e.render()};(i=e)._fontsUnsubscribe??(i._fontsUnsubscribe=n.onFontsLoaded(()=>{void 0===o&&a()})),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver?.observe(e._select.node().parentNode):e._resizeObserver?.unobserve(e._select.node().parentNode),t&&setTimeout(()=>{t(),e._callback=void 0},e.schema.duration+100)}function Jd(e,o){e._callback=o,e.schema.detectVisible&&e.schema.detectVisibleUnload||(e._unloadUnobserve?.(),e._unloadUnobserve=void 0,e._unloaded=!1),e._margin={bottom:0,left:0,right:0,top:0},e._padding={bottom:0,left:0,right:0,top:0},function(e){if(void 0===e._select||"svg"!==e._select.node().tagName.toLowerCase()){const n=void 0===e._select?t.select("body").insert("div","#d3plus-portal").style("height","100dvh").style("width","100%").style("min-height","150px"):e._select,i=n.select(".d3plus-viz").size()?n.select(".d3plus-viz"):n.append("svg");e.select(i.node())}}(e),function(e){if(e._tooltipClass&&e._select?.node){const t=e._select.node()?.parentNode;t&&e._tooltipClass.parent(t)}}(e),function(e){i.resetInjectedBoxes(e._select?.node(),Ud)}(e),qd(e),function(e){e.schema.width&&e.schema.height||e.schema.detectVisible&&!Xd(e)||(e._autoWidth=void 0===e.schema.width||!!e._autoWidth&&e.schema.width===e._measuredWidth,e._autoHeight=void 0===e.schema.height||!!e._autoHeight&&e.schema.height===e._measuredHeight,e._setSVGSize())}(e),qd(e);const r=t.select(e._select.node().parentNode);return function(e,t){!function(e){const t=void 0!==e.schema.width?`${e.schema.width}px`:void 0,n=void 0!==e.schema.height?`${e.schema.height}px`:void 0;e._select.classed("d3plus-viz")||e._select.style("width",t).style("height",n).attr("width",t).attr("height",n),e._select.transition().duration(e.schema.duration).style("width",t).style("height",n).attr("width",t).attr("height",n)}(e),e._select.attr("class",Yd).attr("aria-hidden",e.schema.ariaHidden).attr("aria-labelledby",`${e._uuid}-title ${e._uuid}-desc`).attr("role","img").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").style("position","absolute").style("top",t.style("padding-top")).style("left",t.style("padding-left")).style("content-visibility",e.schema.detectVisible?"auto":null),ve(e),"static"===t.style("position")&&t.style("position","relative"),t.style("font-family",a.fontFamilyStringify(e.schema.fontFamily)),null===e._select.attr("opacity")&&e._select.attr("opacity",1);const n=e._select.selectAll("title").data([0]),i=n.enter().append("title").attr("id",`${e._uuid}-title`);n.merge(i).text(e.schema.svgTitle);const o=e._select.selectAll("desc").data([0]),r=o.enter().append("desc").attr("id",`${e._uuid}-desc`);o.merge(r).text(e.schema.svgDesc)}(e,r),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),e._visibleUnobserve?.(),e._visibleUnobserve=void 0,e.schema.scrollContainer&&t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null)}(e),function(e,i){return e.schema.detectVisible&&"hidden"===e._select.style("visibility")?(e._visiblePoll=setInterval(()=>{"hidden"!==e._select.style("visibility")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(i))},e.schema.detectVisibleInterval),!0):e.schema.detectVisible&&"none"===e._select.style("display")?(e._visiblePoll=setInterval(()=>{"none"!==e._select.style("display")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(i))},e.schema.detectVisibleInterval),!0):!(!e.schema.detectVisible||Xd(e)||(bt()?(e._visibleUnobserve=_t(e._select.node(),e.schema.scrollContainer,()=>{e._visibleUnobserve?.(),e._visibleUnobserve=void 0,e._forceVisible=!0,e.render(i)},e.schema.detectVisibleInterval),0):(t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,()=>{e._scrollPoll||(e._scrollPoll=setTimeout(()=>{n.inViewport(e._select.node())&&(t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null),e.render(i)),e._scrollPoll=clearTimeout(e._scrollPoll)},e.schema.detectVisibleInterval))}),0)))}(e,o)||function(e,t){const n=Qd(e);e.schema.loadingMessage&&n.length&&e._messageClass.render({container:e._select.node().parentNode,html:e.schema.loadingHTML(e),mask:!!e._filteredData&&e.schema.messageMask,style:e.schema.messageStyle}),Promise.all(n).then(()=>Zd(e,t))}(e,o),e._forceVisible=!1,t.select("body").on(`touchstart.${e._uuid}`,Id.bind(e)),e}function ef(e,t,n,i,o){const a=xu({viz:e},[t],n);for(const e of o)i[e]+=a.margin[e],n[e]+=a.margin[e]}function tf(e){if(e._chartScene=[],e._chartTransform=void 0,"panel"===e._facetStep)return{marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:(e._featurePanels??[]).slice()};e._featurePanels=[];const t={marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]},n=Fh(e),i=yu(e.schema.legendPosition.bind(e)(n),e),o=yu(e.schema.colorScalePosition.bind(e)(n),e);t.legendPosition=i,t.colorScalePosition=o;const a={top:e._margin.top,right:e._margin.right,bottom:e._margin.bottom,left:e._margin.left},r=xu({viz:e},[Mu,$u,zu],a);e._featurePanels.push(...r.panels),t.marginDelta.top+=r.margin.top,a.top+=r.margin.top;const s=xu({viz:e},[Au],a);t.marginDelta.bottom+=s.margin.bottom,a.bottom+=s.margin.bottom,Od(e,a.bottom,{width:e.schema.width-a.left-a.right,height:e.schema.height-a.top-a.bottom});const c=oc(e,a.right);a.right+=c,"top"!==i&&"bottom"!==i||ef(e,Th,a,t.marginDelta,["top","bottom"]),"top"!==o&&"bottom"!==o||ef(e,fu,a,t.marginDelta,["top","bottom"]),a.right-=c;const l=ic(e,a.bottom);t.marginDelta.bottom+=l,a.bottom+=l,"left"!==i&&"right"!==i&&!1!==i||ef(e,Th,a,t.marginDelta,["left","right"]),"left"!==o&&"right"!==o&&!1!==o||ef(e,fu,a,t.marginDelta,["left","right"]);const h=oc(e,a.right);t.marginDelta.right+=h,a.right+=h;const u=Math.max(0,wu(e)-t.marginDelta.top);t.marginDelta.top+=u,a.top+=u;const d=t.marginDelta;return e._margin={top:e._margin.top+d.top,right:e._margin.right+d.right,bottom:e._margin.bottom+d.bottom,left:e._margin.left+d.left},t.featurePanels=e._featurePanels.slice(),t}const nf={x:"_x",x2:"_x2",y:"_y",y2:"_y2",size:"_size",stackOrder:"_stackOrder"},of=["dimensions"];const af=e=>null!==e&&"object"==typeof e;function rf(e,t){return e.some(e=>e.some(e=>af(e)&&t in e))}function sf(e){const t=new Set;for(const n of e)for(const e of n)if(af(e))for(const n in e)t.add(n);return Array.from(t)}function cf(e,{key:t,field:n},i){const o=i.slice(0,10);return i.length>10&&o.push("…"),`${e} ${t}: no rows have '${n}'; fields are: ${o.join(", ")}`}function lf(e){const t=({key:e,field:t})=>`missing-field:${e}:${t}`,n=function(e){const t=new Map,n=(e,n)=>{const i=Le(n);void 0===i||t.has(n)||t.set(n,{key:e,field:i})};for(const[t,i]of Object.entries(nf))n(t,e[i]);for(const t of e._confidenceBands??[])n("confidence",t.lower),n("confidence",t.upper);const i=Object.keys(e.schema).filter(e=>"thresholdKey"!==e);for(const t of[...i,"thresholdKey"]){const i=e.schema[t];Array.isArray(i)&&"function"==typeof i[0]?i.forEach(e=>n(t,e)):n(t,i)}const o=Array.from(t.values());for(const t of of){const n=e.schema[t],i=Array.isArray(n)?n:[n];for(const e of i)"string"==typeof e&&o.push({key:t,field:e})}return o}(e).filter(n=>function(e,t){return ue&&!he.get(e)?.has(t)}(e,t(n)));if(!n.length)return;const i=function(e){return[e._sourceData??e._data,e.schema.nodes,e.schema.links].filter(e=>Array.isArray(e))}(e);if(!i.some(e=>e.some(af)))return;let o;for(const a of n)rf(i,a.field)||(o??(o=sf(i)),ge(e,t(a),cf(e.constructor.name,a,o)))}function hf(e,t,n){for(;t.__d3plus__&&t.data;)n=(t=t.data).i;return e(t,n)}function uf(e,t,n){const i={noDataMessage:!1};return h.group(t,n).size>e.schema.dataCutoff?i.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==e._userHover&&(i.hoverOverride={hoverOpacity:e._userHover,duration:e._userDuration,restoreOriginals:!0}),i.noDataMessage=!(!e.schema.noDataMessage||t.length),i}function df(e){lf(e);const t=void 0!==e.schema.depth?h.min([e.schema.depth>=0?e.schema.depth:0,e.schema.groupBy.length-1]):e.schema.groupBy.length-1,{id:n,ids:i,drawLabel:o}=function(e,t){const n=e.schema.groupBy,i=e.schema.label,o=e.schema.thresholdName,a=e.schema.locale,r=e=>"number"==typeof e?`${e}`:e,s=(e,t)=>n.map(n=>`${hf(n,e,t)}`).filter(Boolean);return{id:(e,i)=>{const o=hf(n[t],e,i);return Array.isArray(o)?o.map(r):r(o)},ids:s,drawLabel:(n,r,c)=>{const l=e._drawDepth??t;if(!n)return"";const h=Ye(n),u=c??h??l;for(;n.__d3plus__&&n.data;)r=(n=n.data).i;if(u===h&&"string"==typeof n[Ve])return n[Ve];if(n._isColorScaleBucket)return`${n.id}`;if(n._isAggregation)return`${o(n,r)} < ${d.formatAbbreviate(100*n._threshold,a)}%`;if(i&&u===l)return`${i(n,r)}`;const f=s(n,r).slice(0,u+1),m=f.reverse().find(e=>!(e instanceof Array))||f[f.length-1];return m instanceof Array?function(e){return e.reduce((t,n,i)=>(i?i===e.length-1&&1===i?t+=` and ${n}`:i===e.length-1?t+=`, and ${n}`:t+=`, ${n}`:t+=n,t),"")}(m):`${m}`}}}(e,t);(function(e){const t=e=>!0===e||"number"==typeof e&&e>0,n=t=>e?.[t]?.trailPersist;return!!e&&(t(e.trailPersist)||t(n("Circle"))||t(n("Rect")))})(e.schema.shapeConfig)&&(e._axisPersist=!0,e.schema.timelineConfig={...e.schema.timelineConfig||{},brushing:!1});const a={};Ih(e,a,t,n,Hh(e)),e._drawDepth=t,e._id=n,e._ids=i,e._drawLabel=o,void 0!==a.legendData&&(e._legendData=a.legendData),e._thresholdRows=a.legendData;let c=a.filteredData||[];e._data.length&&a._thresholdTree&&(c=e._thresholdFunction(c,a._thresholdTree,e._thresholdRows),e._thresholdLegend&&a.legendData&&(e._legendData=e._thresholdLegend(a.legendData))),e._filteredData=c,function(e){if(!e.schema.colorOrdinal||e.schema.colorScale)return void(e._ordinalColorScale=void 0);const t=e._filteredData??[],n=e.schema.color,i=new Set,o=[];t.forEach((e,t)=>{const a=n(e,t),r="string"==typeof a?a:JSON.stringify(a);i.has(r)||(i.add(r),o.push(a))});const a=(o.every(e=>"number"==typeof e)?[...o].sort((e,t)=>e-t):o).map(e=>"string"==typeof e?e:JSON.stringify(e)),c=r.colorRamp((e.schema.colorDefaults??r.colorDefaults).sequential,a.length||1,{ordinal:!0});e._ordinalColorScale=s.scaleOrdinal().domain(a).range(c)}(e);const l=uf(e,c,e._id);l.hoverOverride?.stashOriginals?(void 0===e._userHover&&(e._userHover=e.schema.shapeConfig.hoverOpacity||.5),void 0===e._userDuration&&(e._userDuration=e.schema.shapeConfig.duration||600),e.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=l.hoverOverride.duration):l.hoverOverride?.restoreOriginals&&(e.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=l.hoverOverride.duration),l.noDataMessage&&(e._messageClass.render({container:e._select.node().parentNode,html:e.schema.noDataHTML(e),mask:!1,style:e.schema.messageStyle}),e._select.transition().duration(e.schema.duration).attr("opacity",0))}function ff(e,t){const n=e;return{d:n&&n.data?n.data:n,i:n&&"number"==typeof n.i?n.i:t,x:e}}const mf={area:"Area",circle:"Circle",line:"Line",path:"Path",rect:"Rect"};function pf(e,t){const n=[],i=function(e){return"string"==typeof e.shapeType?e.shapeType:mf[e.type]}(e);i&&n.push({shapeType:i,...t});for(const t of e.owners??[])n.some(e=>e.shapeType===t.shapeType)||n.push({shapeType:t.shapeType,...ff(t.datum,t.index)});return n}function gf(e,t){e.interactionGroup=t;const n=e.children;if(n)for(const e of n)gf(e,t)}class yf extends Ba{_preDraw(){df(this)}toScene(){const e=[];if(this._chartScene&&this._chartScene.length){const t=Ha(this._chartScene,this),n=[{type:"group",key:"viz-zoom",transform:this._zoomTransform??{x:0,y:0,scale:1},children:[{type:"group",key:"viz-chart-body",...this._chartTransform?{transform:this._chartTransform}:{},children:t}]}],i=this._chartClip??(this.schema.zoom&&this._margin?ae(this):void 0);e.push({type:"group",key:"viz-chart-cells",...i?{clip:i}:{},children:n})}const t=[["legend",this._legendClass],["colorScale",this._colorScaleClass],["timeline",this._timelineClass]];for(const[n,i]of t)if(i&&"function"==typeof i.toScene&&i._select&&"function"==typeof i._select.node&&i._select.node()){let t=i.toScene();"legend"===n?(gf(t,"legend"),t=Ha([t],this)[0]):"colorScale"===n?t=Oa([t],this)[0]:"timeline"===n&&gf(t,"timeline"),e.push({type:"group",key:`viz-${n}`,children:"timeline"===n?[t]:Za(this,n,t,i.outerBounds())})}return this._featurePanels&&this._featurePanels.length&&e.push({type:"group",key:"viz-features",children:this._featurePanels}),{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:e}}}_draw(){tf(this)}_sizeLegendScale(e){return null}_insetRegion(){return null}_colorScaleShape(e,t){return this.schema.shape(e,t)}_thresholdFunction(e,t,n){return e}_thresholdLegend(e){return e}_setSVGSize(e,t){let[i,o]=e&&t?[e,t]:n.getSize(this._select.node().parentNode);i-=parseFloat(this._select.style("border-left-width")),i-=parseFloat(this._select.style("border-right-width")),o-=parseFloat(this._select.style("border-top-width")),o-=parseFloat(this._select.style("border-bottom-width")),this._autoWidth&&(this._measuredWidth=i),this._autoHeight&&(this._measuredHeight=o),this._autoWidth&&this.schema.width!==i&&(this.width(i),this._select.style("width",`${this.schema.width}px`).attr("width",`${this.schema.width}px`)),this._autoHeight&&this.schema.height!==o&&(this.height(o),this._select.style("height",`${this.schema.height}px`).attr("height",`${this.schema.height}px`))}render(e){return Jd(this,e)}toSVGString(){return function(e,t){const n=_e(t),i=/^\s*<[a-zA-Z][^\s>/]*/.exec(e);if(!n.length||!i)return e;const o=e.indexOf(">",i[0].length),a=e.slice(0,o<0?e.length:o),r=/\sclass="([^"]*)"/.exec(a);if(!r)return`${i[0]} class="${we(n.join(" "))}"${e.slice(i[0].length)}`;const s=r[1].split(/\s+/).filter(Boolean),c=[...s,...n.filter(e=>!s.includes(e))],l=r.index;return`${e.slice(0,l)} class="${we(c.join(" "))}"${e.slice(l+r[0].length)}`}(this._sceneRenderer?.toSVGString?.()??"",this.schema.className)}toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(e){return arguments.length?(this._renderer="canvas"===e?"canvas":"svg",this):this._renderer}_drawSceneToTarget(e){const i="canvas"===this._renderer?"canvas":"svg",o=this._select&&this._select.node?this._select.node():null;if(!o)return;const a=function(e,t){return"canvas"===e&&"undefined"!=typeof Element&&t instanceof Element&&"svg"===t.tagName.toLowerCase()?t.parentNode??t:t}(i,o),r=this.toScene();this._paintedScene=r;const s=this.schema.width||400,c=this.schema.height||300;this._ensureSceneRenderer(i,a,s,c),ve(this);const l=void 0!==e?e:this._instantNextDraw?0:this.schema.duration;l>0&&null!=this._sceneRepaintRAF&&(cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),l>0&&(this._transitionEndsAt=Date.now()+l+30);const h=this._timelineSelection,u=!(!this._timelineClass||!1!==this._timelineClass.schema.brushing)&&Array.isArray(h)&&h.length?Math.max(...h.map(e=>Number(n.date(Number(e))))):void 0,d=void 0!==u&&void 0!==this._trailSeq&&u>this._trailSeq?se(this,r,this._trailSeq,u):void 0;if(void 0!==u&&(this._trailSeq=u),this._sceneRenderer.drawScene(r,{duration:l,sequence:u,trailCatchup:d,enterFrom:this._resolvedEnterFrom,enterFromBody:this._resolvedEnterFromBody,exitTo:this._resolvedExitTo,exitToBody:this._resolvedExitToBody,instantExitKey:this._resolvedInstantExitKey,reunionEnterKey:this._resolvedReunionEnterKey,reunionEnterFrom:this._resolvedReunionEnterFrom,instantExitAll:this._resolvedInstantExitAll}),this._resolvedEnterFrom=void 0,this._resolvedEnterFromBody=void 0,this._resolvedExitTo=void 0,this._resolvedExitToBody=void 0,this._resolvedInstantExitKey=void 0,this._resolvedReunionEnterKey=void 0,this._resolvedReunionEnterFrom=void 0,this._resolvedInstantExitAll=void 0,this._lastSceneRendered=r,dc(this),this._select&&"canvas"===i&&this._select.selectAll("g.d3plus-viz-timeline, g.d3plus-viz-brush").style("pointer-events","auto"),"canvas"===i&&function(e){if(!e.schema.zoom||e._ssr||!e._zoomBehavior||!e._brushGroup)return;const n=e._sceneRenderer,i=n&&"function"==typeof n.toCanvas?n.toCanvas():null;!i||e._zoomEventTarget&&e._zoomEventTarget.node()===i||(uc(e,t.select(i)),mc.bind(e)(Ps(e)))}(this),"svg"===i){const e="function"==typeof o.querySelector?o:null,t=e?e.querySelector(":scope > g.d3plus-viz-timeline"):null;t&&e.appendChild(t),e?.querySelectorAll(":scope > g.d3plus-zoom-brush, :scope > g.d3plus-viz-brush").forEach(t=>{t!==e.lastElementChild&&e.appendChild(t)})}}_interactionDatum(e,t){return ff(e.datum,e.index??0)}_sharedHover(e){}_classNameTargets(){return function(e,t,n){if("canvas"===n)return xe(t).filter(e=>"canvas"===e.localName).map(e=>({el:e,keep:ye}));const i="undefined"!=typeof Element&&e instanceof Element&&e.classList.contains(Yd)?e:void 0;return i?[{el:i,keep:[Yd]}]:[]}(this._select?.node?.(),this._sceneRenderer,"canvas"===this._renderer?"canvas":"svg")}_facetHooks(){return{}}_ensureSceneRenderer(e,t,n,o){const a=this._sceneRenderer?.target?this._sceneRenderer.target()?.container:void 0,r=!!this._sceneRenderer?.target&&a!==t;if(!this._sceneRenderer||this._sceneRenderer.kind!==e||r){this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const a="canvas"===e?i.CanvasRenderer:i.SvgRenderer;this._sceneRenderer=new a,this._sceneRenderer.mount({container:t,width:n,height:o,pixelRatio:this._scenePixelRatio}),this._lastScenePick=null,this._sceneRenderer.on(e=>this._routeSceneEvent(e))}else this._sceneRenderer.resize(n,o)}_routeSceneEvent(e){$c(this,Mc(this,e.point),()=>this._dispatchSceneEvent(e))}_dispatchSceneEvent(e){if(this._sharedHover(e),Ea(this,e),this._transitionEndsAt&&Date.now()<this._transitionEndsAt)return;const t=e.pick,n=(t,n,i,o)=>{const a=this.schema.on&&this.schema.on[t];if("function"==typeof a)try{a.call(this,n,i,o,e.nativeEvent)}catch(e){!function(e){const t=globalThis.reportError;"function"==typeof t?t(e):console.error(e)}(e)}};if("mouseleave"===e.type){const e=this._lastScenePick;if(e){n("mouseleave."+(e.isLegend?"legend":"shape"),e.d,e.i,e.x);for(const t of e.shapeTargets)n(`mouseleave.${t.shapeType}`,t.d,t.i,t.x);n("mouseleave",e.d,e.i,e.x)}return this._lastScenePick=null,void(this._hoverDatum=null)}if(!t||!t.node)return;const i=t.node;if("axis"===i.interactionGroup||"timeline"===i.interactionGroup||"trend"===i.interactionGroup)return;const o=e.nativeEvent&&e.nativeEvent.target,a="legend"===i.interactionGroup||!(!o||"function"!=typeof o.closest)&&!!o.closest('[data-key="viz-legend"]'),r=a?"legend":"shape",s=`${e.type}.${r}`,{d:c,i:l,x:h}=this._interactionDatum(t,e);if(void 0===c)return;const u=a?[]:pf(t.node,{d:c,i:l,x:h});this._lastScenePick={d:c,i:l,x:h,isLegend:a,shapeTargets:u,node:t.node},this._hoverDatum=h,n(s,c,l,h);for(const t of u)n(`${e.type}.${t.shapeType}`,t.d,t.i,t.x);n(e.type,c,l,h)}_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}destroy(){return at(this),Ct(this),this._resizeObserver?.disconnect(),this._fontsUnsubscribe?.(),this._fontsUnsubscribe=void 0,this._tooltipClass.data([]).render(),t.select("body").on(`touchstart.${this._uuid}`,null),this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),this._visibleUnobserve?.(),this._visibleUnobserve=void 0,this._unloadUnobserve?.(),this._unloadUnobserve=void 0,null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),this.schema.scrollContainer&&t.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&(this._sceneRenderer.destroy(),this._sceneRenderer=void 0),this}constructor(){var e;super(),Ms(this),(e=this).schema.legendInset=!0,e.schema.legendInsetConfig={}}}function xf(e,t=yf){class n extends t{_draw(t){return super._draw(t),e.layoutStage&&"chrome"!==this._facetStep&&function(e,t,n,i){if(function(e){return!0===e.paintDriven}(t))throw new Error(`runChartDraw cannot drive ${t.name} — it's a paint-driven chart (ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely on Plot._paint to populate _chartScene imperatively; their _draw should NOT call runChartDraw.`);e._chartScene=[];const o=ne({viz:e},[n]);if(!Array.isArray(e._chartScene))throw new Error(`runChartDraw: stage for ${t.name} replaced viz._chartScene with a non-array value (got ${typeof e._chartScene}). Stages should use \`(v._chartScene ||= []).push(...)\` rather than reassigning.`);const a=e._chartScene.slice(),r=t.emit(o);e._chartScene=[...a,...r],e._chartTransform=i?i(e):function(e){return{x:e._margin.left,y:e._margin.top}}(e),e._chartClip=t.chartClip?t.chartClip(e):void 0,e._bodyRect=t.chartBodyRect?t.chartBodyRect(e):{x:0,y:0,...ie(e)}}(this,e,e.layoutStage,e.chartTransform),this}toScene(){const t=super.toScene();return e.decorateScene?e.decorateScene(this,t):t}_sizeLegendScale(t){return e.sizeLegendScale?e.sizeLegendScale(this,t):super._sizeLegendScale(t)}_insetRegion(){return e.insetRegion?e.insetRegion(this):super._insetRegion()}_colorScaleShape(t,n){return e.colorScaleShape?e.colorScaleShape(this,t,n):super._colorScaleShape(t,n)}_facetHooks(){return e.facet?{...super._facetHooks(),...e.facet}:super._facetHooks()}_thresholdLegend(t){return e.thresholdFunction?e.thresholdFunction(this,t,t):super._thresholdLegend(t)}_thresholdFunction(t,n,i){return e.thresholdFunction?e.thresholdFunction(this,t,i):super._thresholdFunction(t,n,i)}constructor(){super(),function(e,t){if(t.ctx)for(const[n,i]of Object.entries(t.ctx))e.ctx[n]=i;if(t.defaults){const n=e;for(const[e,i]of Object.entries(t.defaults))n[`_${e}`]=i}t.fields&&ee(e,t.fields),t.setup&&t.setup(e)}(this,e)}}return Object.defineProperty(n,"name",{value:e.name}),n}const bf=e=>e._swarm?e._swarm.axis:"y"===e.schema.discrete?"x":"y";function _f(e){return!(!Array.isArray(e)||e.length>2)&&(void 0===e[0]||null===e[0])!=(void 0===e[1]||null===e[1])}function kf(e,t){if("x"!==t&&"y"!==t)return;const n=e[`_${t}Config`]?.domain;if(!_f(n)||!((e,t)=>e.schema.discrete!==t&&!e.schema[`${t}Sort`]&&e._swarm?.cross!==t)(e,t))return;const i=n.slice();return"y"===t&&2===i.length?i.reverse():i}const vf=(e,t)=>kf(e,t)??e.schema[`${t}Domain`];function wf(e){const t=e._userBaseline;if("number"!=typeof t||!Number.isFinite(t))return;const n=bf(e);if(e[`_${n}Time`]||e.schema[`${n}Sort`])return;const i=e[`_${n}Config`];return"log"===i?.scale&&t<=0?void 0:n}function Sf(e,t){return Boolean(vf(e,t))||wf(e)===t}function Cf(e,t){const n=e[`_${t}Config`]?.domain;return Array.isArray(n)&&n.some(e=>null!=e)&&!_f(n)}function Mf(e,t,n){return Cf(e,t)?"none":n}function $f(e,t,n){const i=e[`_${t}Config`]?.rounding;return i??Mf(e,t,n)}function Af(e,t){const n=e[`_${t}Config`]?.domain;if(void 0!==n&&!kf(e,t))return!1;const i=vf(e,t);return i?_f(i):wf(e)===t}function zf(e,t){const n=e[`_${t}Config`]??{};if(!Af(e,t))return n;const i={...n};return delete i.rounding,kf(e,t)&&delete i.domain,i}function Df(e,t,n){const i=vf(e,t),o=i?i.slice():void 0;if(wf(e)!==t)return o;const a=e._userBaseline,r=n?.[1],s="number"==typeof r&&r<=a?1:0,c=o??[];return void 0===c[s]&&(c[s]=a),c}function Ff({stackKey:e,fromZero:t}){return function({data:n,x:i,y:o,x2:a,y2:r,buffer:s=10}){const c=a?"x2":"x",l=r?"y2":"y",u="x"===this.schema.discrete?o:i,d=u.domain().slice(),f="x"===this.schema.discrete;let m,p;if(f&&d.reverse(),this.schema.stacked){const t=h.groups(n,t=>e(t,this.schema.discrete)).map(([,e])=>e.map(e=>e[f?l:c]));p=t.map(e=>h.sum(e.filter(e=>e>0))),m=t.map(e=>h.sum(e.filter(e=>e<0)))}else{const e=n.map(e=>e[f?l:c]);p=t?e.filter(e=>e>0):e,m=t?e.filter(e=>e<0):e}let g=u(h.max(p));t&&!(f?g<u(0):g>u(0))||(g+=f?-s:s),g=u.invert(g);let y=u(h.min(m));return t&&!(f?y>u(0):y<u(0))||(y+=f?s:-s),y=u.invert(y),g>d[1]&&(d[1]=g),y<d[0]&&(d[0]=y),f&&d.reverse(),u.domain(d),[i,o]}}var Bf=Ff({stackKey:(e,t)=>`${e[t]}_${e.group}`,fromZero:!0}),Lf=Ff({stackKey:(e,t)=>e[t],fromZero:!1});const Pf=(e,t,n)=>{if(e.padding)e.padding(.5);else{const i=Array.from(new Set(t.map(e=>+e[n]))).reduce((e,t,n,i)=>{if(!n)return e;const o=i[n-1];return!e||t-o<e?t-o:e},0),o=e.domain().slice();"y"===n&&o.reverse(),o[0]=new Date(+o[0]-i/2),o[1]=new Date(+o[1]+i/2),"y"===n&&o.reverse(),e.domain(o)}},Rf=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,e<0?1:0);function Ef(e,t,n,i,o,a,r){if(void 0===n||isNaN(o[0])||isNaN(o[1]))return o;if(r&&(o=o.slice().reverse()),o[0]===o[1]){if(o=o.slice(),"log"===t)(o=[(c=o[0],Math.pow(10,Math.floor(Math.log10(Math.abs(c))))*Math.pow(-1,c<0?1:0)),Rf(o[0])])[1]<o[0]&&o.reverse();else{const e=Math.abs(parseFloat(o[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));o[0]-=e,o[1]+=e}return e.domain(r?o.slice().reverse():o),r?o.reverse():o}var c;const l=o[0]===o[1]?10:Math.abs(Math.log(o[1]-o[0])/100),h=()=>{let o=e.copy(),c=!1;if("log"===t){let t=e.domain().slice(),n=e.range().slice();if(r&&(t=t.reverse(),n=n.reverse()),c=t[0]*t[1]<0,c){const e=s.scaleLog().domain([1e-6,Math.abs(t[a])]).range([0,1])(Math.abs(t[a?0:1])),i=e/(e+1)*(n[1]-n[0]);t=(0===a?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),n=0===a?[n[0],n[0]+i]:[n[0]+i,n[1]]}o=s.scaleLog().domain(t).range(n)}let l=!1;const h=o.range();let u;return u=o("log"===t&&c?Math.abs(n):n),r?0===a?l=u+i>h[a]:1===a&&(l=u-i<h[a]):0===a?l=u-i<h[a]:1===a&&(l=u+i>h[a]),l};if(e.invert&&h()){const s=10;if("log"===t){let t=0;for(;t<10&&h();){const n=(0===a?-1:1)*(o[a]<0?-1:1);o[a]+=o[a]*l*n,e.domain(r?o.slice().reverse():o),t++}}else if(0===a){const t=e.invert(e(n)+(i+s)*(r?1:-1));t<o[a]&&(o[a]=t,e.domain(r?o.slice().reverse():o))}else if(1===a){const t=e.invert(e(n)+(i+s)*(r?-1:1));t>o[a]&&(o[a]=t,e.domain(r?o.slice().reverse():o))}}return r?o.reverse():o}const Nf={Bar:Bf,Box:Lf,Circle:function({data:e,x:t,y:n,x2:i,y2:o,yScale:a,xScale:r,config:s,buffer:c}){t=t.copy(),n=n.copy();const l=i?"x2":"x",h=o?"y2":"y";let u=t.domain().slice(),d=n.domain().slice();return!t.invert&&t.padding&&Pf(t,e,this.schema.discrete),!n.invert&&n.padding&&Pf(n,e,this.schema.discrete),(t.invert||n.invert)&&e.forEach(e=>{const i=s?.r,o=c||2*("function"==typeof i?i(e.data,e.i):Number(i)||0);t.invert&&(u=Ef(t,r??"linear",e[l],o,u,0,!1),u=Ef(t,r??"linear",e[l],o,u,1,!1)),n.invert&&(d=Ef(n,a??"linear",e[h],o,d,0,!0),d=Ef(n,a??"linear",e[h],o,d,1,!0))}),[t,n]},Line:function({data:e,x:t,y:n,x2:i,y2:o}){const a=i?"x2":"x",r=o?"y2":"y",s="x"===this.schema.discrete?n:t,c=s.domain().slice();"x"===this.schema.discrete&&c.reverse();const l=e.map(e=>e["x"===this.schema.discrete?r:a]),u=s.invert(s(h.max(l))+("x"===this.schema.discrete?-10:10));return u>c[1]&&(c[1]=u),"x"===this.schema.discrete&&c.reverse(),s.domain(c),[t,n]},Rect:function({data:e,x:t,y:n,x2:i,y2:o,yScale:a,xScale:r,config:s}){t=t.copy(),n=n.copy();const c=i?"x2":"x",l=o?"y2":"y";let h=t.domain().slice(),u=n.domain().slice();return!t.invert&&t.padding&&Pf(t,e,this.schema.discrete),!n.invert&&n.padding&&Pf(n,e,this.schema.discrete),(t.invert||n.invert)&&e.forEach(e=>{if(t.invert){const n=(s?.width)(e.data,e.i);h=Ef(t,r??"linear",e[c],n,h,0,!1),h=Ef(t,r??"linear",e[c],n,h,1,!1)}if(n.invert){const t=(s?.height)(e.data,e.i);u=Ef(n,a??"linear",e[l],t,u,0,!0),u=Ef(n,a??"linear",e[l],t,u,1,!0)}}),[t,n]}};function Tf(e,t,n){const i="x"===e?[t.x,n.bottom]:"x2"===e?[t.x,n.top]:"y"===e?[n.left,t.y]:[n.right,t.y];return[[t.x,t.y],i]}function Of(e,t){return"function"==typeof e?e(t.datum,t.index):e}function Wf(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",e}function jf(e,t,n,i){const o=e.schema.axisHoverConfig.guideConfig||{},a=Of(o.strokeDasharray,t);return t.badges.filter(e=>e.guide).map(e=>Wf({type:"line",key:`plot-axis-hover-guide-${e.axis}`,points:Tf(e.axis,t.point,n),paint:{fill:"none",stroke:Of(o.stroke,t)??i,strokeWidth:Of(o.strokeWidth,t)??1,strokeOpacity:Of(o.strokeOpacity,t)??1,strokeDasharray:Array.isArray(a)?a:Oo(a)}}))}function Hf(e,t){const i=e._plotArea;if(!i)return{guides:[],badges:[]};const o=function(e){return{left:e.x,right:e.x+e.width,top:e.y,bottom:e.y+e.height}}(i),a=t.color||r.colorGray[500];return{guides:jf(e,t,o,a),badges:t.badges.map(i=>function(e,t,i,o,a){const s=e.schema.axisHoverConfig.badgeConfig||{},c=Of(s.fontSize,t)??12,l=Of(s.fontFamily,t)||`${e.schema.fontFamily}`,h=Of(s.fontWeight,t)??400,u=Of(s.padding,t)??4,d=Of(s.fill,t)??a,f=Of(s.fontColor,t)??r.colorContrast(d,e.schema.colorDefaults),m=n.textWidth(i.text,{"font-family":l,"font-size":c,"font-weight":h}),p=function(e,t,n,i){const{width:o,height:a}=n;return"x"===e?{x:t-o/2,y:i.bottom,width:o,height:a}:"x2"===e?{x:t-o/2,y:i.top-a,width:o,height:a}:"y"===e?{x:i.left-o,y:t-a/2,width:o,height:a}:{x:i.right,y:t-a/2,width:o,height:a}}(i.axis,i.at,{width:m+2*u,height:c+2*u},o),g=`plot-axis-hover-badge-${i.axis}`;return Wf({type:"group",key:g,children:[Wf({type:"rect",key:`${g}-box`,...p,rx:Of(s.rx,t)??0,paint:{fill:d}}),Wf({type:"text",key:`${g}-text`,x:0,y:0,transform:{x:p.x+p.width/2,y:p.y+p.height/2},lines:[{text:i.text,x:0,y:0,width:m}],font:{family:l,size:c,weight:h,anchor:"middle",baseline:"middle"},paint:{fill:f}})]})}(e,t,i,o,a))}}function If(e){const t=`curve${e.charAt(0).toUpperCase()}${e.slice(1)}`,n=L[t];return"function"==typeof n?n:L.curveLinear}function Gf(e,t){const n=au(e,"Line").curve,i="function"==typeof n?t?n(t,t.i):void 0:n;return"string"==typeof i&&i?i:"linear"}const Vf="fill-between",qf=1e5;function Yf(){return{fillOpacity:.25}}function Kf(e,t){let n=[];!0===e?n=t.length>=2?[[t[0],t[1]]]:[]:Array.isArray(e)&&(n=e.every(Array.isArray)?e:[e]);const i=new Set(t);return n.filter(e=>e.length>=2).map(e=>[`${e[0]}`,`${e[1]}`]).filter(([e,t])=>e!==t&&i.has(e)&&i.has(t))}function Uf(e,t,n,i){const o=new Map;t.forEach(e=>o.set(`${e.discrete}`,e));const a=[];return e.forEach(e=>{const t=o.get(`${e.discrete}`);if(!t)return;const r={pos:n(e),a:i(e),b:i(t)};[r.pos,r.a,r.b].every(Number.isFinite)&&a.push(r)}),a}function Xf(e,t,n,i){const o=y.area().curve(If(i));return n?o.x(e=>e.pos).y0(t).y1(e=>e.a):o.y(e=>e.pos).x0(t).x1(e=>e.a),o(e)||""}function Qf(e){const{viz:t}=e,n=e.values,i=Kf(t.schema.fillBetween,function(e){return Array.from(new Set(e.map(e=>`${e.id}`)))}(n));if(!i.length)return[];const o="x"===(t.schema.discrete||"x"),a=e.shapeConfig.x,r=e.shapeConfig.y,s=o?a:r,c=o?r:a,l=Gf(t,n[0]);return i.flatMap(e=>function(e,t,[n,i],o){const a=t.filter(e=>`${e.id}`===n),r=t.filter(e=>`${e.id}`===i),s=Uf(a,r,o.pos,o.val);if(s.length<2)return[];const c=Zf(t,o.val,o.horizontal?"y":"x"),l=`${Vf}-${n}-${i}`,h=[{id:`${l}-${n}`,above:n,below:i,rep:a[0],edge:-c*qf},{id:`${l}-${i}`,above:i,below:n,rep:r[0],edge:c*qf}],u=h.flatMap(e=>{const t={...e.rep.data,above:e.above,below:e.below};return s.map(n=>({__d3plus__:!0,data:t,i:e.rep.i,id:e.id,...n}))}),d=o.horizontal?{x:e=>e.pos,x0:e=>e.pos,x1:null,y:e=>e.a,y0:e=>e.b,y1:e=>e.a}:{y:e=>e.pos,y0:e=>e.pos,y1:null,x:e=>e.a,x0:e=>e.b,x1:e=>e.a},f=eu("Area").renderMode("compute").data(u).config({...d,curve:o.curve,duration:e.schema.duration,label:!1,fill:tm(e),strokeWidth:0}).config(function(e){return au(e,"Area",{...em(e),...e.schema.fillBetweenConfig})}(e));f.render();const m=su(f);return h.flatMap(e=>{const t=m.filter(t=>t.key===e.id||t.key===`${e.id}-bgimage`);if(!t.some(t=>t.key===e.id))return[];t.forEach(e=>e.interactive=!1);const n=Xf(s,e.edge,o.horizontal,o.curve);return[{type:"group",key:`${e.id}::clip`,interactive:!1,clip:{type:"path",d:n},children:t}]})}(t,n,e,{pos:s,val:c,horizontal:o,curve:l}))}function Zf(e,t,n){const i=e[0];for(const o of e){const e=Number(o[n])-Number(i[n]),a=t(o)-t(i);if(e&&a)return Math.sign(e)===Math.sign(a)?1:-1}return"y"===n?-1:1}const Jf=["texture","textureDefault","backgroundImage","backgroundImageFit"];function em(e){const t=e.schema.shapeConfig??{},n=t.Area??{},i={};for(const e of Jf){const o=void 0!==n[e]?n[e]:t[e];void 0!==o&&(i[e]=o)}return i}function tm(e){return(t,n)=>{const{Line:i,stroke:o}=e.schema.shapeConfig,a=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof a?a(t,n):a}}function nm(){return{fillOpacity:.05,fontSize:12,fontOpacity:.7,lineDasharray:"6 4",strokeDasharray:"4 4",strokeOpacity:.4,strokeWidth:1}}function im(e,t){return e instanceof Date?+e:f.finite(e)?e:t}function om(e){const t=new Map;return e.forEach((e,n)=>{t.has(`${e}`)||t.set(`${e}`,n)}),e=>im(e,t.get(`${e}`)??NaN)}function am(e){return e.reduce((e,t)=>!e||t.at<e.at?t:e,void 0)}function rm(e,t=!1){const n=om(e.map(e=>e.value)),i=new Map;e.forEach(e=>{const t=i.get(e.series)??[];t.push({value:e.value,at:n(e.value),forecast:e.forecast}),i.set(e.series,t)});const o=new Map;for(const[e,n]of i){const i=am(n.filter(e=>e.forecast&&Number.isFinite(e.at)));if(!i)continue;const a=n.filter(e=>e.at<i.at);if(a.length){const t=a.reduce((e,t)=>t.at>e.at?t:e);o.set(e,{value:t.value,next:i.value,at:t.at})}else t&&o.set(e,{value:i.value,next:i.value,at:i.at})}return o}function sm(e,t){const n=e.schema.discrete||"x",i=e.schema.forecast;let o;if("function"==typeof i)o=Boolean(i(t.data,t.i));else{const i=t["x"===n?"y":"x"];o=(e._confidence||[]).some(e=>{const n=e?e(t.data,t.i):void 0;return f.finite(n)&&n!==i})}return{series:`${t.id}`,value:t[n],forecast:o}}function cm(e){let t;const n=[];for(const i of e._trendFits||[])i.samples.forEach((e,o)=>{const a=e[i.axis],r=im(a,o);e.step?n.push({value:a,at:r}):e.projected||t&&!(r>t.at)||(t={value:a,at:r})});if(!t)return null;const i=am(n.filter(e=>e.at>t.at));return i?{value:t.value,next:i.value,series:new Map}:null}function lm(e,t){const i=e.schema.forecast;if(!1===i||null===i)return null;const o=function(e,t){const i=e.schema.forecast;if(!1===i||null==i)return null;const o=e.schema.discrete||"x";if(!0===i||"auto"===i||"function"==typeof i){const n=rm(t.map(t=>sm(e,t)),"function"==typeof i),o=am(Array.from(n.values()));if(!o)return null;const a=new Map(Array.from(n,([e,t])=>[e,t.value]));return{value:o.value,next:o.next,series:a}}const a=("x"===o?e._xTime:e._yTime)?n.date(i):i,r=t.map(e=>e[o]),s=om([...r,a]),c=s(a),l=am(r.map(e=>({value:e,at:s(e)})).filter(e=>e.at>c));return l?{value:a,next:l.value}:{value:a}}(e,t);if(void 0!==i&&!0!==i&&"auto"!==i&&"function"!=typeof i)return o;const a=cm(e);if(!o||!a)return o||a;const r=e.schema.discrete||"x",s=om(t.map(e=>e[r]));return s(a.value)<s(o.value)?{...a,series:o.series}:o}const hm=new WeakMap,um=new WeakSet,dm=e=>e instanceof Date?String(e.getTime()):String(e);function fm(e){if("function"==typeof e)return e;if("string"==typeof e&&e){const t=Be(e);return hm.set(t,{key:e}),t}}function mm(e,t){return hm.set(e,{text:t}),e}function pm(e,t,n,i={}){const a=new Map;for(const n of e){if(!n.data)continue;const e=dm(n[t]),i=a.get(e);i?i.data.push(n.data):a.set(e,{value:n[t],data:[n.data]})}return Array.from(a.values(),({value:e,data:t})=>{const a=1===t.length?t[0]:o.merge(t,i);return{value:e,size:Number(n(a,0)),data:a}})}function gm(e){let t=0;return e.filter(e=>Number.isFinite(e.size)&&e.size>0).map(({value:e,size:n})=>{const i=t+n,o={value:e,size:n,start:t,end:i,mid:(t+i)/2};return t=i,o})}function ym(e,t,n){const i=e.schema.barWidth,o=e.schema.discrete,a=e._discreteExtent&&!um.has(e._discreteExtent);if("function"!=typeof i||"x"!==o&&"y"!==o||a)return function(e){e._barSpans=void 0,e._discreteExtent&&um.has(e._discreteExtent)&&(e._discreteExtent=void 0)}(e),[t,n];const r=pm(n,o,i,e.schema.aggs),s=e.schema[`${o}Sort`];s&&r.sort((e,t)=>s(e.data,t.data));const c=gm(r),l=new Map(c.map(e=>[dm(e.value),e])),h=new WeakMap,u=e=>e.filter(e=>{const t=l.get(dm(e[o]));return!!t&&(e.data&&h.set(e.data,t),e[o]=t.mid,!0)}),d=u(t),f=n===t?d:u(n),m=c.length?c[c.length-1].end:0,p={axis:o,spans:c,total:m,byDatum:h};e._barSpans=p,"x"===o?e._xTime=!1:e._yTime=!1;const g=e=>{const t=p.byDatum.get(e);return t?[t.start,t.end]:[0,0]};return um.add(g),e._discreteExtent=g,[d,f]}function xm(e){return e instanceof Date?d.formatDate(e,[e]):String(e)}function bm(e,t,n){return e.total?`${d.formatAbbreviate(t.size/e.total*100,n)}%`:""}function _m(e,t,n){return t?"x"===n?`${e}\n${t}`:`${e} (${t})`:e}function km(e,t){const n=e._barSpans;if(!n||n.axis!==t)return{};const i=e.schema.locale,o=n.spans.map(e=>e.mid),a=new Map(n.spans.map(e=>[e.mid,xm(e.value)])),r=e=>a.get(e)??"";if(!e.schema.barWidthShare)return{labels:o,ticks:o,tickFormat:r};const s=new Map(n.spans.map(e=>[e.mid,_m(xm(e.value),bm(n,e,i),t)]));return{labels:o,ticks:o,tickFormat:e=>s.get(e)??"",rotatedTickFormat:r}}function vm(e){const t=e.schema.barWidth,n=t?hm.get(t):void 0;return n?.key?n.key:e.schema.translate(n?.text??"Width")}function wm(e,t){const n=e._barSpans,i=n&&t&&"object"==typeof t?n.byDatum.get(t):void 0;if(!n||!i)return[];const o=e.schema.locale,a=bm(n,i,o);return[[vm(e),`${d.formatAbbreviate(i.size,o)}${a?` (${a})`:""}`]]}function Sm(e,t){return Boolean(e._discreteExtent)&&e.schema.discrete===t}function Cm(e,t){return e._discreteExtent(t.data)}function Mm(e,t){const n=t.filter(e=>e.data).map(t=>Cm(e,t));return[h.min(n,e=>e[0]),h.max(n,e=>e[1])]}const $m={method:"confidenceConfig",shapes:{Area:"Area",Bar:"Path"},extra:{"":["bandOpacity","capWidth","tooltip"],Bar:["capWidth"]}};const Am=[.15,.6],zm=e=>!!e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype;function Dm(e){const[t,n,i]=Array.isArray(e)?e:zm(e)?[e.lower,e.upper,e.label]:[],o=function(e){const t=e=>"function"==typeof e?e:!("string"!=typeof e||!e)&&Be(e),n=Array.isArray(e)?[t(e[0]),t(e[1])]:[!1,!1];return!(!n[0]&&!n[1])&&n}([t,n]);if(!o)return null;const a={lower:o[0],upper:o[1]};return"string"!=typeof i&&"number"!=typeof i||(a.label=`${i}`),a}function Fm(e){const t=function(e){return Array.isArray(e)&&e.length>0&&e.every(e=>Array.isArray(e)||zm(e))}(e)?e:[e];return t.map(Dm).filter(e=>null!==e)}function Bm(e){const t=e._confidence;if(!t)return[];const n=e._confidenceBands;return n&&n.length?n:[{lower:t[0],upper:t[1]}]}function Lm(e,t,n){return t?Bm(e).map((i,o)=>{const a={label:i.label??`${e.schema.translate("Band")} ${o+1}`},r=i.lower?i.lower(t,n):void 0,s=i.upper?i.upper(t,n):void 0;return f.finite(r)&&(a.lower=r),f.finite(s)&&(a.upper=s),a}):[]}function Pm(e,t){if(t<=0)return[];if(f.finite(e))return Array.from({length:t},()=>e);const n=Array.isArray(e)&&e.length&&e.every(f.finite)?e:Am;if(1===n.length)return Array.from({length:t},()=>n[0]);const i=x.piecewise(x.interpolateNumber,n);return Array.from({length:t},(e,n)=>i(1===t?1:n/(t-1)))}function Rm(e){let t=0;return e.map(e=>{const n=Math.min(1,Math.max(0,e)),i=t>=1?0:Math.max(0,1-(1-n)/(1-t));return t=1-(1-t)*(1-i),+i.toFixed(6)})}function Em(e,t){return null==e||"number"==typeof e&&Number.isNaN(e)?t:e}function Nm(e,t){const n=Bm(e).slice(1),i=[];for(const e of n)for(const n of t){const t=n.data,o=n.i;for(const n of[e.lower,e.upper]){const e=n?n(t,o):void 0;f.finite(e)&&i.push(e)}}return i}function Tm(e){if(!e.length)return 0;const t=e.slice().sort((e,t)=>e[0]-t[0]);let[n,i]=t[0];for(let e=1;e<=t.length;e++){const o=t[e];if(o&&o[0]<i)o[1]>i&&(i=o[1]);else{if(n<0&&i>0)return-n<=i?n:i;o&&([n,i]=o)}}return 0}function Om(e,t=0){const n=e.map(()=>0);if(e.length<2)return n;const i=e.map((e,t)=>t).sort((t,n)=>e[t].value-e[n].value||t-n),o=2*Math.max(...e.map(e=>e.r))+t,a=[];let r=0;for(const s of i){const{value:i,r:c}=e[s];for(;r<a.length&&e[a[r]].value<i-o;)r++;const l=[];for(let o=r;o<a.length;o++){const r=a[o],s=i-e[r].value,h=c+e[r].r+t;if(s<h){const e=Math.sqrt(h*h-s*s);l.push([n[r]-e,n[r]+e])}}n[s]=Tm(l),a.push(s)}return n}function Wm(e,t,n=1){let i=0;return e.forEach((e,o)=>{i=Math.max(i,Math.abs(t[o])+e.r*n)}),i}const jm=(e,t)=>1===t?e:e.map(e=>({value:e.value,r:e.r*t}));function Hm(e,t,n){let i=1;for(let o=0;o<12;o++){const o=Wm(e,Om(jm(e,i),t*i),i);if(o<=n||0===o)break;i*=Math.max(.5,.98*Math.sqrt(n/o))}return i}function Im(e,t){const{padding:n,extent:i,overflow:o}=t,a="shrink"===o&&i>0?Math.min(1,...e.map(e=>Hm(e,n,i))):1;return{offsets:e.map(e=>{const t=Om(jm(e,a),n*a);return"visible"===o?t:t.map((t,n)=>{const o=Math.max(0,i-e[n].r*a);return Math.max(-o,Math.min(o,t))})}),scale:a}}const Gm=e=>null==e||""===e,Vm=e=>"number"==typeof e&&Number.isFinite(e)||e instanceof Date,qm=e=>e.some(Vm)&&e.every(e=>Gm(e)||Vm(e));function Ym(e,t){if(!e||!t.length)return null;const n=t.map(e=>e.x),i=t.map(e=>e.y);let o;if("x"===e||"y"===e)o=e;else if("auto"===e){if(!t.every(e=>"Circle"===e.shape))return null;i.every(Gm)?o="x":n.every(Gm)&&(o="y")}else o=qm(n)?"x":"y";if(!o||!qm("x"===o?n:i))return null;const a="x"===o?"y":"x",r=t.some(e=>!Gm(e[a])&&!Vm(e[a]));return{axis:o,cross:a,lanes:r}}function Km(e,t){const{cross:n,lanes:i}=t;for(const t of e)t[n]=i&&!Gm(t[n])?`${t[n]}`:""}const Um=(e,t)=>!!e._swarm&&e._swarm.cross===t&&!e._swarm.lanes;function Xm(e,t){const n=e._swarm,i=e.schema.swarmConfig||{},{axis:o,cross:a}=n,r="x"===o?t.x:t.y,s="x"===a?t.x:t.y,c="x"===a?t.xRange:t.yRange,l=Math.abs(c[c.length-1]-c[0]),h=new Map;n.lanes&&t.lanes.forEach(e=>h.set(`${e}`,s(e,a)));const u=Array.from(h.values()).sort((e,t)=>e-t);let d=u.length>1?1/0:l;for(let e=1;e<u.length;e++)d=Math.min(d,u[e]-u[e-1]);const f=(c[0]+c[c.length-1])/2,m=new Map;t.values.forEach((e,n)=>{const i=`${e[a]}`;m.has(i)||m.set(i,{rows:[],nodes:[]});const s=m.get(i);s.rows.push(e),s.nodes.push({value:r(e[o]),r:Math.max(0,Number(t.r(e,n))||0)})});const p=i.padding??1,g=Array.from(m.values()),y=Im(g.map(e=>e.nodes),{padding:p,extent:Math.max(0,d/2-p/2),overflow:i.overflow??"shrink"}),x=new Map;return g.forEach((e,t)=>{e.rows.forEach((n,i)=>{const r=h.get(`${n[a]}`)??f,s=e.nodes[i].value,c=r+y.offsets[t][i];x.set(n,{x:"x"===o?s:c,y:"x"===o?c:s,r:e.nodes[i].r*y.scale})})}),x}const Qm=["x","x2","y","y2"];function Zm(e,t){const n=e._plotFacetScales?.padded;if(!n)return t;const i={...t};for(const e of Qm){const t=i[e];t&&n[e]&&"function"==typeof t.invert&&(i[e]=t.copy().domain(n[e]))}return i}function Jm(e,t){const n=e.schema[`${t}Break`],i={break:void 0!==n&&n},o=zf(e,t),a={...km(e,t),...e._plotAxisDefaults?.[t]};if(!Object.keys(a).length)return{...i,...o};const r=Object.fromEntries(Object.entries(o).filter(([,e])=>void 0!==e));return G({...i,...a},r)}function ep(e,t){const n=Boolean(e.schema.baselineBreak)&&bf(e)===t,{baseline:i}=e.schema;return"number"==typeof i?{baseline:i,baselineBreak:n}:{baselineBreak:n}}function tp(e,t,n,i=e.schema[`${t}Domain`]){if(!e.schema.baselineBreak||t!==bf(e)||"linear"!==n)return!1;const{baseline:o}=e.schema;if("number"!=typeof o||!Array.isArray(i))return!1;const[a,r]=i;return"number"==typeof a&&a>o||"number"==typeof r&&r<o}function np(e,t){const n="y"===bf(e),i=(n?e._yAxis:e._xAxis)?._baselineBreak,o=n?e._yFunc:e._xFunc;if(!i||!o)return t;const a=o(i.edge),r=o(i.value);if(!Number.isFinite(a)||!Number.isFinite(r))return t;const s=n?1:0;return t.map(e=>(e[s]-a)*(r-a)<=0?e:n?[e[0],a]:[a,e[1]])}function ip(e,t){const n="y"===bf(e),i=n?e._yAxis:e._xAxis;if(!i||"function"!=typeof i._getRange)return;const o=i._getRange().map(Number);if(o.length<2||o.some(e=>!Number.isFinite(e)))return;const a=n?t.x2Height:0,r=n?t.yOffset:0;return[Math.min(o[0],o[o.length-1])-a-r,Math.max(o[0],o[o.length-1])-a]}function op(e,t,n){if(!n)return e;const[i,o]=n,a=e=>"number"==typeof e&&Number.isFinite(e)?Math.min(o,Math.max(i,e)):e,r=Object.assign({},e);for(const e of[t,`${t}0`,`${t}1`]){const t=r[e];if("function"==typeof t){const n=t;r[e]=function(...e){return a(n.apply(this,e))}}else"number"==typeof t&&(r[e]=a(t))}return r}function ap(e,t,n){if(!_f(e)||!t)return;const i=e=>null!=e,o=t.slice();return"number"==typeof n&&(o[0]>n?o[0]=n:o[1]<n&&(o[1]=n)),{pinned:[i(e[0]),i(e[1])],auto:o}}function rp(e,t,n,i){const o=t.pinned[0]?1:0,a=On(o?[+t.auto[0],e[1]]:[e[0],+t.auto[1]],n,i);if(!a)return;const r=a[o];if(o?r<=e[0]:r>=e[1])return;const s=e.slice();return s[o]=r,s}const sp=(e,t)=>e[`_${t}Config`]?.rounding??e._plotAxisDefaults?.[t]?.rounding??"outside",cp=({viz:e,plotScales:t,plotConfigScales:n,plotOpenEnds:i})=>{if(!t||!n||!i)return{};const o={...t};for(const t of["x","y"]){const a=i[t],r=n[`${t}ConfigScale`],s=sp(e,t);if(!a||!Tn.includes(r)||"none"===s)continue;const c=o[t],l=e=>"y"===t?e.slice().reverse():e,h=rp(l(c.domain().map(Number)),a,s,r);h&&(o[t]=c.copy().domain(l(h)))}return{plotScales:o}},lp=B;function hp(e,t){return t?e.map(e=>void 0===e?e:n.date(e)):e.slice()}function up(e,t,n,i){const o=e[`_${t}Time`]?"Time":!Sm(e,t)&&(e.schema.discrete===t||e.schema[`${t}Sort`])||e._swarm?.cross===t?"Point":"Linear",a=n[t]?hp(n[t],e[`_${t}Time`]):i[t],r=e.schema[`${t}2Domain`]?hp(e.schema[`${t}2Domain`],e[`_${t}2Time`]):i[`${t}2`];return"Point"!==o&&(a&&void 0===a[0]&&(a[0]=i[t][0]),a&&void 0===a[1]&&(a[1]=i[t][1]),r&&void 0===r[0]&&(r[0]=i[`${t}2`][0]),r&&void 0===r[1]&&(r[1]=i[`${t}2`][1])),[a,o,r,o]}function dp(e,t,n,i){const o=e[`_${n}Config`].scale;if("auto"===o){if(e.schema.discrete===n)return i;const o=t.map(e=>e[n]);return h.deviation(o)/h.mean(o)>3?"log":"linear"}return o||i}const fp=(e,t)=>e.map(e=>e[t]).filter(e=>![NaN,void 0,!1].includes(e));const mp=({viz:e,plotFormattedData:t,plotAxisData:n,plotInitialDomains:i})=>{const o=t||[],a=n||[];let r=i;const s=e.schema.width-e._margin.left-e._margin.right,c=e.schema.height-e._margin.top-e._margin.bottom,l=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,u=e.schema.discrete?"x"===e.schema.discrete?"y2":"x2":void 0,d=[l,u].filter(e=>e),f={x:Df(e,"x",r.x),y:Df(e,"y",r.y)},m={x:ap(f.x,r.x,d.includes("x")?e.schema.baseline:void 0),y:ap(f.y,r.y,d.includes("y")?e.schema.baseline:void 0)},[p,g,y,x]=up(e,"x",f,r),[b,_,k,v]=up(e,"y",f,r),w=dp(e,a,"y",_).toLowerCase(),S=dp(e,a,"y2",v).toLowerCase(),C=dp(e,a,"x",g).toLowerCase(),M=dp(e,a,"x2",x).toLowerCase();r={x:p,x2:y||p.slice(),y:b,y2:k||b.slice()},function(e,t,n,i){Object.keys(t).forEach(o=>{"log"===e[`_${o}ConfigScale`]&&t[o].includes(0)&&(h.min(t[o])<0?t[o][1]=h.max(fp(n,o)):t[o][0]=h.min(fp(i,o)))})}(e,r,o,a),function(e,t,n,i,o){n.forEach(n=>{if(e[`_${n}Config`].domain&&!kf(e,n)){const i=e[`_${n}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),t[n]=i}else if(n&&void 0!==e.schema.baseline&&!tp(e,n,n.startsWith("x")?i.x:i.y,o[n])){const i=e.schema.baseline;t[n]&&t[n][0]>i?t[n][0]=i:t[n]&&t[n][1]<i&&(t[n][1]=i)}})}(e,r,d,{x:C,y:w},f);const $=lp[`scale${g}`]().domain(r.x).range(h.range(0,s+1,s/(r.x.length-1))),A=lp[`scale${x}`]().domain(r.x2).range(h.range(0,s+1,s/(r.x2.length-1))),z=lp[`scale${_}`]().domain(r.y.slice().reverse()).range(h.range(0,c+1,c/(r.y.length-1))),D=lp[`scale${v}`]().domain(r.y2.slice().reverse()).range(h.range(0,c+1,c/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:$,y:z,x2:A,y2:D,xScale:g,yScale:_,x2Scale:x,y2Scale:v},plotConfigScales:{xConfigScale:C,yConfigScale:w,x2ConfigScale:M,y2ConfigScale:S},plotOpps:{opp:l,opp2:u,opps:d},plotOpenEnds:m}},pp="::confidence";function gp(e,t,n){const i=t<0?n[0]:n[1],o=t<0?n[1]:n[0];return i+(e-t)*(t?(i-o)/t:1)}function yp(e,t,n){const i=e[t],o={};for(const[t,a]of[["lower",e.lci],["upper",e.hci]])f.finite(a)&&(n&&f.finite(i)&&f.finite(n[0])&&f.finite(n[1])?o[t]=gp(a,i,n):n||(o[t]=a));return o}function xp(e,t,n,i){const o={lower:f.finite(e),upper:f.finite(t)};if(!i)return{lower:e,upper:t,end:n,caps:o};const[a,r]=i,s=(e,t)=>{if(!f.finite(e))return e;const n=f.clamp(e,a,r);return n!==e&&(o[t]=!1),n};return{lower:s(e,"lower"),upper:s(t,"upper"),end:f.clamp(n,a,r),caps:o}}function bp(e){return{capWidth:"50%",stroke:(t,n)=>{const{Bar:i,fill:o}=e.schema.shapeConfig,a=i&&void 0!==i.fill?i.fill:o,r="function"==typeof a?a(t,n):a,s=l.color(r);return s?s.darker(1.5).formatHex():r},strokeWidth:2}}function _p(e,t){return!(!f.finite(t)||!e)&&e.some(e=>t>Math.min(e.start,e.end)&&t<Math.max(e.start,e.end))}function kp(e,t){const{viz:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:a}=e,r="y"===n.schema.discrete?"y":"x",s="x"===r?"y":"x",c="x"===r?e.y:e.x,l=function(e,t,n){const i="y"===t?e.viz._yAxis:e.viz._xAxis,o=i&&!i._d3ScaleNegative&&i._d3Scale?i._d3Scale.domain():[],a=o.length?[o[0],o[o.length-1]].map(e=>n(e)):[];if(2!==a.length||!a.every(f.finite))return e.valueExtent;const r=Math.min(a[0],a[1]),s=Math.max(a[0],a[1]);return e.valueExtent?[Math.max(r,e.valueExtent[0]),Math.min(s,e.valueExtent[1])]:[r,s]}(e,s,c),h=("y"===s?n._yAxis:n._xAxis)?._breaks,u=new Map;for(const e of t){if("rect"!==e.type||"Bar"!==e.shapeType||`${e.key}`.endsWith("::hit"))continue;const t=e.datum;if(!t||u.has(t))continue;const d=n.schema.stacked?i[o.get(t.id)??-1]?.[a.get(t.discrete)??-1]:void 0;if(n.schema.stacked&&!d)continue;const m=yp(t,s,d);if(!f.finite(m.lower)&&!f.finite(m.upper))continue;const p=void 0!==t[`${s}2`]?`${s}2`:void 0,g=e=>f.finite(e)?c(e,p):void 0,y=e.transform??{},x=t[s],b=xp(g(m.lower),g(m.upper),c(d?x<0?d[0]:d[1]:x,p),l);_p(h,m.lower)&&(b.caps.lower=!1),_p(h,m.upper)&&(b.caps.upper=!1),u.set(t,{key:e.key,center:"x"===r?(y.x??0)+e.x+e.width/2:(y.y??0)+e.y+e.height/2,thickness:"x"===r?e.width:e.height,...b})}return u}function vp(e,t){const{viz:n}=e;if(!n._confidence)return[];const i=kp(e,t);if(!i.size)return[];const o=au(n,"Bar",{...bp(n),...n._confidenceConfig??{}}),a=o.capWidth;delete o.capWidth,delete o.tooltip;const r="y"===n.schema.discrete?"y":"x",s=e=>i.get(e),c=eu("Path").renderMode("compute").config(o).config({d:(e,t)=>{const n=s(e),i="function"==typeof a?a(e,t):a;return function(e,t,n,i,o,a,r={}){const s=f.finite(o)?o:i,c=f.finite(a)?a:i,l=n/2,h=(t,n)=>"x"===e?`${n},${t}`:`${t},${n}`;let u=`M${h(s,t)}L${h(c,t)}`;for(const[e,n]of[[o,r.lower],[a,r.upper]])f.finite(e)&&!1!==n&&l>0&&(u+=`M${h(e,t-l)}L${h(e,t+l)}`);return u}(r,n.center,function(e,t){if(f.finite(e))return Math.max(0,e);if("string"==typeof e&&e.trim().endsWith("%")){const n=parseFloat(e);if(f.finite(n))return Math.max(0,t*n/100)}return t/2}(i,n.thickness),n.end,n.lower,n.upper,n.caps)},fill:"none",hitArea:{"stroke-width":10},id:e=>`${s(e).key}${pp}`,label:!1,x:0,y:0}).data(Array.from(i.keys()));return n._wirePlotShapeEvents(c,"Bar",e.events),su(c).map(e=>({...e,shapeType:"Bar"}))}function wp(e){return e.__d3plusStackOrder=!0,e}function Sp(e){let t,n=-1,i=0;const o=e.length;for(;++n<o;)(t=+e[n][1])&&(i+=t);return i}const Cp=wp(e=>L.stackOrderAscending(e)),Mp=wp(e=>L.stackOrderDescending(e)),$p=wp(e=>{const t=e.map(Sp),n=e.map(e=>e.key.split("_")[0]);return L.stackOrderNone(e).sort((e,i)=>n[e].localeCompare(n[i])||t[e]-t[i])}),Ap=wp(e=>$p(e).reverse());function zp(e,t="descending"){return wp(n=>{const i=n.map(t=>{let n=0;for(let i=0;i<t.length;i++){const o=(t[i].data||[]).find(e=>e.id===t.key);if(o&&o.data){const t=+e(o.data);isNaN(t)||(n+=t)}}return n});return L.stackOrderNone(n).sort((e,n)=>"ascending"===t?i[e]-i[n]:i[n]-i[e])})}const Dp={ascending:Cp,descending:Mp,key:$p,keyReverse:Ap,none:wp(e=>L.stackOrderNone(e)),data:wp(e=>L.stackOrderNone(e)),insideOut:wp(e=>L.stackOrderInsideOut(e)),appearance:wp(e=>L.stackOrderAppearance(e)),reverse:wp(e=>L.stackOrderReverse(e))},Fp=Object.keys(Dp);function Bp(e){if("function"==typeof e)return e.__d3plusStackOrder?e:zp(e);if(Array.isArray(e))return e;if(e&&"object"==typeof e){const{value:i,order:o}=e;return"function"==typeof i?zp(i,o):(t=zp(T(i),o),n=i,Fe.set(t,n),t)}var t,n;return"string"==typeof e?e in Dp?Dp[e]:(console.warn(`[d3plus] Unknown stackOrder "${e}". Expected one of: ${Fp.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),Mp):Mp}function Lp(e,t){let n,i,o,a,r,s;if(!((n=e.length)>0))return;const c=e[t[0]].length;for(let l=0;l<c;++l)for(s=r=0,a=0;a<n;++a)(o=(i=e[t[a]][l])[1]-i[0])>=0?(i[0]=s,i[1]=s+=o):o<0?(i[1]=r,i[0]=r+=o):i[0]=s}const Pp={diverging:Lp,none:L.stackOffsetNone,expand:L.stackOffsetExpand,silhouette:L.stackOffsetSilhouette,wiggle:L.stackOffsetWiggle},Rp=Object.keys(Pp);function Ep(e){return"function"==typeof e?e:"string"==typeof e&&e in Pp?Pp[e]:(console.warn(`[d3plus] Unknown stackOffset "${e}". Expected one of: ${Rp.join(", ")}; or an offset function. Falling back to "diverging".`),Lp)}const Np=[k.timeYear,k.timeMonth,k.timeDay,k.timeHour,k.timeMinute,k.timeSecond];function Tp(e){const t=e.slice().sort((e,t)=>e-t),n=t.length>>1;return t.length%2?t[n]:(t[n-1]+t[n])/2}function Op(e,t){if(!t)return[];const i=function(e){const t=e.some(e=>e instanceof Date);if(e.some(e=>!(e instanceof Date)&&"number"!=typeof e))return null;const n=Array.from(new Set(e.map(Number).filter(Number.isFinite))).sort((e,t)=>e-t);if(n.length<2)return null;const i=n.slice(1).map((e,t)=>e-n[t]);if(!t){const e=Tp(i);return(t,n)=>+(t+e*n).toPrecision(12)}const o=n.map(e=>new Date(e)),a=Np.find(e=>o.every(t=>+e.floor(t)===+t));if(a){const e=Math.round(Tp(o.slice(1).map((e,t)=>a.count(o[t],e))));if(e>0)return(t,n)=>a.offset(t,e*n)}const r=Tp(i);return(e,t)=>new Date(+e+r*t)}(e);if(!i)return[];const o=e.some(e=>e instanceof Date),a=e.reduce((e,t)=>+t>+e?t:e,e[0]);if("number"==typeof t){const e=Math.min(Math.floor(t),1e3);return Array.from({length:Math.max(e,0)},(e,t)=>i(a,t+1))}const r=t.to;if(null==r)return[];const s=o?n.date(r):+r;if(!Number.isFinite(+s))return[];const c=[];for(let e=1;e<=1e3;e++){const t=i(a,e);if(+t>+s)break;c.push(t)}return c}const Wp=["linear","exponential","logarithmic","power","polynomial"];function jp(e){return!0===e?"linear":Wp.includes(e)?e:null}function Hp(e){return"y"===e?"y":"x"}function Ip(e,t,n=50){const[i,o]=e;return t?t.filter(e=>e>=i&&e<=o):i===o?[i]:Array.from({length:n},(e,t)=>i+(o-i)*t/(n-1))}function Gp(e,t,n){const[i,o]=e,a=Math.max(...t);if(!(a>o))return[];if(n)return[o,...n.filter(e=>e>o&&e<=a)];const r=o>i?Math.round(50*(a-o)/(o-i)):50,s=Ip([o,a],null,Math.min(Math.max(r,2),50)+1);return Array.from(new Set([...s,...t.filter(e=>e>o)])).sort((e,t)=>e-t)}function Vp(e,t,n,i=[]){const o=jp(e._trendLine);if(!o||!t.length)return[];const a=e._trendLineConfig||{},r=Hp(e.schema.discrete),s="x"===r?"y":"x",{toNumber:c,fromNumber:l}=function(e){const t=e.map(e=>`${e}`),n=e.some(e=>!(e instanceof Date)&&"number"!=typeof e),i=e.some(e=>e instanceof Date);return{toNumber:e=>{if(e instanceof Date)return+e;if(!n&&"number"==typeof e)return e;const i=t.indexOf(`${e}`);return i<0?NaN:i},fromNumber:t=>n?e[Math.round(t)]:i?new Date(t):t}}(n.concat(i)),u=function(e,t){return!e[`_${t}Time`]&&(e.schema.discrete===t&&!Sm(e,t)||!!e.schema[`${t}Sort`])}(e,r)?n.concat(i).map(c).filter(Number.isFinite):null,d=i.length?n.concat(i).map(c).filter(Number.isFinite):[],m="log"===`${e[`_${s}Config`]?.scale}`.toLowerCase(),p=e.schema.shapeConfig.fill,g=[];for(const[n,i,y,x]of function(e,t,n,i){const o="x"===n?"y":"x",a=e=>[i(e[n]),+e[o]];if(e.schema.stacked)return[["all",h.groups(t,e=>i(e[n])).map(([e,t])=>[e,t.reduce((e,t)=>e+(+t[o]||0),0)]),void 0,-1]];const r=[["all",t.map(a),void 0,-1]];if("all"===e._trendLineConfig?.group)return r;const s=n=>h.groups(t,t=>function(e,t,n){return e._ids(t.data,t.i).slice(0,n+1).join("_")}(e,t,n)).map(([e,t])=>[e,t.map(a),t[0],n]),c=e._drawDepth,l=s(c);return l.some(([,e])=>e.length>1)?l:c>0?s(c-1):r}(e,t,r,c)){const t=f.regression(i,o,{order:a.order});if(!t)continue;const c=a.confidence&&"linear"===o,h=a.confidenceLevel,b=c?f.linearConfidence(i,h):null,_=c?f.linearPrediction(i,h):null,k=[],v=(e,n)=>{const i=t.predict(e);if(!Number.isFinite(i)||m&&i<=0)return;const o={[r]:l(e),[s]:i},a=n?_:b;a&&([o.lci,o.hci]=a(e)),n&&(o.projected=!0),n&&e>t.extent[1]&&d.includes(e)&&(o.step=!0),k.push(o)};if(Ip(t.extent,u).forEach(e=>v(e,!1)),Gp(t.extent,d,u).forEach(e=>v(e,!0)),k.length<2)continue;const w=y?y.data:void 0,S=a.stroke?a.stroke:w?"function"==typeof p?p(w,y.i):p:"#444",C=w?e._drawLabel(w,y.i,x):e.schema.translate("Trend Line");g.push({id:n,label:C,color:S,axis:r,fit:t,samples:k,row:w})}return g}function qp(e){const t=[];for(const{axis:n,samples:i}of e){const e="x"===n?"y":"x";for(const n of i)t.push(n[e]),void 0!==n.lci&&t.push(n.lci,n.hci)}return t.filter(Number.isFinite)}const Yp=({viz:e,plotFormattedData:t,xData:n,yData:i})=>{const o=Hp(e.schema.discrete),a=("x"===o?n:i)||[],r=jp(e._trendLine)?Op(a,e._trendLineConfig?.projection):[],s=e._trendFits=e._swarm?[]:Vp(e,t||[],a,r);if(!s.length)return{};const c=qp(s),l="x"===o?{yData:(i||[]).concat(c)}:{xData:(n||[]).concat(c)};return s.some(e=>e.samples.some(e=>e.projected))?{...l,[`${o}Data`]:a.concat(r)}:l};function Kp(e,t){const{data:n,axisData:i,xData:o,yData:a,opp:r,stackGroup:s}=t;!function(e,t,n){const i=t.filter(e=>["Area","Bar"].includes(e.shape)),o=h.groups(i,e=>e.group).reduce((e,[t,i])=>(e[t]||(e[t]=0),e[t]+=h.sum(i,e=>e[n]),e),{});t.sort((t,i)=>{if(e.schema[`${e.schema.discrete}Sort`])return e.schema[`${e.schema.discrete}Sort`](t.data,i.data);const a=t[e.schema.discrete],r=i[e.schema.discrete];return a-r!==0?a-r:t.group!==i.group?o[i.group]-o[t.group]:i[n]-t[n]})}(e,i,r);const c=Array.from(new Set(i.map(e=>e.discrete))),l=Array.from(new Set(i.map(e=>e.id))),u=h.groups(i,e=>e.discrete).map(([,e])=>e);!1!==e._stackShares&&function(e,t){const n=e.filter(e=>["Area","Bar"].includes(e.shape)),i=new Map;for(const e of n)i.set(e.discrete,(i.get(e.discrete)||0)+Math.abs(+e[t]||0));for(const e of n){const n=i.get(e.discrete),o=n?Math.abs(+e[t]||0)/n:0;wr(e,o),e.data&&wr(e.data,o)}}(n,r),function(e,t){const{axisData:n,data:i,stackData:o,stackKeys:a,stackGroup:r,opp:s}=t;o.forEach(t=>{const o=Array.from(new Set(t.map(e=>e.id)));o.length<a.length&&a.forEach(a=>{if(!o.includes(a)){const o=n.filter(e=>e.id===a)[0],c=o.shape;if("Area"===c){const n=r(o.data,o.i),l={__d3plus__:!0,data:o.data,discrete:"Bar"===o.shape?`${t[0][e.schema.discrete]}_${n}`:`${t[0][e.schema.discrete]}`,group:n,id:o.id,ids:a,shape:c,[e.schema.discrete]:t[0][e.schema.discrete],[s]:0};i.push(l)}}})})}(e,{axisData:i,data:n,stackData:u,stackKeys:l,stackGroup:s,opp:r}),e.schema[`${e.schema.discrete}Sort`]?n.sort((t,n)=>e.schema[`${e.schema.discrete}Sort`](t.data,n.data)):n.sort((t,n)=>t[e.schema.discrete]-n[e.schema.discrete]);const d=new Set(i.filter(e=>e.data?._isAggregation).map(e=>e.id)),m=function(e,t,n,i,o){const a=e._stackOrder;Array.isArray(a)&&t.sort((e,t)=>a.indexOf(e)-a.indexOf(t));const r=Array.isArray(a)?L.stackOrderNone:a;return L.stack().keys(t).offset(e._stackOffset).order(o.size?function(e,t){return n=>{const i=e(n),o=e=>t.has(n[e].key);return i.filter(e=>!o(e)).concat(i.filter(o))}}(r,o):r).value((e,t)=>{const n=e.filter(e=>e.id===t);return n.length?n[0][i]:0})(n)}(e,l,u,r,d),p="x"===e.schema.discrete?o:a,g=qp(e._trendFits||[]);!e._confidence||"x"!==r&&"y"!==r||g.push(...function(e,t,n,i,o){const a=[];for(const r of e){if("Bar"!==r.shape)continue;const e=n[i.indexOf(r.id)],s=e&&e[o.indexOf(r.discrete)];if(!s)continue;const{lower:c,upper:l}=yp(r,t,s);f.finite(c)&&a.push(c),f.finite(l)&&a.push(l)}return a}(i,r,m,l,c));const y="x"===e.schema.discrete?e._xTime:e._yTime;return{plotInitialDomains:{[e.schema.discrete]:e._discreteExtent?Mm(e,i):y?h.extent(p):p,[r]:[h.min([...m.map(e=>h.min(e.map(e=>e[0]))),...g]),h.max([...m.map(e=>h.max(e.map(e=>e[1]))),...g])]},plotDiscreteKeys:c,plotStackData:m,plotStackKeys:l}}const Up=({viz:e,plotFormattedData:t,plotAxisData:n,xData:i,x2Data:o,yData:a,y2Data:r,plotStackGroup:s})=>{const c=t||[],l=n||[],u=s,d=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,f=e.schema.stacked?Kp(e,{data:c,axisData:l,xData:i||[],yData:a||[],opp:d,stackGroup:u}):function(e,t){const{axisData:n,xData:i,x2Data:o,yData:a,y2Data:r}=t,s=e._xTime,c=e._x2Time,l=e._yTime,u=e._y2Time,d=e.schema.discrete||"x";return e.schema[`${e.schema.discrete}Sort`]?n.sort((t,n)=>e.schema[`${e.schema.discrete}Sort`](t.data,n.data)):n.sort((e,t)=>e[d]-t[d]),{plotInitialDomains:{x:Sm(e,"x")?Mm(e,n):!s&&"x"===e.schema.discrete||e.schema.xSort||"x"===e._swarm?.cross?i:h.extent(i),x2:!c&&"x"===e.schema.discrete||e.schema.x2Sort?o:h.extent(o),y:Sm(e,"y")?Mm(e,n):!l&&"y"===e.schema.discrete||e.schema.ySort||"y"===e._swarm?.cross?a:h.extent(a),y2:!u&&"y"===e.schema.discrete||e.schema.y2Sort?r:h.extent(r)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(e,{axisData:l,xData:i||[],x2Data:o||[],yData:a||[],y2Data:r||[]}),m=e._plotFacetScales?.domains;return m&&f.plotInitialDomains&&(f.plotInitialDomains={...f.plotInitialDomains,...m}),f};function Xp(e,t,n){const i=au(e,"Line");t.config(i);const o=t.labelConfig(),a=void 0!==o.fontColor?o.fontColor:n.fontColor(),r=void 0!==o.fontSize?o.fontSize:n.fontSize(),s=void 0!==o.fontWeight?o.fontWeight:n.fontWeight(),c=void 0!==o.fontFamily?o.fontFamily:n.fontFamily(),l=void 0!==o.padding?o.padding:n.padding();return{labelFunction:i.label||e._drawLabel,fontColorAccessor:a,fontSizeAccessor:r,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l}}function Qp(e,t,n){return i=>("log"===t&&0===i&&(i=e._givenDomain()[n[0]<0?1:0]),e._getPosition.bind(e)(i))}const Zp=({viz:e,plotFormattedData:t,plotScales:i,plotConfigScales:o,plotTestAxes:a,plotLineLabelTest:r,y2Exists:s})=>{const c=t||[];if(!e.schema.lineLabels||s)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const l=c.filter(t=>"Line"===t.shape&&("function"!=typeof e.schema.lineLabels||e.schema.lineLabels(t.data,t.i))),u=h.groups(l,e=>e.id);if(!u.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const{testLineShape:d,testTextBox:f}=r,{xTest:m,yTest:p}=a,g=i.x.domain(),y=i.y.domain(),x=o.xConfigScale,b=o.yConfigScale,_=e.schema.width-e._margin.left-e._margin.right,k={...Xp(e,d,f),xEstimate:Qp(m,x,g),yEstimate:Qp(p,b,y)},v=u.map(e=>function([e,t],i){const{labelFunction:o,fontColorAccessor:a,fontSizeAccessor:r,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l,xEstimate:u,yEstimate:d}=i;let f,m=t[t.length-1];for(;m.__d3plus__&&m.data;)m=m.data,f=m.i;const p="function"==typeof o?o(m,f):o,g="function"==typeof a?a(m,f):a,y="function"==typeof r?r(m,f):r,x="function"==typeof s?s(m,f):s;let b="function"==typeof c?c(m,f):c;Array.isArray(b)&&(b=b.map(e=>`'${e}'`).join(", "));const _="function"==typeof l?l(m,f):l,k=n.textWidth(p,{"font-size":y,"font-family":b,"font-weight":x}),v=t.map(e=>[u(e.x),d(e.y)]),w=h.max(t.map(e=>u(e.x))),S=t.find(e=>u(e.x)===w).y;return{id:e,labelWidth:k+2*_,spaceNeeded:k+4*_,value:S,yEstimate:d(S),padding:_,fontSize:y,fontColor:g,maxX:w,xValue:h.max(t,e=>e.x),coords:v}}(e,k)).sort((e,t)=>y[1]>y[0]?e.value-t.value:t.value-e.value).filter((e,t,n)=>!function(e,t){const{fontSize:n,id:i,labelWidth:o,maxX:a,yEstimate:r}=e;return 0!==t.filter(e=>e.id!==i&&e.coords.some(t=>(t[0]>a||t[0]===a&&e.maxX!==a)&&t[0]<=a+o&&t[1]<=r+.75*n&&t[1]>=r-.75*n)).length}(e,n)),w=h.max(v,e=>e.maxX),S=h.max(v.map(e=>e.labelWidth));let C;const M=w===m._getRange.bind(m)()[1]?h.max(v.filter(e=>e.maxX===w),e=>e.spaceNeeded):0;if(M){C=_-h.min([M,_/4])-e._margin.right}return{plotLabelWidths:v,plotLargestLabel:S,plotXRangeMax:C}};function Jp(e,t){const i=()=>Ga(e);return n.assign({barConfig:{stroke:i},baselineBreakConfig:{stroke:i},breakConfig:{stroke:i},shapeConfig:{fill:i,labelConfig:{fontColor:i},stroke:i},titleConfig:{fontColor:i}},t)}function eg(e){return Sf(e,"x")||e._discreteExtent&&"x"===e.schema.discrete?"none":"outside"}function tg(e,t){const{xData:n,xScalePadding:i}=t;return Jp(e,{data:n,locale:e.schema.locale,rounding:Mf(e,"x",eg(e)),scalePadding:i,...ep(e,"x")})}const ng=({viz:e,plotAxisData:t,plotScales:n,x2Exists:i,y2Exists:a,x2Data:r,y2Data:s,yData:c})=>{const l=t||[],{x:h,y:u,x2:d,y2:f,xScale:m,yScale:p,x2Scale:g,y2Scale:y}=n,x=h.domain(),b=d.domain(),_=u.domain(),k=f.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},w=Sf(e,"y")||Sm(e,"y")?"none":"outside",S={...i?{data:r}:v,baselineBreak:!1,rounding:$f(e,"x2",eg(e))},C={...a?{data:s}:v,baselineBreak:!1,rounding:$f(e,"y2",w)},{showX:M,showY:$}=function(e){return{showX:"x"===e.schema.discrete?e.schema.width>e._discreteCutoff&&e.schema.width>e.schema.xCutoff:e.schema.width>e.schema.xCutoff&&!Um(e,"x"),showY:"y"===e.schema.discrete?e.schema.height>e._discreteCutoff&&e.schema.height>e.schema.yCutoff:e.schema.height>e.schema.yCutoff&&!Um(e,"y")}}(e),A=function(e,t,n,i,o){const a={data:n,locale:e.schema.locale,rounding:Mf(e,"y",i),scalePadding:t.padding?t.padding():0,scaleAlign:t.align?t.align():.5,...ep(e,"y")};return o.showX||!o.showY||e._swarm||(a.barConfig={stroke:"transparent"},a.tickSize=0,a.shapeConfig={labelBounds:(t,n)=>{const{width:i,y:o}=t.labelBounds,a=e.schema.height/2;return{x:n?-a:0,y:o,width:i,height:a}},labelConfig:{padding:0,rotate:0},labelRotation:!1}),a}(e,u,c,w,{showX:M,showY:$}),z=function(e,t){const n=au(e,"Bar"),i=void 0!==n.label?"function"==typeof n.label?n.label:()=>n.label:e._drawLabel,o=[],a=[];for(const e of t){if("Box"===e.shape)continue;const t=i(e.data,e.i);("number"==typeof t||t)&&(o.push(String(t)),a.push(e))}return{labels:o,rows:a}}(e,l),D=z.labels;let F;const B=(t,n)=>{if(Sm(e,t))return function(e,t){const n=new Set;return t.filter(e=>e.data).forEach(t=>Cm(e,t).forEach(e=>n.add(e))),Array.from(n).sort((e,t)=>e-t)}(e,l);const i=o.unique(l.map(e=>e[t]));return"Point"===n&&i.every(e=>D.includes(`${e}`))?("x"!==t&&"y"!==t||t===e.schema.discrete&&("x"===t?M:$)&&(F={axis:t,...z}),[]):null},L=B("x",m),P=B("x2",g),R=B("y",p),E=B("y2",y);return{plotDefaultConfig:v,plotDefaultX2Config:Jp(e,S),plotDefaultY2Config:Jp(e,C),plotShowX:M,plotShowY:$,plotYC:Jp(e,A),plotBarLabels:D,plotBarLabelCheck:F,plotXTicks:L,plotX2Ticks:P,plotYTicks:R,plotY2Ticks:E,plotXDomain:x,plotX2Domain:b,plotYDomain:_,plotY2Domain:k}},ig=e=>null===e||"number"==typeof e&&!Number.isFinite(e)||Array.isArray(e)&&0===e.length;function og(e,t){const n=h.extent(t);return lp[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(n).range([n[0]===n[1]?e.schema.sizeMax:h.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}const ag=(e,t)=>(e._plotCircleShapes??["Circle"]).includes(t);function rg(e,t){const{xTime:i,x2Time:o,yTime:a,y2Time:r}=t,s=i||o||a||r,c=(t,n)=>`${!s&&e.schema.time?e.schema.time(t,n):"time"}_${e.schema.stacked?((t,n)=>e._stackGroup?e._stackGroup(t,n):e.schema.groupBy.length>1?e._ids(t,n).slice(0,-1).join("_"):"group")(t,n):`${e._ids(t,n).join("_")}`}`;return{prepData:(t,s)=>{const l={__d3plus__:!0,data:t,group:c(t,s),i:s,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,s),id:e._ids(t,s).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,s),shape:e.schema.shape(t,s),x:i?n.date(e._x(t,s)):e._x(t,s),x2:o?n.date(e._x2(t,s)):e._x2(t,s),y:a?n.date(e._y(t,s)):e._y(t,s),y2:r?n.date(e._y2(t,s)):e._y2(t,s)};return l.discrete="Bar"===l.shape?`${l[e.schema.discrete]}_${l.group}`:`${l[e.schema.discrete]}`,l.id="Bar"===l.shape?`${l.id}_${l[e.schema.discrete]}`:l.id,l},stackGroup:c}}const sg=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return e._sizeLegendFinal=null,e._swarm=null,{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const{prepData:t,stackGroup:n}=rg(e,function(e){const t=!!e.schema.time&&e.schema.time(e._filteredData[0],0),n=e._x2Time=t&&e._x2(e._filteredData[0],0)===t,i=e._xTime=t&&e._x(e._filteredData[0],0)===t,o=e._y2Time=t&&e._y2(e._filteredData[0],0)===t;return{xTime:i,x2Time:n,yTime:e._yTime=t&&e._y(e._filteredData[0],0)===t,y2Time:o}}(e)),i=function(e){const t=e.schema.discrete;if(!t||Sm(e,t))return null;if("x"===t?e._xTime:e._yTime)return null;const n=("x"===t?e._xConfig:e._yConfig)?.domain,i=Array.isArray(n)?n:e.schema[`${t}Domain`];return Array.isArray(i)&&i.length?new h.InternSet(i):null}(e),o=t=>(e=>!(ig(e.x)||ig(e.y)||void 0!==e.x2&&ig(e.x2)||void 0!==e.y2&&ig(e.y2)))(t)&&(!i||i.has(t[e.schema.discrete])),a=e._filteredData.map(t).filter(o),[r,s]=ym(e,a,e._axisPersist?e._data.map(t).filter(o):a);e._formattedData=r;const c=e._swarm=Ym(e.schema.swarm,s);c&&(Km(r,c),s!==r&&Km(s,c)),function(e,t){e._sizeScaleD3=e._size?e._plotFacetScales?.size??og(e,t.map(t=>e._size(t.data))):()=>e.schema.sizeMin,e._sizeLegendFinal=e._size&&t.some(t=>ag(e,t.shape))?e._sizeScaleD3:null}(e,s);const l=s.some(e=>void 0!==e.x2),u=s.some(e=>void 0!==e.y2);return{plotFormattedData:r,plotAxisData:s,x2Exists:l,y2Exists:u,plotStackGroup:n}},cg=({viz:e,plotFormattedData:t,plotAxisData:i})=>{const a=t||[],r=i||[];function s(t){const i=e[`_${t}Time`],s=i?a:r,c=e._plotAxisRows?e._plotAxisRows(s,t):s,l=c.filter(e=>![NaN,void 0,!1].includes(e[t])),u=e._plotAxisValues?e._plotAxisValues(c,t):[];if(!l.length)return u;const d="number"==typeof l[0][t];let f=e.schema.discrete===t?h.rollups(l,t=>1===t.length?t[0].data:o.merge(t.map(e=>e.data),e.schema.aggs),e=>e[t]).sort((n,o)=>{if(e.schema[`${t}Sort`])return e.schema[`${t}Sort`](n[1],o[1]);return(i||d?parseFloat(n[0]):n[0])-(i||d?parseFloat(o[0]):o[0])}).map(([e])=>i?n.date(e):d?parseFloat(e):e):o.unique(l.sort((n,i)=>e.schema[`${t}Sort`]?e.schema[`${t}Sort`](n.data,i.data):n[t]-i[t]).map(e=>e[t]),e=>`${e}`);return e.schema.discrete!==t.charAt(0)&&e._confidence&&(e._confidence[0]&&(f=f.concat(c.map(e=>e.lci))),e._confidence[1]&&(f=f.concat(c.map(e=>e.hci))),f=f.concat(Nm(e,c))),u.length?f.concat(u):f}return{xData:s("x"),x2Data:s("x2"),yData:s("y"),y2Data:s("y2")}},lg=({viz:e,plotFormattedData:t,plotAxisData:n,plotScales:i,plotConfigScales:o})=>{const a=t||[],r=n||[];let{x:s,y:c,x2:l,y2:u}=i;const{xConfigScale:d,yConfigScale:f,x2ConfigScale:m,y2ConfigScale:p}=o,g=i.xScale,y=i.yScale;if("Point"!==("x"===e.schema.discrete||"y"===e._swarm?.axis?y:g)){h.groups(r,e=>e.shape).forEach(([t,n])=>{if(["Bar","Box"].includes(t)&&!e._discreteExtent&&Pf("x"===e.schema.discrete?s:c,a,e.schema.discrete),e._buffer[t]){const i=e._buffer[t].bind(e)({data:n,x:s,y:c,yScale:f,xScale:d,config:e.schema.shapeConfig[t]});s=i[0],c=i[1];const o=e._buffer[t].bind(e)({data:n,x:l,y:u,yScale:p,xScale:m,x2:!0,y2:!0,config:e.schema.shapeConfig[t]});l=o[0],u=o[1]}})}return{plotScales:Zm(e,{...i,x:s,y:c,x2:l,y2:u})}},hg={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:N("Circle"),tooltipShared:!0,trendLine:!1}};function ug(e){return this._sizeScaleD3(this._size?this._size(e):null)}function dg(e,t,n,i){const o=("y"===t?e._y:e._x)(n,i),a="y"===t?e._yAxis:e._xAxis;return o<0!==Boolean(a?.schema?.reverse)}function fg(e,t){if(this.schema.stacked)return!1;const n=this._labelPosition(e,t);if("outside"===n)return!0;if("inside"===n)return!1;const i="x"===this.schema.discrete.charAt(0)?"y":"x",o=this.schema.discrete.replace(this.schema.discrete.charAt(0),i),a="y"===o?this._yAxis:this._xAxis,r="y"===o?this._y:this._x,s=a._d3Scale.range(),c=r(e,t),l=dg(this,o,e,t),h=a._getPosition(0),u="y"===o?l?s[1]-h:h-s[0]:l?h-s[0]:s[1]-h,d=a._getPosition(c);return Math.abs(l?h-d:d-h)<u/2}function mg(e){return!!e._confidence&&!1!==e._confidenceConfig?.tooltip}function pg(e,t,n){const i={},o=e._confidence;if(!o||!t)return i;const[a,r]=o,s=a?a(t,n):void 0,c=r?r(t,n):void 0;return f.finite(s)&&(i.lower=s),f.finite(c)&&(i.upper=c),i}function gg(e,t,n,i){if(!mg(e))return[];if(Bm(e).length>1)return yg(e,t,n,i);const{lower:o,upper:a}=pg(e,t,n),r=[];return f.finite(o)&&r.push([e.schema.translate("Lower Bound"),i(o)]),f.finite(a)&&r.push([e.schema.translate("Upper Bound"),i(a)]),r}function yg(e,t,n,i){return Lm(e,t,n).map(({label:e,lower:t,upper:n})=>[e,bg(t,n,i)]).filter(([,e])=>e)}function xg(e,t,n){const i=bg(e,t,n);return i?` (${i})`:""}function bg(e,t,n){const i=f.finite(e),o=f.finite(t);return i&&o?`${n(e)} – ${n(t)}`:i?`≥ ${n(e)}`:o?`≤ ${n(t)}`:""}const _g=e=>"x"===e?"y":"x";function kg(e,t){const n=e[`_${t}Config`];if(n&&"string"==typeof n.title)return n.title;const i=e[`_${t}Key`];return"string"==typeof i?i:""}function vg(e,t,n){const i=e[`_${t}Config`];if(i&&"function"==typeof i.tickFormat)return i.tickFormat(n);const o=function(e,t,n){if(!e[`_${t}Time`])return;const i=pn(n);if(!i)return;const o=e[`_${t}Axis`];return o&&"time"===o.schema.scale?_n(o,i):d.formatDateFull(i,[i])}(e,t,n);if(void 0!==o)return o;if(wn(n)){const i=e[`_${t}Axis`];return i?_n(i,n):d.formatDateFull(n,[n])}if("number"==typeof n&&t!==e.schema.discrete){const i=e[`_${t}Axis`];return i&&Fn(i)?Bn(n,e.schema.locale):d.formatAbbreviate(n,e.schema.locale)}return String(n)}function wg(e,t,n){const i=n.rows[0],o=e[`_${t}`],a=o&&!i.projected?o(i.datum,i.index):n.value;return[kg(e,t),vg(e,t,a)]}function Sg(e,t,n){const i=n.nativeEvent,o=i&&i.touches&&i.touches.length?[i.touches[0].clientX,i.touches[0].clientY]:i?[i.clientX,i.clientY]:n.point,a=e._zoomTransform,r=e._chartTransform,s=t.axis,c=(t.px+(r?.[s]??0))*(a?.scale??1)+(a?.[s]??0),l="x"===s?0:1,h=[o[0],o[1]];return h[l]=o[l]-n.point[l]+c,h}function Cg(e){const t=e._tooltipClass;e._sharedTooltipSaved||(e._sharedTooltipSaved={arrow:t.arrow(),thead:t.thead(),tbody:t.tbody()});const n=e._sharedTooltipSaved;return t.thead(n.thead).tbody(n.tbody).titleSwatch(!0)}function Mg(e,t,n){const i=n=>vg(e,t,n),o=n.projected;return o?void 0===o.lci||void 0===o.hci?"":xg(o.lci,o.hci,i):function(e,t,n,i){if(!mg(e))return"";const{lower:o,upper:a}=pg(e,t,n);return xg(o,a,i)}(e,n.datum,n.index,i)}function $g(e,t,n){const i=_g(t.axis),{header:o,names:a}=function(e,t){const n=` (${e.schema.translate("Projected")})`,i=wg(e,t.axis,t),o=t.rows.every(e=>e.projected);return{header:o?[i[0],`${i[1]}${n}`]:i,names:t.rows.map(e=>e.projected&&!o?`${e.name}${n}`:e.name)}}(e,t);Cg(e).data([t.rows[0].datum]).config(Ae.bind(e)(e.schema.tooltipConfig)).title(()=>kg(e,i)).thead(o).tbody(t.rows.flatMap((t,n)=>[[Nr(Er(t.color,t.shape),a[n]),`${vg(e,i,t.value)}${Mg(e,i,t)}`],...Br(e,t.datum,5)])).footer(!1).arrow(!1).position(Sg(e,t,n)).render()}function Ag(e){return{label:(t,n)=>!!e.schema.stacked&&e._drawLabel(t,n),labelBounds:(t,n,i)=>{const o=np(e,i.points);let a=f.largestRect(o,{angle:h.range(-20,20,5)});if((!a||a.height<20||a.width<50)&&(a=f.largestRect(o,{angle:h.range(-80,80,5)})),!a)return null;const r=h.min(i.points,e=>e[0]),s=h.max(i.points.filter(e=>e[0]===r),e=>e[1]);return{angle:a.angle,width:a.width,height:a.height,x:a.cx-a.width/2-r,y:a.cy-a.height/2-s}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}function zg(e){const t=(t,n)=>wn(n)?vg(e,t,n):n;return(n,i)=>{let o;return n.nested?o=`${e._drawLabel(n.data,n.i)}`:(o=`${e._drawLabel(n,i)}`,void 0!==e._x(n,i)&&(o+=`, x: ${t("x",e._x(n,i))}`),void 0!==e._y(n,i)&&(o+=`, y: ${t("y",e._y(n,i))}`),void 0!==e._x2(n,i)&&(o+=`, x2: ${t("x",e._x2(n,i))}`),void 0!==e._y2(n,i)&&(o+=`, y2: ${t("y",e._y2(n,i))}`)),`${o}.`}}function Dg(e){return{curve:()=>e.schema.discrete?`monotone${e.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:N("none"),labelConfig:{fontColor:(t,n)=>{const i="function"==typeof e.schema.shapeConfig.Line.stroke?e.schema.shapeConfig.Line.stroke(t,n):e.schema.shapeConfig.Line.stroke;return r.colorLegible(i)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:N(2)}}function Fg(){return{Area:Ag(this),ariaLabel:zg(this),Bar:{labelBounds(e,t,n){const i="y"===this.schema.discrete?"width":"height",o="y"===this.schema.discrete?"height":"width",a="x"===this.schema.discrete.charAt(0)?"y":"x",r="y"===a,s=this.schema.discrete.replace(this.schema.discrete.charAt(0),a),c=("y"===s?this._yAxis:this._xAxis)._d3Scale.range(),l=Math.abs(c[1]-c[0]),h=dg(this,s,e,t);return fg.bind(this)(e,t)?{[i]:l-n[i],[o]:n[o],x:r?-n.width/2:h?-l:n.width+1,y:r?h?n.height+1:-l:-n.height/2+1}:{[i]:n[i],[o]:n[o],x:r?-n.width/2:h?(this.schema.stacked,1-n.width):-1,y:r?h?(this.schema.stacked,1):1-n.height:-n.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(e,t){if(fg.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return r.colorContrast(e,this.schema.colorDefaults)}return r.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(e,t):this.schema.shapeConfig.fill,this.schema.colorDefaults)},fontStroke(e,t){if(fg.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return r.colorContrast(e,this.schema.colorDefaults)}return"transparent"},fontStrokeWidth(e,t){return fg.bind(this)(e,t)?.1:0},padding:3,textAnchor(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",o="y"===i,a=dg(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),i),e,t),r=o?"middle":fg.bind(this)(e,t)?a?"end":"start":a?"start":"end";return n.rtl()?"start"===r?"end":"end"===r?"start":r:r},verticalAlign(e,t){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=dg(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),e,t);return i?fg.bind(this)(e,t)?o?"top":"bottom":o?"bottom":"top":"middle"}}},Circle:{r:ug.bind(this),trail:!0},Line:Dg(this),Rect:{height:e=>2*ug.bind(this)(e),width:e=>2*ug.bind(this)(e),trail:!0}}}const Bg=[{key:"axisHover",coerce:"identity",default:!0},{key:"axisHoverConfig",merge:!0,factory:function(){return{guideConfig:{strokeDasharray:"4 3",strokeWidth:1},badgeConfig:{fontSize:12,fontWeight:400,padding:4,rx:2}}}},{key:"barPadding",coerce:"identity"},{key:"baselineBreak",coerce:"identity"},{key:"fillBetween",coerce:"identity",default:!1},{key:"fillBetweenConfig",merge:!0,factory:Yf},{key:"forecast",coerce:"identity"},{key:"forecastConfig",merge:!0,factory:nm},{key:"lineLabels",coerce:"identity"},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"stacked",coerce:"identity"},{key:"swarm",coerce:"identity",default:"auto"},{key:"swarmConfig",merge:!0,factory:()=>({padding:1,overflow:"shrink"})},{key:"tooltipShared",coerce:"identity"},{key:"xBreak",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yBreak",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}];function Lg(e){const t=hg.defaults;e._axisPersist=t.axisPersist,e._annotations=t.annotations,e._backgroundConfig={duration:0,fill:"transparent"},e.schema.barPadding=t.barPadding,e._buffer=n.assign({},Nf,{Bar:!1,Line:!1}),e._confidence=!1,e._confidenceConfig={fill:(t,n)=>{const{Line:i,stroke:o}=e.schema.shapeConfig,a=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof a?a(t,n):a},fillOpacity:N(.5)},e._crosshairConfig={stroke:r.colorGray[500],strokeDasharray:"4 3",strokeWidth:1},e._discreteCutoff=t.discreteCutoff,e._groupPadding=t.groupPadding,e._labelConnectorConfig={strokeDasharray:"1 1"},e._labelPosition=N("auto"),e._lineMarkerConfig={fill:(t,n)=>r.colorAssign(e._id(t,n),rt(e)),r:N(3)},e._lineMarkers=t.lineMarkers,e._previousAnnotations={back:[],front:[]},e._previousShapes=[],e.schema.shape=t.shape,e.schema.shapeConfig=n.assign(e.schema.shapeConfig,Fg.call(e)),e._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],e.schema.shapeSort=(t,n)=>e._shapeOrder.indexOf(t)-e._shapeOrder.indexOf(n),e.schema.tooltipShared=t.tooltipShared,e.schema.sizeMax=20,e.schema.sizeMin=5,e.schema.sizeScale="sqrt",e._stackOffset=Lp,e._stackOrder=Mp,e.schema.threshold=N(0),e._thresholdMemberFormat=t=>vg(e,"y"===e.schema.discrete?"x":"y",t),e.schema.timelineConfig=n.assign(e.schema.timelineConfig,{brushMin:()=>e._xTime||e._yTime||e._x2Time||e._y2Time?2:1})}const Pg=["ellipsis","fontFamily","fontMax","fontMin","fontResize","fontSize","fontWeight","lineHeight","maxLines","overflow","padding","split"];function Rg(e,t,n,i){if(!e.length)return!0;const o=function(e,t){const n=new ro;for(const i of Pg){const o=e[i];if(void 0!==o)if("split"===i||"function"!=typeof o)n[i](o);else{const e=o;n[i]((n,i)=>e(t[i].data,t[i].i))}}return n}(i,t);return e.every((e,t)=>{const i=io(o,{text:e,width:n.width,height:n.height},t);return!!i&&!i.truncated&&""!==i.lines.join("")})}function Eg(e,t,n,i,o){const a="y"===e.schema.discrete?"y":"x",r=new Map;for(const e of t){const t=String(e[a]);r.set(t,(r.get(t)??0)+1)}const s=e.schema.stacked?1:h.max(Array.from(r.values()))??1,c=function(e,t,n,i,o){const a="x"===e?t.width:t.height,r=("x"===e?t.height:t.width)/2;let s=a/Math.max(1,n);return o.group<s&&(s-=o.group),i>1&&(s=(s-o.bar*i-1)/i),s=Math.max(0,s),"x"===e?{width:s,height:r}:{width:r,height:s}}(a,i,r.size,s,{group:e._groupPadding??0,bar:e.schema.barPadding??0});return Rg(n,t,c,o)}function Ng(e,t,n){const i=au(e,"Bar").labelConfig||{};return!Eg(e,t.rows,t.labels,n,i)}function Tg(e,t,n){const{xTest:i,x2Test:o,showX:a,x2Exists:r,width:s}=e,c=e.xRangeMax||void 0;a&&i.range([t,c]).measure(),r&&o.range([t,c]).measure();const l=i._getRange()[1],u=o._getRange()[1];return h.max([0,n,s-l,s-u])}function Og(e,t,n){const{yDomain:i,y2Domain:o,yConfigScale:a,y2ConfigScale:r}=t,{defaultY2Config:s,showY:c,y2Exists:l,yC:u}=t,{yTicks:d,x2TestRange:f,xTestRange:m,height:p,width:g}=t,{yTest:y,y2Test:x}=t;let{xOffsetRight:b}=t;c&&y.domain(i).height(p).maxSize(g/2).range(n).ticks(d).width(g).config(u).config(Jm(e,"y")).scale(a).measure();const _=y.outerBounds(),k=_.width?_.width+y.padding():void 0,v=h.max([0,k,m[0],f[0],e._plotMinLeft?.()]);l&&x.config(u).domain(o).gridSize(0).height(p).range(n).width(g-h.max([0,b-t.y2Width])).title(!1).config(e._y2Config).config(s).scale(r).measure();const w=x.outerBounds(),S=w.width?w.width+x.padding():void 0;return b=Tg(t,v,S),{yBounds:_,yWidth:k,y2Bounds:w,y2Width:S,xOffsetLeft:v,xOffsetRight:b}}function Wg(e,t){const{xTest:n,showX:i,xLabelMode:o}=e;if(i&&(!o||"axis"===o))return n.range(t).measure(),n.outerBounds().height+n.padding()}function jg(e,t,n){const{x2Height:i,topOffset:o,height:a,horizontalMargin:r,verticalMargin:s}=t,c=(t,r=0)=>{const c=a-(t+o+s),l=n?.insetBottom??Math.max(0,e._plotInsetBottom?.(c-i)??0)+r;return{yBottom:c,insetBottom:l,yRange:[i,c-l]}};let l=c(t.xHeight),h=n||Og(e,t,l.yRange);for(let i=0;!n&&i<3;i++){const n=Wg(t,[h.xOffsetLeft,t.width-(h.xOffsetRight+r)]);if(void 0===n||n===t.xHeight)break;e._padding.bottom+=n-t.xHeight,t={...t,xHeight:n},l=c(n),h=Og(e,t,l.yRange)}const u=n?0:function(e,t){const n=[e.yTest,...e.y2Exists?[e.y2Test]:[]],i=Math.max(0,...n.map(e=>e._labelOverflow?.[1]??0));return Math.max(0,Math.ceil(i-(e.xHeight+t)))}(t,l.insetBottom);return u&&(l=c(t.xHeight,u),h=Og(e,t,l.yRange)),{pCtx:t,...l,solved:h}}const Hg={labels:[]},Ig=(e,t,n)=>"function"==typeof e?e(t,n):e;function Gg(e,t,n){const i=!(n||Um(e,"y")&&e.schema.height>e.schema.yCutoff);return t&&i&&void 0===e._xConfig?.labels}function Vg(e){const t=e._getDomain();if(!t.length)return[];const n="time"===e.schema.scale,[i,o]=[t[0],t[t.length-1]].map(e=>n?+e:e);return i===o||i instanceof Date&&o instanceof Date&&+i===+o?[i]:[i,o]}function qg(e){const t=e.schema.shapeConfig,i=t.labelConfig||{},o=e._labelFormat||(e=>`${e}`);let r=0,s=0;const c=Vg(e).map((e,c)=>{const l=Ig(i.fontSize??12,e,c),h=t.lineHeight?t.lineHeight(e,c):1.4*l,u=`${o(e)??""}`,d=a.textWrap().fontFamily(n.fontExists(Ig(i.fontFamily??a.fontFamily,e,c))).fontSize(l).fontWeight(Ig(i.fontWeight??400,e,c)).lineHeight(h).width(Number.MAX_SAFE_INTEGER).height(h)(u),f=d.lines.filter(e=>""!==e);return r=Math.max(r,Math.ceil(f.length*h)),s=Math.max(s,Ig(i.padding??0,e,c)),{value:e,text:u,width:f.length?Math.ceil(Math.max(...d.widths)):0}});return{labels:c,padding:s,height:r}}function Yg(e,t){const n=e.height?e.padding+e.height:0;return t-n>=n?n:0}function Kg(e,t,n,i){const o=Math.max(0,n-i);if(e+t<=o)return[o-t,o-e];const a=o/2;return e<=a?[e,o-e]:t<=a?[o-t,t]:[a,a]}function Ug(e,t,n,i=!1){const{labels:o,padding:a,height:r}=e;if(!o.length||!r)return[];const[s,c]=[t[0],t[t.length-1]],l=n+a;if(1===o.length){const[{value:e,text:t}]=o;return[{value:e,text:t,x:s,y:l,width:c-s,height:r,textAnchor:"middle"}]}const[h,u]=o,d=Kg(h.width,u.width,c-s,a);return[{value:h.value,text:h.text,x:s,y:l,width:d[0],height:r,textAnchor:i?"end":"start"},{value:u.value,text:u.text,x:c-d[1],y:l,width:d[1],height:r,textAnchor:i?"start":"end"}]}function Xg(e,t,i){return Ug(qg(e),t,i,n.rtl())}function Qg(e,t){e.measure();const n=e._outerBounds.y+e._margin.top;e.height(e.height()+t-n)}function Zg(e,t){if(!t.length)return null;const n=e.schema.shapeConfig.labelConfig||{},i=(new ro).renderMode("compute").config(n).config({fontResize:!1,padding:0,rotate:0,textAnchor:e=>e.textAnchor,verticalAlign:"top"}).data(t.map((e,n)=>({...e,id:1===t.length?"middle":n?"end":"start",i:n,data:{id:e.value,text:e.text}}))),{children:o}=i.toScene();return o.length?{type:"group",key:"plot-x-end-labels",children:o}:null}function Jg(e,t,n,i,o,a,r){const{xTest:s,x2Test:c,yTest:l,showX:u,showY:d,x2Exists:f,height:m,width:p}=t,{labelWidths:g,largestLabel:y,xRangeMax:x}=function(e,t,n,i,o){const{xTest:a,x2Test:r,xDomain:s,x2Domain:c,xTicks:l,x2Ticks:h,xConfigScale:u,x2ConfigScale:d,defaultX2Config:f,showX:m,x2Exists:p,height:g,width:y}=t;let x;const b=o?Hg:{};m&&a.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(Jm(e,"x")).config(b).scale(u).measure();const{labelWidths:_,largestLabel:k,xRangeMax:v}=i();return void 0!==v&&(x=v),m&&x&&a.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(Jm(e,"x")).config(b).scale(u).measure(),p&&r.domain(c).height(g).range([void 0,x]).ticks(h).width(y).config(n).tickSize(0).config(f).config(e._x2Config).scale(d).measure(),{labelWidths:_,largestLabel:k,xRangeMax:x}}(e,t,n,a,r),b=s._getRange(),_=c._getRange(),k=c.outerBounds(),v=f?k.height+c.padding():0,w=h.max([0,i,b[0],_[0],e._plotMinLeft?.()]),S=l.shapeConfig().labelConfig,C=(d?S.fontSize()/2:0)+(e._plotInsetTop??0),M=Tg({xTest:s,x2Test:c,showX:u,x2Exists:f,xRangeMax:x,width:p},w,o),$=s.outerBounds(),A=r?Yg(qg(s),m-v):0;return{xRangeMax:x,labelWidths:g,largestLabel:y,xTestRange:b,x2TestRange:_,x2Height:v,xOffsetLeft:w,xOffsetRight:M,topOffset:C,xHeight:r?A:$.height+(d||u?s.padding():0),xLabelMode:r?A?"ends":"none":"axis"}}function ey(e,t,n){let i=t;const o=i.barLabelCheck,a="y"===o?.axis&&Ng(e,o,ty(e,i,0,function(e,t){if(!t.showX)return 0;const n=(new ui).align("end").gridSize(0);return n.domain(t.xDomain).height(t.height).maxSize(t.height/2).range([void 0,void 0]).ticks(t.xTicks).width(t.width).config(tg(e,t)).config(Jm(e,"x")).scale(t.xConfigScale).measure(),n.outerBounds().height+n.padding()}(e,i)+function(e,t){const{yTest:n,yC:i,showY:o}=t;o&&n.config(i).config(Jm(e,"y"));const a=n.shapeConfig().labelConfig;return(o?a.fontSize()/2:0)+(e._plotInsetTop??0)}(e,i)));a&&(i={...i,yTicks:null});const{yBounds:r,yWidth:s,y2Bounds:c,y2Width:l}=function(e,t){const{yTest:n,y2Test:i,yDomain:o,y2Domain:a,yTicks:r,y2Ticks:s,yConfigScale:c,y2ConfigScale:l,defaultY2Config:h,yC:u,showY:d,y2Exists:f,height:m,width:p}=t;d&&n.domain(o).height(m).maxSize(p/2).range([void 0,void 0]).ticks(r).width(p).config(u).config(Jm(e,"y")).scale(c).measure();const g=n.outerBounds(),y=g.width?g.width+n.padding():void 0;f&&i.domain(a).height(m).range([void 0,void 0]).ticks(s).width(p).config(u).config(h).config(e._y2Config).scale(l).measure();const x=i.outerBounds();return{yBounds:g,yWidth:y,y2Bounds:x,y2Width:x.width?x.width+i.padding():void 0}}(e,i),h="x"===o?.axis&&Ng(e,o,ty(e,i,(s??0)+(l??0),0));h&&(i={...i,xTicks:null});const u=Gg(e,i.showX,i.showY),d=tg(e,i),f=Jg(e,i,d,s,l,n,u);return e._padding.left+=f.xOffsetLeft,e._padding.right+=f.xOffsetRight,e._padding.bottom+=f.xHeight,e._padding.top+=f.x2Height+f.topOffset,{yBounds:r,y2Bounds:c,yWidth:s,y2Width:l,xC:d,...f,barLabelsOnAxis:a||h,xTicks:i.xTicks,yTicks:i.yTicks}}function ty(e,t,n,i){const o="panel"===e._facetStep?0:wu(e);return{width:t.width-n,height:t.height-i-o}}const ny=new ya,iy=new ro,oy=(e,t)=>yf.prototype._draw.call(e,t);function ay(e,t){if(e._axisHoverState=null,"chrome"===e._facetStep||!e._filteredData.length&&!e._annotations?.length)return oy(e,t),e;const n={xTest:(new ui).align("end").gridSize(0),x2Test:(new mi).align("start").gridSize(0),yTest:(new di).align("start").gridSize(0),y2Test:(new di).align("end").gridSize(0)},i=function(e){const t=ne({viz:e},[sg,cg,Yp]);return{data:t.plotFormattedData,axisData:t.plotAxisData,x2Exists:t.x2Exists,y2Exists:t.y2Exists,xData:t.xData,x2Data:t.x2Data,yData:t.yData,y2Data:t.y2Data,stackGroup:t.plotStackGroup}}(e),{data:o,axisData:a,x2Exists:r,y2Exists:s,xData:c,x2Data:l,yData:u,y2Data:d}=i,f=e.schema.height-e._margin.top-e._margin.bottom,m=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,p=e.schema.width-e._margin.left-e._margin.right,g=function(e,t,n,i,o){const{xData:a,x2Data:r,yData:s,y2Data:c}=o,l=ne({viz:e,plotFormattedData:t,plotAxisData:n,xData:a,x2Data:r,yData:s,y2Data:c,plotStackGroup:i},[Up,mp]);return{plotInitialDomains:l.plotInitialDomains,plotDiscreteKeys:l.plotDiscreteKeys,plotStackData:l.plotStackData,plotStackKeys:l.plotStackKeys,plotDomains:l.plotDomains,plotScales:l.plotScales,plotConfigScales:l.plotConfigScales,plotOpps:l.plotOpps,plotOpenEnds:l.plotOpenEnds}}(e,o,a,i.stackGroup,{xData:c,x2Data:l,yData:u,y2Data:d}),{x:y,y:x,x2:b,y2:_,xScale:k,yScale:v}=g.plotScales,w=h.groups(o,e=>e.shape).sort(([t],[n])=>e.schema.shapeSort(t,n)),S=function(e,t,n,i,o){const a=ne({viz:e,plotFormattedData:t,plotAxisData:n,plotScales:{...i.plotScales,...o},plotConfigScales:i.plotConfigScales,plotOpenEnds:i.plotOpenEnds},[lg,cp]).plotScales;return{x:a.x,y:a.y,x2:a.x2,y2:a.y2}}(e,o,a,g,{x:y,y:x,x2:b,y2:_}),C=function(e,t,n,i,o,a){const{x2Exists:r,y2Exists:s}=o,{x2Data:c,y2Data:l,yData:h}=a,u=ne({viz:e,plotAxisData:t,plotScales:{...n.plotScales,...i},x2Exists:r,y2Exists:s,x2Data:c,y2Data:l,yData:h},[ng]);return{xDomain:u.plotXDomain,x2Domain:u.plotX2Domain,yDomain:u.plotYDomain,y2Domain:u.plotY2Domain,defaultConfig:u.plotDefaultConfig,defaultX2Config:u.plotDefaultX2Config,defaultY2Config:u.plotDefaultY2Config,showX:u.plotShowX,showY:u.plotShowY,yC:u.plotYC,xTicks:u.plotXTicks,x2Ticks:u.plotX2Ticks,yTicks:u.plotYTicks,y2Ticks:u.plotY2Ticks,barLabels:u.plotBarLabels,barLabelCheck:u.plotBarLabelCheck}}(e,a,g,S,{x2Exists:r,y2Exists:s},{x2Data:l,y2Data:d,yData:u}),M=e.schema.lineLabels&&!s,$=function(e,t,n,i,o){const{xTest:a,yTest:r}=o;return()=>{const o=ne({viz:e,plotFormattedData:t,plotScales:n.plotScales,plotConfigScales:n.plotConfigScales,plotTestAxes:{xTest:a,yTest:r},plotLineLabelTest:{testLineShape:ny,testTextBox:iy},y2Exists:i},[Zp]);return{labelWidths:o.plotLabelWidths,largestLabel:o.plotLargestLabel,xRangeMax:o.plotXRangeMax}}}(e,o,g,s,n),A=ey(e,function(e,t,n,i){const{x2Exists:o,y2Exists:a,height:r,width:s,xData:c,x:l}=i;return{...e,xDomain:t.xDomain,x2Domain:t.x2Domain,yDomain:t.yDomain,y2Domain:t.y2Domain,xTicks:t.xTicks,x2Ticks:t.x2Ticks,yTicks:t.yTicks,y2Ticks:t.y2Ticks,xConfigScale:n.xConfigScale,x2ConfigScale:n.x2ConfigScale,yConfigScale:n.yConfigScale,y2ConfigScale:n.y2ConfigScale,defaultX2Config:t.defaultX2Config,defaultY2Config:t.defaultY2Config,yC:t.yC,showX:t.showX,showY:t.showY,x2Exists:o,y2Exists:a,height:r,width:s,xData:c,xScalePadding:l.padding?l.padding():0,barLabelCheck:t.barLabelCheck}}(n,C,g.plotConfigScales,{x2Exists:r,y2Exists:s,height:f,width:p,xData:c,x:S.x}),$),z={...e._margin};oy(e,t);const D=e._margin.left+e._margin.right-z.left-z.right,F=e._margin.top+e._margin.bottom-z.top-z.bottom,B={...i,domains:g.plotDomains,shapeData:w,discreteKeys:g.plotDiscreteKeys,stackData:g.plotStackData,stackKeys:g.plotStackKeys,...S,xScale:k,yScale:v,...g.plotConfigScales,...C,...A,...n,height:f,width:p,opp:m,showLineLabels:M,horizontalMargin:D,verticalMargin:F};return e._paint(B)}function ry(e){const t=Object.create(e);return t._d3Scale=e._d3Scale?e._d3Scale.copy():null,t._d3ScaleNegative=e._d3ScaleNegative?e._d3ScaleNegative.copy():null,t.schema={...e.schema},t}const sy={domainTicks:!0,fixedSize:void 0};const cy=e=>!!e._labelRotation&&e._labelAngle;const ly=([e,t])=>[e,Math.max(e,t)];function hy(e,t,n){const{labelWidths:i}=t,o=jg(e,t,n);t=o.pCtx;const{x2Height:a,horizontalMargin:r}=t;let s=o.yRange;const{insetBottom:c,yBottom:l}=o,{yBounds:u,yWidth:d,y2Bounds:f,y2Width:m,xOffsetLeft:p,xOffsetRight:g}=o.solved,y=n?.xRange??ly([p,t.width-(g+r)]),x=function(e,t,n,i){const{x2Height:o,topOffset:a}=t,r={x:e._margin.left,y:e._margin.top+o+a};e._chartTransform=r;const s=n>i?n-i:0,c={x:{x:e._margin.left,y:e._margin.top+o+a},x2:{x:e._margin.left,y:e._margin.top+a},y:{x:e._margin.left+s,y:e._margin.top+a},y2:{x:e._margin.left-t.horizontalMargin,y:e._margin.top+a}};return e=>({x:c[e].x-r.x,y:c[e].y-r.y})}(e,t,p,d),b=[],_=(n?.yRange??s)[1]+c-a,k=function(e,t,n,i,o,a){const{xDomain:r,x2Domain:s,xConfigScale:c,x2ConfigScale:l}=t,{defaultX2Config:h,showX:u,x2Exists:d,xC:f}=t,{xTicks:m,x2Ticks:p,x2Height:g,topOffset:y,height:x,width:b,verticalMargin:_}=t,k=e._xAxis,v=e._x2Axis;k.renderMode("compute").select(null).domain(r).height(x-(g+y+_)).maxSize(x/2).range(n).ticks(m).width(b).labelRotation(cy(t.xTest)).config({...sy,...f}).config(Jm(e,"x")).config(t.zoomAxes?.x??{}).scale(c);const w=Boolean(t.xLabelMode&&"axis"!==t.xLabelMode);w&&Qg(k,a),k.render(),u&&o.push({key:"plot-x-axis",transform:i("x"),axis:k,gridOnly:w}),d&&(v.renderMode("compute").select(null).domain(s).height(x-(t.xHeight+y+_)).range(n).ticks(p).width(b).labelRotation(cy(t.x2Test)).config({...sy,...f}).config(h).config(e._x2Config).config(t.zoomAxes?.x2??{}).scale(l).render(),o.push({key:"plot-x2-axis",transform:i("x2"),axis:v}));const S=ry(k),C=ry(v),M=(e,t)=>"x2"===t?("log"===l&&0===e&&(e=C._givenDomain()[s[0]<0?1:0]),C._getPosition(e)):("log"===c&&0===e&&(e=S._givenDomain()[r[0]<0?1:0]),S._getPosition(e));return e._xFunc=M,M}(e,t,y,x,b,_),v="ends"===t.xLabelMode?Xg(e._xAxis,y,_):[];s=n?.yRange??ly([e._xAxis.outerBounds().y+a,l-c]);const w=function(e,t,n,i,o,a,r,s){const{yDomain:c,y2Domain:l,yConfigScale:u,y2ConfigScale:d}=t,{defaultY2Config:f,showY:m,y2Exists:p,yC:g}=t,{yTicks:y,x2Height:x,height:b,width:_}=t,k=e._yAxis,v=e._y2Axis;k.renderMode("compute").select(null).domain(c).height(b).maxSize(_/2).range(i).ticks(y).width(n[n.length-1]).config({...sy,...g}).config(Jm(e,"y")).config(t.zoomAxes?.y??{}).scale(u).render(),m&&s.push({key:"plot-y-axis",transform:r("y"),axis:k}),p&&(v.renderMode("compute").select(null).config({...sy,...g}).domain(p?l:c).gridSize(0).height(b).range(i).width(_-h.max([0,o-a])).title(!1).config(e._y2Config).config(f).config(t.zoomAxes?.y2??{}).scale(d).render(),s.push({key:"plot-y2-axis",transform:r("y2"),axis:v}));const w=ry(k),S=ry(v),C=(e,t)=>"y2"===t?("log"===d&&0===e&&(e=l[1]<0?S._givenDomain(!0)[0]:S._givenDomain()[1]),S._getPosition(e)-x):("log"===u&&0===e&&(e=c[1]<0?w._givenDomain(!0)[0]:w._givenDomain()[1]),w._getPosition(e)-x);return e._yFunc=C,C}(e,t,y,s,g,m,x,b),S=function(e,t,n){let i={};return t&&(h.groups(t,e=>e.xValue).forEach(([,t])=>{const i=h.max(t.map(e=>e.fontSize)),o=h.range(n[0],n[1],i).reverse(),a=(n[1]-n[0])/8;t.forEach(function t(n,i,r){if(n.defaultY||(n.defaultY=e._yAxis._getPosition(n.value)),i){const e=r[i-1],{fontSize:s,padding:c}=n,l=n.newY||n.defaultY,h=e.newY||e.defaultY;if(l-s/2-c<h){const s=o.find(e=>e<h);n.defaultY-s<a&&(e.newY=s,i&&t(e,i-1,r))}}})}),i=t.reduce((e,t)=>(t.newY&&(e[t.id]=t.newY),e),{})),i}(e,i,s);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:k,y:w,xRange:y,yRange:s,xOffsetLeft:p,xOffsetRight:g,yWidth:d,y2Width:m,yBounds:u,y2Bounds:f,axisSceneQueue:b,yOffset:C||0,labelPositions:S,xEndLabels:v,insetBottom:c}}const uy=e=>"text"===e.type||"htmlOverlay"===e.type,dy="plot-break-mask";function fy(e,t){return["y","x"].flatMap(n=>{const i=e[`_${n}Axis`];if(!i||!i._breaks||!i._breaks.length)return[];const o="y"===n,a=o?t.x2Height:0,r=(o?t.xRange:t.yRange.map(e=>e-t.x2Height)).slice(0,2).sort((e,t)=>e-t);return i._breaks.map(e=>({axis:i,brk:e,vertical:o,gap:dn(i,e).map(e=>e-a),extent:r}))})}const my=e=>e.baseline?"baselineBreakConfig":"breakConfig";function py(e,t){return{...ti(e,e.schema.barConfig),...ti(e,(e.schema[my(t)]||{}).lineConfig||{})}}function gy(e,t){return fy(e,t).flatMap(({axis:e,brk:t,vertical:n,gap:i,extent:o},a)=>{if(!sn(e,my(t)).lines)return[];const r=py(e,t),s=`break-line-${n?"y":"x"}-${a}`;return i.map((e,t)=>({type:"line",key:`${s}-${t}`,points:n?[[o[0],e],[o[1],e]]:[[e,o[0]],[e,o[1]]],paint:r,interactive:!1,interactionGroup:"axis"}))})}const yy=e=>e.reduce((t,[n,i],o)=>{const[a,r]=e[(o+1)%e.length];return t+n*r-a*i},0)/2;function xy(e,t){const n=Math.sign(yy(e));return[e,...t.map(e=>Math.sign(yy(e))===n?e.slice().reverse():e)].map(e=>`M${e.map(([e,t])=>`${e},${t}`).join("L")}Z`).join("")}function by(e,t,n,i=0){const o=e[0]+i,a=e[1]-i,[r,s]=t;return n?[[r,o],[s,o],[s,a],[r,a]]:[[o,r],[a,r],[a,s],[o,s]]}function _y(e,t,n){const i=[[-1e6,-1e6],[1e6,-1e6],[1e6,1e6],[-1e6,1e6]],o=fy(e,n),a=[!0,!1].flatMap(e=>{const t=o.filter(t=>t.vertical===e&&t.brk.mask).map(({axis:t,brk:n,gap:i,extent:o})=>{const a=sn(t,my(n)).lines?(py(t,n).strokeWidth??1)/2:0;return by(i,o,e,a)});return t.length?[{axis:e?"y":"x",d:xy(i,t)}]:[]});if(!a.length)return t;const r=[];let s=[],c=0;const l=()=>{if(!s.length)return;const e=c++?"-"+(c-1):"",t=a.reduce((t,{axis:n,d:i})=>[{type:"group",key:`${dy}-${n}${e}`,clip:{type:"path",d:i},children:t}],s);r.push(...t),s=[]};for(const e of t)uy(e)?(l(),r.push(e)):s.push(e);return l(),r}const ky=e=>"group"===e.type&&String(e.key).startsWith(dy);function vy(e){return e.some(ky)?e.flatMap(e=>ky(e)?vy(e.children):[e]):e}const wy="plot-domain-clip",Sy=e=>String(e.key).endsWith("::hit"),Cy=e=>"text"===e.type||"htmlOverlay"===e.type||"axis"===e.interactionGroup,My=e=>"circle"===e.type;function $y(e){const t=e.paint;if(!t||!t.stroke||"none"===t.stroke||"transparent"===t.stroke)return 0;const n=Number(t.strokeWidth??1);return Number.isFinite(n)&&n>0?n/2:0}function Ay(e){return e.reduce((e,t)=>Math.max(e,function(e){if(Sy(e))return 0;if("group"===e.type)return Ay(e.children);const t=Math.abs(e.transform?.scale??1);return("circle"===e.type?e.r+$y(e):$y(e))*t}(t)),0)}function zy(e,t,n=[]){if(Sy(e))return!1;const i=e.transform?[e.transform,...n]:n;return"group"===e.type?e.children.some(e=>zy(e,t,i)):function(e){switch(e.type){case"circle":return[[e.cx,e.cy]];case"rect":case"image":return[[e.x,e.y],[e.x+e.width,e.y+e.height]];case"path":{const t=f.pathBounds(e.d);return[[t.x,t.y],[t.x+t.width,t.y+t.height]]}case"line":return e.points;case"area":return[...e.topline,...e.baseline];default:return[]}}(e).some(e=>{const[n,o]=i.reduce((e,t)=>Iu(e,t),e);return Number.isFinite(n)&&Number.isFinite(o)&&(n<t.x0||n>t.x1||o<t.y0||o>t.y1)})}const Dy=(e,t,n=0)=>({x0:e.x0-t,y0:e.y0-t-n,x1:e.x1+t,y1:e.y1+t+n});function Fy(e,t){const n=function(e){const t=e.xRange.slice(0,2).map(Number),n=e.yRange.slice(0,2).map(t=>Number(t)-e.x2Height);return{x0:Math.min(...t),y0:Math.min(...n),x1:Math.max(...t),y1:Math.max(...n)}}(t);if(![n.x0,n.y0,n.x1,n.y1].every(Number.isFinite))return e;const i=Dy(n,1,t.yOffset??0),o=[];let a=[],r=0,s=!1;const c=()=>{if(!a.length)return;const e=`${wy}-${r++}`;if(a.some(e=>zy(e,i))){const t=Dy(n,Ay(a)),i=a.map(e=>e.z).filter(e=>"number"==typeof e);o.push({type:"group",key:e,clip:{type:"rect",x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0},children:a,...i.length?{z:Math.min(...i)}:{}}),s=!0}else o.push(...a);a=[]};for(const t of e)Cy(t)?(c(),o.push(t)):(a.length&&My(a[0])!==My(t)&&c(),a.push(t));return c(),s?o:e}const By=new RegExp(`(^|/)${wy}-\\d+$`),Ly=e=>"group"===e.type&&By.test(String(e.key));function Py(e){return e.some(Ly)?e.flatMap(e=>"group"===e.type&&Ly(e)?e.children:[e]):e}function Ry(e,t){const n=[];try{const t=e.toScene();t&&Array.isArray(t.children)&&t.children.length&&n.push(t);const i=e._labelClass;if(i&&"function"==typeof i.toScene){const e=i.toScene();e&&Array.isArray(e.children)&&e.children.length&&n.push(e)}}catch{return null}if(!n.length)return null;const i={type:"group",key:t,children:n};return function(e){const t=e=>{e.interactive=!1;const n=e.children;if(n)for(const e of n)t(e)};e.forEach(t)}([i]),i}function Ey(e,t,n,i,o,a){const r=Object.assign({},t);delete r.shape,delete r.layer;const s=eu(t.shape).renderMode("compute").duration(e.schema.duration).config(r).config(de({x:e=>e.x2?n(e.x2,"x2"):n(e.x),x0:"x"===e.schema.discrete?e=>e.x2?n(e.x2,"x2"):n(e.x):n(o.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?n(e.x2,"x2"):n(e.x),y:e=>e.y2?i(e.y2,"y2"):i(e.y),y0:"y"===e.schema.discrete?e=>e.y2?i(e.y2,"y2"):i(e.y):i(o.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?i(e.y2,"y2"):i(e.y)-a}));return s.render(),s}function Ny(e,t,n,i,o,a){const r=[];return Object.keys(e._previousAnnotations).forEach(s=>{const c=e._annotations.filter(e=>"back"===s&&!e.layer||e.layer===s),l=c.map(e=>e.shape);c.forEach((c,l)=>{const h=(t=>Ey(e,t,n,i,o,a))(c);if("front"===s)r.push(h);else{const e=Ry(h,`annotation-${s}-${l}`);e&&t.push(e)}});e._previousAnnotations[s].filter(e=>!l.includes(e)).forEach(e=>{eu(e).renderMode("compute").data([]).render()}),e._previousAnnotations[s]=l}),r}const Ty=["bandOpacity","capWidth","tooltip"];function Oy(e){const{viz:t,x:i,y:o,values:a}=e,r=Bm(t);if(!r.length)return[];const s=t.schema.discrete||"x",c="x"===s?"y":"x",l="x"===s?o:i,h=Object.assign({},t.schema.shapeConfig,t._confidenceConfig),u=n.assign(au(t,"Line",h),au(t,"Area",h));Ty.forEach(e=>delete u[e]);const d=r.length>1,f=d?Rm(Pm(t._confidenceConfig?.bandOpacity,r.length)):[],m=[];return r.forEach((t,n)=>{const i=(e,t,n)=>l(e?Em(e(t.data,t.i),n):n),o=de(Object.assign({},e.shapeConfig));o[`${c}0`]=e=>i(t.lower,e,e[c]),o[`${c}1`]=e=>i(t.upper,e,e[c]),n&&(o.id=e=>`${e.id}::band-${n}`);const r=eu("Area").renderMode("compute").config(o).data(a);r.config(u),d&&r.config({fillOpacity:f[n]}),r.render(),m.push(...su(r))}),m}function Wy(e,t,n,i){const o=e/2;if(t<2)return[-o,o];const a=2*i/(t-1),r=n*a-i;return[(n<=0?-o:r-a/2)-r,(n>=t-1?o:r+a/2)-r]}const jy=e=>"Bar"===e.shapeType&&String(e.key).endsWith("::hit");function Hy(e,t){const n=e=>Sr(e),i=t.label(),o=t.labelBounds(),a=t.labelConfig(),r="number"==typeof a.padding?a.padding:0,s=a.verticalAlign;if("function"!=typeof o)return;const c=new WeakSet,l=(e,t)=>{const o=i(e,t);return!(!1===o||null==o||Array.isArray(o)||!Number.isFinite(n(e)))&&o};t.label((t,o)=>{const a=l(t,o);return!1===a?i(t,o):[a,`${d.formatAbbreviate(100*n(t),e.schema.locale)}%`]}),t.labelBounds((e,t,n)=>{const i=o(e,t,n);if(!i||Array.isArray(i)||!1===l(e,t))return i;const a=function(e,t){const n=Math.min(14,.4*(e.height-2*t));if(n<8)return null;const i=e.height-t-n;return[{...e,height:i+t},{...e,height:n+2*t,y:e.y+i-t}]}(i,r);return a?(c.add((e=>e.__d3plusShape__?e.data:e)(e)),a):[i,{...i,height:0,width:0}]}),t.labelConfig({verticalAlign:(e,t)=>!!e&&c.has(e.data)?1===e.l?"top":"bottom":"function"==typeof s?s(e,t):s})}function Iy(e,t){return{start:i.cubicInOut(e/t),end:i.cubicInOut((e+1)/t)}}function Gy(e,t){const{viz:n}=e;if(!n.schema.stacked||function(e){const t=e=>"rect"===e.type&&"Bar"===e.shapeType||"group"===e.type&&e.children.some(t);return!!e&&t(e.root)}(n._paintedScene))return t;const{levels:i,depth:o}=function(e,t){const{opp:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:a}=t,r=new Map;for(const t of e){const e=Number(t[n??"y"]),s=i[o.get(t.id)??-1],c=a.get(t.discrete);if(!e||!Number.isFinite(e)||!s||void 0===c)continue;const l=s.index??o.get(t.id),h=`${c}|${t.group}|${e<0?"-":"+"}`;r.has(h)||r.set(h,[]),r.get(h).push({row:t,order:l})}const s=new Map;let c=0;for(const e of r.values())e.sort((e,t)=>e.order-t.order),e.forEach(({row:e},t)=>s.set(e,t)),c=Math.max(c,e.length);return{levels:s,depth:c}}(e.values,e);if(o<2)return t;const a=new Map;for(const e of t){const t="Bar"===e.shapeType?i.get(e.datum):void 0;void 0!==t&&a.set(e.datum,Iy(t,o))}return t.map(e=>{const t=e.datum,n=a.get(t)??a.get(t?.data);return n?{...e,enterWindow:n}:e})}function Vy(e,t,n,i){if("none"===t.paint?.fill)return null;const o=tu(e.backgroundImage,n,i);if("string"!=typeof o||!o)return null;const a=Ro(t,[],"contain"===tu(e.backgroundImageFit,n,i)?"contain":"cover");if(!(a&&a.box.width>0&&a.box.height>0))return null;const r=t.paint?.opacity,[s]=Eo([{key:t.key,index:t.index??i??0,datum:t.datum,url:o,box:a.box,clip:a.clip,preserveAspectRatio:a.preserveAspectRatio,opacity:"number"==typeof r?r:void 0,transform:t.transform}],null,0);return s}function qy(e,t,n){if(!e.backgroundImage)return[];const i=[];return t.forEach((t,o)=>{const[a,r]=n(o),s=Vy(e,t,a,r);s&&i.push(s)}),i}function Yy(e,t,n=16){const i=[];let o=0,a=0;const r=(e,t)=>{i.push([e,t]),o=e,a=t},s={moveTo:r,lineTo:r,closePath:()=>{},bezierCurveTo(e,t,r,s,c,l){const h=o,u=a;for(let o=1;o<=n;o++){const a=o/n,d=1-a,f=d*d*d,m=3*d*d*a,p=3*d*a*a,g=a*a*a;i.push([f*h+m*e+p*r+g*c,f*u+m*t+p*s+g*l])}o=c,a=l},quadraticCurveTo(e,t,r,s){const c=o,l=a;for(let o=1;o<=n;o++){const a=o/n,h=1-a;i.push([h*h*c+2*h*a*e+a*a*r,h*h*l+2*h*a*t+a*a*s])}o=r,a=s}};return y.line().curve(If(t)).context(s)(e),i}function Ky(e,t,n){let i,o=0;if(e.length){const o=Math.sign(e[e.length-1][t]-e[0][t])||1;(e[0][t]-n)*o>=0&&(i=0)}for(let a=1;a<e.length;a++){const r=e[a-1],s=e[a],c=Math.hypot(s[0]-r[0],s[1]-r[1]);void 0===i&&(r[t]-n)*(s[t]-n)<=0&&s[t]!==r[t]&&(i=o+c*((n-r[t])/(s[t]-r[t]))),o+=c}return[i??o,o]}function Uy(e,t,n){const i=n.length%2?n.concat(n):n,o=i.reduce((e,t)=>e+t,0);if(!(o>0)||e>=t)return;const a=[+e.toFixed(2),0];for(let n=0;n<t-e;n+=o)a.push(...i);return a}const Xy="plot-forecast",Qy=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t;function Zy(e,t,n){return"x"===(e.schema.discrete||"x")?t.x(n):t.y(n)}function Jy(e,t,n){const i=e.schema.discrete||"x",o=om(n.map(e=>e[i])),a=n.map(n=>({at:o(n[i]),px:Zy(e,t,n[i])})).filter(e=>Number.isFinite(e.px)).sort((e,t)=>e.at-t.at);return a.length<2?1:a[a.length-1].px<a[0].px?-1:1}function ex(e,t,n,i,o){if(void 0===i.next)return NaN;const a=Zy(e,t,i.next);if(!Number.isFinite(a))return NaN;const r=Zy(e,t,i.value);if(Number.isFinite(r)&&Math.abs(r-a)>=.5)return(r+a)/2;const s=e.schema.discrete||"x",c=n.map(n=>Zy(e,t,n[s])).filter(e=>Number.isFinite(e)),l=e=>c.filter(t=>(t-a)*o*e>.5).reduce((e,t)=>void 0===e||Math.abs(t-a)<Math.abs(e-a)?t:e,void 0),h=l(-1);if(void 0!==h)return(h+a)/2;const u=l(1);return void 0!==u?a-(u-a)/2:a}function tx(e,t,i,o=!1){const a=lm(e,t);if(!a||!t.length)return[];const s="x"===(e.schema.discrete||"x"),c=Jy(e,i,t),l=o?ex(e,i,t,a,c):Zy(e,i,a.value);if(!Number.isFinite(l))return[];const h=s?i.xRange:[0,i.yRange[1]-i.yRange[0]],u=s?[0,i.yRange[1]-i.yRange[0]]:i.xRange,d=Math.min(h[0],h[1]),f=Math.max(h[0],h[1]),m=c>0?f:d,p=Math.min(Math.max(l,d),f);if(Math.abs(m-p)<1)return[];const g=l>=d-.5&&l<=f+.5,y=e.schema.forecastConfig,x=function(e){const t=n.backgroundColor(e._select?.node());return r.colorContrast(t,e.schema.colorDefaults)}(e),b=Math.min(p,m),_=Math.abs(m-p),k={type:"rect",key:`${Xy}-region`,x:s?b:u[0],y:s?u[0]:b,width:s?_:u[1]-u[0],height:s?u[1]-u[0]:_,paint:{fill:y.fill||x,fillOpacity:Qy(y.fillOpacity,.05)},interactive:!1},v=[];if(!1!==y.fill&&"none"!==y.fill&&v.push(k),v.push(...nx(y,k,x)),g&&!1!==y.stroke&&"none"!==y.stroke){const e={fill:"none",stroke:y.stroke||x,strokeWidth:Qy(y.strokeWidth,1),strokeOpacity:Qy(y.strokeOpacity,.4)},t=Oo(y.strokeDasharray);t&&(e.strokeDasharray=t),v.push({type:"line",key:`${Xy}-rule`,points:s?[[p,u[0]],[p,u[1]]]:[[u[0],p],[u[1],p]],curve:"linear",paint:e,interactive:!1})}const w=g?function(e,t){const n=t.label;return!1===n||null===n||""===n?"":"function"==typeof n?`${n(e.schema.locale)}`:"string"==typeof n?n:e.schema.translate("Forecast")}(e,y):"";return w&&v.push(function(e,t,i,o){const a=Qy(t.fontSize,12),r=t.fontFamily||`${e.schema.fontFamily}`,s=n.textWidth(i,{"font-family":r,"font-size":a}),c=5,l=o.dir>=0,h=o.horizontal?o.from+(l?c:-c):o.cross[0]+c,u=o.horizontal?o.cross[0]+c+a/2:o.from+(l?c+a/2:-c-a/2);return{type:"text",key:`${Xy}-label`,interactive:!1,x:0,y:0,transform:{x:h,y:u},lines:[{text:i,x:0,y:0,width:s}],font:{family:r,size:a,weight:t.fontWeight??400,anchor:o.horizontal&&!l?"end":"start",baseline:"middle"},paint:{fill:t.fontColor||o.ink,opacity:Qy(t.fontOpacity,.7)}}}(e,y,w,{from:p,dir:Math.sign(m-p),horizontal:s,cross:u,ink:x})),v.length?[{type:"group",key:Xy,interactive:!1,children:v}]:[]}function nx(e,t,n){const i=[],o="string"==typeof e.fill&&"none"!==e.fill?e.fill:n,a=Do(e.texture,()=>"transparent",()=>o,e.textureDefault||void 0);a&&i.push({...t,key:`${Xy}-texture`,paint:{fill:`pattern:${a}`,opacity:Qy(e.textureOpacity,.3)}});const r=e.backgroundImage,s="string"==typeof r&&Vy({backgroundImage:r,backgroundImageFit:e.backgroundImageFit},{...t,paint:{}},void 0,0);return s&&i.push(s),i}function ix(e,t,n,i){const o=Oo(e.schema.forecastConfig.lineDasharray);if(!o||!o.some(e=>e>0))return null;const a=lm(e,t);if(!a||a.series&&!a.series.size)return null;const r="x"===(e.schema.discrete||"x")?0:1,s=n.x,c=n.y,l=Gf(e,t[0]),h=new Map;return(n,u)=>{const d=`${t[u]?.id}`;if(!h.has(d)){const n=(t=>{const n=a.series?a.series.get(t):a.value;return void 0===n?NaN:Zy(e,i,n)})(d);if(Number.isFinite(n)){const e=t.filter(e=>`${e.id}`===d).map(e=>[s(e),c(e)]),[i,a]=Ky(Yy(e,l),r,n);h.set(d,Uy(i,a,o))}else h.set(d,void 0)}return h.get(d)}}function ox(e,t){return(n,i)=>{const o=e(n,i);return o||("function"==typeof t?t(n,i):t)}}function ax(e){const t=e.map(([e])=>e),n=e.flatMap(([,e])=>e);return{rows:n,slots:t.includes("Bar")&&!t.includes("Line")&&!t.includes("Area")}}function rx(e,t){const{viz:n,opp:i,x:o,y:a,stackData:r,domains:s,stackKeyIndex:c,discreteKeyIndex:l}=e,h=de(Object.assign({},e.shapeConfig));if("Circle"===t&&n._size){const e=n._size;h.sort=(t,n)=>(Number(e(n))||0)-(Number(e(t))||0)}if("Box"===t&&(h.id=e=>e.discrete),n.schema.stacked&&["Area","Bar"].includes(t)){const e="x"===i?o:a;h[`${i}`]=h[`${i}0`]=t=>{const n=c.get(t.id)??-1,o=l.get(t.discrete)??-1,a=t[i]<0?1:0;return e(n>=0?r[n][o][a]:s[i]["x"===i?0:1])},h[`${i}1`]=t=>{const n=c.get(t.id)??-1,o=l.get(t.discrete)??-1,a=t[i]<0?0:1;return e(n>=0?r[n][o][a]:s[i]["x"===i?0:1])}}return h}function sx(e,t,n,i){const{viz:o,events:a}=e;o._wirePlotShapeEvents(n,t,a);const r=au(o,t);void 0===o.schema.shapeConfig.duration&&delete r.duration,n.config(r),i&&n.config(i(r)),"Bar"===t&&e.barLabelsOnAxis&&n.label(!1),o.schema.stacked&&"Bar"===t&&Hy(o,n),n.render();const s=su(n);if("Bar"!==t)return s;const c=vp(e,s);if(!c.length)return Gy(e,s);let l=-1;return s.forEach((e,t)=>{"Bar"===e.shapeType&&(l=t)}),Gy(e,[...s.slice(0,l+1),...c,...s.slice(l+1)])}const cx=(e,t)=>sx(e,t,eu(t).renderMode("compute").config(rx(e,t)).data(e.values));function lx(e){const{viz:t,values:n}=e,i=t.schema.discrete;if("Time"!==("x"===i?e.xScale:e.yScale))return n;const o=e.zoomRanges?.[i];if(o){const t="x"===i?e.x:e.y,[a,r]=h.extent(o);return n.filter(e=>{const n=t(e[i]);return n>=a-.5&&n<=r+.5})}const[a,r]=h.extent(("x"===i?e.xDomain:e.yDomain).map(Number));return n.filter(e=>{const t=+e[i];return t>=a&&t<=r})}function hx(e,t,n){const{viz:i}=e;i.schema.stacked||function(e,t,n,i){n&&e.config({hitArea:(o,a)=>function(e,t,n,i){const[o,a]=t,[r,s]=n;return"x"===e?{x:o,y:r-(i.y??0),width:a-o,height:s-r}:{x:r-(i.x??0),y:o,width:s-r,height:a-o}}(t,i(o,a),n,e._sceneTransform(o,a))})}(t,"y"===i.schema.discrete?"y":"x",e.valueExtent,n)}const ux={Bar:e=>{const t={...e,values:lx(e)},{viz:n,x:i,y:o,xScale:a,yScale:r,xDomain:s,yDomain:c,xRange:l,yRange:u,values:d,zoomRanges:f}=t,m=eu("Bar").renderMode("compute").config(op(rx(t,"Bar"),bf(n),t.valueExtent)).data(d),p="x"===n.schema.discrete?i:o;if(n._discreteExtent)return function(e,t,n){const{viz:i,values:o}=e,a=e=>{const[t,o]=Cm(i,e);return Math.max(1,Math.abs(n(o)-n(t))-i._groupPadding)},r=e=>{const[t,o]=Cm(i,e);return Math.abs(n(o)-n(t))},s=i.schema.discrete,c=i._barSpans?function(e,t){const n=new Map,i=new Set;let o=!1;for(const a of e){const e=dm(a[t]),r=n.get(e)??new Set;r.add(a.group),n.set(e,r),i.add(a.group),r.size>1&&(o=!0)}return o?Array.from(i):[]}(o,s):[];if(c.length<2)return t.width(a),t.height(a),hx(e,t,e=>Wy(r(e),1,0,0)),sx(e,"Bar",t);const l=e=>function(e,t,n,i){const o=Math.max(1,(e-i*t-1)/t);if(t<2)return{size:o,offset:0};const a=Math.max(0,e-o)/2;return{size:o,offset:n*a*2/(t-1)-a}}(a(e),c.length,c.indexOf(e.group),i.schema.barPadding),h=e.shapeConfig[s];return t[s]((e,t)=>h(e,t)+l(e).offset),t.width(e=>l(e).size),t.height(e=>l(e).size),hx(e,t,e=>Wy(r(e),c.length,c.indexOf(e.group),Math.max(0,a(e)-l(e).size)/2)),sx(e,"Bar",t)}(t,m,p);let g;const y="x"===n.schema.discrete?a:r,x="x"===n.schema.discrete?s:c,b="x"===n.schema.discrete?l:u,_=f?.[n.schema.discrete];if("Point"!==y&&2===x.length){const e=Array.from(new Set(d.map(e=>p(e[n.schema.discrete]))));e[0]>e[e.length-1]&&e.reverse();const t=e[0],i=e[e.length-1];e.unshift(_?2*_[0]-t:b[0]-t-b[0]),e.push(_?2*_[1]-i:b[1]+b[1]-i),g=e.reduce((e,t,n,i)=>{if(n){const o=Math.abs(t-i[n-1]);o<e&&(e=o)}return e},1/0)}else g=x.length>1?Math.abs(p(x[1])-p(x[0])):b[b.length-1]-b[0];const k=g;n._groupPadding<g&&(g-=n._groupPadding);let v=g||1;const w=h.groups(d,e=>e[n.schema.discrete],e=>e.group),S=h.merge(w.map(([,e])=>e.map(([e])=>e))),C=Array.from(new Set(S)),M=n.schema.discrete,$=t.shapeConfig[M];let A=()=>Wy(k,1,0,0);if(1===h.max(w.map(([,e])=>e.length)))m[M]((e,t)=>$(e,t));else{v=(v-n.schema.barPadding*C.length-1)/C.length;const e=g/2-v/2,t=B.scaleLinear().domain([0,C.length-1]).range([-e,e]);m[M]((e,n)=>$(e,n)+t(C.indexOf(e.group))),A=t=>Wy(k,C.length,C.indexOf(t.group),e)}return m.width(v),m.height(v),hx(t,m,A),sx(t,"Bar",m)},Circle:(e,t)=>{if(!e.viz._swarm)return cx(e,t);const{viz:n,values:i,x:o,y:a,xRange:r,yRange:s}=e,c=eu("Circle").renderMode("compute").config(rx(e,"Circle")).data(i);return sx(e,"Circle",c,t=>{const c=t.r,l=Xm(n,{values:i,x:o,y:a,xRange:r,yRange:s,lanes:"x"===n._swarm.cross?e.xDomain:e.yDomain,r:"function"==typeof c?c:()=>c}),h=e=>l.get(e);return{x:e=>h(e).x,y:e=>h(e).y,r:e=>h(e).r}})},Line:e=>{const{viz:t,values:n,width:i,showLineLabels:o,labelWidths:a,largestLabel:r,labelPositions:s}=e,c=[],l=eu("Line").renderMode("compute").config(rx(e,"Line")).data(n);t.schema.fillBetween&&c.push(...Qf(e)),l.duration(1.5*i),t._confidence&&c.push(...Oy(e)),l.config({discrete:e.shapeConfig.discrete||"x",label:!!o&&((e,n)=>{if(!("function"!=typeof t.schema.lineLabels||t.schema.lineLabels(e.data,e.i)))return!1;const i=a.find(t=>t.id===e.id);if(i){const o=i.newY||i.defaultY,r=a.filter(e=>e.newY===o);return r.length>1?r[0].id===e.id&&`+${d.formatAbbreviate(r.length,t.schema.locale)} ${t.schema.translate("more")}`:t._drawLabel(e,n)}return!1}),labelBounds:!!o&&((e,n,i)=>{const[o,a]=i.points[0],[c,l]=i.points.reduce((e,t)=>t[0]>=e[0]?t:e),h=t.schema.height/4;return{x:c-o,y:l-a-h/2-(s[e.id]?l-s[e.id]:0),width:r,height:h}})});const h=ix(t,n,e.shapeConfig,e);c.push(...sx(e,"Line",l,h?e=>({strokeDasharray:ox(h,e.strokeDasharray)}):void 0));const u=eu("Circle").renderMode("compute").data(t._lineMarkers?n:[]).config(e.shapeConfig).config(t._lineMarkerConfig).id(e=>`${e.id}_${e.discrete}`);return t._wirePlotShapeEvents(u,"Circle",e.events),u.render(),c.push(...su(u)),c}};const dx=["group","order","confidence","confidenceLevel","confidenceConfig","projection","projectionConfig","tooltip","stroke"];function fx(e,t,n){const i=e;return i.interactive=n,i.interactionGroup="trend",n&&(i.trendFit=t),i.datum=t.row,i.children&&i.children.forEach(e=>fx(e,t,n)),e}function mx(e,t,n){return(e._trendFits||[]).map(i=>function(e,t,n,i){const o=e._trendLineConfig||{},a=[],r=()=>`trend-${t.id}`;if(void 0!==t.samples[0].lci){const s=eu("Area").renderMode("compute").duration(e.schema.duration).data(t.samples).config({id:r,label:!1,fill:t.color,stroke:"none",strokeWidth:0}).config(o.confidenceConfig||{}).config(function(e,t,n){const i=i=>"x"===e.axis?t(i.x):n(i.y),o=i=>"x"===e.axis?n(i.lci):t(i.lci),a=i=>"x"===e.axis?n(i.hci):t(i.hci);return"x"===e.axis?{x:i,x0:i,x1:null,y:o,y0:o,y1:a}:{y:i,y0:i,y1:null,x:o,x0:o,x1:a}}(t,n,i));a.push(...su(s).map(e=>fx(e,t,!1)))}const s=Object.fromEntries(Object.entries(o).filter(([e])=>!dx.includes(e))),c=(r,c,l)=>{if(r.length<2)return;const h=eu("Line").renderMode("compute").duration(e.schema.duration).data(r).config({...s,id:c,label:!1,stroke:t.color}).config(l).config({x:e=>n(e.x),y:e=>i(e.y)});a.push(...su(h).map(e=>fx(e,t,!1!==o.tooltip)))};return c(t.samples.filter(e=>!e.projected),r,{}),c(t.samples.filter(e=>e.projected),()=>`trend-${t.id}-projection`,o.projectionConfig||{}),a.length?{type:"group",key:`plot-trend-${t.id}`,children:a}:null}(e,i,t,n)).filter(e=>null!==e)}function px(e,t,n,i,o){const{shapeData:a,domains:r,discreteKeys:s,stackData:c,stackKeys:l,xDomain:h,yDomain:u}=n,{xScale:d,yScale:f}=n,{labelWidths:m,largestLabel:p}=n,{width:g}=n,{opp:y,showLineLabels:x}=n,{x:b,y:_,xRange:k,yRange:v,labelPositions:w,yOffset:S}=i,C=Object.keys(e.schema.on),M=new Map;for(let e=0;e<l.length;e++)M.set(l[e],e);const $=new Map;for(let e=0;e<s.length;e++)$.set(s[e],e);const A={viz:e,shapeConfig:o,events:C,x:b,y:_,xScale:d,yScale:f,xDomain:h,yDomain:u,xRange:k,yRange:v,opp:y,domains:r,stackData:c,stackKeyIndex:M,discreteKeyIndex:$,showLineLabels:x,labelWidths:m,largestLabel:p,labelPositions:w,width:g,values:[],valueExtent:ip(e,{x2Height:n.x2Height,yOffset:S}),barLabelsOnAxis:n.barLabelsOnAxis,insetBottom:i.insetBottom??0,x2Height:n.x2Height,zoomRanges:n.zoomRanges};var z;t.push(...(z=a.flatMap(([e,t])=>function(e,t){return(e.viz._plotShapeEmitters?.[t]??ux[t]??cx)(e,t)}({...A,values:t},e)),z.some(jy)?[...z.filter(jy),...z.filter(e=>!jy(e))]:z))}const gx=e=>"string"==typeof e.key&&e.key.startsWith("grid-"),yx=e=>{e.interactionGroup="axis";const t=e.children;if(t)for(const e of t)yx(e)};function xx(e,t,i,o){const a=[],{shapeData:r,domains:s}=t,{labelWidths:c}=t,{x:l,y:h,xRange:u,yRange:d,yOffset:f,axisSceneQueue:m}=i,p=function(e){const t=[],n=[];return e.forEach(({key:e,transform:i,axis:o,gridOnly:a})=>{if(!o||"function"!=typeof o.toScene)return;const r=o.toScene();if(!r)return;const s=r.children||[],c=s.filter(gx),l=s.filter(e=>!gx(e));if(c.length){const n={type:"group",key:`${e}-grid`,transform:i,children:c};yx(n),t.push(n)}if(l.length&&!a){const t={type:"group",key:e,transform:i,children:l};yx(t),n.push(t)}}),{grid:t,rest:n}}(m);!function(e,t,n,i){const o=e._backgroundConfig;if(o&&o.fill&&"transparent"!==o.fill){const e=eu("Rect").renderMode("compute").data([{}]).x(n[0]+(n[1]-n[0])/2).width(n[1]-n[0]).y((i[1]-i[0])/2).height(i[1]-i[0]).config(o);e.render();const a=su(e);t.unshift(...a)}}(e,a,u,d),a.push(...p.grid),a.push(...gy(e,{xRange:u,yRange:d,x2Height:t.x2Height})),a.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const o=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=eu("Line").config({data:o,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),su(a)}(e,c));const g=Ny(e,a,l,h,s,f),y=ax(r);a.push(...tx(e,y.rows,{x:l,y:h,xRange:u,yRange:d},y.slots));const x=mx(e,l,h),b=function(e,t,n,i,o){const a=e.schema.discrete||"x";return de({discrete:e.schema.discrete,duration:e.schema.duration,label:t=>e._drawLabel(t.data,t.i),x:e=>void 0!==e.x2?t(e.x2,"x2"):t(e.x),x0:"x"===a?e=>e.x2?t(e.x2,"x2"):t(e.x):t("number"==typeof e.schema.baseline?e.schema.baseline:i.x[0]),x1:"x"===a?null:e=>e.x2?t(e.x2,"x2"):t(e.x),y:e=>void 0!==e.y2?n(e.y2,"y2"):n(e.y),y0:"y"===a?e=>e.y2?n(e.y2,"y2"):n(e.y):n("number"==typeof e.schema.baseline?e.schema.baseline:i.y[1])-o,y1:"y"===a?null:e=>e.y2?n(e.y2,"y2"):n(e.y)-o})}(e,l,h,s,f),_=x.length;px(e,x,t,i,b);const k=function(e,t){const n=[];for(let i=e.length-1;i>=t;i--)"axis"===e[i].interactionGroup&&n.unshift(...e.splice(i,1));return n}(x,_);e._plotUnderlay&&x.splice(_,0,...e._plotUnderlay(x.slice(_),l,h));const v=[d[0],d[1]+(i.insetBottom??0)];a.push(...o?x:Fy(x,{xRange:u,yRange:v,x2Height:t.x2Height,yOffset:f})),function(e,t,n){const i=t.map(([e])=>e);i.includes("Line")&&(e._confidence&&i.push("Area"),e._lineMarkers&&i.push("Circle")),e._previousShapes.filter(t=>!i.includes(t)&&!e._plotShapeEmitters?.[t]).forEach(e=>{const t=eu(e);"function"==typeof t.renderMode&&t.renderMode("compute"),"function"==typeof t.select&&t.select(null),t.config(n).data([]).render()}),e._previousShapes=i}(e,r,b),g.forEach((e,t)=>{const n=Ry(e,`annotation-front-${t}`);n&&a.push(n)});const w=_y(e,a,{xRange:u,yRange:d,x2Height:t.x2Height}),S=e.schema.zoom?[{type:"group",key:bx,...o?{clip:o}:{},children:w}]:w,C=Zg(e._xAxis,i.xEndLabels??[]);return C&&yx(C),[...S,...k,...p.rest,...C?[C]:[]]}const bx="plot-zoom-content";function _x(e,t,n,i){const o=hy(e,t,n),{xRange:a,yRange:r}=o;return e._bodyRect={x:a[0],y:r[0],width:a[1]-a[0],height:r[1]-r[0]},e._plotAxisDomains={x:e._xAxis?._d3Scale?.domain()??[],y:e._yAxis?._d3Scale?.domain()??[]},e._plotArea={x:a[0],y:0,width:a[1]-a[0],height:r[1]-r[0]+(o.insetBottom??0)},{nodes:xx(e,t,o,i),layout:o}}const kx=(e,t)=>"time"===t||"Linear"===e&&["linear","pow","sqrt"].includes(t);function vx(e,t,n){const{nodes:i,layout:o}=_x(e,t);if(clearTimeout(e._plotUnclipTimer),e._plotZoomBase=void 0,e._zoomShapes=void 0,!e.schema.zoom)return i;const a={},r={},s={},c={};for(const n of function(e){const t=[];return kx(e.xScale,e.xConfigScale)&&t.push("x"),e.x2Exists&&kx(e.xScale,e.x2ConfigScale)&&t.push("x2"),kx(e.yScale,e.yConfigScale)&&t.push("y"),e.y2Exists&&kx(e.yScale,e.y2ConfigScale)&&t.push("y2"),t}(t)){const t=e[`_${n}Axis`],i=t?._d3Scale;i&&"function"==typeof i.invert&&(a[n]=i.copy(),r[n]=t?._labelSpace,s[n]=Boolean(t?._baselineBreak),c[n]=Boolean(t?.schema.reverse))}if(e._zoomShapes=function(e){const t=e.find(e=>e.key===bx);return t&&"group"===t.type?Py(vy(t.children)):void 0}(i),!Object.keys(a).length)return i;const{x:l=0,y:h=0}=e._chartTransform||{};if(e._plotZoomBase={pCtx:t,layout:o,chartTransform:{x:l,y:h},scales:a,labelSpace:r,breaks:s,reversed:c},n&&(1!==n.k||n.x||n.y)){const t=wx(e,n);if(t)return t}return i}function wx(e,t,n=!1){const i=e._plotZoomBase;if(!i)return;const{pCtx:o,layout:a}=i,r=1===t.k&&!t.x&&!t.y,s=r?{}:function(e,t){const{pCtx:n,layout:i,chartTransform:o,scales:a}=e,r=i=>{const r=a[i],s="y"===i[0],c=s?o.y:o.x,l=s?t.y:t.x,h=s?-n.x2Height:0,u=r.range().map(e=>r.invert((e+h+c-l)/t.k-c-h)),[d,f]=r.domain();return(+f-+d)*(+u[1]-+u[0])<0!==Boolean(e.reversed[i])?u.reverse():u},s={};for(const e of Object.keys(a))s[`${e}Domain`]=r(e);s.zoomAxes={};for(const t of Object.keys(a))s.zoomAxes[t]={rounding:"none",domainTicks:!1,fixedSize:e.labelSpace[t],domain:s[`${t}Domain`],...e.breaks[t]?{}:{baselineBreak:!1}};const c=(e,i)=>{const a=i?o.y:o.x,r=i?-n.x2Height:0;return(e+r+a)*t.k+(i?t.y:t.x)-a-r};return s.zoomRanges={},a.x&&(s.zoomRanges.x=i.xRange.map(e=>c(e,!1))),a.y&&(s.zoomRanges.y=i.yRange.map(e=>c(e,!0))),s}(i,t),c=r&&!n?void 0:{type:"rect",x:a.xRange[0],y:a.yRange[0]-o.x2Height,width:a.xRange[1]-a.xRange[0],height:a.yRange[1]-a.yRange[0]+(a.insetBottom??0)};return _x(e,{...o,...s},a,c).nodes}const Sx={2:"²",3:"³"},Cx={exponential:"Exponential",linear:"Linear",logarithmic:"Logarithmic",polynomial:"Polynomial",power:"Power"};function Mx(e,t){const n=e.filter(([e])=>0!==e);return n.length?n.map(([e,n],i)=>{const o=`${t(Math.abs(e))}${n}`;return 0===i?e<0?`−${o}`:o:e<0?` − ${o}`:` + ${o}`}).join(""):t(0)}function $x(e,t=String,n="x"){const i=n,o="x"===n?"y":"x",a=e.coefficients;let r;if("exponential"===e.type)r=`${t(a[0])}e^(${t(a[1])}${i})`;else if("power"===e.type)r=`${t(a[0])}${i}^${t(a[1])}`;else if("logarithmic"===e.type)r=Mx([[a[1],`ln(${i})`],[a[0],""]],t);else{r=Mx(a.map((e,t)=>[e,0===t?"":1===t?i:`${i}${Sx[t]||`^${t}`}`]).reverse(),t)}return`${o} = ${r}`}function Ax(e,t,n,i){const o=n.nativeEvent,a=o&&o.touches&&o.touches.length?[o.touches[0].clientX,o.touches[0].clientY]:o?[o.clientX,o.clientY]:n.point;Ur(Cg(e).data([t.row||{}]).config(Ae.bind(e)(e.schema.tooltipConfig)).title(()=>t.label),Er(t.color,"Line")).thead([]).tbody(function(e,t,n){const{fit:i,axis:o}=t,a=t=>e.schema.translate(t),r=[];if(n&&n.projected){const t="x"===o?"y":"x",i=n=>vg(e,t,n),s=void 0!==n.lci?` (${i(n.lci)} – ${i(n.hci)})`:"";r.push([kg(e,o),`${vg(e,o,n[o])} (${a("Projected")})`],[kg(e,t),`${i(n[t])}${s}`])}var s;return r.push([a("Trend Line"),a(Cx[i.type])]),e[`_${o}Time`]||r.push([a("Equation"),$x(i,(s=e.schema.locale,e=>0!==e&&Math.abs(e)<.001?e.toPrecision(3):d.formatAbbreviate(e,s)),o)]),r.push(["R²",i.r2.toFixed(3)],[a("Observations"),`${i.n}`]),r}(e,t,i?function(e,t,n){const i="x"===t.axis?e._xFunc:e._yFunc;if(!i)return;const o="x"===t.axis?n[0]:n[1],a=e=>{let n,a=1/0;for(const r of e){const e=Math.abs(i(r[t.axis])-o);e<a&&([n,a]=[r,e])}return n},r=a(t.samples);return r&&r.projected?a(t.samples.filter(e=>e.step)):void 0}(e,t,i):void 0)).footer(!1).position(a).render()}function zx(e,t){const n=e._zoomTransform,i=n&&n.scale?n.scale:1,o=e._chartTransform;return[(t[0]-(n?.x??0))/i-(o?.x??0),(t[1]-(n?.y??0))/i-(o?.y??0)]}const Dx=e=>e instanceof Date?String(e.getTime()):String(e);function Fx(e,t){return!(!t.shapeType||!t.datum||"Box"===t.shapeType)&&("Bar"!==t.shapeType||!!e.schema.stacked)}function Bx(e,t,n){const i=new Map,o="x"===t?e._xFunc:e._yFunc,a=(e,o,a,r)=>{if(!e||!Number.isFinite(o))return null;const s=Dx(e[t]);let c=i.get(s);if(c||(c={px:o,value:e[t],members:new Map,bars:new Set,markers:[]},i.set(s,c)),"Bar"===r){const t=e.data||e;c.bars.add(t),n.bars.add(t)}const l=String(e.id),h=c.members.get(l);return h?h.color||(h.color=a):c.members.set(l,{wrapped:e,color:a,shape:r}),c},r=new Set,s=i=>{if(i.interactionGroup||!1===i.interactive)return;if(i.children&&i.children.forEach(e=>s(e)),"Box"===i.shapeType&&(n.box=!0),!Fx(e,i))return;const c=i.paint||{},l=Tr(c.stroke)??Tr(c.fill);if("Area"===i.shapeType&&(n.area=!0),i.interactionPoints)for(const e of i.interactionPoints){const n=a(e.datum,e[t],l,i.shapeType);n&&"Line"===i.shapeType&&!r.has(e.datum)&&(r.add(e.datum),n.markers.push({datum:e.datum,x:e.x,y:e.y}))}else if(o&&!i.datum.__d3plusShape__){const e=i.datum;a(e,o(e[t]),l,i.shapeType)}};return(e._chartScene||[]).forEach(e=>s(e)),o&&function(e,t,n,i){for(const o of e._trendFits||[])if(o.axis===t&&!1!==e._trendLineConfig?.tooltip)for(const e of o.samples){if(!e.step)continue;const a=e[t],r=i(a);if(!Number.isFinite(r))continue;const s=Dx(a);let c=n.get(s);c||(c={px:r,value:a,members:new Map,bars:new Set,markers:[]},n.set(s,c));const l=o.row||{};c.members.set(`${o.id}::projected`,{wrapped:l,color:o.color,shape:"Line",trend:{fit:o,sample:e}})}}(e,t,i,o),i}function Lx(e,t,n,i){if(i.trend){const{fit:e,sample:o}=i.trend,a=Number(o["x"===t?"y":"x"]);if(!Number.isFinite(a))return null;const r=String(e.label),s=e.row||{};return{id:n,name:r,value:a,color:i.color,shape:"Line",datum:s,index:0,projected:{lci:o.lci,hci:o.hci}}}const o="x"===t?e._y:e._x,a=i.wrapped.data||i.wrapped,r="number"==typeof i.wrapped.i?i.wrapped.i:0,s=o?Number(o(a,r)):NaN;if(!Number.isFinite(s)||!e.schema.tooltip(a,r))return null;return{id:n,name:String(e._drawLabel(a,r)),value:s,color:i.color,shape:i.shape,datum:a,index:r}}function Px(e,t,n){let i=null;for(const o of e.values())(void 0===n||o.members.has(n))&&(!i||Math.abs(o.px-t)<Math.abs(i.px-t))&&(i=o);return i}const Rx=e=>!(!e||!e.shapeType||!e.datum||e.interactionGroup||!1===e.interactive);function Ex(e,t){const n=t?.datum?.data;if(!n||Rx(t))return;let i;const o=e=>{i||(Rx(e)&&e.datum===n?i=e:e.children&&e.children.forEach(e=>o(e)))};return(e._chartScene||[]).forEach(e=>o(e)),i}function Nx(e,t,n,i){const o=e.schema.discrete;if("x"!==o&&"y"!==o)return null;const a=o,r="x"===a?n[0]:n[1],s={bars:new Set,area:!1,box:!1},c=Bx(e,a,s);if(s.box)return null;const l=s.area?"front":"back",h=t.pick?t.pick.node:void 0,u=Ex(e,h)??h,d=Rx(u)&&"Box"!==u.shapeType,f=(t,n,i,o)=>{const r=t?.members.get(n)??(o?{wrapped:o,color:Hr(e,u),shape:u?.shapeType}:void 0),s=r?Lx(e,a,n,r):null;if(!s||!Number.isFinite(i))return null;const c=t?t.markers.filter(e=>String(e.datum.id)===n):[],h=t?t.value:r.wrapped[a];return{mode:"single",axis:a,px:i,value:h,rows:[s],markers:c,layer:l}};if(i&&e.schema.tooltipShared){const t=Px(c,r);if(t){const n=[];if(t.members.forEach((t,i)=>{const o=Lx(e,a,i,t);o&&n.push(o)}),n.length>=2||n.some(e=>e.projected)){!function(e,t,n){const i="x"===t?e._yFunc:e._xFunc,o=e=>{const n=i?i(e):NaN;return Number.isFinite(n)?"x"===t?n:-n:-e};n.sort((e,t)=>o(e.value)-o(t.value))}(e,a,n);const i=t.bars.size?{rows:t.bars,bars:s.bars}:void 0;return{mode:"shared",axis:a,px:t.px,value:t.value,rows:n,markers:t.markers,layer:l,stack:i}}if(1===n.length&&!d)return f(t,n[0].id,t.px)}}if(!d)return null;const m=u.datum,p=String(m.id);if(u.interactionPoints){const e=Px(c,r,p);return e?f(e,p,e.px):null}return f(null,p,function(e,t){const n=e,i=n.transform?.[t]??0;return"rect"===n.type?i+(n[t]??0)+(("x"===t?n.width:n.height)??0)/2:"circle"===n.type?i+(("x"===t?n.cx:n.cy)??0):NaN}(jr(e,u)??u,a),m)}function Tx(e,t){let n=null;const i=e._plotArea;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;const o=t.pick&&t.pick.node;if(o&&o.trendFit)return void function(e,t,n){const i=e._sharedHoverState;e._sharedHoverActive=!0,e._sharedHoverState=null;const o=Array.isArray(n.point)?zx(e,n.point):void 0;Ax(e,t,n,o),i&&("shared"===i.mode&&"function"==typeof e._hover&&e.hover(!1),e._scheduleSceneRepaint())}(e,o.trendFit,t);if(i&&Array.isArray(t.point)&&(!o||"legend"!==o.interactionGroup)){const[o,a]=zx(e,t.point);n=Nx(e,t,[o,a],o>=i.x&&o<=i.x+i.width&&a>=i.y&&a<=i.y+i.height)}}else if("mouseleave"!==t.type||t.nativeEvent&&"mouseleave"!==t.nativeEvent.type)return;const o=e._sharedHoverState;if(n){e._sharedHoverActive=!0;const{mode:i,axis:a,px:r,value:s,markers:c,layer:l}=n,h=Mc(e,t.point)?.key;e._sharedHoverState={mode:i,axis:a,px:r,value:s,markers:c,layer:l,panel:h},"shared"===i?$g(e,n,t):function(e,t,n){const i=t.rows[0],o=e._drawDepth<e.schema.groupBy.length-1,a=Cg(e).data([i.datum]).title(()=>e._drawLabel(i.datum,i.index)).footer(!(!o||!e.schema.on["click.shape"])&&e.schema.translate("Click to Expand")).config(Ae.bind(e)(e.schema.tooltipConfig)),r=a.tbody(),s="function"==typeof r?r(i.datum,i.index):r;Ur(a,Er(i.color,i.shape)).tbody([...!1===e._tooltipAxisRows?[]:[wg(e,"x",t),wg(e,"y",t)],...i.projected?[]:gg(e,i.datum,i.index,n=>vg(e,_g(t.axis),n)),...Array.isArray(s)?s:[],...Br(e,i.datum)]).arrow(!1).position(Sg(e,t,n)).render()}(e,n,t),o&&o.px===r&&o.mode===i&&o.panel===h||(!function(e,t,n){const i=t.stack,o=()=>{"function"==typeof e._hover&&e.hover(!1)},a=e._plotColumnHighlight;if(a&&1===e.schema.shapeConfig.hoverOpacity)o();else if(a){const n=new Set(t.rows.map(e=>e.datum));ht(e,e=>n.has(e)),e.hover(a(n))}else"single"===t.mode?"shared"===n&&o():i?(ht(e,e=>i.rows.has(e)),e.hover(e=>i.rows.has(e)||!i.bars.has(e))):o()}(e,n,o?.mode),e._scheduleSceneRepaint())}else e._sharedHoverActive&&(e._sharedHoverActive=!1,e._sharedHoverState=null,e._tooltipClass.data([]).render(),function(e){const t=e._sharedTooltipSaved;t&&e._tooltipClass.arrow(t.arrow).thead(t.thead).tbody(t.tbody),e._sharedTooltipSaved=void 0}(e),"function"==typeof e._hover&&e.hover(!1),e._scheduleSceneRepaint())}const Ox=/::(hit|stem|confidence)$/;function Wx(e,t){return Math.abs(e)>=Math.abs(e+t)?e:e+t}function jx(e,t,n){return Number.isFinite(t)?{...e,[n]:t,span:[e[n],t]}:e}function Hx(e,t,n){const i=e,o=i.datum;if(!o||"string"==typeof i.key&&Ox.test(i.key))return[];const a=i.shapeType;if(i.interactionPoints)return i.interactionPoints.map(e=>({x:e.x,y:e.y,datum:e.datum,color:n,shape:a}));const r=i.transform?.x??0,s=i.transform?.y??0;if("circle"===i.type)return[{x:r+(i.cx??0),y:s+(i.cy??0),datum:o,color:n,shape:a}];if("rect"!==i.type)return[];const c=i.x??0,l=i.y??0,h=i.width??0,u=i.height??0;if("Bar"!==a)return[{x:r+c+h/2,y:s+l+u/2,datum:o,color:n,shape:a}];if("x"===t){const e=r+Wx(c,h);return[{x:e,y:s+l+u/2,datum:o,color:n,shape:a,span:[r,e]}]}const d=s+Wx(l,u);return[{x:r+c+h/2,y:d,datum:o,color:n,shape:a,span:[s,d]}]}function Ix(e){return!(!e||!e.shapeType||!e.datum||"Box"===e.shapeType||e.interactionGroup||!1===e.interactive||e.datum.__d3plusShape__)}function Gx(e,t,n){let i=null,o=1/0;for(const a of e){const e=a.span,r=e&&n>=Math.min(e[0],e[1])&&n<=Math.max(e[0],e[1])?0:Math.abs(a[t]-n);r<o&&(o=r,i=a)}return i}const Vx=(e,t,n)=>e(t,n);function qx(e,t,n,i){return Number.isFinite(t)&&Math.abs(t-n)<=1?e:i?i(n):e}function Yx(e,t){if(null==t)return"";if("number"==typeof t&&!Number.isFinite(t))return"";return`${(e?e(t):`${t}`)??""}`.replace(/<[^>]*>/g,"").trim()}function Kx(e,t,n,i){const o=e[`_${t}Axis`]?._d3Scale;if(!o||"function"!=typeof o.invert)return;const a=Vx(n,i,t)-o(i);return Number.isFinite(a)?e=>o.invert(e-a):void 0}function Ux(e,t,n){if("Area"!==t.shape)return t;const i=void 0!==t.datum[`${n}2`]?`${n}2`:n,o="x"===n?e._xFunc:e._yFunc,a=Number(t.datum[i]);if(!o||!Number.isFinite(a))return t;if(!e.schema.stacked)return jx(t,Vx(o,a,i),n);const r=Kx(e,i,o,a),s=r?Number(r(t[n])):NaN;return Number.isFinite(s)?jx(t,Vx(o,s+a,i),n):t}function Xx(e){const t=e.schema.discrete;return"x"===t||"y"===t?t:void 0}function Qx(e,t,n){const i=Xx(e),o=t.pick?t.pick.node:void 0,a=jr(e,Ex(e,o)??o),r=Ix(a);if(i){const t=e._sharedHoverState;if(!t)return r?function(e,t,n,i){const o="x"===n?"y":"x",a=Hx(t,o,Hr(e,t));return a.length&&void 0!==a[0].datum[`${o}2`]?Gx(a.map(t=>Ux(e,t,o)),n,i["x"===n?0:1]):null}(e,a,i,n):null;const o="single"===t.mode&&r?String(a.datum.id):void 0,s="x"===i?"y":"x",c=function(e){const t="y"===e.schema.discrete?"x":"y",n=[],i=o=>{o.interactionGroup||!1===o.interactive||(o.children&&o.children.forEach(e=>i(e)),Ix(o)&&n.push(...Hx(o,t,Hr(e,o))))};return(e._chartScene||[]).forEach(e=>i(e)),n}(e).map(t=>Ux(e,t,s)).filter(e=>Math.abs(e[i]-t.px)<=1&&(void 0===o||String(e.datum.id)===o)),l="x"===i?"y":"x";return Gx(c,l,n["x"===l?0:1])}if(!r)return null;return function(e,t){let n=null,i=1/0;for(const o of e){const e=Math.hypot(o.x-t[0],o.y-t[1]);e<i&&(i=e,n=o)}return n}(Hx(a,"y",Hr(e,a)).map(t=>Ux(e,t,"y")),n)}const Zx=e=>e?JSON.stringify([e.point,e.color,e.panel,e.badges]):"";function Jx(e,t){let n=null;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;const i=t.pick?.node;if(!1!==e.schema.axisHover&&e._plotArea&&Array.isArray(t.point)&&(!i||"legend"!==i.interactionGroup)&&(n=function(e,t,n){const i=Qx(e,t,n);if(!i||!function(e,t){const n=e._plotArea;return!!n&&t.x>=n.x-1&&t.x<=n.x+n.width+1&&t.y>=n.y-1&&t.y<=n.y+n.height+1}(e,i))return null;const o=Xx(e),a=o?e._sharedHoverState:null,r=e.schema.axisHover,s=function(e,t){const n=[];for(const i of["x","y"])t.bar&&i===(t.discrete??"x")||t.cross!==i&&(t.only&&t.only!==i||n.push(void 0!==e[`${i}2`]?`${i}2`:i));return n}(i.datum,{discrete:o,bar:"Bar"===i.shape,cross:e._swarm?.cross,only:"x"===r||"y"===r?r:void 0}),c=[];for(const t of s){const n=t.charAt(0),r=!!a&&n===o,s=r?a.px:i[n],l="x"===n?e._xFunc:e._yFunc,h=r?a.value:i.datum[t],u=Yx(n=>vg(e,t,n),r||!l?h:qx(h,Vx(l,h,t),s,Kx(e,t,l,h)));u&&c.push({axis:t,at:s,text:u,guide:!r})}if(!c.length)return null;const l=i.datum.data||i.datum;return{point:{x:i.x,y:i.y},color:i.color,datum:l,index:"number"==typeof i.datum.i?i.datum.i:0,badges:c}}(e,t,zx(e,t.point)),n)){const i=Mc(e,t.point)?.key;void 0!==i&&(n.panel=i)}}else if("mouseleave"!==t.type)return;const i=e._axisHoverState;Zx(i)!==Zx(n)&&(e._axisHoverState=n,e._scheduleSceneRepaint())}function eb(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",t.children&&t.children.forEach(eb),e}const tb=e=>{const t=e,n=t.datum;return!!t.shapeType&&!t.interactionGroup&&!1!==t.interactive&&!!n&&void 0!==n.id};function nb(e,t,n,i){const o=[...e];if(t.length){const e=o.findIndex(e=>tb(e)||Ly(e)&&e.children.some(tb));"back"===i&&e>=0?o.splice(e,0,...t):o.push(...t)}return o.push(...n),o}function ib(e,t,n,i){const o=e._plotArea;if(!o)return t;const{state:a,axis:r}=n,s="x"===e.schema.discrete||"y"===e.schema.discrete,c=s&&e.schema.tooltipShared&&function(e){const t=n=>!n.interactionGroup&&!1!==n.interactive&&(!!Fx(e,n)||!!n.children&&n.children.some(e=>t(e)));return(e._chartScene||[]).some(e=>t(e))}(e)?[{type:"rect",key:i("plot-hover-surface"),...o,interactionGroup:"axis",paint:{fill:"transparent"}}]:[];let l=t;const h=a&&s?function(e,t){const n=()=>t.px,i="x"===t.axis?n:e._xFunc,o="y"===t.axis?n:e._yFunc,a=e._plotAxisDomains?.x,r=e._plotAxisDomains?.y;if(!(i&&o&&a?.length&&r?.length))return null;const s="x"===t.axis?r:a,c=Ry(Ey(e,{shape:"Line",data:[s[0],s[s.length-1]].map(e=>"x"===t.axis?{x:t.value,y:e}:{x:e,y:t.value}),id:()=>"crosshair",...e._crosshairConfig},i,o,{x:a,y:r},0),"plot-crosshair");return c?eb(c):null}(e,a):null,u=r?Hf(e,r):null,d=bd([...h?[h]:[],...u?u.guides:[]],i),f=bd(a&&s?function(e,t){if(e._lineMarkers||!t.markers.length)return[];const n=new Map(t.markers.map(e=>[e.datum,e])),i=eu("Circle").renderMode("compute").data(t.markers.map(e=>e.datum)).config(e._lineMarkerConfig).x(e=>n.get(e).x).y(e=>n.get(e).y).id(e=>`${e.id}_shared`);return i.render(),[{type:"group",key:"plot-shared-markers",children:su(i)}].map(eb)}(e,a):[],i);if(d.length||f.length){const e=a?a.layer:"back",t=l.findIndex(e=>e.key===i(bx));if(t>=0){const n=l[t];l=[...l],l[t]={...n,children:nb(n.children||[],d,f,e)}}else l=nb(l,d,f,e)}const m=u?bd(u.badges,i):[];return[...c,...l,...m]}function ob(e,t){const n=e.schema.discrete;if("x"!==n&&"y"!==n&&!e._axisHoverState)return;const i=t.root.children.find(e=>"viz-chart-cells"===e.key),o=i&&i.children&&i.children[0],a=o&&o.children&&o.children[0];if(!a||!a.children)return;const r=e._facetPanels;a.children=r?a.children.map(t=>{const n=r.find(e=>e.key===t.key);return n?function(e,t,n){const i=t.children||[],o=i.findIndex(e=>e.key===`${n.key}/cells`),a=i[o],r=a&&a.children&&a.children[0];if(!a||!r||!r.children)return t;const s=e._sharedHoverState,c=e._axisHoverState,l=$c(e,n,()=>ib(e,r.children,{state:s&&s.panel===n.key?s:null,axis:c&&c.panel===n.key?c:null},e=>`${n.key}/${e}`)),h=[...i];return h[o]={...a,children:[{...r,children:l},...a.children.slice(1)]},{...t,children:h}}(e,t,n):t}):ib(e,a.children,{state:e._sharedHoverState,axis:e._axisHoverState},e=>e)}const ab=/^plot-(x|x2|y|y2)-axis$/;function rb(e,t){if(e.schema[`${t}Sort`])return!0;if(Sm(e,t))return!1;const n=e[`_${t}Time`];return e.schema.discrete===t.charAt(0)&&!n}function sb(e){let t,n;for(const i of e)for(const e of i)null==e||Number.isNaN(+e)||((void 0===t||+e<+t)&&(t=e),(void 0===n||+e>+n)&&(n=e));return void 0===t||void 0===n?void 0:[t,n]}function cb(e,t){const n=t.filter(e=>e.length).map(t=>function(e,t){e._filteredData=t;const n=ne({viz:e},[sg,cg,Yp,Up]);return{formatted:n.plotFormattedData||[],domains:n.plotInitialDomains||{}}}(e,t)),i=n.flatMap(e=>e.formatted),o=ne({viz:e,plotFormattedData:i,plotAxisData:i},[cg]),a={};for(const t of Qm)if(n.some(e=>e.domains[t]))if(rb(e,t)){const e=o[`${t}Data`];e&&e.length&&(a[t]=e)}else{const e=sb(n.map(e=>e.domains[t]||[]));e&&(a[t]=e)}const r=e._size?i.map(t=>e._size(t.data)):[],s=r.length?og(e,r):void 0;return{domains:a,size:s,padded:lb(e,i,a,s)}}function lb(e,t,n,i){const o=e._sizeScaleD3;i&&(e._sizeScaleD3=i);const a=ne({viz:e,plotFormattedData:t,plotAxisData:t,plotInitialDomains:{...n}},[mp,lg]);e._sizeScaleD3=o;const r={},s=a.plotScales;if(!s)return r;for(const e of Qm){const t=s[e];t&&"function"==typeof t.invert&&(r[e]=t.domain())}return r}function hb(e,t){const n=e||{};return{...n,labels:t?n.labels:[],title:!!t&&n.title}}function ub(e,t){e&&e.config({labels:t?.labels,title:t?.title})}function db(e,t){const n={scales:e._plotFacetScales,x:e._xConfig,y:e._yConfig};return e._plotFacetScales=t.shared?t.scales:void 0,e._xConfig=hb(n.x,t.labels.x),e._yConfig=hb(n.y,t.labels.y),()=>{e._plotFacetScales=n.scales,e._xConfig=n.x,e._yConfig=n.y,ub(e._xAxis,n.x),ub(e._yAxis,n.y)}}function fb(e){const t=e._plotArea,n=e._chartTransform;if(!t||!n)return{top:0,right:0,bottom:0,left:0};const i=t.x+(n.x??0),o=t.y+(n.y??0);return{top:o-e._margin.top,right:e.schema.width-e._margin.right-(i+t.width),bottom:e.schema.height-e._margin.bottom-(o+t.height),left:i-e._margin.left}}const mb={aspect:4/3,share:cb,panel:db,insets:fb,capture:e=>({_plotArea:e._plotArea,_plotAxisDomains:e._plotAxisDomains,_xFunc:e._xFunc,_yFunc:e._yFunc,_trendFits:e._trendFits,_barSpans:e._barSpans})},pb=e=>Array.isArray(e)?e.map(pb).join(""):e instanceof Date?+e:e;function gb(e,t){const{aggs:n,id:i,position:a,threshold:r,value:s}=t,c=Math.min(1,Math.max(0,+r(e)));if(!(c>0))return null;const l=new Map,h=new Map;let u=0;if(e.forEach((e,t)=>{const n=`${i(e,t)}`,o=Math.abs(+s(e,t))||0;l.set(n,(l.get(n)??0)+o);const a=h.get(n);a?a.push(e):h.set(n,[e]),u+=o}),!(u>0))return null;const d=new Set;if(l.forEach((e,t)=>{e<c*u&&d.add(t)}),d.size<2)return null;const f=function(e,t,n){const i=new Set;e.forEach(e=>e.forEach(e=>Object.keys(e).forEach(e=>i.add(e))));const a=Array.from(i).filter(n=>e.every(e=>{let i;return e.every((e,o)=>{const a=e[n];if("number"==typeof a)return!1;const r=pb(a);return!t.some(t=>pb(t(e,o))===r)&&(0===o&&(i=r),r===i)})})),r=e.filter(e=>e.length).map(e=>{const t={};for(const n of a)t[n]=e[0][n];return t});return o.merge(r,n)}(Array.from(d,e=>h.get(e)),a,n);return{members:d,percent:c,identity:f}}function yb(e,t,n){const{aggs:i,id:a,position:r}=n,s=n.label??a,c=n.measure??n.value,l=[],h=new Map;if(e.forEach((e,n)=>{if(!t.members.has(`${a(e,n)}`))return void l.push(e);const i=r.map(t=>`${pb(t(e,n))}`).join(""),o=h.get(i);o?o.push(e):h.set(i,[e])}),!h.size)return e;const u=Array.from(h.values(),e=>{const n=o.merge(e,i),l=e[0],h=r.map(e=>pb(e(l,0)));for(const t of Object.keys(l))h.some(n=>e.every(e=>pb(e[t])===n))&&(n[t]=l[t]);return{...n,...t.identity,_isAggregation:!0,_threshold:t.percent,[zr]:Dr(e,a,s,c)}});return l.concat(u)}function xb(e){const t="y"===e.schema.discrete?"y":"x",n="x"===t?"y":"x",i=[e[`_${t}`]];return e.schema.time&&i.push(e.schema.time),{aggs:e.schema.aggs,id:e._id,label:e._drawLabel,measure:e[`_${n}`],position:i,threshold:e.schema.threshold,value:e.schema.thresholdKey??e[`_${n}`]}}function bb(e){const t=e?.domain;return Array.isArray(t)?{...e,domain:t.slice().reverse()}:e}class _b extends yf{_preDraw(){["x","y","x2","y2"].forEach(e=>{if(this[`_${e}Key`]){const t=this[`_${e}Key`];this.schema.aggs[t]||this.schema.discrete!==e||(this.schema.aggs[t]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),t!==e&&this[`_${e}Title`]===this[`_${e}Config`].title&&this.schema.discrete!==e&&(this[`_${e}Title`]=t,this[`_${e}Config`].title=t)}}),super._preDraw()}_thresholdLegend(e){return function(e,t){if(!e.schema.stacked||!t.length)return t;const n=xb(e),i=gb(t,n);return i?yb(t,i,{...n,position:[]}):t}(this,e)}_thresholdFunction(e,t,n){return function(e,t,n=t){if(!e.schema.stacked)return t;const i=xb(e),o=gb(n,i);return o?yb(t,o,i):t}(this,e,n)}toScene(){const e=yf.prototype.toScene.call(this);if(Array.isArray(this._filteredData)&&0===this._filteredData.length&&(!this._annotations||0===this._annotations.length))return e;const t=[];for(const e of["_xAxis","_x2Axis","_yAxis","_y2Axis"]){const n=this[e];n&&"function"==typeof n.toScene&&n._select&&"function"==typeof n._select.node&&n._select.node()&&t.push({type:"group",key:`plot-${e}`,children:[n.toScene()]})}return e.root.children.unshift(...t),ob(this,e),e}_wirePlotShapeEvents(e,t,n){const i=n.filter(e=>e.includes(`.${t}`)),o=n.filter(e=>!e.includes(".")),a=n.filter(e=>e.includes(".shape")),r=e=>(t,n,i,o)=>this.schema.on[e](t.data,t.i,i,o);for(const t of o)e.on(t,r(t));for(const t of a)e.on(t,r(t));for(const t of i)e.on(t,r(t))}_interactionDatum(e,t){const n=e.node,i=n&&n.interactionPoints;if(n&&"legend"!==n.interactionGroup&&Array.isArray(i)&&i.length&&t&&Array.isArray(t.point)){const e=this._nearestInteractionPoint(i,t.point);if(e){const t=e.datum;return{d:t&&t.data?t.data:t,i:"number"==typeof t.i?t.i:e.index,x:t}}}return super._interactionDatum(e,t)}_nearestInteractionPoint(e,t){const[n,i]=zx(this,t),o="y"===this.schema.discrete?"y":"x",a="y"===o?i:n;let r=null,s=1/0;for(const t of e){const e=Math.abs(t[o]-a);e<s&&(s=e,r=t)}return r}_sharedHover(e){Tx(this,e),Jx(this,e)}_draw(e){return ay(this,e)}_facetHooks(){return mb}_sizeLegendScale(){return function(e){if(!e._size)return null;const t=e._axisPersist?e._data:e._filteredData||[],n=[];let i=!1;return t.forEach((t,o)=>{ig(e._x(t,o))||ig(e._y(t,o))||(n.push(e._size(t,o)),ag(e,e.schema.shape(t,o))&&(i=!0))}),i?og(e,n):null}(this)}_insetRegion(){return function(e){const t=e._plotArea,n=e._chartTransform;return t&&n?Uu(e,{x:t.x+(n.x??0),y:t.y+(n.y??0),width:t.width,height:t.height},e=>ab.test(String(e.key))):null}(this)}_paint(e){const t=this,n=t._zoomEventTarget||t._container;return this._chartScene=vx(t,e,n&&n.node()?b.zoomTransform(n.node()):void 0),this}_zoomRescale(e,t=0){if(this._facetPanels)return!1;const n=function(e,t,n){clearTimeout(e._plotUnclipTimer);const i=e._chartScene?.find(e=>e.key===bx),o="group"===i?.type&&!!i.clip&&n>0&&1===t.k&&!t.x&&!t.y,a=wx(e,t,o);return a&&o&&(e._plotUnclipTimer=setTimeout(()=>{const n=wx(e,t);n&&(e._chartScene=n,e._drawSceneToTarget(0))},n)),a}(this,e,t);return!!n&&(this._chartScene=n,!0)}annotations(e){return arguments.length?(this._annotations=e instanceof Array?e:[e],this):this._annotations}axisPersist(e){return arguments.length?(this._axisPersist=e,this):this._axisPersist}baseline(e){return arguments.length?(function(e,t){e._userBaseline=t===O||void 0===t?void 0:t}(this,e),this):(t=this)._userBaseline??t.schema.baseline;var t}backgroundConfig(e){return arguments.length?(this._backgroundConfig=Y(this,"backgroundConfig",e,this._backgroundConfig),this):this._backgroundConfig}buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=Nf;else{this._buffer=n.assign({},this._buffer,e);for(const e in this._buffer){const t=this._buffer;!0===t[e]&&(t[e]=Nf[e])}}else this._buffer={};return this}return this._buffer}confidence(e){if(!arguments.length)return this._confidenceBands&&this._confidenceBands.length>1?this._confidenceBands:this._confidence;const t=this._confidenceBands=Fm(e);return this._confidence=!!t.length&&[t[0].lower,t[0].upper],this}confidenceConfig(e){return arguments.length?(t=this.constructor.name,(n=e)&&"object"==typeof n&&Object.getPrototypeOf(n)===Object.prototype&&Fa(t,n,$m),this._confidenceConfig=Y(this,"confidenceConfig",e,this._confidenceConfig),this):this._confidenceConfig;var t,n}discreteCutoff(e){return arguments.length?(this._discreteCutoff=e,this):this._discreteCutoff}groupPadding(e){return arguments.length?(this._groupPadding=e,this):this._groupPadding}labelConnectorConfig(e){return arguments.length?(this._labelConnectorConfig=Y(this,"labelConnectorConfig",e,this._labelConnectorConfig),this):this._labelConnectorConfig}labelPosition(e){return arguments.length?(this._labelPosition="function"==typeof e?e:N(e),this):this._labelPosition}crosshairConfig(e){return arguments.length?(this._crosshairConfig=Y(this,"crosshairConfig",e,this._crosshairConfig),this):this._crosshairConfig}trendLine(e){return arguments.length?(this._trendLine=e,this):this._trendLine}trendLineConfig(e){return arguments.length?(this._trendLineConfig=Y(this,"trendLineConfig",e,this._trendLineConfig),this):this._trendLineConfig}lineMarkerConfig(e){return arguments.length?(this._lineMarkerConfig=Y(this,"lineMarkerConfig",e,this._lineMarkerConfig),this):this._lineMarkerConfig}lineMarkers(e){return arguments.length?(this._lineMarkers=e,this):this._lineMarkers}size(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size}stackOffset(e){return arguments.length?(this._stackOffset=Ep(e),this):this._stackOffset}stackOrder(e){return arguments.length?(this._stackOrder=Bp(e),this):this._stackOrder}x(e){return arguments.length?("function"==typeof e?this._x=e:(this._x=Be(e),this._xKey=e),this):this._x}x2(e){return arguments.length?("function"==typeof e?this._x2=e:(this._x2=Be(e),this._x2Key=e),this):this._x2}xConfig(e){return arguments.length?(this._xConfig=Y(this,"xConfig",e,this._xConfig),this):this._xConfig}x2Config(e){return arguments.length?(this._x2Config=Y(this,"x2Config",e,this._x2Config),this):this._x2Config}y(e){return arguments.length?("function"==typeof e?this._y=e:(this._y=Be(e),this._yKey=e),this):this._y}y2(e){return arguments.length?("function"==typeof e?this._y2=e:(this._y2=Be(e),this._y2Key=e),this):this._y2}yConfig(e){return arguments.length?(this._yConfig=Y(this,"yConfig",bb(e),this._yConfig),this):this._yConfig}y2Config(e){return arguments.length?(this._y2Config=Y(this,"y2Config",bb(e),this._y2Config),this):this._y2Config}constructor(){var e;super(),this._trendLine=hg.defaults.trendLine,this._trendLineConfig={confidence:!1,confidenceConfig:{fillOpacity:.15},confidenceLevel:.95,group:"series",order:2,projection:0,projectionConfig:{strokeDasharray:"2 4"},strokeDasharray:"6 4",strokeWidth:2,tooltip:!0},ee(this,Bg),Lg(this),(e=this)._x=T("x"),e._xKey="x",e._xAxis=(new ui).align("end"),e._xConfig={gridConfig:{stroke:t=>{if("x"===e.schema.discrete?.charAt(0)||"x"===e._swarm?.cross)return"transparent";const n=e._xAxis.range(),i=e._xAxis._getPosition.bind(e._xAxis)(t.id);return n[0]===i?"transparent":Zn(e._select?.node(),e.schema.colorDefaults)}}},e.schema.xCutoff=150,e._x2=T("x2"),e._x2Key="x2",e._x2Axis=(new mi).align("start"),e._x2Config={},e._y=T("y"),e._yKey="y",e._yAxis=(new di).align("start"),e._yKey="y",e._yConfig={gridConfig:{stroke:t=>{if("y"===e.schema.discrete?.charAt(0)||"y"===e._swarm?.cross)return"transparent";const n=e._yAxis.range(),i=e._yAxis._getPosition.bind(e._yAxis)(t.id);return n[n.length-1]===i?"transparent":Zn(e._select?.node(),e.schema.colorDefaults)}}},e.schema.yCutoff=150,e._y2=T("y2"),e._y2Key="y2",e._y2Axis=(new fi).align("end"),e._y2Config={}}}K(_b.prototype,"backgroundConfig","baseline","confidenceConfig","crosshairConfig","labelConnectorConfig","lineMarkerConfig","trendLineConfig","xConfig","x2Config","yConfig","y2Config");var kb=xf({name:"AreaPlot",paintDriven:!0,ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:N("Area"),coerce:"const"}]},_b);function vb(e){const t=[()=>e.schema.translate("Share"),(t,n,i)=>{const o=Mr(i);let a=Sr(o);if(!Number.isFinite(a)){const t=e["_"+("y"===e.schema.discrete?"x":"y")];a=o?$r(o,e._legendData||[],t):NaN}return Number.isFinite(a)?`${d.formatAbbreviate(100*a,e.schema.locale)}%`:""}];return{tbody:()=>e.schema.stacked?[t]:[]}}const wb={name:"BarChart",paintDriven:!0,ctx:{},fields:[{key:"barWidth",coerce:fm},{key:"barWidthShare",default:!1},{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:N("Bar"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:function(e){const t=vb(e);return{tbody:n=>[...wm(e,n),...t.tbody()]}}},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{if(e._legendCategories)return t.call(e,n,i);return i.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()!==e._filteredData.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()&&t.call(e,n,i)}}}]};var Sb=xf(wb,_b);const Cb={name:"Beeswarm",paintDriven:!0,ctx:{},fields:[{key:"shapeConfig",merge:!0,default:{Circle:{label:!1,trail:!1}}},{key:"swarm",default:!0}]};var Mb=xf(Cb,_b);const $b=new WeakMap;function Ab(e,t){for(;e.__d3plus__&&e.data;)t=e.i,e=e.data;return[e,t]}function zb(e){const t=e.schema.shapeConfig||{},n=(t.Box||{}).whiskerMode??t.whiskerMode;return void 0===n?["tukey","tukey"]:Zo(n)}function Db(e,t,n){if(!t)return[];const i=t=>void 0===t?"":d.formatAbbreviate(t,e.schema.locale),o=t=>e.schema.translate(t),[a,r]=Ab(t,n);if(ca(e.schema)){const t=fa(e.schema,a,r);return t?[[o("Maximum"),i(t.max)],[o("Upper Quartile"),i(t.q3)],[o("Median"),i(t.median)],[o("Lower Quartile"),i(t.q1)],[o("Minimum"),i(t.min)]]:[]}const s=function(e,t){const n=$b.get(t);if(!n)return null;const i="vertical"===n.orient,o=n.values.map(e=>{const t=i?e.y2??e.y:e.x2??e.x;return"number"==typeof t||t instanceof Date?+t:NaN}).filter(Number.isFinite).sort((e,t)=>e-t);return o.length?Jo(o,zb(e)):null}(e,a);if(!s)return[];const c=zb(e);return[["extent"===c[1]?"Maximum":"Upper Whisker",s.upperLimit],["Upper Quartile",s.third],["Median",s.median],["Lower Quartile",s.first],["extent"===c[0]?"Minimum":"Lower Whisker",s.lowerLimit]].filter(([,e])=>void 0!==e).map(([e,t])=>[o(e),i(t)])}const Fb=e=>"y"===e.schema.discrete?"x":"y";function Bb(e){const t=au(e,"Box").outlier;return"function"==typeof t?t:void 0===t||Qo(t)?null:()=>t}const Lb=(e,t)=>{const n=e[t];return"number"==typeof n||n instanceof Date?+n:NaN};function Pb(e,t,n){if(ca(e.schema)||n.charAt(0)!==Fb(e))return t;const i=Bb(e);return i?function(e,t){const n=e.schema.discrete,i="function"==typeof e.schema.facet?e.schema.facet:void 0;return h.groups(t,e=>i?`${e[n]}\0${i(e.data,e.i)}`:`${e[n]}`).map(([,e])=>e)}(e,t).flatMap(t=>function(e,t,n,i){const o=t.map(e=>Lb(e,n)).filter(Number.isFinite).sort((e,t)=>e-t);if(!o.length)return t;const{lowerLimit:a,upperLimit:r}=Jo(o,zb(e)),s=t.filter(e=>{const t=Lb(e,n);return!(t<a||t>r)||Qo(i(e,e.i))});if(s.length===t.length)return t;const c=t[0][n]instanceof Date,l=[a,r].filter(e=>Number.isFinite(e)).map(e=>({...t[0],[n]:c?new Date(e):e}));return s.concat(l)}(e,t,n,i)):t}const Rb=e=>ca(e.schema);function Eb(e){const t=function(e){const t=Bb(e);return e=>!t||Qo(t(e,e.i))}(e);return n=>function(e,t,n,i=!0){const o=[];for(const i of ra){const a=e[i],r="function"==typeof a?ua(a(t,n)):NaN;ha(r)&&o.push(r)}return i?o.concat(da(e,t,n)):o}(e.schema,n.data,n.i,t(n))}function Nb(e){const t=Lf,n=this,i=Fb(this);if(!Rb(this)){const o=Pb(this,e.data,e.x2?`${i}2`:i);return t.call(n,{...e,data:o})}if(e.x2)return t.call(n,e);const o=Eb(this),a=e.data.flatMap(e=>o(e).map(t=>({...e,[i]:t})));return t.call(n,{...e,data:a})}function Tb(e,t){const n=e=>"number"==typeof e||e instanceof Date?t(e):NaN;return t=>{const i=e(t.data,t.i);return Array.isArray(i)?i.map(n):n(i)}}const Ob=(e,t)=>{const{viz:n}=e;if(!Rb(n))return function(e){const t=e=>{for(const n of e){"group"===n.type&&t(n.children);for(const e of n.owners||[])"Box"===e.shapeType&&e.datum&&$b.set(Ab(e.datum,e.index)[0],e.datum)}};return t(e),e}(cx(e,t));const i="y"===Fb(n)?e.y:e.x,o={};for(const e of[...ra,"boxOutliers"]){const t=n.schema[e];"function"==typeof t&&(o[e]=Tb(t,i))}return cx({...e,shapeConfig:{...e.shapeConfig,...o}},t)};var Wb=xf({name:"BoxWhisker",paintDriven:!0,setup:e=>{e._buffer={...e._buffer,Box:Nb},e._plotShapeEmitters={Box:Ob},e._plotAxisValues=(t,n)=>function(e,t,n){return Rb(e)&&n===Fb(e)?t.flatMap(Eb(e)):[]}(e,t,n),e._plotAxisRows=(t,n)=>Pb(e,t,n)},ctx:{},fields:[{key:"boxMax",coerce:sa},{key:"boxMedian",coerce:sa},{key:"boxMin",coerce:sa},{key:"boxOutliers",coerce:sa},{key:"boxQ1",coerce:sa},{key:"boxQ3",coerce:sa},{key:"discrete",default:"x"},{key:"shape",default:N("Box"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)n=(t=t.data).i;const i=e.schema.label;if(i)return i(t,n);const o=e._drawDepth+(Rb(e)?1:0),a=e._ids(t,n).slice(0,o);return a[a.length-1]},tbody:(t,n)=>Db(e,t,n)})}]},_b);const jb=e=>e*Math.PI/180,Hb=e=>180*e/Math.PI;function Ib(e,t,n,i){const[o,a]=t,r=a-o,s=Number.isFinite(e)&&r?(e-o)/r:0;return n+Math.max(0,Math.min(1,s))*(i-n)}function Gb(e,t=[],n=void 0,i=10){const o=[0,...e,...t.flatMap(e=>[e.min,e.max])].filter(e=>"number"==typeof e&&Number.isFinite(e)),[a,r]=n??[],c=Number.isFinite(a)?a:Math.min(...o);let l=Number.isFinite(r)?r:Math.max(...o);l>c||(l=c+1);const[h,u]=s.scaleLinear().domain([c,l]).nice(i).domain();return[Number.isFinite(a)?c:h,Number.isFinite(r)?l:u]}function Vb(e,t){return Math.max(2,Math.round(Math.abs(Hb(t-e))/45))}function qb(e,t,n,i){const[o,a]=e,r=a-o;if(!1===t)return{major:[],minor:[]};const c=s.scaleLinear().domain(e),l="number"==typeof t?Math.max(1,t):i;let h;if(Array.isArray(t))h=t.filter(e=>Number.isFinite(e)&&e>=o&&e<=a).sort((e,t)=>e-t);else{const e=c.ticks(l),t=e.length>1?e[1]-e[0]:r;h=[o,...e.filter(e=>e-o>=t/2&&a-e>=t/2),a]}const u=n?c.ticks(Math.max(1,5*(h.length-1||l))).filter(e=>e>o&&e<a&&!h.some(t=>((e,t,n)=>Math.abs(e-t)<=1e-9*n)(t,e,r))):[];return{major:h,minor:u}}function Yb(e,t,n){const[i,o]=t,a=[];let r=i;for(const t of e??[]){if(!t)continue;const e=f.clamp(Number.isFinite(t.min)?t.min:r,i,o),s=f.clamp(Number.isFinite(t.max)?t.max:o,i,o);r=s,s>e&&a.push({min:e,max:s,color:t.color??n})}return a}function Kb(e,t){const n=Math.min(e,t),i=Math.max(e,t),o=[n,i],a=Math.PI/2;for(let e=Math.ceil(n/a);e*a<=i;e++)o.push(e*a);const r=[0,...o.map(e=>Math.sin(e))],s=[0,...o.map(e=>-Math.cos(e))];return{x0:Math.min(...r),x1:Math.max(...r),y0:Math.min(...s),y1:Math.max(...s)}}function Ub(e,t){return{x0:Math.min(e.x0,t.x0),x1:Math.max(e.x1,t.x1),y0:Math.min(e.y0,t.y0),y1:Math.max(e.y1,t.y1)}}function Xb(e,t,n){const i=n.x1-n.x0||1,o=n.y1-n.y0||1,a=Math.max(0,Math.min(e/i,t/o));return{cx:e/2-(n.x0+n.x1)/2*a,cy:t/2-(n.y0+n.y1)/2*a,radius:a}}function Qb(e,t,n){const i=.2*t,o=.7*t;return`M${-t},0L${-i},${-e}L${i},${-e}L${t},0L${o},${n}L${-o},${n}Z`}function Zb(e,t){const{indicator:n,hasBands:i,hasValue:o,extent:a}=t,r=t.hasName&&o,s="progress"!==n,c=function(e,t,n,i){const o=i?Math.max(1,n):1,a=o>1?Math.max(2,.02*e):0;let r=e*t;return o>1&&o*r+(o-1)*a>.5*e&&(r=Math.max(1,(.5*e-(o-1)*a)/o)),Array.from({length:o},(t,n)=>{const i=e-n*(r+a);return{inner:Math.max(0,i-r),outer:i}})}(e,f.clamp(t.thickness,.02,1),t.rows,!s),l=e,h=c[c.length-1].inner,u=s?l:h-.025*e,d=s?h:u-Math.max(2,.035*e),m=(s||!i?h:d)-.03*e,p=.07*e,g=t.tickFontSize??f.clamp(.075*e,8,16),y=m-p-.03*e-.8*g,x=Math.max(3,.055*e),b=o?f.clamp(e*(s?.2:.3),10,72):0,_=r?f.clamp(.085*e,9,20):0,k=.03*e,v=b+(r?k+_:0);let w;w=s?x+.06*e:a.y1>=.3?-v/2:-v-k;const S=w+b/2;return{outer:l,inner:h,rings:c,bandOuter:u,bandInner:d,tickOuter:m,majorLength:p,minorLength:p/2,tickLabelRadius:y,tickFontSize:g,hubRadius:x,needleLength:(h+l)/2,needleHalfWidth:Math.max(2,.03*e),needleTail:.12*e,valueY:S,valueFontSize:b,valueMaxWidth:Math.max(0,y)*(s?1.3:1.6),nameY:S+b/2+k+_/2,nameFontSize:_,nameMaxWidth:1.2*e}}function Jb(e,t,n){if(e.schema.label)return!0;return(e.schema.groupBy??[]).some(e=>void 0!==e(t,n))}function e_(e){const t=e.schema.axisConfig??{},n=t.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?n:void 0}const t_=({viz:e})=>{const{width:t,height:n}=ie(e),i=e._filteredData??[],o=e.schema.value,a=i.map((e,t)=>Number(o(e,t))),r=Array.isArray(e.schema.bands)?e.schema.bands:[],s=jb(Number(e.schema.startAngle)||0),c=jb(Number(e.schema.endAngle)||0),l=e.schema.ticks,h="number"==typeof l?l:Vb(s,c),u=Gb(a,r,e.schema.domain,h),d=Yb(r,u,e.schema.colorDefaults?.missing??"#ced4da"),f=qb(u,l,!1!==e.schema.minorTicks,h),m=1===i.length,p={indicator:"progress"===e.schema.indicator?"progress":"needle",thickness:Number(e.schema.thickness)||.2,hasBands:d.length>0,rows:i.length,hasValue:m,hasName:m&&Jb(e,i[0],0),extent:Kb(s,c),tickFontSize:e_(e)},g=Xb(Math.max(0,t-4),Math.max(0,n-4),function(e){const t=100,n=Zb(t,e);if(!n.valueFontSize){const i="progress"===e.indicator?0:n.needleTail/t;return Ub(e.extent,{x0:0,x1:0,y0:0,y1:i})}const i=(n.nameFontSize?n.nameY+n.nameFontSize/2:n.valueY+n.valueFontSize/2)/t,o=(n.valueY-n.valueFontSize/2)/t,a="progress"===e.indicator?0:n.needleTail/t;return Ub(e.extent,{x0:-.5,x1:.5,y0:Math.min(o,0),y1:Math.max(i,a)})}(p)),y=i.map((e,t)=>({__d3plus__:!0,data:e,i:t,value:a[t],angle:Ib(a[t],u,s,c)}));return e.ctx.gauge={cx:g.cx+2,cy:g.cy+2,radius:g.radius,domain:u,start:s,end:c,ticks:f,bands:d,dial:p},{shapeData:y}};function n_(e){if(!Array.isArray(e))return[];const t=[];let n=!1;for(const i of e)"number"==typeof i?Number.isFinite(i)&&(t.push({max:i}),n=!0):i&&"object"==typeof i&&t.push({...i});const i=t[t.length-1];return n&&i&&void 0!==i.max&&t.push({}),t}function i_(e,t,n){const i=[...e,...t.flatMap(e=>[e.min,e.max])].filter(e=>"number"==typeof e&&Number.isFinite(e));return{extent:i.length?[Math.min(...i),Math.max(...i)]:[],input:n}}function o_(e,t=5){return Gb(e.extent,[],e.input,t)}function a_(e,t,n,i,o){const a=t[1]-t[0]||1;return e.every((t,r)=>{if(!r)return!0;return(t-e[r-1])/a*n>=(i(t)+i(e[r-1]))/2+o})}function r_(e,t,n,i,o=70,a=8){if(!1===t)return{domain:o_(e),ticks:[]};if(Array.isArray(t)){const n=o_(e);return{domain:n,ticks:qb(n,t,!1,5).major}}if("number"==typeof t){const n=Math.max(1,t),i=o_(e,n);return{domain:i,ticks:qb(i,n,!1,n).major}}const r=Math.max(1,Math.floor(Math.max(0,n)/o));let s={domain:o_(e,1),ticks:[]};for(let t=r;t>=1;t--){const o=o_(e,t),r=qb(o,t,!1,t).major;if(s={domain:o,ticks:r},a_(r,o,n,i,a))return s}return{domain:s.domain,ticks:s.domain.slice()}}function s_(e,t){const n=function(e,t){const[n,i]=t,o=i-n;return Number.isFinite(e)&&o?Math.max(0,Math.min(1,(e-n)/o)):0}(t,e.domain),{band:i}=e;return"vertical"===e.orient?i.y+i.height*(1-n):i.x+i.width*n}function c_(e){const[t,n]=e;return Math.max(t,Math.min(n,0))}function l_(e,t,n,i){const{band:o}=e,a=s_(e,t),r=s_(e,n),s=Math.min(a,r),c=Math.abs(r-a),l=Math.max(0,Math.min(1,i));if("vertical"===e.orient){const e=o.width*l;return{x:o.x+(o.width-e)/2,y:s,width:e,height:c}}const h=o.height*l;return{x:s,y:o.y+(o.height-h)/2,width:c,height:h}}function h_(e,t,n){const i=s_(e,t);return"vertical"===e.orient?{...n,y:i,height:0}:{...n,x:i,width:0}}function u_(e,t,n){const{band:i}=e,o=s_(e,t),a=Math.max(0,Math.min(1,n));if("vertical"===e.orient){const e=i.width*(1-a)/2;return[[i.x+e,o],[i.x+i.width-e,o]]}const r=i.height*(1-a)/2;return[[o,i.y+r],[o,i.y+i.height-r]]}function d_(e){return e.axis?"vertical"===e.orient?7+e.tickLabelWidth:7+e.tickFontSize:0}function f_(e){return e.count>0&&e.width>0&&e.height>0?"vertical"===e.orient?function(e){const{width:t,height:n,count:i,labelHeight:o}=e,a=d_(e),r="row"===e.axis?a:0,s="shared"===e.axis?a:0,c=o?o+12:0,l=e.axis?e.tickFontSize/2:0,h=2+c+l,u=Math.max(0,n-h-Math.max(2,l)-2),d=Math.max(0,t-s-4),m=d/i,p=Math.min(Math.max(0,m-r),f.clamp(.45*(m-r),4,e.bulletSize)),g=r+p,y=Math.min(m,Math.max(g+Math.max(16,p),e.labelWidth+12)),x=2+s+(d-y*i)/2;return Array.from({length:i},(t,n)=>{const i=x+n*y,o=i+(y-p)/2+r/2;return{band:{x:o,y:h,width:p,height:u},label:{x:o+p/2,y:2,anchor:"middle",maxWidth:Math.max(0,y-8)},axis:"row"===e.axis||"shared"===e.axis&&0===n,hit:{x:i,y:2,width:y,height:h+u-2}}})}(e):function(e){const{width:t,height:n,count:i,labelHeight:o}=e,a=d_(e),r="row"===e.axis?a:0,s="shared"===e.axis?a:0,c=Math.min(e.labelWidth,.35*t),[l,h]=e.axis?e.tickOverhang:[0,0],u=c?2+c+Math.max(12,l):2+l,d=Math.max(0,t-u-2-h),m=Math.max(0,n-s-4),p=m/i,g=Math.min(Math.max(0,p-r),f.clamp(.62*(p-r),4,e.bulletSize)),y=g+r,x=Math.max(12,.6*g),b=Math.min(p,Math.max(y,o)+x),_=Math.max(0,(o-g)/2),k=b*(i-1)+y,v=2+Math.max(_,(m-k)/2);return Array.from({length:i},(t,n)=>{const a=v+n*b,r={x:u,y:a,width:d,height:g},s=Math.min(a,a+g/2-o/2);return{band:r,label:{x:2+c,y:a+g/2,anchor:"end",maxWidth:c},axis:"row"===e.axis||"shared"===e.axis&&n===i-1,hit:{x:0,y:s,width:u+d,height:Math.max(a+y,a+g/2+o/2)-s}}})}(e):[]}function m_(e,t){const n=function(e,t=.36,n=.12){if(e<=0)return[];if(1===e)return[(t+n)/2];const i=(t-n)/(e-1);return Array.from({length:e},(e,n)=>t-n*i)}(e.length);return e.map((e,i)=>e.color?e:{...e,color:t(n[i])})}function p_(e,t,n){if("function"!=typeof e)return NaN;const i=e(t,n);return null==i||""===i?NaN:Number(i)}function g_(e,t,n){return e._ids(t,n).join("-")}function y_(e,t,n){const i=e.schema.bands;return n_("function"==typeof i?i(t,n):i)}function x_(e,t,n){return[p_(e.schema.value,t,n),p_(e.schema.target,t,n),p_(e.schema.forecast,t,n)]}function b_(e,t){const n=!!e.schema.sharedDomain,i=new Map;return t.forEach((t,o)=>{const a=n?"*":g_(e,t,o),r=i_(x_(e,t,o),y_(e,t,o),function(e,t,n){const i=e.schema.domain,o="function"==typeof i?i(t,n):i;return Array.isArray(o)?o:void 0}(e,t,o)),s=i.get(a);var c,l;i.set(a,s?(l=r,i_([...(c=s).extent,...l.extent],[],c.input)):r)}),i}const __=(e,t,i,o=400)=>e?n.textWidth(e,{"font-family":t,"font-size":i,"font-weight":o}):0;function k_(e,t,n,i){const o=e.ctx.bulletFacet,a=e.schema.sharedDomain?"*":g_(e,n,i);return o?.get(a)??t.get(a)??{extent:[],input:void 0}}function v_(e,t){const n=e.some(e=>e.name),i=e.some(e=>e.subLabel);return{labelWidth:Math.max(0,...e.map(e=>__(e.name,t,13,600)),...e.map(e=>__(e.subLabel,t,11))),labelHeight:(n?13:0)+(i?11+(n?2:0):0)}}const w_=({viz:e})=>{const{width:t,height:n}=ie(e),i=e._filteredData??[],o="vertical"===e.schema.orient?"vertical":"horizontal",s=function(e,t,n){const i=(e.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},s=Ia(e),c=r.colorContrast(s,e.schema.colorDefaults),l=x.interpolateRgb(s,c),h=tu(o.fontColor,t,n)??c,u=tu(o.fontFamily,t,n)??e.schema.fontFamily,d=tu(o.fontSize,t,n),f=e.schema.tickFormat;return{background:s,mix:l,trackFill:tu(i.fill,t,n)??l(.08),tickStroke:tu(i.stroke,t,n)??l(.55),tickStrokeWidth:tu(i.strokeWidth,t,n)??1,fontColor:h,mutedColor:x.interpolateRgb(s,h)(.68),fontFamily:a.fontFamilyStringify(u),tickFontSize:"number"==typeof d&&d>0?d:10,tickFormat:e=>`${f(e)}`}}(e,i[0]??{},0),c=s.fontFamily,l=function(e,t){const n=e.schema.subLabel,i=b_(e,t);return t.map((t,o)=>{const a="function"==typeof n?n(t,o):void 0,[r,s,c]=x_(e,t,o);return{d:t,i:o,value:r,target:s,forecast:c,name:Jb(e,t,o)?`${e._drawLabel(t,o)??""}`:"",subLabel:null==a?"":`${a}`,extent:k_(e,i,t,o)}})}(e,i),h=e.schema.ticks,u=e=>__(s.tickFormat(e),c,s.tickFontSize),d=l.map(e=>o_(e.extent,10)),f=f_({orient:o,width:t,height:n,count:l.length,bulletSize:Math.max(1,Number(e.schema.bulletSize)||1),...v_(l,c),axis:!1!==h&&(e.schema.sharedDomain?"shared":"row"),tickFontSize:s.tickFontSize,tickLabelWidth:Math.max(0,...d.flatMap(e=>qb(e,10,!1,10).major.map(u))),tickOverhang:[Math.max(0,...d.map(e=>u(e[0])/2)),Math.max(0,...d.map(e=>u(e[1])/2))]}),m="vertical"===o,p=f.map((t,n)=>{const i=l[n],a=r_(i.extent,h,m?t.band.height:t.band.width,m?()=>1.2*s.tickFontSize:u,m?45:70);return{__d3plus__:!0,data:i.d,i:i.i,key:g_(e,i.d,i.i),value:i.value,target:i.target,forecast:i.forecast,name:i.name,subLabel:i.subLabel,track:{orient:o,band:t.band,domain:a.domain},bands:Yb(m_(y_(e,i.d,i.i),s.mix),a.domain,s.mix(.2)),ticks:t.axis?a.ticks:[],axis:t.axis,label:t.label,hit:t.hit}});return e.ctx.bullet={orient:o,style:s,nameFontSize:13,subFontSize:11},{shapeData:p}};function S_(e,t,n){return{type:"path",key:e,interactive:!1,d:i.arcPath(t),arc:t,paint:{fill:n}}}function C_(e,t,i,o,a=8,r=400){const s=(e,i)=>n.textWidth(e,{"font-family":t,"font-size":i,"font-weight":r});let c=s(e,i);c>o&&c>0&&(c=s(e,i=Math.max(a,i*o/c)));let l=e;for(;c>o&&l.length>1;)if(l=l.slice(0,-1),c=s(`${l.trimEnd()}…`,i),c<=o)return{text:`${l.trimEnd()}…`,size:i,width:c};return{text:l,size:i,width:c}}function M_(e,t,i,o,a){return{type:"text",key:e,interactive:!1,x:0,y:0,transform:{x:i,y:o},lines:[{text:t,x:0,y:0,width:a.width??n.textWidth(t,{"font-family":a.family,"font-size":a.size})}],font:{family:a.family,size:a.size,weight:a.weight??400,anchor:"middle",baseline:"middle"},paint:{fill:a.color}}}function $_(e,t,n){return e.map(e=>{const i=Math.sin(e),o=Math.cos(e);return`M${t*i},${-t*o}L${n*i},${-n*o}`}).join("")}function A_(e,t,n,i){const{domain:o,start:a,end:r,ticks:s,bands:c}=n,l=e=>Ib(e,o,a,r),h=t.rings.map((t,n)=>S_(`${e}-track-${n}`,{innerRadius:t.inner,outerRadius:t.outer,startAngle:a,endAngle:r},i.trackFill));c.forEach((n,i)=>h.push(S_(`${e}-band-${i}`,{innerRadius:t.bandInner,outerRadius:t.bandOuter,startAngle:l(n.min),endAngle:l(n.max)},n.color)));const u={fill:"none",stroke:i.tickStroke,strokeLinecap:"round"};return s.minor.length&&h.push({type:"path",key:`${e}-minor-ticks`,interactive:!1,d:$_(s.minor.map(l),t.tickOuter,t.tickOuter-t.minorLength),paint:{...u,strokeWidth:i.tickStrokeWidth/2,strokeOpacity:.75}}),s.major.length&&h.push({type:"path",key:`${e}-major-ticks`,interactive:!1,d:$_(s.major.map(l),t.tickOuter,t.tickOuter-t.majorLength),paint:{...u,strokeWidth:i.tickStrokeWidth}}),t.tickLabelRadius>0&&s.major.forEach((n,o)=>{const a=l(n),r=t.tickLabelRadius;h.push(M_(`${e}-tick-${o}`,i.tickFormat(n),r*Math.sin(a),-r*Math.cos(a),{size:t.tickFontSize,family:i.fontFamily,color:i.fontColor}))}),h}function z_(e,t,n,i,o){const a=[];if(i){const o=C_(i,n.fontFamily,t.valueFontSize,t.valueMaxWidth,8,600);a.push(M_(`${e}-value`,o.text,0,t.valueY,{size:o.size,family:n.fontFamily,color:n.fontColor,weight:600,width:o.width}))}if(o&&t.nameFontSize){const i=C_(o,n.fontFamily,t.nameFontSize,t.nameMaxWidth);a.push(M_(`${e}-name`,i.text,0,t.nameY,{size:i.size,family:n.fontFamily,color:n.fontColor,width:i.width}))}return a}function D_(e,t,n,i,o){return{type:"text",key:e,x:0,y:0,transform:{x:n,y:i},lines:[{text:t,x:0,y:0,width:o.width}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:o.anchor,baseline:"middle"},paint:{fill:o.color}}}function F_(e,t,n){const{track:i}=e,[o,a]=i.domain,r=c_(i.domain),s=(e,t,n,o)=>{const a=l_(i,t,n,1);return((e,t,n,i)=>({type:"rect",key:e,interactive:!1,...t,enterRect:i,paint:{fill:n}}))(e,a,o,h_(i,r,a))},c=[s(`${t}-track`,o,a,n.trackFill)];if(e.bands.forEach((e,n)=>c.push(s(`${t}-band-${n}`,e.min,e.max,e.color))),!e.ticks.length)return c;const l="vertical"===i.orient,{band:h}=i,u=l?h.x:h.y+h.height,d=e.ticks.map(e=>{const t=s_(i,e);return l?`M${u-4},${t}L${u},${t}`:`M${t},${u}L${t},${u+4}`}).join("");c.push({type:"path",key:`${t}-ticks`,interactive:!1,d:d,paint:{fill:"none",stroke:n.tickStroke,strokeWidth:n.tickStrokeWidth}});return e.ticks.forEach((e,o)=>{const a=s_(i,e),r=C_(n.tickFormat(e),n.fontFamily,n.tickFontSize,1/0);c.push({...D_(`${t}-tick-${o}`,r.text,l?u-7:a,l?a:u+7+n.tickFontSize/2,{size:n.tickFontSize,family:n.fontFamily,color:n.fontColor,anchor:l?"end":"middle",width:r.width}),interactive:!1})}),c}function B_(e,t,n){const{style:i,nameFontSize:o,subFontSize:a}=n,{label:r}=e,s=[];if(e.name&&s.push({text:e.name,size:o,weight:600,color:i.fontColor,kind:"name"}),e.subLabel&&s.push({text:e.subLabel,size:a,weight:400,color:i.mutedColor,kind:"sub"}),!(s.length&&r.maxWidth>0))return[];const c=s.reduce((e,t)=>e+t.size,0)+2*(s.length-1);let l="vertical"===n.orient?r.y:r.y-c/2;return s.map(n=>{const o=C_(n.text,i.fontFamily,n.size,r.maxWidth,8,n.weight),a=D_(`${t}-${n.kind}`,o.text,r.x,l+n.size/2,{size:o.size,family:i.fontFamily,color:n.color,anchor:r.anchor,width:o.width,weight:n.weight});return l+=n.size+2,{...a,datum:e.data,index:e.i}})}function L_(e,t,n,i){const{track:o,data:a,i:r}=t,s=[],c=c_(o.domain),l=au(e,"Rect"),h=iu(l,a,r),u=e.schema.valueFormat,d=[t.name,Number.isFinite(t.value)?u(t.value,a):""];Number.isFinite(t.target)&&d.push(`${e.schema.translate("Target")} ${u(t.target,a)}`);const f={datum:a,index:r,aria:{label:`${d.filter(Boolean).join(", ")}.`}},m=e.schema.forecastConfig??{};if(Number.isFinite(t.forecast)){const e=tu(m.size,a,r)??.6,i=tu(m.fill,a,r)??tu(l.fill,a,r),h=l_(o,c,t.forecast,e),u={type:"rect",key:`${n}-forecast`,...h,enterRect:h_(o,c,h),shapeType:"Rect",paint:{fill:nu({...l,...m},a,r,i),opacity:tu(m.opacity,a,r)??.35},...f};s.push(u);const d=Vy(m,u,a,r);d&&s.push(d)}if(Number.isFinite(t.value)){const i=Number(e.schema.measureSize),u=l_(o,c,t.value,Number.isFinite(i)?i:.35),d={type:"rect",key:`${n}-measure`,...u,enterRect:h_(o,c,u),shapeType:"Rect",paint:h,...f};s.push(d);const m=Vy(l,d,a,r);m&&s.push(m)}const p=e.schema.targetConfig??{};if(Number.isFinite(t.target)){const e=tu(p.size,a,r)??.75;s.push({type:"line",key:`${n}-target`,points:u_(o,t.target,e),shapeType:"Line",paint:{fill:"none",stroke:tu(p.stroke,a,r)??i.style.fontColor,strokeWidth:tu(p.strokeWidth,a,r)??3},...f})}return s}function P_(e){return"function"==typeof e?e:"string"==typeof e?Be(e):"number"==typeof e&&N(e)}const R_={name:"Bullet",layoutStage:w_,emit:({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.bullet;if(!n.length||!i)return[];const o=new Map;return n.map(t=>{const n=o.get(t.key)??0;o.set(t.key,n+1);const a=`bullet-${t.key}${n?`-${n}`:""}`,r={type:"rect",key:`${a}::hit`,...t.hit,datum:t.data,index:t.i,paint:{fill:"transparent"}};return{type:"group",key:a,children:[{type:"group",key:`${a}-static`,interactive:!1,aria:{hidden:!0},children:F_(t,a,i.style)},r,...B_(t,a,i),...L_(e,t,a,i)]}})},facet:{aspect:2,share:(e,t)=>b_(e,t.flat()),panel:(e,t)=>(t.shared&&t.scales instanceof Map&&(e.ctx.bulletFacet=t.scales),()=>{e.ctx.bulletFacet=void 0})},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"bulletSize",default:40},{key:"domain"},{key:"forecast",default:T("forecast"),coerce:P_},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{const o=e._filteredData??[],a=new Set(o.map((t,n)=>g_(e,t,n)));return!(i.length>=a.size)&&t.call(e,n,i)}}},{key:"measureSize",default:.35},{key:"orient",default:"horizontal"},{key:"sharedDomain",default:!1},{key:"subLabel",default:!1,coerce:P_},{key:"target",default:T("target"),coerce:P_},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"value",default:T("value"),coerce:e=>P_(e)||T("value")},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1},{key:"forecastConfig",merge:!0,default:{opacity:.35,size:.6}},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>Ia(e),strokeWidth:1})},{key:"targetConfig",merge:!0,default:{size:.75,strokeWidth:3}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>function(e,t,n){const i=e.schema.valueFormat,o=[];for(const[a,r]of[["value","Value"],["target","Target"],["forecast","Forecast"]]){const s=p_(e.schema[a],t,n);Number.isFinite(s)&&o.push([e.schema.translate(r),`${i(s,t)}`])}return o}(e,t,n)})}]};var E_=xf(R_);const N_={name:"BumpChart",paintDriven:!0,setup:e=>{const t=e;t.y2((t,n)=>e._y(t,n)),t.yConfig({tickFormat:t=>{const n=e._formattedData??[],i=n[0].x instanceof Date?n[0].x.getTime():n[0].x,o=n.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===i),a=o.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.y2Config({tickFormat:t=>{const n=e._formattedData??[],i=n[n.length-1].x instanceof Date?n[n.length-1].x.getTime():n[n.length-1].x,o=n.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===i),a=o.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.ySort((t,n)=>e._y(n)-e._y(t)),t.y2Sort((t,n)=>e._y(n)-e._y(t))},facet:{axes:"all"},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"discrete",default:"x"},{key:"shape",default:N("Line"),coerce:"const"}]};var T_=xf(N_,_b);const O_=/^(\d{4})-(\d{2})-(\d{2})$/;function W_(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function j_(e){if(Array.isArray(e))return e.length?j_(e[0]):null;if(e instanceof Date)return isNaN(+e)?null:W_(e);if("number"==typeof e)return Number.isFinite(e)?W_(new Date(e)):null;if("string"!=typeof e||!e.trim())return null;const t=O_.exec(e.trim());if(t){const[e,n,i]=[+t[1],+t[2]-1,+t[3]],o=new Date(e,n,i);return o.setFullYear(e),o.getMonth()===n&&o.getDate()===i?o:null}const n=new Date(e);return isNaN(+n)?null:W_(n)}function H_(e){return`${`${e.getFullYear()}`.padStart(4,"0")}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")}`}function I_(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),i=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((i-n)/864e5)}function G_(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function V_(e,t){return((e.getDay()-t)%7+7)%7}function q_(e,t,n){return Math.floor((I_(t,e)+V_(t,n))/7)}const Y_=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function K_(e,t){if("number"==typeof e&&Number.isFinite(e))return(Math.round(e)%7+7)%7;if("string"==typeof e&&e.length>=2){const t=e.toLowerCase(),n=Y_.findIndex(e=>e.startsWith(t));if(n>=0)return n}return c.findWeekStart("string"==typeof t?t:"")}function U_(e){if(!e.length)return null;let t=e[0],n=e[0];for(const i of e)+i<+t&&(t=i),+i>+n&&(n=i);return[t,n]}function X_(e,t,n){const i=[];if(+t<+e)return i;if("month"===n){let n=e.getFullYear(),o=e.getMonth();const a=12*t.getFullYear()+t.getMonth();for(;12*n+o<=a;)i.push({key:`${H_(new Date(n,o,1)).slice(0,7)}`,start:new Date(n,o,1),end:new Date(n,o+1,0)}),o+=1,o>11&&([n,o]=[n+1,0]);return i}for(let n=e.getFullYear();n<=t.getFullYear();n++)i.push({key:`${n}`,start:new Date(n,0,1),end:new Date(n,11,31)});return i}function Q_(e,t){return q_(e.end,e.start,t)+1}function Z_(e,t){const n=I_(e.start,e.end)+1,i=V_(e.start,t),o=[];for(let t=0;t<n;t++){const n=G_(e.start,t);o.push({date:n,key:H_(n),week:Math.floor((t+i)/7),day:(t+i)%7})}return o}function J_(e){return X_(e.start,e.end,"month")}function ek(e){return"string"==typeof e&&c.locale[e]||c.locale["en-US"]}function tk(e,t,n){const i=void 0===e?n:e;if("function"==typeof i){const e=i;return t=>`${e(t)??""}`}return"string"==typeof i&&i?g.timeFormatLocale(t).format(i):null}function nk(e){const t=e.dateTime.replace(/[,.]?\s*%X/g,"").replace(/[\s,.]+$/,"").replace(/%e/g,"%-d").trim()||e.date;return/%[aA]/.test(t)?t:`%A, ${t}`}function ik(e,t){const[n=""]=Array.from(e.trim());try{return n.toLocaleUpperCase(t)}catch{return n.toUpperCase()}}function ok(e){const{count:t,gridColumns:n,gridRows:i,insetTop:o,insetLeft:a,gap:r,width:s,height:c}=e,l=Math.max(1,t),h=e.columns?[Math.min(l,Math.max(1,Math.round(e.columns)))]:Array.from({length:l},(e,t)=>t+1);let u;for(const e of h){const t=Math.ceil(l/e),h=(s-e*a-(e-1)*r)/(e*n),d=(c-t*o-(t-1)*r)/(t*i),f=Math.max(0,Math.min(h,d));(!u||f>u.cell+1e-9)&&(u={cell:f,columns:e,rows:t})}const{cell:d,columns:f,rows:m}=u,p=a+n*d,g=o+i*d;return{cell:d,columns:f,rows:m,blockWidth:p,blockHeight:g,width:f*p+(f-1)*r,height:m*g+(m-1)*r}}function ak(e,t,n){return"vertical"===n?[t,e]:[e,t]}function rk(e,t){return"vertical"===t?{columns:7,rows:e}:{columns:e,rows:7}}function sk(e,t,n,i){const{week:o,day:a}=e,{week:r,day:s}=t,c=e=>Math.round(100*e)/100;return`${[[o+1,a],[o,a],[o,7],[r,7],[r,s+1],[r+1,s+1],[r+1,0],[o+1,0]].map(([e,t],o)=>{const[a,r]=ak(e,t,i);return`${o?"L":"M"}${c(a*n)},${c(r*n)}`}).join("")}Z`}function ck(e){return 0===e.day?e.week:e.week+1}function lk(e,t){return e>=t?[0,1,2,3,4,5,6]:[1,3,5]}function hk(e,t){return e>0&&t>0?Math.min(e,t/3):0}const uk=new Date(2023,0,1);function dk(e){return Math.max(3,Math.round(.4*e))}function fk(e,t){return Array.from({length:7},(n,i)=>e(G_(uk,(t+i)%7)))}function mk(e,t,n,i,o){const a=n.fontSize,r=dk(a),s=1.15*a+r,c=a+r,l=n.weekday?i+r:0;if("month"===e){return{top:(n.title.length?s:0)+("vertical"===t&&n.weekday?c:0),left:"horizontal"===t?l:0}}return"vertical"===t?{top:(n.year?s:0)+(n.weekday?c:0),left:n.month?o+r:0}:{top:n.month?c:0,left:l+(n.year?s:0)}}function pk(e,t,n){const i=e=>Math.round(100*e)/100;return e.replace(/(-?[\d.]+),(-?[\d.]+)/g,(e,o,a)=>`${i(+o+t)},${i(+a+n)}`)}function gk(e){const{start:t,end:n,period:i,orient:o,weekStart:a,width:r,height:s,labels:c}=e,l=X_(t,n,i),h=Math.max(1,...l.map(e=>Q_(e,a))),u=c.weekday?fk(c.weekday,a):[],d=c.month?Math.max(0,...Array.from({length:12},(e,t)=>c.measure(c.month(new Date(2023,t,1))))):0,f=Math.max(0,...u.map(c.measure)),m=mk(i,o,c,f,d),p=rk(h,o),g="month"===i?1.5*c.fontSize:c.fontSize,y=ok({count:l.length,gridColumns:p.columns,gridRows:p.rows,insetTop:m.top,insetLeft:m.left,gap:g,width:r,height:s,columns:"month"===i?void 0:"vertical"===o?l.length:1}),{cell:x}=y,b=Math.max(0,(r-y.width)/2),_=Math.max(0,(s-y.height)/2),k=[],v=[],w=[];return l.forEach((t,n)=>{const r=b+n%y.columns*(y.blockWidth+g),s=_+Math.floor(n/y.columns)*(y.blockHeight+g),l={block:t,left:r,top:s,x:r+m.left,y:s+m.top};for(const e of Z_(t,a)){const[n,i]=ak(e.week,e.day,o);k.push({...e,block:t.key,x:l.x+n*x,y:l.y+i*x,size:x})}c.weekday&&v.push(...function(e,t,n,i){const{labels:o,orient:a}=n,r=o.fontSize,s=dk(r),c="vertical"===a;let l=t,h=lk(i,1.25*r);if(c){const e=(e,t)=>Math.max(...e.map(o.measure))<=t,n=t.map(o.narrow);e(t,i-2)?h=[0,1,2,3,4,5,6]:e(n,i)?[l,h]=[n,[0,1,2,3,4,5,6]]:e(n,2*i-2)?[l,h]=[n,[0,2,4,6]]:h=[]}return h.map(t=>({key:`${e.block.key}-weekday-${t}`,kind:"weekday",text:l[t],x:c?e.x+(t+.5)*i:e.x-s,y:c?e.y-s-r/2:e.y+(t+.5)*i,anchor:c?"middle":"end"}))}(l,u,e,x)),"year"===i&&c.month&&v.push(...function(e,t,n,i){const{labels:o,orient:a,weekStart:r}=t,s=o.month,c=o.fontSize,l=dk(c),h=[];let u=-1/0;for(const t of J_(e.block)){const d=ck({week:q_(t.start,e.block.start,r),day:V_(t.start,r)});if(d>=i)continue;const f=s(t.start),m=d*n,p="vertical"===a?c:o.measure(f);m<u||m+("vertical"===a?0:p)>i*n+l||(u=m+p+l,h.push({key:`${e.block.key}-month-${t.key}`,kind:"month",text:f,x:"vertical"===a?e.x-l:e.x+m,y:"vertical"===a?e.y+m+n/2:e.y-l-c/2,anchor:"vertical"===a?"end":"start"}))}return h}(l,e,x,Q_(t,a)));const h=function(e,t,n,i){const{labels:o,orient:a,period:r}=t,s=o.fontSize,c=`${e.block.key}-${"month"===r?"title":"year"}`;if("month"===r){const t=o.title.map(t=>t(e.block.start)).find((e,t,i)=>t===i.length-1||1.1*o.measure(e)<=n.blockWidth);return void 0===t?null:{key:c,kind:"title",text:t,x:e.left,y:e.top+.6*s,anchor:"start"}}if(!o.year)return null;const l=o.year(e.block.start);return"vertical"===a?{key:c,kind:"year",text:l,x:e.x+i/2,y:e.top+.6*s,anchor:"middle"}:{key:c,kind:"year",text:l,x:e.left+.6*s,y:e.y+7*n.cell/2,anchor:"middle",rotate:-90}}(l,e,y,p.columns*x);h&&v.push(h),"year"===i&&w.push(...function(e,t,n,i){return J_(e.block).map(o=>{const a=n=>({week:q_(n,e.block.start,t),day:V_(n,t)}),r=sk(a(o.start),a(o.end),n,i);return{key:`${e.block.key}-outline-${o.key}`,d:pk(r,e.x,e.y)}})}(l,a,x,o))}),{blocks:l,fit:y,cells:k,labels:v,outlines:w}}function yk(e,t,n){const i=e.schema.date;return j_("function"==typeof i?i(t,n):void 0)}function xk(e,t){const n=[];return t.forEach((t,i)=>{const o=yk(e,t,i);o&&n.push(o)}),U_(n)}function bk(e){return"month"===e.schema.period?"month":"year"}function _k(e){const t=e.schema.orient;return"horizontal"===t||"vertical"===t?t:"month"===bk(e)?"vertical":"horizontal"}function kk(e){const t=e.schema.calendarLabelConfig??{},n=t.fontFamily??e.schema.fontFamily;return{fontColor:"string"==typeof t.fontColor?t.fontColor:void 0,fontFamily:a.fontFamilyStringify(n),fontSize:"number"==typeof t.fontSize?t.fontSize:11,fontWeight:t.fontWeight??400}}function vk(e){const t=ek(e.schema.locale);return tk(nk(t),t,!1)}function wk(e,t,i){const o=ek(e.schema.locale),a=[];if("month"===t){const t=tk(e.schema.monthFormat,o,!1);if(t)a.push(t);else if(!1!==e.schema.monthFormat)for(const e of["%B %Y","%b %Y","%b"])a.push(tk(e,o,!1))}return{fontSize:i.fontSize,measure:e=>n.textWidth(e,{"font-family":i.fontFamily,"font-size":i.fontSize,"font-weight":i.fontWeight}),weekday:tk(e.schema.weekdayFormat,o,"%a"),month:"year"===t?tk(e.schema.monthFormat,o,"%b"):null,year:"year"===t?tk(e.schema.yearFormat,o,"%Y"):null,title:a,narrow:t=>ik(t,e.schema.locale)}}const Sk=({viz:e})=>{const t=e._filteredData??[],n=new Map;t.forEach((t,i)=>{const o=yk(e,t,i);if(!o)return;const a=H_(o);n.has(a)||n.set(a,{datum:t,i:i})});const i=e.ctx.calendarSharedExtent??xk(e,t);if(e.ctx.calendarLayout=void 0,!i)return{shapeData:[]};const{width:o,height:a}=ie(e),r=bk(e),s=kk(e),c=gk({start:i[0],end:i[1],period:r,orient:_k(e),weekStart:K_(e.schema.weekStart,e.schema.locale),width:o,height:a,labels:wk(e,r,s)});e.ctx.calendarLayout=c,e.ctx.calendarDateFormat=vk(e),e.ctx.calendarLabelStyle=s;return{shapeData:c.cells.map(e=>{const t=n.get(e.key);return t?{...e,datum:t.datum,i:t.i}:e})}};function Ck(e,t){const n=x.interpolateRgb(e,t);return{empty:n(.09),outline:n(.45),text:n(.75)}}function Mk(e,t,n){const i=e.schema.colorScale;if("function"!=typeof i)return;const o=i(t,n);return null!=o&&""!==o&&"boolean"!=typeof o&&Number.isFinite(+o)?+o:void 0}function $k(e,t,n){return"function"!=typeof e.schema.colorScale||void 0!==Mk(e,t,n)}function Ak(e,t,n){if(!e.schema.monthOutline)return[];const i=e.schema.monthOutlineConfig??{},o=i.strokeDasharray;return t.outlines.map(e=>({type:"path",key:`calendar-${e.key}`,d:e.d,interactive:!1,paint:{fill:"none",stroke:i.stroke??n,strokeWidth:i.strokeWidth??1,...o?{strokeDasharray:o}:{}}}))}const zk=({viz:e,shapeData:t})=>{const i=t??[],o=e.ctx.calendarLayout;if(!i.length||!o)return[];const a=e.ctx.calendarLabelStyle,s=Ia(e),c=Ck(s,r.colorContrast(s,e.schema.colorDefaults)),l=au(e,"Rect"),h=o.fit.cell,u=Math.min(Math.max(0,Number(e.schema.cellPadding)||0),h/2),d=Math.max(0,h-u),f={viz:e,sc:l,emptyFill:e.schema.emptyFill??c.empty,padding:u,side:d,radius:hk(Number(e.schema.cellRadius)||0,d),noData:e.schema.translate("No Data"),dateFormat:e.ctx.calendarDateFormat},m=i.map(e=>function(e,t){const{viz:n,sc:i,emptyFill:o,noData:a}=t,r={type:"rect",key:`calendar-${e.key}`,x:e.x+t.padding/2,y:e.y+t.padding/2,width:t.side,height:t.side,...t.radius?{rx:t.radius,ry:t.radius}:{}},{datum:s,i:c}=e;if(!s){const n=t.dateFormat?t.dateFormat(e.date):e.key;return{...r,interactive:!1,paint:{fill:o},aria:{label:`${n}, ${a}.`}}}const l=Mk(n,s,c??0),h=$k(n,s,c??0),u=h?tu(i.fill,s,c):o,d=tu(i.ariaLabel,s,c)??e.key,f=h?l:a;return{...r,datum:s,index:c,shapeType:"Rect",paint:{fill:h?nu(i,s,c,u):u,stroke:tu(i.stroke,s,c),strokeWidth:tu(i.strokeWidth,s,c),opacity:tu(i.opacity,s,c)??1},aria:{label:`${void 0===f?d:`${d}, ${f}`}.`}}}(e,f)),p=i.filter(e=>e.datum),g=m.filter(e=>e.datum),y=e=>n.textWidth(e,{"font-family":a.fontFamily,"font-size":a.fontSize,"font-weight":a.fontWeight}),x=o.labels.map(e=>function(e,t,n,i){const o="year"===e.kind||"title"===e.kind;return{type:"text",key:`calendar-label-${e.key}`,interactive:!1,x:0,y:0,transform:{x:e.x,y:e.y,...e.rotate?{rotate:e.rotate}:{}},lines:[{text:e.text,x:0,y:0,width:i(e.text)}],font:{family:t.fontFamily,size:t.fontSize,weight:o?600:t.fontWeight,anchor:e.anchor,baseline:"middle"},paint:{fill:n}}}(e,a,a.fontColor??c.text,y));return[...m,...qy(l,g,e=>[p[e].datum,p[e].i]),...Ak(e,o,c.outline),...x]},Dk=e=>void 0!==e.date?e.date:e.time,Fk={name:"Calendar",layoutStage:Sk,emit:zk,insetRegion:function(e){const{width:t,height:n}=ie(e);return{bounds:{x:e._margin.left,y:e._margin.top,width:t,height:n},obstacles:Ku(e._chartScene||[],e._chartTransform,void 0,!0)}},defaults:{hoverOutline:!0},facet:{aspect:3,share:(e,t)=>U_(t.flatMap(t=>xk(e,t)??[])),panel:(e,{shared:t,scales:n})=>(e.ctx.calendarSharedExtent=t&&n?n:void 0,()=>{e.ctx.calendarSharedExtent=void 0})},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellRadius",default:2},{key:"date",default:Dk,coerce:e=>"function"==typeof e?e:Be(e)},{key:"emptyFill"},{key:"monthFormat"},{key:"monthOutline",default:!0},{key:"orient"},{key:"period",default:"year"},{key:"weekStart"},{key:"weekdayFormat"},{key:"yearFormat"},{key:"zoom",default:!1},{key:"colorScale",default:T("value"),coerce:rr},{key:"groupBy",factory:e=>[(t,n)=>{const i=yk(e,t,n);return i?H_(i):t.id}]},{key:"label",coerce:"const",factory:e=>(t,n)=>{const i=yk(e,t,n);return i?vk(e)(i):""}},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>!!e._legendCategories&&t.call(e,n,i)}},{key:"calendarLabelConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,default:{hoverOpacity:1}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Value"),(t,n)=>{const i=Mk(e,t,n);return void 0===i?"":d.formatAbbreviate(i,e.schema.locale)}]]})},{key:"monthOutlineConfig",merge:!0,default:{}}]};var Bk=xf(Fk);function Lk(e){const t=(t,n)=>{const i=e._id(t,n);return Array.isArray(i)?i:[i]};return n=>{const i=new Set;(e._facetPanels?e._facetPanels.map(e=>e.scene):[e._chartScene||[]]).forEach(e=>Ze(e,e=>i.add(e)));const o=new Set;return n.forEach(e=>t(e,0).forEach(e=>o.add(e))),(e,a)=>!e.__d3plus__&&(i.has(e)?n.has(e):t(e,a).some(e=>o.has(e)))}}function Pk(e){if(null==e||""===e||"boolean"==typeof e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function Rk(e,t,n){const i=Pk(n.close(e,t));if(void 0===i)return;const o=Pk(n.open(e,t))??i,a=Pk(n.high(e,t)),r=Pk(n.low(e,t));return{open:o,high:Math.max(a??-1/0,o,i),low:Math.min(r??1/0,o,i),close:i}}function Ek(e,t){return t>=e?"up":"down"}function Nk(e,t){if(Number.isFinite(e)&&Number.isFinite(t)&&0!==e)return(t-e)/Math.abs(e)}function Tk(e,t){let n=1/0,i=-1/0;for(const{d:o,i:a}of e){const e=Rk(o,a,t);e&&(e.low<n&&(n=e.low),e.high>i&&(i=e.high))}return n<=i?[n,i]:void 0}function Ok(e,t){const n=Array.from(new Set(e.filter(Number.isFinite))).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);return Number.isFinite(i)&&i>0?i:t}function Wk(e,t){const n=Number.isFinite(t)?Math.min(1,Math.max(0,t)):.7;return Math.max(1,e*n)}const jk=e=>Math.round(e-.5)+.5;function Hk(e,t,n){const i=Math.min(n.open,n.close),o=Math.max(n.open,n.close),a=Math.min(n.high,i),r=Math.max(n.low,o),s=t/2;let c="";return a<i&&(c+=`M${e},${a}V${i}`),r>o&&(c+=`M${e},${o}V${r}`),c+=`M${e-s},${i}H${e+s}V${o}H${e-s}Z`,c}function Ik(e,t,n){const i=t/2;return`M${e},${n.high}V${n.low}M${e-i},${n.open}H${e}M${e},${n.close}H${e+i}`}const Gk=["open","high","low","close","volume"],Vk=new WeakMap;function qk(e){if("function"==typeof e)return e;if("string"!=typeof e)return N(e);const t=Be(e);return Vk.set(t,e),t}function Yk(e){const t=T(e);return Vk.set(t,e),t}function Kk(e){return"function"==typeof e?Vk.get(e):void 0}const Uk=(e,t)=>e.map(t).map(Pk).filter(e=>void 0!==e),Xk=(e,t)=>Uk(e,t)[0],Qk=(e,t)=>Uk(e,t).at(-1),Zk=(e,t)=>{const n=Uk(e,t);return n.length?Math.max(...n):void 0},Jk=(e,t)=>{const n=Uk(e,t);return n.length?Math.min(...n):void 0},ev=(e,t)=>{const n=Uk(e,t);return n.length?n.reduce((e,t)=>e+t,0):void 0},tv={open:Xk,high:Zk,low:Jk,close:Qk,volume:ev},nv=new Set(Object.values(tv)),iv=e=>nv.has(e);function ov(e,t){const n=new Map;for(const e of Gk){const i=Kk(t[e]);void 0!==i&&n.set(i,tv[e])}for(const t of Object.keys(e))iv(e[t])&&!n.has(t)&&delete e[t];n.forEach((t,n)=>{e[n]&&!iv(e[n])||(e[n]=t)})}function av(e,t,n){let i;for(const o of Gk){const a=t[o];if("function"!=typeof a||void 0!==Kk(a))continue;const r=n[o],s="function"!=typeof r||iv(r)?tv[o]:r;(i??(i={}))[o]=s(e,t=>a(t,e.indexOf(t)))}return i}const rv=e=>Object.fromEntries(Gk.map(t=>[t,e.schema[t]])),sv=new WeakMap;function cv(e,t){return(n,i)=>{const o=sv.get(e)?.get(n);return o&&t in o?o[t]:e.schema[t](n,i)}}function lv(e){return{open:cv(e,"open"),high:cv(e,"high"),low:cv(e,"low"),close:cv(e,"close")}}function hv(e,t,n,i=4){let[o,a]=e;const r=n.invert,s=(e,t)=>{const i=n(e);if(!r||!Number.isFinite(i))return e;const o=Number(r(i+t));return Number.isFinite(o)?o:e},c=s(t[1],-i),l=s(t[0],i);return c>a&&(a=c),l<o&&(o=l),[o,a]}function uv({data:e,x:t,y:n,x2:i}){if(i)return[t,n];!function(e,t){if(e.padding)return void e.padding(1);const n=Array.from(new Set(t.filter(Number.isFinite))).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);if(!Number.isFinite(i))return;const[o,a]=e.domain().map(Number);e.domain([new Date(o-i),new Date(a+i)])}(t,e.map(e=>+e.x));const o=Tk(e.map(e=>({d:e.data,i:e.i})),lv(this));if(!o)return[t,n];const a=hv(n.domain().slice().reverse(),o,n);return n.domain(a.slice().reverse()),[t,n]}const dv=["day","week","month","quarter","year"],fv=[2,5,10,20,50,100,200,500,1e3];function mv(e){if(e instanceof Date)return e;if("string"!=typeof e&&"number"!=typeof e)return e;const t=n.date(e);return t instanceof Date&&!isNaN(+t)?t:e}function pv(e){const t=!e.getHours()&&!e.getMinutes()&&!e.getSeconds();return g.timeFormat(t?"%b %-d, %Y":"%b %-d, %Y %-I:%M %p")(e)}function gv(e,t){const n=e.getFullYear(),i=e.getMonth();switch(t){case"day":return 31*(12*n+i)+e.getDate();case"week":return+k.timeMonday.floor(e);case"month":return 12*n+i;case"quarter":return 4*n+Math.floor(i/3);default:return n}}function yv(e,t){if(!e.length)return[];const n=Math.max(1,Math.floor(t)),i=dv.map(t=>function(e,t){const n=[];for(let i=1;i<e.length;i++)gv(e[i],t)!==gv(e[i-1],t)&&n.push(e[i]);return n}(e,t)),o=i[i.length-1],a=i.concat(fv.map(e=>o.filter(t=>t.getFullYear()%e===0))).filter((e,t,n)=>{return e.length&&!(t&&(i=e,o=n[t-1],i.length===o.length&&i.every((e,t)=>+e===+o[t])));var i,o}),r=a.filter(e=>e.length<=n),s=r.length?r:a.slice(-1);return s.length?s.flatMap(t=>t.length>1?[[e[0],...t],t]:[[e[0],...t]]):[[e[0]]]}function xv(e){const t=new Map(e.map((e,t)=>[+e,t])),n=(n,i)=>{const o=t.get(+n);return Boolean(o)&&gv(e[o],i)!==gv(e[o-1],i)},i=new WeakMap;return function(e){if(!(e instanceof Date))return String(e);const t=this?Cn(this):void 0;if(!t?.length)return pv(e);let o,a=i.get(t);a||i.set(t,a=function(e,t){return dv.slice().reverse().find(n=>e.slice(1).every(e=>t(e,n)))??"day"}(t,n));for(const n of t)+n<+e&&(o=n);return function(e,t,n){const i=!t||t.getFullYear()!==e.getFullYear();return"year"===n?g.timeFormat("%Y")(e):"day"===n||"week"===n?g.timeFormat(i?"%b %-d, %Y":"%b %-d")(e):t?g.timeFormat(i?"%Y":"%b")(e):g.timeFormat("%b %Y")(e)}(e,o,a)}}function bv(e){const t=function(e){const t=e._filteredData||[],n=new Map;return t.forEach((t,i)=>{const o=e._x?e._x(t,i):void 0;o instanceof Date&&!isNaN(+o)&&!n.has(+o)&&n.set(+o,o)}),Array.from(n.values()).sort((e,t)=>+e-+t)}(e);return{labels:yv(t,(e.schema.width-e._margin.left-e._margin.right-60)/72),tickFormat:xv(t)}}const _v={height:.2,gap:16,axisConfig:{},shapeConfig:{fillOpacity:.5}};function kv(e){return null==e||!1===e?void 0:qk(e)}const vv=e=>"function"==typeof e.schema.volume;function wv(e){const t=e.schema.volumeConfig??{};return{..._v,...t}}function Sv(e,t,n){return vv(e)?Pk(cv(e,"volume")(t,n)):void 0}function Cv(e,t){if(!(t>0))return{height:0,gap:0};const n=Number(e.height),i=Number.isFinite(n)&&n>0?n:_v.height,o=Math.min(i<=1?i*t:i,.5*t),a=Math.max(0,Number.isFinite(Number(e.gap))?Number(e.gap):_v.gap);return{height:Math.round(o),gap:a}}function Mv(e){const t=s.scaleLinear().domain([0,e>0?e:1]).nice(2);return{domain:t.domain(),ticks:t.ticks(2)}}function $v(e,t){return h.max(t,(t,n)=>Sv(e,t,n))??0}const Av=new WeakMap;function zv(e){return"panel"===e._facetStep&&e._plotFacetScales?Av.get(e)??0:$v(e,e._filteredData||[])}function Dv(e){const t=e._yConfig?.labels;return!(Array.isArray(t)&&!t.length)}function Fv(e,t){return d.formatAbbreviate(t,e.schema.locale)}function Bv(e,t){const{domain:n,ticks:i}=Mv(zv(e)),o=Dv(e);return(new di).renderMode("compute").select(null).config(Jp(e,{locale:e.schema.locale,scale:"linear",domain:[n[1],n[0]],range:t,ticks:i,labels:o?i.filter(e=>e>0):[],tickFormat:t=>Fv(e,t),gridSize:0,rounding:"none",title:!1,height:t[1],width:t[1]})).config(wv(e).axisConfig)}function Lv(e){e._plotInsetBottom=t=>{if(!vv(e))return 0;const{height:n,gap:i}=Cv(wv(e),t);return n?n+i:0},e._plotMinLeft=()=>vv(e)&&Dv(e)?function(e){const t=e.outerBounds();return t.width?t.width+e.padding():0}(Bv(e,[0,100]).measure()):0}function Pv(e){const t=e.insetBottom??0;if(!(t>0))return;const n=e.yRange[1]-(e.x2Height??0),{gap:i}=wv(e.viz);return{top:n+Math.min(i,t),bottom:n+t,left:e.xRange[0],right:e.xRange[e.xRange.length-1]}}const Rv=e=>"path"===e.type||String(e.key).endsWith("::hit");function Ev(e,t,n,i,o){const{viz:a}=e,r=Pv(e);if(!r||!t.size)return[];const{domain:s}=Mv(zv(a)),c=r.bottom-r.top,l=new Map;t.forEach(({cx:e,width:t},n)=>{const i=Sv(a,n.data,n.i);if(void 0===i||i<0)return;const o=Math.min(c,i/s[1]*c);l.set(n,{cx:e,width:t,top:r.bottom-o})});const h=wv(a),u=eu("Path").renderMode("compute").config(au(a,i)).config(n).config(Ae.bind(a)(h.shapeConfig)).config({d:e=>{const{cx:t,width:n,top:i}=l.get(e),o=n/2;return`M${t-o},${i}H${t+o}V${r.bottom}H${t-o}Z`},hitArea:e=>{const{cx:t,width:n}=l.get(e),i=Math.max(n,6);return{x:t-i/2,y:r.top,width:i,height:c}},id:e=>`${e.id}_${e.discrete}_volume`,label:!1,x:0,y:0}),d=u.schema.fill,f=u.schema.texture;u.config({texture:(e,t)=>o(f(e,t),d(e,t))}).data(Array.from(l.keys())),a._wirePlotShapeEvents(u,i,e.events);const m=su(u).map(e=>{const n=e.datum,o=n&&Rv(e)?{interactionPoints:t.get(n)?.interactionPoints}:{};return{...e,shapeType:i,...o}}),p=Bv(a,[r.top,r.bottom]);p.render();const g=p.toScene();return[...m,Tv({...g,key:"candlestick-volume-axis",transform:{x:r.left-Nv(p,g),y:0}})]}function Nv(e,t){const n=(t.children||[]).find(e=>"bar"===e.key&&"line"===e.type),i=n?.points?.[0]?.[0];if(Number.isFinite(i))return i;const o=e.outerBounds();return o.x+o.width}function Tv(e){const t=e.children;return{...e,interactionGroup:"axis",...t?{children:t.map(Tv)}:{}}}function Ov(e,t){if(Math.abs(e)<1)return d.formatAbbreviate(e,t,".3~g");const n=d.formatAbbreviate(1.5,t,".1f").charAt(1),[i,o=""]=d.formatAbbreviate(e,t,",.2f").split(n);return`${i}${n}${o.padEnd(2,"0")}`}function Wv(e,t){return`${e>0?"+":""}${d.formatAbbreviate(100*e,t,".2f")}%`}function jv(e,t,n){const i=e._x?e._x(t,n):void 0,o=e._xConfig?.tickFormat,a=mv(i);return"function"==typeof o?String(o(a)):a instanceof Date?pv(a):String(i??"")}function Hv(e,t,n){const i=Rk(t,n,lv(e));if(!i)return[];const o=t=>e.schema.translate(t),a=function(e){const t=e._yConfig?.tickFormat;return"function"==typeof t?e=>String(t(e)):t=>Ov(t,e.schema.locale)}(e),r=[[kg(e,"x"),jv(e,t,n)],[o("Open"),a(i.open)],[o("High"),a(i.high)],[o("Low"),a(i.low)],[o("Close"),a(i.close)]],s=Nk(i.open,i.close);void 0!==s&&r.push([o("Change"),Wv(s,e.schema.locale)]);const c=Sv(e,t,n);return void 0!==c&&r.push([o("Volume"),Fv(e,c)]),r}function Iv(e,t,n){const[i,...o]=Hv(e,t,n);return`${Vv(e,t,n,i?.[1])}: ${o.map(([e,t])=>`${e} ${t}`).join(", ")}.`}function Gv(e,t,n){const i=Sv(e,t,n),o=void 0===i?"":` ${Fv(e,i)}`;return`${Vv(e,t,n,jv(e,t,n))}: ${e.schema.translate("Volume")}${o}.`}function Vv(e,t,n,i){return[e._drawLabel(t,n),i].filter(e=>void 0!==e&&""!==e).join(", ")}const qv="Candlestick",Yv=(e,t)=>"function"==typeof e?e(t.data,t.i):e;function Kv(e,t,n,i,o){const a=lv(e),r=e.schema.variant,s=Math.min(Math.abs(o[o.length-1]-o[0]),40),c=t.map(e=>n(e.x)),l=Wk(Ok(c,s),Number(e.schema.bodyWidth)),h=l>=2?2*Math.round(l/2):l,u=new Map;return t.forEach((e,t)=>{const n=Rk(e.data,e.i,a);if(!n||!Number.isFinite(c[t]))return;const o={open:jk(i(n.open)),high:jk(i(n.high)),low:jk(i(n.low)),close:jk(i(n.close))};if(![o.open,o.high,o.low,o.close].every(Number.isFinite))return;const s=jk(c[t]);u.set(e,{cx:s,width:h,px:o,direction:Ek(n.open,n.close),d:"ohlc"===r?Ik(s,h,o):Hk(s,h,o)})}),u}function Uv(e,t){if(!e)return e;const n="string"==typeof t?l.color(t):null;if(!n)return e;const i="object"==typeof e?{...e}:{texture:e};return i.stroke||(i.stroke=n.darker(1).formatHex()),i}const Xv=e=>{const{viz:t,x:n,y:i,xRange:o}=e,a=e.values,r=Kv(t,a,n,i,o);if(!r.size)return[];const s=e=>r.get(e),c=t.schema.shapeConfig[qv],l=eu("Path").renderMode("compute").config(au(t,qv)).config(function(e,t){const n=n=>Yv("up"===t(n).direction?e.schema.upColor:e.schema.downColor,n);return{fill:i=>{const{direction:o}=t(i);return"ohlc"===e.schema.variant||"up"===o&&e.schema.hollow?"none":n(i)},stroke:n,strokeWidth:1,strokeLinecap:"butt"}}(t,s)).config(c?Ae.bind(t)(c):{}).config({ariaLabel:e=>Iv(t,e.data,e.i),d:e=>s(e).d,hitArea:e=>{const{cx:t,width:n,px:i}=s(e),o=Math.max(n,6);return{x:t-o/2,y:i.high-2,width:o,height:i.low-i.high+4}},id:e=>`${e.id}_${e.discrete}`,label:!1,x:0,y:0}),h=l.schema.fill,u=l.schema.backgroundImage,d=l.schema.texture;l.config({backgroundImage:(e,t)=>"none"!==h(e,t)&&u(e,t),texture:(e,t)=>Uv(d(e,t),h(e,t))}).data(Array.from(r.keys())),t._wirePlotShapeEvents(l,qv,e.events);const f=(e,t)=>[{x:t.cx,y:t.px.close,datum:e,index:e.i}],m=su(l).map(e=>{const t=e.datum,n=t&&r.get(t),i=n&&Rv(e)?{interactionPoints:f(t,n)}:{};return{...e,shapeType:qv,...i}});if(!vv(t)||!Pv(e))return m;const p=new Map;r.forEach((e,t)=>p.set(t,{cx:e.cx,width:e.width,interactionPoints:f(t,e)}));const g=Ev(e,p,function(e,t){return{ariaLabel:t=>Gv(e,t.data,t.i),fill:n=>Yv("up"===t(n).direction?e.schema.upColor:e.schema.downColor,n),stroke:"none",strokeWidth:0}}(t,s),qv,Uv),y=e.yRange[0]-(e.x2Height??0);return[{type:"group",key:"candlestick-price",clip:{type:"rect",x:o[0],y:y,width:o[o.length-1]-o[0],height:e.yRange[1]-e.yRange[0]},children:m},...g]};const Qv=e=>e.ctx.candlestick;function Zv(e){const t=Qv(e),n=cv(e,"close");Object.defineProperty(e,"_x",{configurable:!0,enumerable:!0,get:()=>e.schema.skipGaps?t.xDate:t.x,set:e=>{e!==t.xDate&&e!==t.x&&(t.x=e)}}),Object.defineProperty(e,"_y",{configurable:!0,enumerable:!0,get:()=>n,set:t=>{t!==n&&(e.schema.close=t)}}),Object.defineProperty(e,"_yKey",{configurable:!0,enumerable:!0,get:()=>t.yKey??e.schema.translate("Close"),set:n=>{t.yKey="y"===n?void 0:n,void 0!==t.yKey&&"function"==typeof e.schema.close&&function(e,t){Vk.set(e,t)}(e.schema.close,n)}})}const Jv={name:"Candlestick",paintDriven:!0,facet:{aspect:16/9},setup:e=>{const t=T("date");e.ctx.candlestick={x:t,xDate:(t,n)=>mv(Qv(e).x(t,n))},e._xKey="date",Zv(e),function(e){const t=new WeakMap;sv.set(e,t),e._mergeRows=n=>{const i=o.merge(n,e.schema.aggs);if(n.length>1){const o=av(n,rv(e),e.schema.aggs);o&&t.set(i,o)}return i}}(e),Lv(e),e._buffer={...e._buffer,[qv]:uv},e._plotShapeEmitters={[qv]:Xv},e._plotColumnHighlight=Lk(e),e._tooltipAxisRows=!1,e._yTitle=null;const n=e._preDraw.bind(e);e._preDraw=()=>{!function(e){const t=Qv(e),n=e.schema.time;void 0!==n&&n!==t.time||(t.time=e.schema.skipGaps?void 0:(t,n)=>e._x(t,n),e.schema.time=t.time)}(e),function(e){ov(e.schema.aggs,rv(e))}(e),n()};const i=e._draw.bind(e);e._draw=t=>(e._plotAxisDefaults=e.schema.skipGaps?{x:bv(e)}:void 0,"chrome"===e._facetStep&&function(e){Av.set(e,$v(e,e._filteredData||[]))}(e),i(t))},ctx:{},fields:[{key:"open",coerce:qk,factory:()=>Yk("open")},{key:"high",coerce:qk,factory:()=>Yk("high")},{key:"low",coerce:qk,factory:()=>Yk("low")},{key:"close",coerce:qk,factory:()=>Yk("close")},{key:"volume",coerce:kv},{key:"volumeConfig",merge:!0,default:_v},{key:"variant",default:"candlestick"},{key:"upColor",default:"#2f9e44"},{key:"downColor",default:"#e03131"},{key:"hollow",default:!0},{key:"bodyWidth",default:.7},{key:"skipGaps",default:!0},{key:"discrete",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:N(qv),coerce:"const"},{key:"timeline",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>Hv(e,t,n)})}]};var ew=xf(Jv,_b);const tw=({viz:e})=>{const t=e,{width:n,height:i}=ie(t),o=Array.isArray(t.schema.nodes)&&t.schema.nodes.length>0,a=Array.isArray(t.schema.links)&&t.schema.links.length>0;if(!o&&!a)return t.ctx.nodeLookup={},t.ctx.adjacency={},{viz:e};const r=(o?t.schema.nodes:function(e,t,n){const i=new Set,o=[];for(const a of e){const e=a[t];i.has(e)||(i.add(e),o.push(e));const r=a[n];i.has(r)||(i.add(r),o.push(r))}return o.map(e=>({id:e}))}(t.schema.links,t.schema.linksSource,t.schema.linksTarget)).map((e,n)=>({__d3plus__:!0,data:e,node:e,i:n,id:t.schema.nodeId(e,n),shape:"Path"})),s={};r.forEach((e,t)=>{s[String(e.id)]=t}),t.ctx.nodeLookup=s;const c=r.length,l=Array.from({length:c},()=>new Array(c).fill(0)),u={},d=(e,t)=>{var n,i;((n=u)[i=String(e)]??(n[i]=[])).push(t)};t.schema.links.forEach((e,n)=>{const i=s[String(e[t.schema.linksSource])],o=s[String(e[t.schema.linksTarget])];null!=i&&null!=o&&(l[i][o]+=t.schema.value(e,n)||0,d(r[i].id,r[o].id),d(r[o].id,r[i].id))}),t.ctx.adjacency=u;const f=Math.min(n,i)/2,m=Math.min(.28*f,90),p=Math.max(0,f-m),g=Math.min(t.schema.arcThickness,p),x=Math.max(0,p-g),b=null!=t.schema.padAngle?t.schema.padAngle:t.schema.padPixel/(p||1),_=(t.schema.directed?v.chordDirected():v.chord()).padAngle(b).sortSubgroups(h.descending)(l);_.groups.forEach(e=>{const t=r[e.index];t&&(t.group=e)});const k=y.arc().innerRadius(x).outerRadius(p),w=t.schema.arrows,S="function"==typeof w||!!w&&"source"!==w,C="number"==typeof t.schema.arrowSize?t.schema.arrowSize:void 0;let M;if(S){const e=v.ribbonArrow().radius(x).headRadius(C??Math.max(10,.75*g));M=t=>e(t)??""}else{const e=v.ribbon().radius(x);M=t=>e(t)??""}return function(e,t,n){e.forEach(e=>{const i=e.group;if(!i)return;const o=(i.startAngle+i.endAngle)/2,a=o-Math.PI/2;e.labelX=Math.cos(a)*t,e.labelY=Math.sin(a)*t;let r=180*o/Math.PI-90;o>Math.PI?(r+=180,e.labelBounds={x:-(n+4),y:-7.5,width:n,height:15},e.labelAnchor="end"):(e.labelBounds={x:4,y:-7.5,width:n,height:15},e.labelAnchor="start"),e.labelRotate=r})}(r,p,m),t.ctx.chordCtx={nodes:r,chords:_,arcFn:e=>k(e)??"",ribbonFn:M},t.ctx.chordWidth=n,t.ctx.chordHeight=i,{shapeData:r}},nw={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",rotate(e){const t=e.r??e.data?.r;return"number"==typeof t?t:0},rotateAnchor(e){const t=e.rotateAnchor??e.data?.rotateAnchor;return Array.isArray(t)?t:[(e.w??0)/2,(e.h??0)/2]},fontColor(e,t){const n="function"==typeof this._fill?this._fill(e,t):this._fill;return"string"==typeof n?r.colorContrast(n):"black"}};function iw(e){const t=$o(e);if(!t.length)return[];const n=(new ro).config({...nw,...e.labelConfig??{}}).data(t).renderMode("compute");try{const e=n.toScene();return Array.isArray(e?.children)?e.children:[]}catch{return[]}}function ow(e){return arguments.length?(this._hover=e,this.schema.legend&&this._legendClass&&this._legendClass.hover(e),this._sceneRenderer&&this._scheduleSceneRepaint(),dt(this,"hover",e),this):this._hover}const aw={name:"Chord",layoutStage:tw,emit:({viz:e})=>{const t=e.ctx.chordCtx;if(!t)return[];const n=[],i=au(e,"Path"),o=e.schema.chordOpacity??.6;n.push(...function(e,t,n,i){const o=[],a=[];for(let r=0;r<t.chords.length;r++){const s=t.chords[r],c=t.nodes[s.source.index],l=t.nodes[s.target.index];if(!c||!l)continue;const h=tu(n.fill,c.data,c.i),u="string"==typeof h?h:void 0,d=tu(n.opacity,c.data,c.i),f={type:"path",shapeType:"Chord",key:`chord-ribbon-${c.id}-${l.id}`,d:t.ribbonFn(s),datum:{source:{id:c.id},target:{id:l.id},value:s.source.value},index:r,paint:{fill:nu(n,c.data,c.i,h),fillOpacity:i,stroke:u,strokeOpacity:1,opacity:"number"==typeof d?d:1},aria:{label:`${e._drawLabel(c.data,c.i)} to ${e._drawLabel(l.data,l.i)}, ${s.source.value}.`}};o.push(f);const m=Vy(n,{...f,paint:{...f.paint,opacity:(f.paint?.opacity??1)*i}},c.data,c.i);m&&a.push(m)}return[...o,...a]}(e,t,i,o));const a=[],r=t.nodes.filter(e=>Boolean(e.group));for(const n of r){const o=iu(i,n.data,n.i);a.push({type:"path",key:`chord-arc-${n.id}`,d:t.arcFn(n.group),datum:n.data,index:n.i,paint:o,aria:{label:`${e._drawLabel(n.data,n.i)}, ${n.group.value}.`}})}if(n.push(...a,...qy(i,a,e=>[r[e].data,r[e].i])),r.length){const t=iw({data:r,label:t=>{const n=t;return e._drawLabel(n.data,n.i)},x:e=>e.labelX??0,y:e=>e.labelY??0,aes:()=>({}),rotate:e=>e.labelRotate??0,id:e=>`chord-label-${e.id}`,labelBounds:e=>e.labelBounds??!1,labelConfig:{...ru(e,"Path"),fontResize:!1,padding:0,textAnchor:e=>(e.data??e).labelAnchor??"start",verticalAlign:"middle"}});n.push(...t)}return n},chartTransform:e=>oe(e,e.ctx.chordWidth,e.ctx.chordHeight),chartBodyRect:e=>{const t=e.ctx.chordWidth??0,n=e.ctx.chordHeight??0;return{x:-t/2,y:-n/2,width:t,height:n}},setup:e=>{const t=e;e.schema.color=(t,n)=>e.schema.groupBy[0](t,n)??e.schema.nodeId(t,n),e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{if(n(i,o,a,r),e._focus&&e._focus===i.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(i,o,a,r),void(e._focus=void 0);const s=i;if(s.source&&s.target){const n=s.source.id,i=s.target.id;return void t.hover((t,o)=>{if(t.source&&t.target)return t.source.id===n&&t.target.id===i;const a=e.schema.nodeId(t,o);return a===n||a===i})}const c=e.schema.nodeId(i,o),l=e.ctx.adjacency[String(c)]??[],h=[c,...l];t.hover((t,n)=>t.source&&t.target?t.source.id===c||t.target.id===c:h.includes(e.schema.nodeId(t,n)))},t.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:Be(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:Be(e),this):this.schema.value},t.hover=ow},facet:{aspect:1},ctx:{},fields:[{key:"arcThickness",default:20},{key:"arrows",default:!1},{key:"arrowSize"},{key:"chordOpacity",default:.6},{key:"directed",default:!0},{key:"links",default:T("links")},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:T("nodes")},{key:"nodeId",default:T("id")},{key:"padAngle"},{key:"padPixel",default:2},{key:"value",default:N(1)},{key:"shape",default:N("Path"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>({Path:{label:!1}})},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};var rw=xf(aw);function sw(e,t){return[()=>e.schema.translate("Share"),(n,i,o)=>{const a=t=>`${d.formatAbbreviate(100*t,e.schema.locale)}%`;if(o._isColorScaleBucket){const n=Pa(e,o.color,e.schema[t]);return null==n?"":a(n)}const r=Cr(o);return Number.isFinite(r)?a(r):""}]}function cw(e,t=()=>!0){const n=e.schema.legend;return(i,o)=>(o.length!==e._filteredData.length||!t(e))&&n.call(e,i,o)}const lw=({viz:e})=>{const{width:t,height:n}=ie(e),i=e.schema.shapeConfig??{},o=3*("number"==typeof i.strokeWidth?i.strokeWidth:2)/2,a=Math.max(0,Math.min(t,n)/2-o),r=e.ctx.pie,s=e.schema.padAngle??0,c=e.schema.padPixel??0,l=e.schema.sort,h=e.schema.value,u=r.padAngle(s||c/a).sort(l).value(h)(e._filteredData),d=u.reduce((e,t)=>e+t.value,0);u.forEach((e,t)=>{e.__d3plus__=!0,e.i=t;const n=d?e.value/d:0;e.share=n,wr(e.data,n)});const f=e.schema.innerRadius;return e.ctx.arcData=L.arc().innerRadius("function"==typeof f?f:()=>f).outerRadius(a),e.ctx.pieData=u,e.ctx.pieWidth=t,e.ctx.pieHeight=n,e.ctx.pieOuterRadius=a,{shapeData:u}};const hw={name:"Pie",layoutStage:lw,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o=e.ctx.arcData,a=e=>o(e)??"",s=o.innerRadius(),c=o.outerRadius(),l=au(e,"Path"),h=e._pendingEnterOrigin,u=h?.parentStartAngle,m=h?.parentEndAngle,p=void 0!==u&&void 0!==m?{start:u,span:m-u}:void 0,g=Boolean(e._pendingExitReunion),y=e.schema.value,x=e.schema.locale,b=e=>`${d.formatAbbreviate(100*(e.share??0),x)}%`,_={viz:e,arcMaker:a,resolveInnerRadius:s,resolveOuterRadius:c,sc:l,value:y,sharePct:b,flipSource:p,isReunionDraw:g},k=n.map((e,t)=>function(e,t,n){const{viz:o,arcMaker:a,resolveInnerRadius:r,resolveOuterRadius:s,sc:c,value:l,sharePct:h,flipSource:u,isReunionDraw:d}=n,f=tu(c.fill,e.data,e.i??0),m=tu(c.stroke,e.data,e.i??0),p=tu(c.strokeWidth,e.data,e.i??0),g={innerRadius:r(e,e.i??0),outerRadius:s(e,e.i??0),startAngle:e.startAngle,endAngle:e.endAngle,padAngle:e.padAngle},y=u?{...g,startAngle:u.start+e.startAngle/i.FULL_TURN*u.span,endAngle:u.start+e.endAngle/i.FULL_TURN*u.span}:void 0,x=d?{...g,startAngle:0,endAngle:i.FULL_TURN}:void 0;return{type:"path",key:`pie-${o._ids(e.data,e.i??0).join("-")}`,d:a(e),arc:g,flipFromArc:y,reunionFromArc:x,shapeType:"Pie",transform:{x:0,y:0},startAngle:e.startAngle,endAngle:e.endAngle,datum:e.data,paint:{fill:nu(c,e.data,e.i??0,f),stroke:m,strokeWidth:p,opacity:1},aria:{label:`${t+1}. ${o._drawLabel(e.data,e.i??0)}, ${l(e.data,e.i??0)}, ${h(e)}.`}}}(e,t,_)),v=n.map(e=>{const t=f.largestRect(f.path2polygon(a(e)),{angle:0,nTries:40});if(!t)return!1;const n=t.cx-t.width/2,i=t.cy-t.height/2;if(t.height<50)return[{angle:t.angle,width:t.width,height:t.height,x:n,y:i}];const o=Math.min(32,.3*(t.height-10))+10;return[{angle:t.angle,width:t.width,height:t.height-o,x:n,y:i},{angle:t.angle,width:t.width,height:o,x:n,y:i+t.height-o}]}),w=iw({data:n,label:(t,i)=>{const o=e._drawLabel(n[i].data,n[i].i??i),a=v[i];return a&&a.length>1?[o,b(n[i])]:[o]},x:()=>0,y:()=>0,aes:()=>({}),rotate:N(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>v[t],labelConfig:{fontColor:t=>{const n=t.data??t,i=tu(l.fill,n.data,n.i??0);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:!0,textAnchor:"middle",verticalAlign:e=>{if(e&&1===e.l)return"top";const t=!(!e||!e.data)&&v[n.indexOf(e.data)];return t&&t.length>1?"bottom":"middle"},...ru(e,"Path")}});!function(e,t){for(const n of e){const e=n;if(e.shapeType="Label",!t)continue;const o=e.transform??{},a=o.x??0,r=o.y??0,s=Math.hypot(a,r),c=Math.atan2(a,-r),l=c<0?c+i.FULL_TURN:c,h=t.start+l/i.FULL_TURN*t.span;e.flipFromTransform={x:s*Math.sin(h),y:-s*Math.cos(h)}}}(w,p);const S=qy(l,k,e=>[n[e].data,n[e].i??0]);return[...k,...S,...w]},insetRegion:Uu,chartTransform:e=>oe(e,e.ctx.pieWidth,e.ctx.pieHeight),chartBodyRect:e=>{const t=e.ctx.pieOuterRadius??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:{aspect:1},ctx:{pie:y.pie()},fields:[{key:"innerRadius",default:0},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"sort",factory:e=>{const t=e.schema.value;return(e,n)=>t(n)-t(e)}},{key:"legendSort",factory:e=>{const t=e.schema.value;return(e,n)=>t(n)-t(e)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e.ctx.pieData;return i?`${++i[n].index}. ${e._drawLabel(t,n)}, ${e.schema.value(t,n)}.`:""},Path:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:2})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"value")]})},{key:"legend",coerce:"const",factory:cw}]};var uw=xf(hw);var dw=xf({name:"Donut",emit:hw.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:e=>()=>{const{width:t,height:n}=ie(e);return(h.min([t,n])??0)/4}}]},uw);const fw="::connector";function mw(e,t){const n="x"===t?"y":"x",i=new Map;for(const o of e){const e=`${o[t]}`;let a=i.get(e);a||i.set(e,a={});const r=o[n];f.finite(r)&&((!a.lo||r<a.lo[n])&&(a.lo=o),(!a.hi||r>a.hi[n])&&(a.hi=o))}const o=[];return i.forEach(({lo:e,hi:t},i)=>{e&&t&&e!==t&&e[n]!==t[n]&&o.push({category:i,lo:e,hi:t})}),o}function pw(e){const t={...e,interactive:!1};return delete t.datum,t}function gw(e){const{viz:t}=e,n="x"===t.schema.discrete?"x":"y",i=mw(e.values,n);if(!i.length)return[];const o=i.flatMap(({category:e,lo:t,hi:n})=>[{__d3plus__:!0,data:t,i:t.i,category:e},{__d3plus__:!0,data:n,i:n.i,category:e}]),a=t=>{const n=e.shapeConfig[t];return e=>n(e.data,e.data.i)},r=eu("Line").renderMode("compute").config(e.shapeConfig).data(o),s=au(t,"Line");return void 0===t.schema.shapeConfig.duration&&delete s.duration,r.config(s).config({curve:"linear",hitArea:!1,id:e=>`${e.category}${fw}`,label:!1,x:a("x"),y:a("y")}),su(r).map(pw)}const yw=(e,t)=>{const n=de({...e.shapeConfig,id:e=>`${e.id}_${e.discrete}`});return[...gw(e),...ux.Circle({...e,shapeConfig:n},t)]};function xw(e,t,n){const i=new Map;e.forEach((e,o)=>{const a=`${t(e,o)}`,r=n(e,o),s=i.get(a);f.finite(r)?s&&f.finite(s[0])?i.set(a,[Math.min(s[0],r),Math.max(s[1],r)]):i.set(a,[r,r]):s||i.set(a,[NaN,NaN])});const o=new Map;return i.forEach(([e,t],n)=>o.set(n,f.finite(e)?t-e:0)),o}function bw(e,t,n){const i=t=>e().get(`${n(t)}`)??0;return(e,n)=>"ascending"===t?i(e)-i(n):i(n)-i(e)}function _w(e,t){t.axis&&t.sort&&e.schema[`${t.axis}Sort`]===t.sort&&(e.schema[`${t.axis}Sort`]=void 0),t.axis=t.sort=void 0;const n=e.schema.gapSort;if("ascending"!==n&&"descending"!==n)return;const i="x"===e.schema.discrete?"x":"y";if(e.schema[`${i}Sort`])return;const o=e[`_${i}`],a=e["_"+("x"===i?"y":"x")],r=new WeakMap,s="y"===i?"ascending"===n?"descending":"ascending":n;t.axis=i,t.sort=e.schema[`${i}Sort`]=bw(()=>{const t=e._filteredData||[];let n=r.get(t);return n||r.set(t,n=xw(t,o,a)),n},s,e=>o(e,0))}function kw(e){const t=e._select&&"function"==typeof e._select.node?e._select.node():null,i=t?n.backgroundColor(t):"rgb(255, 255, 255)";return r.colorContrast(i,e.schema.colorDefaults)===e.schema.colorDefaults.dark?r.colorGray[500]:r.colorGray[700]}const vw={name:"Dumbbell",paintDriven:!0,setup:e=>{const t={};e.ctx.dumbbell=t,e._plotShapeEmitters={Circle:yw},e._plotColumnHighlight=Lk(e);const n=e._preDraw.bind(e);e._preDraw=()=>{_w(e,t),n()}},ctx:{},fields:[{key:"discrete",default:"y"},{key:"gapSort",default:!1},{key:"shapeConfig",merge:!0,factory:e=>({Circle:{label:!1,trail:!1},Line:{label:!1,stroke:()=>kw(e),strokeWidth:3}})}]};var ww=xf(vw,_b);var Sw=xf({name:"LinePlot",paintDriven:!0,ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:N("Line"),coerce:"const"}]},_b);const Cw={name:"FanChart",paintDriven:!0,ctx:{},fields:[{key:"forecast",default:"auto"}]};var Mw=xf(Cw,Sw);function $w(e,t,n){if(e<=0||!(t>0))return[];const i=e>1?Math.min(.95,Math.max(0,n||0)):0,o=t/(e-i),a=o*(1-i);return Array.from({length:e},(e,t)=>({start:t*o,end:t*o+a}))}function Aw(e){return Number.isFinite(e)&&e>0?e:0}function zw(e){return e.reduce((e,t)=>Math.max(e,Aw(t)),0)}function Dw(e,t,n=0){const i=Math.max(zw(e),Aw(n));return e.map(e=>i>0?Aw(e)/i*t:0)}function Fw(e){const t=e.length;if(t<2)return e.map(()=>0);const n=[];for(let i=0;i<t-1;i++){const t=e[i+1].s-e[i].s;n.push(t>0?(e[i+1].w-e[i].w)/t:0)}const i=e.map((e,i)=>{if(0===i)return n[0];if(i===t-1)return n[t-2];const o=n[i-1],a=n[i];return o*a<=0?0:(o+a)/2});for(let e=0;e<t-1;e++){const t=n[e];if(0===t){i[e]=0,i[e+1]=0;continue}const o=i[e]/t,a=i[e+1]/t,r=o*o+a*a;if(r>9){const n=3/Math.sqrt(r);i[e]=n*o*t,i[e+1]=n*a*t}}return i}function Bw(e,t,n){if(!e.length)return[];if(!n)return e.flatMap((e,n)=>[{s:e.start,w:t[n],m:0},{s:e.end,w:t[n],m:0}]);const i=e.length-1,o=e.map((e,n)=>({s:e.start,w:t[n]}));o.push({s:e[i].end,w:t[i]});const a=Fw(o);return o.map((e,t)=>({...e,m:a[t]}))}function Lw(e,t,n,i){const o=t.s-e.s;if(!(o>0))return e.w;const a=Math.min(1,Math.max(0,(n-e.s)/o));if("smooth"!==i)return e.w+(t.w-e.w)*a;const r=a*a,s=r*a;return(2*s-3*r+1)*e.w+(s-2*r+a)*o*e.m+(-2*s+3*r)*t.w+(s-r)*o*t.m}function Pw(e,t){return e.w===t.w&&0===e.m&&0===t.m}function Rw(e,t,n,i,o=12){const a=[];if(!(n>t))return a;for(let r=0;r<e.length-1;r++){const s=e[r],c=e[r+1],l=Math.max(t,s.s),h=Math.min(n,c.s);if(!(h>l&&c.s>s.s))continue;const u="smooth"!==i||Pw(s,c)?1:Math.max(1,Math.ceil(o*(h-l)/(c.s-s.s)));for(let e=0;e<=u;e++){const t=l+(h-l)*e/u,n=Lw(s,c,t,i),o=a[a.length-1];o&&o[0]===t&&o[1]===n||a.push([t,n])}}return a}const Ew=e=>Math.round(100*e)/100;function Nw(e,t,n){if(e.length<2)return"";const i=(e,t)=>"horizontal"===n?`${Ew(e)},${Ew(t)}`:`${Ew(t)},${Ew(e)}`,o=e.map(([e,n])=>i(e,t-n/2)),a=e.slice().reverse().map(([e,n])=>i(e,t+n/2));return`M${o.join("L")}L${a.join("L")}Z`}function Tw(e){if(!e.length)return{min:0,max:0};const t=e.map(e=>e[1]);return{min:Math.min(...t),max:Math.max(...t)}}function Ow(e){const t=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&0!==t?e/t:NaN;return{first:e.map(n=>t(n,e[0])),previous:e.map((n,i)=>i?t(n,e[i-1]):NaN)}}function Ww(e){var t;return(t=e.ctx).funnelRates??(t.funnelRates=new WeakMap)}function jw(e,t){const n=e.schema.sort;return"function"==typeof n?t.slice().sort(n):t}function Hw(e){const t=Number(e.ctx.funnelScaleMax);return Number.isFinite(t)&&t>0?t:0}function Iw(e){return"horizontal"===e.schema.orient?"horizontal":"vertical"}function Gw(e){return"smooth"===e.schema.curve?"smooth":"linear"}function Vw(e,t,{width:n,height:i},o){const a=Iw(e),r=Gw(e),s=e.schema.value,c=t.map((e,t)=>Number(s(e,t))),l="vertical"===a,h=Math.max(0,(l?i:n)-4),u=Math.max(0,(l?n:i)-4),d=$w(t.length,h,Number(e.schema.stagePadding)).map(e=>({start:e.start+2,end:e.end+2})),f=Dw(c,u,o),m=Bw(d,f,!!e.schema.taper),p=Ow(c);return{stages:t.map((e,t)=>{const n=d[t],i=Rw(m,n.start,n.end,r),o=t?Rw(m,d[t-1].end,n.start,r):[];return{__d3plus__:!0,data:e,i:t,value:c[t],first:p.first[t],previous:p.previous[t],start:n.start,end:n.end,points:i,neck:o,...Tw(i)}}),shared:{orient:a,curve:r,center:(l?n:i)/2,breadth:u,offset:2}}}const qw=({viz:e})=>{const t=jw(e,e._filteredData??[]),{stages:n,shared:i}=Vw(e,t,ie(e),Hw(e)),o=Ww(e);for(const e of n)o.set(e.data,{first:e.first,previous:e.previous});return e.ctx.funnel=i,{shapeData:n}};function Yw(e){return!0===e||"both"===e?["first","previous"]:"first"===e||"previous"===e?[e]:Array.isArray(e)?["first","previous"].filter(t=>e.includes(t)):[]}function Kw(e,t,n,i){const{fontMax:o,padding:a,lineHeight:r}=i,s=t.width-2*a,c=t.height-2*a;if(!(e.length&&s>0&&c>0))return 0;const l=Math.max(...e.map(e=>n(e,o))),h=c/(e.length*r),u=l>0?s/l*o:o,d=Math.min(o,h,u);return Math.floor(2*d)/2}function Uw(e,t,n,i,o){for(let a=e.length;a>0;a--){const r=e.slice(0,a),s=Kw(r,t,i,o),c=n?Kw(r,n,i,o):0;if(s>=o.fontMin&&s>=.8*c)return{position:"inside",fontSize:s,lines:r};if(c>=o.fontMin)return{position:"outside",fontSize:c,lines:r}}return null}function Xw(e,t,n,i=1/0){const o=e.map(e=>Uw(e.lines,e.inside,e.outside,t,e.fixed?{...n,fontMin:e.fixed,fontMax:e.fixed}:n)),a=o.flatMap((t,n)=>t&&!e[n].fixed?[n]:[]);if(!a.length)return{plans:o,fontSize:0};const r=Math.min(i,...a.map(e=>o[e].fontSize));for(const i of a){const a=o[i],s="inside"===a.position||Kw(a.lines,e[i].inside,t,n)>=r;o[i]={...a,position:s?"inside":"outside",fontSize:r}}return{plans:o,fontSize:r}}function Qw(e,t,n,i){const o=t*n,a="top"===i?e.y:e.y+(e.height-o)/2;return Array.from({length:t},(t,i)=>({x:e.x,y:a+i*n,width:e.width,height:n}))}function Zw(e,t){return`${d.formatAbbreviate(100*t,e.schema.locale)}%`}function Jw(e,t){const n=e.schema.valueFormat,i=[e._drawLabel(t.data,t.i)];if(Number.isFinite(t.value)&&i.push(`${n(t.value,t.data)}`),!t.i)return i;const o=Yw(e.schema.conversion);for(const n of o){const o="first"===n?t.first:t.previous;if(!Number.isFinite(o))continue;const a=e.schema.translate("first"===n?"of first":"of previous");i.push(`${Zw(e,o)} ${a}`)}return i}function eS(e,t){const n=e.end-e.start,i=t.center+e.max/2+6,o=Math.max(0,(t.breadth-e.max)/2-6);return"horizontal"===t.orient?{inside:{x:e.start,y:t.center-e.min/2,width:n,height:e.min},outside:{x:e.start,y:i,width:n,height:o}}:{inside:{x:t.center-e.min/2,y:e.start,width:e.min,height:n},outside:{x:i,y:e.start,width:o,height:n}}}function tS(e,t){return{x:e.x+t,y:e.y+t,width:Math.max(0,e.width-2*t),height:Math.max(0,e.height-2*t)}}function nS(e,t,n){const i=(e,i)=>{const o=tu(e,t,n);return"number"==typeof o&&o>0?o:i};return{fontMin:i(e.fontMin,10),fontMax:i(e.fontMax,16),padding:4,lineHeight:1.2}}function iS(e,t,i,o=1/0){const r=ru(e,"Path"),s=t[0],c=s?nS(r,s.data,s.i):nS({},{},0),l=a.fontFamilyStringify((s?tu(r.fontFamily,s.data,s.i):void 0)??e.schema.fontFamily),h=t.map(t=>{const{inside:n,outside:o}=eS(t,i),a=tu(r.fontSize,t.data,t.i);return{lines:Jw(e,t),inside:n,outside:o,fixed:"number"==typeof a&&a>0?a:void 0}}),{plans:u,fontSize:d}=Xw(h,(e,t)=>Number(n.textWidth(e,{"font-family":l,"font-size":t,"font-weight":600}))||0,c,o),f=new Map;return u.forEach((e,n)=>{e&&f.set(t[n].data,e)}),{plans:f,fontSize:d,sizing:c,user:r}}function oS(e,t,n){return t.length?iS(e,t,n).fontSize:0}function aS(e){const t=Number(e.ctx.funnelLabelSize);return Number.isFinite(t)&&t>0?t:1/0}function rS(e,t,n){const i=au(e,"Path"),{plans:o,sizing:a,user:s}=iS(e,t,n,aS(e)),c="horizontal"===n.orient,l=new Map;for(const e of t){const t=o.get(e.data);if(!t)continue;const{inside:i,outside:a}=eS(e,n),r="inside"===t.position?i:a,s="outside"===t.position&&c?"top":"middle",h=Qw(tS(r,4),t.lines.length,1.2*t.fontSize,s);l.set(e.data,{stage:e,plan:t,boxes:h})}const h=e=>l.get((e&&e.data)??e);return iw({data:t.map(e=>e.data),datum:e=>e,label:e=>l.get(e)?.plan.lines??!1,labelBounds:e=>{const t=l.get(e)?.boxes;return!!t&&t.map(e=>({...e,y:e.y-1,height:e.height+2}))},x:()=>0,y:()=>0,aes:()=>({}),rotate:N(0),id:(t,n)=>`funnel-label-${e._ids(t,n).join("-")}`,labelConfig:{fontResize:!1,padding:0,lineHeight:e=>1.2*(h(e)?.plan.fontSize??a.fontMin),fontWeight:e=>e&&0===e.l?600:400,textAnchor:e=>"outside"!==h(e)?.plan.position||c?"middle":"start",verticalAlign:"top",fontColor:t=>{const n=h(t);if(!n||"outside"===n.plan.position)return Ga(e);const o=tu(i.fill,n.stage.data,n.stage.i);return"string"==typeof o?r.colorContrast(o,e.schema.colorDefaults):Ga(e)},...s,fontSize:e=>h(e)?.plan.fontSize??a.fontMin}})}function sS(e,t={}){return{...t,...e.schema.connectorConfig??{}}}function cS(e,t,n,i={}){const o=e.schema.connectorConfig??{},a=t.data,r=t.i,s=tu(o.fill,a,r)??n;return{fill:nu(sS(e,i),a,r,s),opacity:tu(o.opacity,a,r),stroke:tu(o.stroke,a,r),strokeWidth:tu(o.strokeWidth,a,r)}}function lS(e,t){const n=e.schema.valueFormat,i=Number.isFinite(t.value)?`, ${n(t.value,t.data)}`:"";return`${t.i+1}. ${e._drawLabel(t.data,t.i)}${i}.`}const hS=({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.funnel;if(!n.length||!i)return[];const o=au(e,"Path"),a=t=>`funnel-${e._ids(t.data,t.i).join("-")}`,r=[],s=[],c=[];for(const t of n){const n=iu(o,t.data,t.i);r.push({type:"path",key:a(t),d:Nw(t.points,i.center,i.orient),datum:t.data,index:t.i,shapeType:"Path",paint:n,aria:{label:lS(e,t)}});const l=Nw(t.neck,i.center,i.orient);if(!1!==e.schema.connector&&l){const n=tu(o.fill,t.data,t.i);s.push({type:"path",key:`${a(t)}-neck`,d:l,datum:t.data,index:t.i,interactive:!1,aria:{hidden:!0},paint:cS(e,t,"string"==typeof n?n:void 0,o)}),c.push(t)}}const l=qy(sS(e,o),s,e=>[c[e].data,c[e].i]),h=qy(o,r,e=>[n[e].data,n[e].i]),u=!1===(e.schema.shapeConfig??{}).label?[]:rS(e,n,i);return[...s,...l,...r,...h,...u]};function uS(e,t,n){if(!1===(e.schema.shapeConfig??{}).label)return 0;const i=ie(e),o=t.filter(e=>e.length).map(t=>{const{stages:o,shared:a}=Vw(e,jw(e,t),i,n);return oS(e,o,a)}).filter(e=>e>0);return o.length?Math.min(...o):0}function dS(e,t){const n=e.schema.value,i=zw(t.flatMap(e=>e.map((e,t)=>Number(n(e,t)))));return{max:i,fontSize:uS(e,t,i)}}function fS(e,t){const n=e.ctx.funnelScaleMax,i=e.ctx.funnelLabelSize,o=t.shared?t.scales:void 0;return e.ctx.funnelScaleMax=o?o.max:void 0,e.ctx.funnelLabelSize=o&&o.fontSize?o.fontSize:void 0,()=>{e.ctx.funnelScaleMax=n,e.ctx.funnelLabelSize=i}}const mS={scales:"independent",share:dS,panel:fS};function pS(e,t,n){const i=Number(e.schema.value(t,n)),o=e.schema.valueFormat,a=[];Number.isFinite(i)&&a.push([e.schema.translate("Value"),`${o(i,t)}`]);const r=t?Ww(e).get(t):void 0,s=r?r.first:NaN,c=r?r.previous:NaN;return Number.isFinite(c)&&(Number.isFinite(s)&&a.push([e.schema.translate("% of First Stage"),Zw(e,s)]),a.push([e.schema.translate("% of Previous Stage"),Zw(e,c)])),a}const gS={name:"Funnel",layoutStage:qw,emit:hS,insetRegion:Uu,facet:mS,ctx:{},fields:[{key:"connector",default:!0},{key:"conversion",default:!1},{key:"curve",default:"linear"},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{const o=new Set(e._filteredData.map((t,n)=>e._ids(t,n).join("_")));return!(i.length>=o.size)&&t.call(e,n,i)}}},{key:"orient",default:"vertical"},{key:"sort"},{key:"stagePadding",default:.3},{key:"taper",default:!1},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):N(e)},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1},{key:"connectorConfig",merge:!0,default:{opacity:.35}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>pS(e,t,n)})}]};var yS=xf(gS);function xS(e){const t=Ia(e),n=r.colorContrast(t,e.schema.colorDefaults),i=x.interpolateRgb(t,n);return{track:i(.12),tick:i(.6),text:n}}const bS={name:"Gauge",layoutStage:t_,emit:({viz:e,shapeData:t})=>{const n=t??[],o=e.ctx.gauge;if(!(n.length&&o&&o.radius>0))return[];const r=1===n.length,s=n[0],c=Zb(o.radius,o.dial),l=function(e,t,n){const i=(e.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},r=xS(e),s=tu(o.fontFamily,t,n)??e.schema.fontFamily,c=e.schema.tickFormat;return{trackFill:tu(i.fill,t,n)??r.track,tickStroke:tu(i.stroke,t,n)??r.tick,tickStrokeWidth:tu(i.strokeWidth,t,n)??1,fontColor:tu(o.fontColor,t,n)??r.text,fontFamily:a.fontFamilyStringify(s),tickFormat:e=>`${c(e)}`}}(e,s.data,s.i),h=e.schema.valueFormat,u=r&&Number.isFinite(s.value)?`${h(s.value,s.data)}`:"",d=o.dial.hasName?e._drawLabel(s.data,s.i):void 0,f={type:"group",key:"gauge-dial",interactive:!1,aria:{hidden:!0},children:[...A_("gauge",c,o,l),...z_("gauge",c,l,u,d)]},m={viz:e,layout:c,shared:o,single:r},p=[f,...n.flatMap(e=>function(e,t){const{viz:n,layout:o,shared:a,single:r}=t,s=`gauge-${n._ids(e.data,e.i).join("-")}`,c=au(n,"Path"),l=iu(c,e.data,e.i),h=n.schema.valueFormat,u=`${[Jb(n,e.data,e.i)?n._drawLabel(e.data,e.i):"",h(e.value,e.data)].filter(Boolean).join(", ")}.`,d={datum:e.data,index:e.i,shapeType:"Path",aria:{label:u}},f="progress"===a.dial.indicator,m=o.rings[f?e.i:0],p={startAngle:a.start,endAngle:a.end},g={rotate:Hb(e.angle)},y={type:"path",key:`${s}-indicator::hit`,d:r?i.arcPath({innerRadius:0,outerRadius:o.outer,...p}):f?i.arcPath({innerRadius:m.inner,outerRadius:m.outer,...p}):Qb(o.needleLength,3*o.needleHalfWidth,o.needleTail),transform:r||f?void 0:g,datum:e.data,index:e.i,paint:{fill:"transparent"}};if(!Number.isFinite(e.value))return[y];if(f){const t={innerRadius:m.inner,outerRadius:m.outer,startAngle:a.start,endAngle:e.angle},n={type:"path",key:`${s}-indicator`,d:i.arcPath(t),arc:t,paint:l,...d},o=Vy(c,n,e.data,e.i);return o?[y,n,o]:[y,n]}const x={type:"path",key:`${s}-indicator`,d:Qb(o.needleLength,o.needleHalfWidth,o.needleTail),transform:g,paint:l,...d};return r?[y,x,{type:"circle",key:`${s}-hub`,cx:0,cy:0,r:o.hubRadius,paint:l,...d}]:[y,x]}(e,m))];return r||"progress"===o.dial.indicator||p.push({type:"circle",key:"gauge-hub",interactive:!1,cx:0,cy:0,r:c.hubRadius,paint:{fill:l.fontColor,stroke:Ia(e),strokeWidth:1.5}}),[{type:"group",key:"gauge",transform:{x:o.cx,y:o.cy},children:p}]},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"domain"},{key:"endAngle",default:120},{key:"indicator",default:"needle"},{key:"minorTicks",default:!0},{key:"startAngle",default:-120},{key:"thickness",default:.2},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>Ia(e),strokeWidth:()=>"progress"===e.schema.indicator?0:1.5})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Value"),(t,n)=>{const i=Number(e.schema.value(t,n));return Number.isFinite(i)?`${e.schema.valueFormat(i,t)}`:""}]]})},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):N(e)},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1}]};var _S=xf(bS);const kS=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["tile.openstreetmap.org"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["openstreetmap.fr/hot"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>"},{matches:["stadiamaps.com"],text:"© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["World_Light_Gray_Base","World_Dark_Gray_Base"],text:"Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}],vS={light:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",dark:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}"},wS=e=>"object"==typeof e&&null!==e&&"light"in e&&"dark"in e;function SS(e,t){return wS(e)?t?e.dark:e.light:e}function CS(e){return wS(e.schema.tileUrl)||wS(e.schema.ocean)}function MS(e){if(e._ssr||"undefined"==typeof window||"function"!=typeof getComputedStyle)return!1;let t=e._select?.node()??null;for(;t;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e)return l.lab(e).l<50;t=t.parentElement}const n=getComputedStyle(document.documentElement).colorScheme||"";return!!n.includes("dark")&&(!n.includes("light")||"function"==typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches)}function $S(e,t){const n=t&&e.objects[t]?t:Object.keys(e.objects)[0];return C.feature(e,n)}function AS(e){return e._filteredData.filter((t,n)=>e.schema.point(t,n)instanceof Array)}function zS(e,t){const n=`scale${e.schema.pointSizeScale.charAt(0).toUpperCase()}${e.schema.pointSizeScale.slice(1)}`;return B[n]().domain(h.extent(t,(t,n)=>e.schema.pointSize(t,n))).range([e.schema.pointSizeMin,e.schema.pointSizeMax])}const DS=({viz:e})=>{const t=e,n=e.ctx,{width:i,height:o}=ie(t),a=t.schema.topojson?$S(t.schema.topojson,t.schema.topojsonKey):{type:"FeatureCollection",features:[]};n.coordData=a,t.schema.topojsonFilter&&(a.features=a.features.filter(t.schema.topojsonFilter));const r=P.geoPath().projection(t.schema.projection);n.path=r;const s=AS(t),c=t._filteredData.filter((e,n)=>!(t.schema.point(e,n)instanceof Array)).reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),l=a.features.reduce((e,n)=>{const i=t.schema.topojsonId(n);return e.push({__d3plus__:!0,data:c[i],feature:n,id:i}),e},[]),u=zS(t,s);if(t._sizeLegendFinal=s.length?u:null,!t._zoomSet||!n.extentBounds){n.effectivePadding=void 0;const e=t.schema.fitObject?$S(t.schema.fitObject,t.schema.fitKey):a;n.extentBounds={type:"FeatureCollection",features:t.schema.fitFilter?e.features.filter(t.schema.fitFilter):e.features.slice()},n.extentBounds.features=function(e,t){return e.reduce((e,n)=>{const i=n;if(!i.geometry)return e;const o={type:i.type,id:i.id,geometry:{coordinates:i.geometry.coordinates,type:i.geometry.type}};if("MultiPolygon"===i.geometry.type&&i.geometry.coordinates.length>1){const e=[],n=[];i.geometry.coordinates.forEach(n=>{o.geometry.coordinates=[n],e.push(t.area(o))}),o.geometry.coordinates=[i.geometry.coordinates[e.indexOf(h.max(e))]];const a=t.centroid(o);i.geometry.coordinates.forEach(e=>{o.geometry.coordinates=[e],n.push(f.pointDistance(t.centroid(o),a))});const r=h.quantile(e.reduce((t,i,o)=>(n[o]&&t.push(e[o]/n[o]),t),[]),.9);o.geometry.coordinates=i.geometry.coordinates.filter((t,i)=>{const o=n[i];return 0===o||e[i]/o>=r})}return e.push(o),e},[])}(n.extentBounds.features,r),!n.extentBounds.features.length&&s.length&&function(e,t,n,i){const o=[[void 0,void 0],[void 0,void 0]];n.forEach((t,n)=>{const i=e.schema.projection(e.schema.point(t,n));(void 0===o[0][0]||i[0]<o[0][0])&&(o[0][0]=i[0]),(void 0===o[1][0]||i[0]>o[1][0])&&(o[1][0]=i[0]),(void 0===o[0][1]||i[1]<o[0][1])&&(o[0][1]=i[1]),(void 0===o[1][1]||i[1]>o[1][1])&&(o[1][1]=i[1])}),t.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:o.map(t=>e.schema.projection.invert(t))}}]};const a=h.max(n,(t,n)=>i(e.schema.pointSize(t,n)));t.effectivePadding={top:e.schema.projectionPadding.top+a,right:e.schema.projectionPadding.right+a,bottom:e.schema.projectionPadding.bottom+a,left:e.schema.projectionPadding.left+a}}(t,n,s,u)}const d=n.effectivePadding||t.schema.projectionPadding;return t.schema.projection=t.schema.projection.fitExtent(n.extentBounds.features.length?[[d.left,d.top],[i-d.right,o-d.bottom]]:[[0,0],[i,o]],n.extentBounds.features.length?n.extentBounds:{type:"Sphere"}),n.geomapWidth=i,n.geomapHeight=o,n.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:s,pointR:(e,n)=>u(t.schema.pointSize(e,n)),pointSort:(e,n)=>t.schema.pointSize(n)-t.schema.pointSize(e),pointX:(e,n)=>t.schema.projection(t.schema.point(e,n))[0],pointY:(e,n)=>t.schema.projection(t.schema.point(e,n))[1]},{shapeData:l}},FS={geoAlbers:S.geoAlbers,geoAlbersUsa:R.geoAlbersUsa??S.geoAlbersUsa,...R.geoAlbersUsaTerritories&&{geoAlbersUsaTerritories:R.geoAlbersUsaTerritories},geoAzimuthalEqualArea:S.geoAzimuthalEqualArea,geoAzimuthalEquidistant:S.geoAzimuthalEquidistant,geoConicConformal:S.geoConicConformal,geoConicEqualArea:S.geoConicEqualArea,geoConicEquidistant:S.geoConicEquidistant,geoEqualEarth:S.geoEqualEarth,geoEquirectangular:S.geoEquirectangular,geoGnomonic:S.geoGnomonic,geoMercator:S.geoMercator,geoMiller:M.geoMiller,geoNaturalEarth1:S.geoNaturalEarth1,geoOrthographic:S.geoOrthographic,geoRobinson:M.geoRobinson,geoStereographic:S.geoStereographic,geoTransverseMercator:S.geoTransverseMercator,geoWinkel3:M.geoWinkel3};function BS(e){const{width:t,height:n}=ie(e);return[[0,0],[t,n]]}function LS(e){return SS(e.schema.tileUrl,Boolean(e._basemapDark))}function PS(e){const t=!!e.schema.tiles&&function(e){const t=kS.find(t=>t.matches.some(t=>e.includes(t)));return!!t&&t.text}(LS(e)),n=e.schema.attribution;n&&n!==e._tileAttribution||(e.schema.attribution=t||""),e._tileAttribution=t}function RS(e){const t=e._draw.bind(e);e._draw=function(n){e._basemapDark=MS(e),CS(e)&&function(e){if(e._themeWatch||e._ssr||"undefined"==typeof window)return;const t=()=>{const t=e._select?.node();t&&t.isConnected&&CS(e)&&MS(e)!==e._basemapDark&&e.render?.()},n="function"==typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):null;n?.addEventListener?.("change",t);const i="function"==typeof MutationObserver?new MutationObserver(t):null;for(const e of[document.documentElement,document.body])e&&i?.observe(e,{attributes:!0});e._themeWatch=!0}(e),PS(e);const i=t(n),{width:o,height:a}=ie(e);return tr(e,{kind:"geomap",width:o,height:a,duration:e.schema.duration,ocean:e._facetStep?"transparent":SS(e.schema.ocean,Boolean(e._basemapDark))}),e._zoomSet=!0,i}}function ES(e){!function(e){const t=e;t.fitFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.fitFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.fitFilter=e=>t.includes(e.id),this}return this.schema.fitFilter},t.fitKey=function(e){return arguments.length?(this.schema.fitKey=e,this._zoomSet=!1,this):this.schema.fitKey},t.fitObject=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},t.point=function(e){return arguments.length?(this.schema.point="function"==typeof e?e:N(e),this):this.schema.point},t.pointSize=function(e){return arguments.length?(this.schema.pointSize="function"==typeof e?e:N(e),this):this.schema.pointSize}}(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?(n=e,Object.hasOwn(FS,n)?FS[n]():(pe(`Geomap received unknown projection "${n}"; using geoMercator. Pass the projection itself to use one not built in, e.g. .projection(${n}()).`),S.geoMercator())):e,this):this.schema.projection;var n},t.projectionPadding=function(e){return arguments.length?(this.schema.projectionPadding=n.parseSides(e),this):this.schema.projectionPadding},t.projectionRotate=function(e){return arguments.length?(this.schema.projection.rotate(e),t.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}(e),function(e){const t=e;t.tiles=function(e){return arguments.length?(this.schema.tiles=e,PS(this),this):this.schema.tiles},t.tileUrl=function(e){return arguments.length?(this.schema.tileUrl=e,PS(this),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:N(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:T(e),this):this.schema.topojsonId}}(e)}const NS={name:"Geomap",layoutStage:DS,sizeLegendScale:e=>{const t=AS(e);return t.length?zS(e,t):null},emit:({viz:e})=>{const t=e.ctx.geomapCtx;if(!t)return[];const n=function(e){const t=[],n="panel"===e._facetStep;if(e._ssr||n){const n=SS(e.schema.ocean,Boolean(e._basemapDark));if(n&&"transparent"!==n){const{width:i,height:o}=ie(e);t.push({type:"rect",key:"geomap-ocean",x:0,y:0,width:i,height:o,paint:{fill:n}})}}const i=e._ssrTiles;if((i&&i.size||n&&!e._ssr)&&"function"==typeof e._computeTileList)for(const n of e._computeTileList()){const e=i&&i.size?i.get(n.key):n.url;e&&t.push({type:"image",key:`geomap-tile-${n.key}`,x:n.x,y:n.y,width:n.size,height:n.size,href:e,preserveAspectRatio:"none",interactive:!1})}return t}(e);if(t.topoData&&t.topoData.length){const i=au(e,"Path"),o=e.schema.colorScale,a=n.length;for(let a=0;a<t.topoData.length;a++){const r=t.topoData[a],s=r.data??r,c=iu(i,s,a),l=o?`, ${o(s,a)}`:"";n.push({type:"path",key:`geomap-path-${r.id}`,d:t.pathFn(r),datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${e._drawLabel(s,a)}${l}.`}})}n.push(...qy(i,n.slice(a),e=>{const n=t.topoData[e];return[n.data??n,e]}))}if(t.pointData&&t.pointData.length){const i=au(e,"Circle"),o=t.pointSort?[...t.pointData].sort(t.pointSort):t.pointData,a=n.length;for(let a=0;a<o.length;a++){const r=o[a],s=iu(i,r,a);n.push({type:"circle",key:`geomap-point-${e._id(r,a)}`,cx:0,cy:0,r:t.pointR(r,a),transform:{x:t.pointX(r,a),y:t.pointY(r,a)},datum:r,paint:{...s,vectorEffect:s.vectorEffect??"non-scaling-stroke"},aria:{label:`${e._drawLabel(r,a)}, ${e.schema.pointSize(r,a)}.`},...i.trail?{trail:!0}:{},...i.trailPersist?{trailPersist:i.trailPersist}:{}})}n.push(...qy(i,n.slice(a),e=>[o[e],e]))}return n},insetRegion:Uu,colorScaleShape:(e,t,n)=>e.schema.point(t,n)instanceof Array?e.schema.shape(t,n):"Path",chartClip:ae,setup:e=>{const t=e;e._zoomSet=!1,e.schema.tiles=!0,e._tileGen=w.tile(),function(e){e._renderTiles=function(e=fc(this),t=0){if(this._ssr)return;if(this._facetPanels||this._facetStep)return void this._tileGroup?.selectAll("image.d3plus-geomap-tile").remove();let n=[];this.schema.tiles&&(n=this._tileGen.extent(BS(this)).scale(this.schema.projection.scale()*(2*Math.PI)*e.k).translate(e.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(t).attr("transform",e));const i=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(n,([e,t,n])=>`${e}-${t}-${n}`);i.exit().transition().duration(t).attr("opacity",0).remove();const o=n.scale/e.k,a=i.enter().append("image").attr("class","d3plus-geomap-tile");a.attr("opacity",0).transition().duration(t).attr("opacity",1),i.interrupt(),i.merge(a).attr("width",o).attr("height",o).attr("xlink:href",([e,t,n])=>LS(this).replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${n}`).replace("{x}",`${e}`).replace("{y}",`${t}`)).attr("x",([t])=>t*o+n.translate[0]*o-e.x/e.k).attr("y",([,t])=>t*o+n.translate[1]*o-e.y/e.k)},e._computeTileList=function(){if(!this.schema.tiles)return[];const e=this._tileGen.extent(BS(this)).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),t=e.scale;return e.map(([n,i,o])=>({key:`${n}-${i}-${o}`,url:LS(this).replace("{s}","a").replace("{z}",`${o}`).replace("{x}",`${n}`).replace("{y}",`${i}`),x:n*t+e.translate[0]*t,y:i*t+e.translate[1]*t,size:t}))}}(e),RS(e),ES(e),t.tileUrl(vS),e.schema.topojsonFill=()=>e._basemapDark?"#3d3e44":"#f5f5f3"},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:{light:"#d0cfd4",dark:"#222327"}},{key:"point",default:T("point")},{key:"pointSize",default:N(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:S.geoMercator()},{key:"projectionPadding",default:n.parseSides(20)},{key:"shape",default:N("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:N("#f5f5f3")},{key:"topojsonFilter",default:e=>!["010"].includes(e.id)},{key:"topojsonId",default:T("id")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>`${e._drawLabel(t,n)}, ${e.schema.pointSize(t,n)}`,hoverOpacity:1,Path:{ariaLabel:(t,n)=>{const i=e.schema.colorScale,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},fill:(t,n)=>{const i=e.ctx.coordData?.features??[],o=e.schema.colorScale;if(o&&!i.includes(t)){const n=o(t);if(null!=n){if(e._colorScaleClass._colorScale)return e._colorScaleClass._colorScale(n);let t=e._colorScaleClass.color();return t instanceof Array&&(t=t[t.length-1]),t}}return e.schema.topojsonFill(t,n)},on:{mouseenter:(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseenter.bind(e)(t,n,i,o),"mousemove.shape":(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on["mousemove.shape"].bind(e)(t,n,i,o),mouseleave:(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseleave.bind(e)(t,n,i,o)},stroke:(t,n)=>{const i=e.schema.shapeConfig.Path,o="function"==typeof i.fill?i.fill(t,n):i.fill,a=l.color(o);return a?a.darker().toString():o},strokeWidth:1},Circle:{trail:!0}})}]};var TS=xf(NS);const OS=new WeakMap;function WS(e){const t=T(e);return OS.set(t,e),t}function jS(e){return"function"==typeof e?OS.get(e)??Le(e):void 0}function HS(e,t,n){!e||void 0!==e.title&&e.title!==t||(e.title=n)}function IS(e,t){let[n,i]=t.domain??h.extent(e),o=Boolean(t.domain);if(n===i&&([n,i]=[n-.5,i+.5],o=!0),t.width&&t.width>0)return function(e,t,n){const i=Math.floor(e/n)*n,o=Math.max(Math.ceil(t/n)*n,i+n);return h.range(0,Math.round((o-i)/n)+1).map(e=>i+e*n)}(n,i,t.width);let a=h.bin();o&&(a=a.domain([n,i]));const r=t.thresholds??h.thresholdSturges,s=a.thresholds(r)(e);return[s[0].x0,...s.map(e=>e.x1)]}function GS(e,t){const{value:n,panel:i=()=>""}=t,o=e.map((e,t)=>({d:e,i:t,v:Number(n(e,t))})).filter(e=>e.d&&Number.isFinite(e.v));if(!o.length)return[];const a=t.sharedEdges?IS(o.map(e=>e.v),t):void 0;return h.groups(o,e=>i(e.d,e.i)).flatMap(([,e])=>function(e,t,n){const{group:i=()=>"",normalize:o="count"}=n,a=h.bin().domain([t[0],t[t.length-1]]).thresholds(t.slice(1,-1)),r=e.length,s=[];for(const[,t]of h.groups(e,e=>i(e.d,e.i))){const e=a(t.map(e=>e.v)),n=t[0].d;e.forEach(e=>{const t=e.x0,i=e.x1,a=e.length,c="density"===o?a/(r*(i-t)):"relative"===o?a/r:a;s.push({...n,x0:t,x1:i,x:(t+i)/2,count:a,y:c})})}return s}(e,a??IS(e.map(e=>e.v),t),t))}const VS={count:"Count",density:"Density",relative:"Relative Frequency"};function qS(e){for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}const YS=e=>Array.isArray(e.x);function KS(e){const t=e.ctx.histogram;e._data!==t.bins&&(t.raw=e._data),e._sourceData=t.raw;const n=function(e,t){if(e.schema.timeFilter)return e.schema.timeFilter;const n=e._data;e._data=t;try{return Hh(e)}finally{e._data=n}}(e,t.raw),i=e.schema.filter,o=n?t.raw.filter(n):t.raw,a=i?o.filter(i):o,r=Ie(e)?e.schema.facet:void 0,s=e.schema.groupBy,c=jS(e.schema.value),l=GS(a,{value:e.schema.value,group:(e,t)=>s.map(n=>`${n(e,t)}`).join("_"),panel:r?(e,t)=>Gh(Vh(r(e,t))):void 0,sharedEdges:"independent"!==Ne(e.schema.facetConfig).scales,thresholds:e.schema.binThresholds,domain:e.schema.binDomain,width:e.schema.binWidth,normalize:e.schema.binNormalize}),h=l.every((e,t)=>s.every(n=>void 0===n(e,t)));l.forEach(t=>{c&&delete t[c],h&&(t.id=c??e.schema.translate("Value"))});const u=n?t.raw.filter((e,t)=>!n(e,t)):[];t.bins=e._data=u.length?[...l,...u]:l,t.binned=new Set(l);const d=e.schema.translate(VS[e.schema.binNormalize]??VS.count);HS(e._yConfig,t.yTitle,d),t.yTitle=d,HS(e._xConfig,t.xTitle,c),t.xTitle=c}const US={name:"Histogram",paintDriven:!0,thresholdFunction:(e,t)=>t,defaults:{groupPadding:1},setup:e=>{const t={raw:[],bins:[],binned:new Set};e.ctx.histogram=t,e._filterApplied=e=>t.binned.has(e),e.stackOrder("key"),e.schema.shapeConfig.Bar={...e.schema.shapeConfig.Bar,label:!1},e._discreteExtent=e=>[e.x0,e.x1];const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(t,i,o,a)=>{if(n(t,i,o,a),1===e.schema.shapeConfig.hoverOpacity)return;const r=qS(t),s=`${e._id(r,i)}`;e.hover((t,n)=>{const i=qS(t);return`${e._id(i,n)}`===s&&(YS(i)||i.x0===r.x0)})};const i=e._preDraw.bind(e);e._preDraw=()=>{KS(e),i()}},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"binThresholds"},{key:"binDomain"},{key:"binWidth"},{key:"binNormalize",default:"count"},{key:"discrete",default:"x"},{key:"shape",default:N("Bar"),coerce:"const"},{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:e=>{const t=t=>d.formatAbbreviate(t,e.schema.locale),n=e=>{const n=qS(e);return`${t(n.x0)} – ${t(n.x1)}`},i=(t,n)=>e.schema.groupBy.some(e=>void 0!==e(qS(t),n));return{title:(t,o)=>i(t,o)?e._drawLabel(qS(t),o):n(t),tbody:(o,a)=>{const r=qS(o),s=[];if(YS(r))return[[e.schema.translate(VS.count),t(r.count)]];i(o,a)&&s.push([e.schema.translate("Range"),n(o)]),s.push([e.schema.translate(VS.count),t(r.count)]);const c=e.schema.binNormalize;return"count"!==c&&s.push([e.schema.translate(VS[c]),t(r.y)]),s}}}},{key:"value",default:WS("value"),coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:N(e)}]};var XS=xf(US,_b);function QS(e,t){const{aggs:n,drawDepth:i,groupBy:a,label:r,threshold:s,thresholdKey:c}=t,l=h.sum(e,c);if(!s||!c)return e;return function e(t,u){if(u<i)return[...h.group(t,a[u])].reduce((t,[,n])=>{const i=e(n,u+1)??[];return t.concat(i)},[]);if(u===i){const e=Math.min(1,Math.max(0,s(t)));if(!isFinite(e)||isNaN(e))return null;const i=[],h=[],d=e*l;for(let e=0;e<t.length;e++){const n=t[e];c(n)<d?i.push(n):h.push(n)}if(i.length<2)return t;const f=o.merge(i,n);return f._isAggregation=!0,f._threshold=e,f[zr]=Dr(i,(e,t)=>t,r??(e=>a[u](e)),c),h.push(f),h}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}function ZS(e,t,n={}){const{level:i=0,path:o=[],index:a=()=>0}=n;if(!t.length)return{children:[],own:e};const[r,...s]=t,c=[],l=new Map;for(const t of e){const e=r(t,a(t));if(null==e){c.push(t);continue}const n=l.get(e);n?n.push(t):l.set(e,[t])}return{children:[...l].map(([e,t])=>{const n=[...o,e];if(!s.length)return{key:e,path:n,level:i,rows:t,own:t};const r=ZS(t,s,{level:i+1,path:n,index:a});return{key:e,path:n,level:i,rows:t,own:r.own,children:r.children.length?r.children:void 0}}),own:c}}function JS(e){const{children:t,rows:n}=e.data;return!t&&1===n.length&&!0===n[0]._isAggregation}function eC(e){return(t,n)=>{const i=JS(t),o=JS(n);return i&&!o?1:!i&&o?-1:e(t,n)}}function tC(e){if(!(_r in e))return e;const t={...e};return t.share===t[_r]&&delete t.share,delete t[_r],t}function nC(e,t){const n=o.merge(e.map(tC),t);return delete n._isAggregation,delete n._threshold,delete n[zr],n}function iC(e,t){const{data:n,keys:i,firstLevel:o,focusPath:a,sum:r,sort:s,aggs:c}=e;if(!n.length)return[];const l=e=>n.indexOf(e),h=ZS(n,i,{level:o,path:a,index:l}),u={key:a[a.length-1],path:a,level:o-1,rows:n,own:h.own,children:h.children};let d=A.hierarchy(u,e=>e.children).sum(e=>e.own.reduce((e,t)=>e+(Number(r(t))||0),0));s&&(d=d.sort(s));const f=A.partition().size([e.breadth??1,i.length+1])(d),m=f.value??0,p=[],g=new Map;for(const e of f.descendants()){if(0===e.depth&&!a.length)continue;const n=e.value??0;if(!(n>0)||e.x1-e.x0<=0)continue;const i=e.data,o=!i.children&&1===i.rows.length,r=o?i.rows[0]:nC(i.rows,c),s=e.parent?e.parent.value??0:n,h={id:JSON.stringify(i.path),path:i.path,level:i.level,depth:e.depth,datum:r,i:o?l(r):void 0,value:n,share:m?n/m:0,parentShare:s?n/s:0,x0:e.x0,x1:e.x1,hasChildren:Boolean(e.children&&e.children.length)},u={...h,...t(h),parent:e.parent?g.get(e.parent.data):void 0};g.set(i,u),p.push(u)}return p}function oC(e){const t=[];for(let n=e;n;n=n.parent)t.push(n);return t}function aC(e){const t=e._history?.[e._history.length-1],n=e._filteredData??[],i=e.schema.groupBy;if(!t||void 0===t.groupDepth||!n.length)return{level:-1,path:[]};const o=Math.min(t.groupDepth,e._drawDepth-1);if(o<0)return{level:-1,path:[]};return{level:o,path:i.slice(0,o+1).map(e=>e(n[0],0))}}function rC(e,t,n){const i=e.ctx[t];if(i&&i.data===e._filteredData)return i.base;const o=n();return e.ctx[t]={data:e._filteredData,base:o},o}function sC(e,t){const n=new Set(t.map(e=>e.id));return e.filter(e=>!n.has(e.id))}function cC(e,t){const n=e.find(e=>0===e.depth);if(!n)return;return t.filter(e=>e.depth>0&&(e=>e.path.length<=n.path.length&&e.path.every((e,t)=>e===n.path[t]))(e)).sort((e,t)=>t.path.length-e.path.length)[0]}function lC(e,t,n){const i=new Map,o=cC(e,t);if(!o)return i;const a=new Set(e.map(e=>e.id));for(const e of t)a.has(e.id)||i.set(e.id,n(e,o));return i}function hC(e,t){if(0===t.depth||t.datum._isAggregation)return!1;const n=e.schema.groupBy.length-1;return t.hasChildren||t.level===e._drawDepth&&t.level<n}function uC(e,t){return 0===t.depth?Boolean(e._history?.length):hC(e,t)}function dC(e){e.hover(!1),e._tooltipClass?.data([]).render()}function fC(e,t){return`${d.formatAbbreviate(100*t,e.schema.locale)}%`}function mC(e,t,n){const i=e._tooltipClass,o=e.schema.tooltipConfig;if(void 0===o.title){const n=e._drawLabel(t.datum,t.i??0,t.level);Ur(i.title(()=>n),Kr(e,e._lastScenePick))}if(void 0===o.footer){const n=!!uC(e,t)&&e.schema.translate(hC(e,t)?"Click to Expand":"Click to Zoom Out");i.footer(n)}const a=function(e,t){if(t&&t.parent&&0!==t.parent.depth)return[e.schema.translate("Share of Parent"),fC(e,t.parentShare)]}(e,t);a&&function(e,t){if(!Array.isArray(e)||1!==e.length||!Array.isArray(e[0]))return!1;const n=e[0];return n.length===t.length&&n.every((e,n)=>e===t[n])}(o.tbody,n)&&i.tbody([...o.tbody,a]),(void 0===o.title||void 0===o.footer||a)&&i.render()}function pC(e,t,n){const{prefix:i}=n,o=e.schema.on,a=o.mouseenter,r=o["mousemove.shape"],s=t=>function(e,t,n){let i=t;for(;i&&i.__d3plus__&&i.data;)i=i.data;const o=e.ctx[`${n}Nodes`];return i&&o?o.get(i):void 0}(e,t,i),c=t=>{if(e.ctx[`${i}Hovered`]=t,1===e.schema.shapeConfig.hoverOpacity)return;const n=function(e){return new Set(oC(e).map(e=>e.datum))}(t);var o;o=e=>n.has(e),e.hover(o)};return{mouseenter:(t,n,i,o)=>{const r=s(t);r?c(r):a.call(e,t,n,i,o)},"mousemove.shape":(n,o,a,l)=>{r.call(e,n,o,a,l);const h=s(n);if(!h)return;e.ctx[`${i}Hovered`]!==h&&c(h);const u=Boolean(e.schema.on.click);e._select?.style("cursor",u||uC(e,h)?"pointer":"auto"),e._tooltipClass&&e.schema.tooltip(n,o)&&mC(e,h,t)},"click.shape":(t,i,o,a)=>{a?.stopPropagation?.();const r=s(t);r&&(0===r.depth?function(e){const t=e._history?.pop();if(!t)return;dC(e);const n={depth:t.depth,filter:t.filter};e.config(n).render()}(e):hC(e,r)&&function(e,t,n){var i;const o=e.schema.groupBy,a=aC(e),r=e.schema.filter,s=o.slice(0,t.level+1),c=t.path;dC(e);const l={depth:e.schema.depth,filter:r,groupId:c[t.level],groupDepth:t.level};((i=e)._history??(i._history=[])).push(l),e.ctx[`${n.prefix}ZoomOrigin`]=n.origin(t);const h={filter:(e,t)=>(!r||r(e,t))&&s.every((n,i)=>n(e,t)===c[i])};if(void 0!==e.schema.depth){const n=t.level-a.level;h.depth=Math.min(o.length-1,e._drawDepth+n)}e.config(h).render()}(e,r,n))}}}function gC(e,t){return QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)})}const yC=(e,t)=>(t.value??0)-(e.value??0);function xC(e,t){return eC(t)}function bC(e){return"function"==typeof e?e:Be(e)}function _C(e,t){e.schema.thresholdKey=t}function kC(e){const t=e.schema.sum;return(e,n)=>t(n)-t(e)}function vC(e,t){const{prefix:n}=t;e.ctx[`${n}DefaultColor`]=e.schema.color,e.ctx[`${n}DefaultFill`]=e.schema.shapeConfig.fill,Object.assign(e.schema.on,pC(e,(e.schema.tooltipConfig.tbody??[])[0]??[],t))}const wC={step:.22,max:.6};function SC(e,t={}){const{step:n,max:i}={...wC,...t};return e<=0?0:Math.max(0,Math.min(i,n*e))}function CC(e,t,n,i){const o=function(e,t,n="Path"){const i=e.shapeConfig??{},o=i[n]??{};return!1!==e.shade&&!e.colorScale&&!e.colorOrdinal&&e.color===t.color&&i.fill===t.fill&&void 0===o.fill}(e,n,i),a=e.shadeConfig??{};return e=>{const n=tu(t.fill,e.datum,e.i??0);if("string"==typeof n)return o?function(e,t){return e&&t>0&&l.color(e)?r.colorLighter(e,t):e}(n,SC(e.level,a)):n}}function MC(e){const{width:t,height:n,orient:i}=e,o=Math.max(0,t),a=Math.max(0,n);return"vertical"===i?{depth:a,breadth:o}:{depth:o,breadth:a}}function $C(e,t,n){const i=Math.max(0,e),o=Math.max(0,t)+(n?1:0);if(o<1)return[[0,0]];const a=i/o,r=n?[]:[[0,0]];for(let e=0;e<o;e++)r.push([e*a,(e+1)*a]);return r}function AC(e,t,n){const{breadth:i}=MC(n),o=e.x0*i,a=e.x1*i,[r,s]=t;return"vertical"===n.orient?{x:o,y:r,width:a-o,height:s-r}:{x:r,y:o,width:s-r,height:a-o}}function zC(e,t,n,i,o){const a=n.x1-n.x0||1,r=e=>Math.min(1,Math.max(0,(e-n.x0)/a)),s=t-n.depth,c=i[i.length-1]?.[1]??0,l=s<0?[0,0]:i[s]??[c,c];return AC({x0:r(e.x0),x1:r(e.x1)},l,o)}function DC(e,t){return"vertical"===t?{x:e.x+e.width/2,y:e.y,width:0,height:0}:{x:e.x,y:e.y+e.height/2,width:0,height:0}}function FC(e,t,n){const o=new Map;for(const n of e){if(!t.has(n.id))continue;const e=n.parent;o.set(n.id,e?(o.get(e.id)??-1)+1:0)}const a=Math.max(0,...o.values())+1,r=new Map,s=new Map;for(const t of e){const e=o.get(t.id);void 0!==e&&(r.set(t.id,DC(t,n)),s.set(t.id,{start:i.cubicInOut(e/a),end:i.cubicInOut((e+1)/a)}))}return{rects:r,windows:s}}function BC(e){const{bands:t,frame:n,...i}=e;return iC({...i,breadth:1},e=>AC(e,t[e.depth]??[0,0],n))}function LC(e){return"vertical"===e?"vertical":"horizontal"}const PC=({viz:e})=>{const{width:t,height:n}=ie(e),i={width:Math.max(0,t),height:Math.max(0,n),orient:LC(e.schema.orient)};e.ctx.icicleWidth=i.width,e.ctx.icicleHeight=i.height,e.ctx.icicleNodes=new Map,e.ctx.icicleGhosts=[];const o=function(e){return rC(e,"iciclePass",()=>{const t={laid:e.ctx.icicleLaid,bands:e.ctx.icicleBands,frame:e.ctx.icicleFrame,origin:e.ctx.icicleZoomOrigin};return e.ctx.icicleZoomOrigin=void 0,t})}(e),a=e._filteredData??[];if(!a.length)return e.ctx.icicleLaid=[],e.ctx.icicleBands=void 0,e.ctx.icicleFrame=i,e.ctx.icicleEnterRects=new Map,e.ctx.icicleEnterWindows=new Map,{shapeData:[]};const r=aC(e),s=e.schema.groupBy.slice(r.level+1,e._drawDepth+1),c=$C(MC(i).depth,s.length,r.path.length>0),l=BC({data:a,keys:s,firstLevel:r.level+1,focusPath:r.path,sum:e.schema.sum,sort:e.schema.sort,aggs:e.schema.aggs,bands:c,frame:i}),{laid:h,bands:u,origin:d}=o;e.ctx.icicleGhosts=d&&h?function(e,t,n,i,o){return sC(e,t).map(e=>({id:e.id,datum:e.datum,i:e.i,level:e.level,rect:zC(e,e.depth,n,i,o)}))}(h,l,d,c,i):[];const f=h&&u&&o.frame?function(e,t,n,i){return lC(e,t,(e,t)=>zC(e,e.depth,{x0:t.x0,x1:t.x1,depth:t.depth},n,i))}(h,l,u,o.frame):new Map,m=Boolean(d)||Boolean(h&&cC(h,l)),p=new Set((h??[]).map(e=>e.id)),g=m?{rects:f,windows:new Map}:FC(l,new Set(l.filter(e=>!p.has(e.id)).map(e=>e.id)),i.orient);e.ctx.icicleEnterRects=g.rects,e.ctx.icicleEnterWindows=g.windows,e.ctx.icicleLaid=l,e.ctx.icicleBands=c,e.ctx.icicleFrame=i;const y=e.ctx.icicleNodes;for(const e of l)wr(e.datum,e.share),y.set(e.datum,e);return{shapeData:l}},RC=1e-6;function EC(e={}){return{fontMin:8,fontMax:24,padding:2,lineHeight:1.2,maxLines:3,...e}}function NC(e){const t=[];let n=!1;for(const i of a.textSplit(e))n?t[t.length-1]+=i.replace("",""):t.push(i.replace("","")),n=i.endsWith("");return t}function TC(e,t){const n=NC(e).map(e=>e.trim()).filter(Boolean);if(!n.length)return{words:[],space:0};const[i,...o]=t([" ",...n]);return{words:o,space:i}}function OC(e,t,n){return("function"==typeof e?e(t,0):e)??n}function WC(e,t,i){const o={"font-family":n.fontExists(OC(i.fontFamily,t,a.fontFamily)),"font-size":100,"font-weight":OC(i.fontWeight,t,400)};return TC(e,e=>n.textWidth(e,o).map(e=>e/100))}function jC(e,t,n){let i=1,o=0;for(const a of e.words){const r=a*t;if(r>n+RC)return 1/0;const s=o?o+e.space*t+r:r;s>n+RC?(i++,o=r):o=s}return i}function HC(e,t,n){if(!e(t))return null;let i=t,o=Math.max(t,n);for(;i<o;){const t=Math.ceil((i+o)/2);e(t)?i=t:o=t-1}return i}function IC(e,t,n={}){const{width:i,height:o}=e;if(!(t.words.length&&i>0&&o>0))return null;const a=EC(n),r=(e,n)=>HC(i=>function(e,t,n,i,o={}){const{padding:a,lineHeight:r,maxLines:s}=EC(o),c=n-2*a;if(c<=0)return!1;for(let n=1;n<=s;n++){if(n*r*t+2*a>i)return!1;if(jC(e,t,c)<=n)return!0}return!1}(t,i,e,n,a),a.fontMin,a.fontMax),s=r(i,o),c=o>i?r(o,i):null,l=e.x+i/2,h=e.y+o/2;return null!==s&&(null===c||s>=c)?{orientation:"upright",x:l,y:h,width:i,height:o,rotate:0,fontSize:s}:null===c?null:{orientation:"rotated",x:l,y:h,width:o,height:i,rotate:-90,fontSize:c}}function GC(e,t){return e._drawLabel(t.datum,t.i??0,t.level)}function VC(e,t){return(e.ctx.icicleGhosts??[]).map(e=>({type:"rect",key:`icicle-${e.id}`,...e.rect,paint:{fill:t(e),opacity:1}}))}const qC={out:.06,in:.06};function YC(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}const KC={prefix:"icicle",origin:function(e){return{x0:e.x0,x1:e.x1,depth:e.depth}}},UC={name:"Icicle",layoutStage:PC,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=au(e,"Rect"),o=e.schema.sum,a=e.schema.locale,s=function(e,t){return CC(e.schema,t,{color:e.ctx.icicleDefaultColor,fill:e.ctx.icicleDefaultFill},"Rect")}(e,i),c=e.ctx.icicleEnterRects??new Map,l=e.ctx.icicleEnterWindows??new Map,h=n.map(t=>{const n=t.i??0;return{type:"rect",key:`icicle-${t.id}`,x:t.x,y:t.y,width:t.width,height:t.height,enterRect:c.get(t.id),enterWindow:l.get(t.id),datum:t.datum,paint:{fill:nu(i,t.datum,n,s(t)),stroke:tu(i.stroke,t.datum,n),strokeWidth:tu(i.strokeWidth,t.datum,n),opacity:tu(i.opacity,t.datum,n)??1},aria:{label:`${GC(e,t)}, ${o(t.datum)}, ${d.formatAbbreviate(100*t.share,a)}%`}}}),u=qy(i,h,e=>[n[e].datum,n[e].i??0]),f=ru(e,"Rect")??{},m="number"==typeof f.fontMin?f.fontMin:8,p="number"==typeof f.fontMax?f.fontMax:24,g=function(e,t,n,i){const o=new Map;for(const a of t){const t=IC(a,WC(GC(e,a),a.datum,n),i);t&&o.set(a,t)}return o}(e,n,f,{fontMin:m,fontMax:p}),y=n.filter(e=>g.has(e)),x=e=>g.get(e),b=e.ctx.icicleNodes,_=iw({data:y,label:t=>GC(e,t),x:e=>x(e).x,y:e=>x(e).y,rotate:e=>x(e).rotate,aes:()=>({}),id:e=>`icicle-${e.id}`,datum:e=>e.datum,labelBounds:e=>{const{width:t,height:n}=x(e);return{x:-t/2,y:-n/2,width:t,height:n}},labelConfig:{fontMax:p,fontMin:m,split:NC,fontResize:!0,padding:2,textAnchor:"middle",verticalAlign:"middle",fontColor:t=>{const n=b.get(YC(t)),i=n?s(n):void 0;return r.colorContrast(i??"rgb(255, 255, 255)",e.schema.colorDefaults)},...f}});for(const e of _)e.fadeSwap=qC;const k=new Map(n.map(e=>[e.datum,l.get(e.id)]));for(const e of[...u,..._])e.datum&&(e.enterWindow=k.get(YC(e.datum)));return[...VC(e,s),...h,...u,..._]},thresholdFunction:gC,setup:e=>vC(e,KC),ctx:{},fields:[{key:"orient",default:"horizontal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...wC})},{key:"sort",default:yC,decorate:xC},{key:"sum",default:T("value"),coerce:bC,onSet:_C},{key:"shapeConfig",merge:!0,factory:e=>({Rect:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:kC},{key:"legend",coerce:"const",factory:cw}]};var XC=xf(UC);const QC="::stem";function ZC(e,t,n){const i=(e.transform?.x??0)+e.x,o=(e.transform?.y??0)+e.y,a=i+e.width,r=o+e.height;if("x"===t){const t=i+e.width/2;return!f.finite(n)||Math.abs(o-n)<=Math.abs(r-n)?{x:t,y:o,x0:t,y0:r}:{x:t,y:r,x0:t,y0:o}}const s=o+e.height/2;return!f.finite(n)||Math.abs(a-n)<=Math.abs(i-n)?{x:a,y:s,x0:i,y0:s}:{x:i,y:s,x0:a,y0:s}}function JC(e){const t=[];for(const n of e)t.push({__d3plus__:!0,data:n,i:n.i,end:!1}),t.push({__d3plus__:!0,data:n,i:n.i,end:!0});return t}function eM(e,t){let n=0;for(const i of e){const e="function"==typeof t?t(i.data,i.i):t;f.finite(e)&&e>n&&(n=e)}return n}function tM(e){const t=this.schema.shapeConfig.Circle,n=eM(e.data,t?.r);return Bf.call(this,{...e,buffer:n+2})}function nM(e){const t=e.datum,n={...e,datum:t?.data??e.datum,shapeType:"Circle"};return delete n.interactionPoints,n}function iM(e,t,n){const{viz:i}=e,o=e=>n.get(e.data),a=eu("Line").renderMode("compute").config(e.shapeConfig).data(JC(t));i._wirePlotShapeEvents(a,"Circle",e.events);const r=au(i,"Line");return void 0===i.schema.shapeConfig.duration&&delete r.duration,a.config(r).config({curve:"linear",id:e=>`${e.data.id}${QC}`,label:!1,x:e=>e.end?o(e).x:o(e).x0,y:e=>e.end?o(e).y:o(e).y0}),su(a).map(nM)}function oM(e,t,n){const i=de({...e.shapeConfig,x:e=>n.get(e).x,y:e=>n.get(e).y});return ux.Circle({...e,shapeConfig:i,values:t},"Circle")}const aM=(e,t)=>{const n=ux.Bar(e),i=function(e,t){const{viz:n}=e,i="y"===n.schema.discrete?"y":"x",o="x"===i?"y":"x",a="x"===i?e.y:e.x,r=new Map;for(const e of t){if("rect"!==e.type||"Bar"!==e.shapeType||`${e.key}`.endsWith("::hit"))continue;const t=e.datum;if(!t||r.has(t))continue;const n=void 0!==t[`${o}2`],s=n?t[`${o}2`]:t[o];r.set(t,ZC(e,i,a(s,n?`${o}2`:void 0)))}return r}(e,n),o=e.values.filter(e=>i.has(e)),a=n.filter(e=>`${e.key}`.endsWith(pp));return[...iM(e,o,i),...a,...oM(e,o,i)]},rM=wb.fields.find(e=>"legend"===e.key),sM=e=>(t,n)=>{const i=e.schema.shapeConfig.fill;return"function"==typeof i?i(t,n):i},cM={name:"Lollipop",paintDriven:!0,setup:e=>{e._buffer={...e._buffer,Bar:tM},e._plotShapeEmitters={Bar:aM},e._plotCircleShapes=["Bar"],e._plotColumnHighlight=Lk(e)},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},rM,{key:"shape",default:N("Bar"),coerce:"const"},{key:"legendConfig",merge:!0,default:{shape:"Circle"}},{key:"shapeConfig",merge:!0,factory:e=>({Bar:{label:!1},Circle:{label:!1,trail:!1},Line:{label:!1,stroke:sM(e)}})}]};var lM=xf(cM,_b);function hM(e){const t=t=>{const n=t.map(t=>{const n=function(e){for(let t=0;t<e.length;t++){const n=(e[t].data||[]).find(t=>t.id===e.key);if(n)return n}}(t);return n&&n.data?e(n.data,n.i??0):`${t.key}`}),i=new Map;n.forEach((e,n)=>i.set(e,(i.get(e)??0)+function(e){let t=0;for(let n=0;n<e.length;n++)t+=Math.abs(+e[n][1]||0);return t}(t[n])));const o=Array.from(i.keys()).sort((e,t)=>i.get(t)-i.get(e)),a=new Map(o.map((e,t)=>[e,t]));return t.map((e,t)=>t).sort((e,t)=>a.get(n[e])-a.get(n[t])||e-t)};return t.__d3plusStackOrder=!0,t}function uM(e){return e._stackOffset===Ep("expand")}function dM(e,t){return`${d.formatAbbreviate(100*e,t)}%`}function fM(e){return e.schema.stacked&&uM(e)?{[bf(e)]:{rounding:"none",tickFormat:t=>dM(t,e.schema.locale)}}:{}}function mM(e){return"y"===bf(e)?{x:"all",y:"outer"}:{x:"outer",y:"all"}}function pM(e){return e.schema.stacked&&uM(e)?{[bf(e)]:!0}:{}}const gM={name:"Marimekko",paintDriven:!0,defaults:{groupPadding:1},facet:{axes:mM,fixedAxes:pM},setup:e=>{e._stackOffset=Ep("expand"),e._stackOrder=hM((t,n)=>e._ids(t,n).slice(0,e._drawDepth+1).join("_"));const t=e._preDraw.bind(e);e._preDraw=()=>{e._plotAxisDefaults=fM(e),t()}},ctx:{},fields:[{key:"barWidth",coerce:fm,factory:function(e){return mm((t,n)=>{const i="y"===e.schema.discrete?e._x:e._y;return i?i(t,n??0):void 0},"Bar Total")}},{key:"barWidthShare",default:!0},{key:"stacked",default:!0},{key:"tooltipShared",default:!1}]};var yM=xf(gM,Sb);function xM(e){const t=this._filteredData,n=(this.schema.rowList||o.unique(t.map(this.schema.row))).sort(this.schema.rowSort),i=(this.schema.columnList||o.unique(t.map(this.schema.column))).sort(this.schema.columnSort);if(!n.length||!i.length)return{rowValues:[],columnValues:[],shapeData:[]};var a,r;return{rowValues:n,columnValues:i,shapeData:(a=n,r=i,[].concat(...a.map(e=>r.map(t=>[e,t])))).map(([e,n])=>{const i={__d3plusTooltip__:!0,__d3plus__:!0,column:n,row:e},o=t.findIndex((t,i)=>this.schema.row(t,i)===e&&this.schema.column(t,i)===n);return o>=0?(i.i=o,i.data=t[o]):i.data={row:e,column:n},i})}}const bM=({viz:e})=>{const t=xM.bind(e)(e._filteredData),{rowValues:n,columnValues:i,shapeData:o}=t;if(!n.length||!i.length)return{shapeData:[]};const{width:a,height:r}=ie(e),s=a/i.length<120||void 0;e._padding={top:0,right:0,bottom:0,left:0};const c=e.ctx.rowAxis,l=e.ctx.columnAxis,h=e.schema.rowConfig,u=e.schema.columnConfig;c.domain(n).height(r-e._padding.bottom-e._padding.top).maxSize(a/4).width(a).config(h).measure();const d=c.outerBounds().width;e._padding.left+=d,l.domain(i).range([e._margin.left+e._padding.left,e._margin.left+a-e._padding.right]).height(r).maxSize(r/4).width(a).labelRotation(s).config(u).measure();const f=l.outerBounds().height;e._padding.top+=f,c.renderMode("compute").select(void 0).height(r-e._padding.bottom).maxSize(d).range([f+l.padding(),void 0]).render();const m=c.toScene();var p;m&&((p=e)._chartScene||(p._chartScene=[])).push({type:"group",key:"matrix-row-axis",transform:{x:e._margin.left,y:0},children:m.children??[]});l.renderMode("compute").select(void 0).range([e._margin.left+e._padding.left+c.padding(),e._margin.left+a-e._padding.right]).maxSize(f).render();const g=l.toScene();var y;g&&((y=e)._chartScene||(y._chartScene=[])).push({type:"group",key:"matrix-column-axis",transform:{x:0,y:0},children:g.children??[]});const x=c._getPosition.bind(c),b=l._getPosition.bind(l),_=n.length>1?x(n[1])-x(n[0]):c.height(),k=i.length>1?b(i[1])-b(i[0]):l.width();return e.ctx.columnScale=b,e.ctx.rowScale=x,e.ctx.cellWidth=k,e.ctx.cellHeight=_,{shapeData:o}},_M={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},kM=(e,t)=>`${e}`.localeCompare(`${t}`),vM={name:"Matrix",layoutStage:bM,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.columnScale,o=e.ctx.rowScale,a=e.ctx.cellWidth,r=e.ctx.cellHeight,s=e.schema.cellPadding??0,c=au(e,"Rect"),l=e.schema.colorScale,h=n.map((e,t)=>{const n=tu(c.fill,e,t),h=tu(c.stroke,e,t),u=tu(c.strokeWidth,e,t),d=a-s,f=r-s,m=i(e.column)+a/2-d/2,p=o(e.row)+r/2-f/2,g=l?`, ${l(e.data??e,t)}`:"";return{type:"rect",key:`matrix-${t}`,x:m,y:p,width:d,height:f,datum:e,paint:{fill:nu(c,e,t,n),stroke:h,strokeWidth:u},aria:{label:`${e.row}, ${e.column}${g}.`}}});return[...h,...qy(c,h,e=>[n[e],e])]},chartTransform:e=>({x:0,y:e._margin.top}),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),Ra(o)||Ra(n))return;const r=ze.bind(e)("row",n,i),s=ze.bind(e)("column",n,i),c=e.schema.colorScale;e.hover((t,n)=>!(ze.bind(e)("row",t,n)!==r&&ze.bind(e)("column",t,n)!==s||"function"==typeof c&&"number"!=typeof c(t,n)))}},facet:{aspect:1},ctx:{rowAxis:new hi,columnAxis:new hi},fields:[{key:"cellPadding",default:2},{key:"column",default:T("column"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"row",default:T("row"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:kM},{key:"rowSort",default:kM},{key:"rowConfig",merge:!0,default:{orient:"left",..._M}},{key:"columnConfig",merge:!0,default:{orient:"top",..._M}},{key:"label",coerce:"const",factory:e=>(t,n)=>`${ze.bind(e)("row",t,n)} / ${ze.bind(e)("column",t,n)}`}]};var wM=xf(vM);function SM(e){const t=e._filteredData.reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{});let n=e.schema.nodes.reduce((t,n,i)=>(t[((t,n)=>`${e._id(t,n)||e.schema.nodeGroupBy[h.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](t,n)}`)(n,i)]=n,t),{});const i=Array.from(new Set(Object.keys(t).concat(Object.keys(n)))).map((i,o)=>{const a=t[i],r=n[i];if(void 0===r)return!1;const s=(e,t=e=>void 0!==e)=>void 0!==a&&t(e(a))?e(a):e(r);return{__d3plus__:!0,data:a||r,i:o,id:i,fx:s(e._x,e=>!isNaN(e)),fy:s(e._y,e=>!isNaN(e)),node:r,r:e._size?s(e._size):e.schema.sizeMin,shape:s(e.schema.shape)}}).filter(e=>!!e);return n={},i}function CM(e,t){const n=t.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=n;const i=new Map;for(const e of t)i.set(e.node,e);const o=e.schema.links.map(t=>{const o=typeof t.source;return{size:e.schema.linkSize(t),source:"number"===o?i.get(e.schema.nodes[t.source]):"string"===o?n[t.source]:n[t.source.id],target:"number"===o?i.get(e.schema.nodes[t.target]):"string"===o?n[t.target]:n[t.target.id]}});return e.ctx.linkLookup=o.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{}),o}function MM(e,t,n){if(!t.some(e=>void 0===e.fx||void 0===e.fy))return;const i=`${t.map(e=>e.id).join("\0")}|${n.map(e=>`${e.source.id}>${e.target.id}:${e.size}`).join("\0")}`,o=e.ctx.networkForceCache;o&&o.key===i?t.forEach((e,t)=>{e.fx=o.positions[t][0],e.fy=o.positions[t][1]}):(!function(e,t){const n=B.scaleLinear().domain(h.extent(t,e=>e.size)).range([.1,.5]),i=z.forceSimulation().force("link",z.forceLink(t).id(e=>e.id).distance(1).strength(e=>n(e.size)).iterations(4)).force("charge",z.forceManyBody().strength(-1)).stop(),o=1-Math.pow(.001,.01);i.velocityDecay(0),i.alphaMin(.001),i.alphaDecay(o),i.alphaDecay(0),i.nodes(e),i.tick(100).stop();const a=e.map(e=>[e.vx??0,e.vy??0]);let r=0,s=0,c=0;if(2===a.length)r=100;else if(a.length>2){const e=D.polygonHull(a)||[],t=f.largestRect(e,{verbose:!0});r=t.angle,s=t.cx,c=t.cy}e.forEach(e=>{const t=f.pointRotate([e.vx??0,e.vy??0],Math.PI/180*r*-1,[s,c]);e.fx=t[0],e.fy=t[1]})}(t,n),e.ctx.networkForceCache={key:i,positions:t.map(e=>[e.fx,e.fy])})}function $M(e,t,n,i){const o=h.extent(t.map(e=>e.fx)),a=h.extent(t.map(e=>e.fy)),r=B.scaleLinear().domain(o).range([0,n]),s=B.scaleLinear().domain(a).range([0,i]),c=(o[1]-o[0])/(a[1]-a[0])||1,l=n/i;if(c>l){const e=i*l/c;s.range([(i-e)/2,i-(i-e)/2])}else{const e=n*c/l;r.range([(n-e)/2,n-(n-e)/2])}t.forEach(e=>{e.x=r(e.fx),e.y=s(e.fy)});const u=h.extent(t.map(e=>e.r));let d=e.schema.sizeMax||h.max([1,h.min(h.merge(t.map(e=>t.map(t=>e===t?null:f.pointDistance([e.x??0,e.y??0],[t.x??0,t.y??0])))))/2]);const m=B[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(u).range([u[0]===u[1]?d:h.min([d/2,e.schema.sizeMin]),d]),p=r.domain(),g=s.domain(),y=p[1]-p[0],x=g[1]-g[0];t.forEach(e=>{const t=m(e.r)+3,n=e.x??0,i=e.y??0;p[0]>r.invert(n-t)&&(p[0]=r.invert(n-t)),p[1]<r.invert(n+t)&&(p[1]=r.invert(n+t)),g[0]>s.invert(i-t)&&(g[0]=s.invert(i-t)),g[1]<s.invert(i+t)&&(g[1]=s.invert(i+t))});const b=p[1]-p[0],_=g[1]-g[0];d*=h.min([y/b,x/_]),m.range([u[0]===u[1]?d:h.min([d/2,e.schema.sizeMin]),d]),r.domain(p),s.domain(g);const k=(c>l?n:i)/2;return t.forEach(e=>{e.x=r(e.fx),e.fx=e.x,e.y=s(e.fy),e.fy=e.y,e.r=m(e.r)||k,e.width=2*e.r,e.height=2*e.r}),m}const AM=({viz:e})=>{const t=e,{width:n,height:i}=ie(t);Array.isArray(t._filteredData)||(t._filteredData=[]),Array.isArray(t.schema.nodes)||(t.schema.nodes=[]),Array.isArray(t.schema.links)||(t.schema.links=[]);const o=SM(t),a=CM(t,o);MM(t,o,a);const r=$M(t,o,n,i);t._sizeLegendFinal=t._size?r:null,function(e,t,n){const i=h.extent(t,e=>e.size);if(i[0]!==i[1]){const o=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(i).range([e.schema.linkSizeMin,n.range()[0]]);t.forEach(e=>{e.size=o(e.size)})}}(t,a,r);const s=au(t,"Path",t.schema.shapeConfig,"edge");delete s.on;const c={label:e=>!!(o.length<=t.schema.dataCutoff||t._hover&&t._hover(e)||t._active&&t._active(e))&&t._drawLabel(e.data||e.node,e.i)},l=Array.from(h.groups(o,e=>e.shape));return t.ctx.networkCtx={links:a,linkConfig:s,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:c},{shapeData:o}};function zM(e,t,n){const i="function"==typeof e?e(t,n):e;return!0===i||"target"===i?{source:!1,target:!0}:"source"===i?{source:!0,target:!1}:"both"===i?{source:!0,target:!0}:{source:!1,target:!1}}const DM=e=>Math.round(100*e)/100;function FM(e,t,n,i){const o=.6*i,a=e-Math.cos(n)*i,r=t-Math.sin(n)*i,s=Math.cos(n+Math.PI/2),c=Math.sin(n+Math.PI/2);return`M${DM(e)},${DM(t)}L${DM(a+s*o)},${DM(r+c*o)}L${DM(a-s*o)},${DM(r-c*o)}Z`}function BM(e,t,n,i,o,a=1){const r=Math.atan2(i-t,n-e);return{x:n-Math.cos(r)*(o+a),y:i-Math.sin(r)*(o+a),angle:r}}function LM(e,t,n,i){const o="function"==typeof e?e(t,n):e;return"number"==typeof o?o:Math.max(6,3*i)}function PM(e){const t=zM(e.arrows,e.datum,e.i);if(!t.source&&!t.target)return[];const n=LM(e.arrowSize,e.datum,e.i,"number"==typeof e.strokeWidth?e.strokeWidth:1),{source:i,target:o,datum:a,fill:r,keyPrefix:s}=e,c=[];if(t.target){const e=BM(i.x,i.y,o.x,o.y,o.r??0,1);c.push(RM({key:`${s}-t`,datum:a,x:e.x,y:e.y,angle:e.angle,size:n,fill:r}))}if(t.source){const e=BM(o.x,o.y,i.x,i.y,i.r??0,1);c.push(RM({key:`${s}-s`,datum:a,x:e.x,y:e.y,angle:e.angle,size:n,fill:r}))}return c}function RM(e){return{type:"path",key:e.key,d:FM(e.x,e.y,e.angle,e.size),datum:e.datum,interactive:!1,paint:{fill:e.fill,...void 0!==e.opacity?{opacity:e.opacity}:{}}}}function EM(e,t,n,i,o,a,r){return PM({arrows:e.schema.arrows,arrowSize:e.schema.arrowSize,strokeWidth:o,datum:n,i:a,keyPrefix:r,fill:"string"==typeof i?i:void 0,source:t.source,target:t.target})}function NM(e,t,n,i,o){const a=`network-${e}-${t.id}`;if("Circle"===e)return{type:"circle",key:a,cx:t.x,cy:t.y,r:t.r,...i};if("Rect"===e){const e=Number(t.width??tu(n.width,i.datum,o)??0),r=Number(t.height??tu(n.height,i.datum,o)??0);return{type:"rect",key:a,x:t.x-e/2,y:t.y-r/2,width:e,height:r,...i}}return null}function TM(e,t,n){return`${e._id(t,n)||e.schema.nodeGroupBy[h.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](t,n)}`}function OM(e,t,n){const i=b.zoomTransform((e._zoomEventTarget||e._container).node()),{x:o=0,y:a=0}=e._chartTransform||{};e._zoomToBounds([[(t[0]+o)*i.k+i.x,(n[0]+a)*i.k+i.y],[(t[1]+o)*i.k+i.x,(n[1]+a)*i.k+i.y]])}function WM(e,t){!function(e,t){e.schema.on["click.shape"]=(n,i,o,a)=>{if(e._tooltipClass.data([]).render(),e._drawDepth>=e.schema.groupBy.length-1){const r=TM(e,n,i);if(e._focus&&e._focus===r)t.active(!1),e.schema.on.mouseenter.bind(e)(n,i,o,a),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const n=e.ctx.linkLookup[r]??[],i=e.ctx.nodeLookup[r];if(!i)return;const o=[r],a=[i.x-i.r,i.x+i.r],s=[i.y-i.r,i.y+i.r];n.forEach(e=>{o.push(e.id),e.x-e.r<a[0]&&(a[0]=e.x-e.r),e.x+e.r>a[1]&&(a[1]=e.x+e.r),e.y-e.r<s[0]&&(s[0]=e.y-e.r),e.y+e.r>s[1]&&(s[1]=e.y+e.r)}),t.active((t,n)=>t.source&&t.target?t.source.id===r||t.target.id===r:o.includes(TM(e,t,n))),e._focus=r,OM(e,a,s)}}}}(e,t),function(e,t){e.schema.on["click.legend"]=(n,i,o,a)=>{const r=e._ids(n,i),s=r[r.length-1],c=e._id(n,i);if(e._drawDepth>=e.schema.groupBy.length-1){if(e._focus&&e._focus===c)t.active(!1),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const n=(Array.isArray(c)?c:[c]).map(t=>e.ctx.nodeLookup[String(t)]),i=[`${s}`],o=[n[0].x-n[0].r,n[0].x+n[0].r],a=[n[0].y-n[0].r,n[0].y+n[0].r];n.forEach(e=>{i.push(e.id),e.x-e.r<o[0]&&(o[0]=e.x-e.r),e.x+e.r>o[1]&&(o[1]=e.x+e.r),e.y-e.r<a[0]&&(a[0]=e.y-e.r),e.y+e.r>a[1]&&(a[1]=e.y+e.r)}),t.active((t,n)=>{if(t.source&&t.target)return i.includes(t.source.id)&&i.includes(t.target.id);const o=e._ids(t,n);return i.includes(`${o[o.length-1]}`)}),e._focus=c,OM(e,o,a)}e.schema.on.mouseenter.bind(e)(n,i,o,a),e.schema.on["mousemove.legend"].bind(e)(n,i,o,a)}}}(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{n(i,o,a,r);const s=TM(e,i,o),c=e.ctx.linkLookup[s]??[],l=e.ctx.nodeLookup[s];if(!l)return;const h=[s],u=[l.x-l.r,l.x+l.r],d=[l.y-l.r,l.y+l.r];c.forEach(e=>{h.push(e.id),e.x-e.r<u[0]&&(u[0]=e.x-e.r),e.x+e.r>u[1]&&(u[1]=e.x+e.r),e.y-e.r<d[0]&&(d[0]=e.y-e.r),e.y+e.r>d[1]&&(d[1]=e.y+e.r)}),t.hover((t,n)=>t.source&&t.target?t.source.id===s||t.target.id===s:h.includes(`${e._ids(t,n)[e._drawDepth]}`))}}(e,t)}const jM={name:"Network",layoutStage:AM,sizeLegendScale:(e,{width:t,height:n})=>function(e,t,n){if(!e._size)return null;if(!Array.isArray(e._filteredData)||!Array.isArray(e.schema.nodes)||!Array.isArray(e.schema.links))return null;const i=SM(e);if(!i.length)return null;const{nodeLookup:o,linkLookup:a}=e.ctx,r=CM(e,i);return e.ctx.nodeLookup=o,e.ctx.linkLookup=a,MM(e,i,r),$M(e,i,t,n)}(e,t,n),emit:({viz:e})=>{const t=e.ctx.networkCtx;if(!t)return[];const n=[];if(t.links&&t.links.length&&n.push(...function(e,t){const n=[];for(let i=0;i<t.links.length;i++){const o=t.links[i],a=o,r=iu(t.linkConfig,a,i);"number"==typeof o.size&&(r.strokeWidth=o.size);const s="number"==typeof o.size?`, ${o.size}`:"",c=o.source.id??"",l=o.target.id??"";n.push({type:"path",key:`network-link-${c}-${l}-${i}`,d:t.linkD(o),datum:a,paint:r,aria:{label:`${ou(e,o.source,0)} to ${ou(e,o.target,0)}${s}.`}}),n.push(...EM(e,o,a,r.stroke,r.strokeWidth,i,`network-arrow-${c}-${l}-${i}`))}return n}(e,t)),t.nodeGroups&&t.nodeGroups.length)for(const[i,o]of t.nodeGroups){if(!o.length)continue;const a={...au(e,i),...t.nodeShapeConfig},s=[];for(let t=0;t<o.length;t++){const r=o[t],c=r.data??r,l=iu(a,c,r.i??t);void 0===l.vectorEffect&&(l.vectorEffect="non-scaling-stroke");const h=e._size,u=h?`, ${h(c,r.i??t)}`:"",d={label:`${ou(e,r,t)}${u}.`},f=NM(i,r,a,{datum:c,paint:l,aria:d},r.i??t);if(!f)continue;n.push(f);const m=Vy(a,f,c,r.i??t);m&&s.push(m)}n.push(...s);const c=t.nodeShapeConfig.label;if(c){const t=iw({data:o,label:(e,t)=>c(e,t),x:e=>e.x,y:e=>e.y,aes:e=>{const t=e;return"Circle"===i?{r:t.r,width:2*t.r,height:2*t.r}:{width:t.width??0,height:t.height??0}},rotate:N(0),id:e=>`network-label-${e.id}`,labelBounds:(e,t,n)=>{const o=n;if("Circle"===i){const e=o.r??0;return{width:1.5*e,height:1.5*e,x:.75*-e,y:.75*-e}}const a=o.width??0,r=o.height??0;return{width:a,height:r,x:-a/2,y:-r/2}},labelConfig:{...a.labelConfig??{fontResize:!0},fontColor:t=>{const n=t.data??t,i=tu(a.fill,n.data??n,n.i??0);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},...ru(e,i)}});n.push(...t)}}return n},insetRegion:Uu,setup:e=>{const t=e;WM(e,t),function(e){e.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},e.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},e.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>{if("function"==typeof e)return e;const t=e;return this.schema.aggs[t]||(this.schema.aggs[t]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),Be(t)}),this},e.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size},e.x=function(e){if(!arguments.length)return this._x;if("function"==typeof e)this._x=e;else{const t=e;this._x=Be(t),this.schema.aggs[t]||(this.schema.aggs[t]=h.mean)}return this},e.y=function(e){if(!arguments.length)return this._y;if("function"==typeof e)this._y=e;else{const t=e;this._y=Be(t),this.schema.aggs[t]||(this.schema.aggs[t]=h.mean)}return this},e.hover=ow}(t),e._x=T("x"),e._y=T("y");const n=t._draw.bind(e);t._draw=function(t){const i=n(t),{width:o,height:a}=ie(e);return tr(e,{kind:"network",width:o,height:a,duration:e.schema.duration}),i}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"links",default:[]},{key:"linkSize",default:N(1),coerce:e=>"function"==typeof e?e:N(e)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[T("id")]},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e._size,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#adb5bd"}})}]};var HM=xf(jM);const IM=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const n=e.schema.height-e._margin.top-e._margin.bottom,i=e.schema.width-e._margin.left-e._margin.right,a=Math.min(n,i),r=o.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),s=e.schema.packOpacity,c=e.ctx.pack.padding(e.schema.layoutPadding).size([a,a])(A.hierarchy({key:r.key,values:r},e=>e.values).sum(e.schema.sum).sort(e.schema.sort)).descendants().filter((e,t)=>{const n=e;n.__d3plus__=!0,n.i=t,n.id=n.parent?n.parent.data.key:"root";const i=n.data;return i.__d3plusOpacity__=n.height?s(i,t):1,i.__d3plusTooltip__=!n.height,!n.children||n.children.length>1});return e.ctx.packDiameter=a,e.ctx.packOffsetX=(i-a)/2,e.ctx.packOffsetY=(n-a)/2,{shapeData:c}};function GM(e,t=[]){return e.values?e.values.forEach(e=>{t.push(e),GM(e,t)}):t.push(e),t}const VM=e=>Array.isArray(e)?e:[e],qM={name:"Pack",layoutStage:IM,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=au(e,"Circle"),o=(e.schema.shapeConfig.Circle??{}).label,a=n.map((t,n)=>{const o=t.data,a=tu(i.fill,o,n),r=tu(i.stroke,o,n),s=tu(i.strokeWidth,o,n);return{type:"circle",key:`pack-${t.id}-${t.i}`,cx:t.x,cy:t.y,r:t.r,shapeType:"Pack",datum:o,paint:{fill:nu(i,o,n,a),stroke:r,opacity:o.__d3plusOpacity__,strokeWidth:s},aria:{label:`${e._drawLabel(o,t.i)}, ${t.value}.`}}}),r=iw({data:n,label:(e,t)=>{const n=e;return!n.children&&(o?o(n.data,t):!!n.parent&&(n.data.id??!1))},x:e=>e.x,y:e=>e.y,datum:e=>e.data,aes:e=>{const t=e.r;return{r:t,width:2*t,height:2*t}},rotate:N(0),id:e=>e.id,labelBounds:(e,t,n)=>{const i=n.r;return{width:1.6*i,height:.8*i,x:.8*-i,y:.4*-i}},labelConfig:{fontResize:!0,...ru(e,"Circle")}}),s=qy(i,a,e=>[n[e].data,e]);return[...a,...s,...r]},insetRegion:Uu,chartTransform:e=>({x:e._margin.left+(e.ctx.packOffsetX??0),y:e._margin.top+(e.ctx.packOffsetY??0)}),chartBodyRect:e=>{const t=e.ctx.packDiameter??0;return{x:0,y:0,width:t,height:t}},setup:e=>{const t=e.hover.bind(e);e.hover=n=>(t(n),e.schema.legend&&e._legendClass.hover(n),e)},facet:{aspect:1},ctx:{pack:A.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0)},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"packOpacity",default:N(.25),coerce:e=>"function"==typeof e?e:N(e)},{key:"shape",default:N("Circle"),coerce:e=>"function"==typeof e?e:N(e)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:e=>{const t=e;return!(!t.parent||t.children)&&t.id},labelConfig:{fontResize:!0},opacity:e=>e.__d3plusOpacity__}})},{key:"legend",coerce:"const",factory:cw},{key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],n=e.schema.on["mousemove.shape"],i=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(n,o,a,r)=>{t(n,o,a,r);const s=e._ids(n,o),c=GM(n);i(e=>(Object.keys(e).filter(e=>"value"!==e&&!e.startsWith("__d3plus")).every(t=>null!=n[t]&&VM(e[t]).every(e=>VM(n[t]).includes(e)))?c.push(e):s.includes(e.key)&&c.push(...GM(e,[e])),c.includes(e)))},"mousemove.shape":(e,t,o,a)=>{e.__d3plusTooltip__&&n(e,t,o,a);const r=GM(e,[e]);i(e=>r.includes(e))}}}}]};var YM=xf(qM);function KM(e){return"number"==typeof e&&Number.isFinite(e)}function UM(e){return null==e||""===e||"number"==typeof e&&!Number.isFinite(e)}function XM(e,t=[]){const n=new Set(t),i=[],o=new Map;for(const t of e)for(const e of Object.keys(t)){if(n.has(e)||e.startsWith("_"))continue;const a=t[e];o.has(e)||(o.set(e,!0),i.push(e)),UM(a)||KM(a)||o.set(e,!1)}return i.filter(t=>o.get(t)&&e.some(e=>KM(e[t])))}function QM(e){const t=e.filter(e=>!UM(e));return t.length&&t.every(KM)?"numeric":"categorical"}function ZM(e,t,n={}){const i=Array.isArray(n.domain)?n.domain:void 0;if("numeric"===t){const[t,n]=h.extent(e.filter(KM));return[i&&KM(i[0])?i[0]:t??0,i&&KM(i[i.length-1])?i[i.length-1]:n??0]}if(i)return i.map(String);return Array.from(new Set(e.filter(e=>!UM(e)).map(String))).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function JM(e,t,n={},i){return e.map(e=>{const o=n[e]??{},a=t.map(t=>t[e]),r="point"===o.scale||"band"===o.scale?"categorical":QM(a),s=i?.[e]??ZM(a,r,o);return{key:e,title:"string"==typeof o.title?o.title:e,type:r,domain:s,reverse:Boolean(o.reverse)}})}function e$(e,t,n={}){const i={};for(const o of JM(e,t,n))i[o.key]=o.domain;return i}function t$(e){return e<=50?1:Math.max(.1,Math.round(100*Math.sqrt(50/e))/100)}function n$(e,t,n){if(e<=0)return[];if(1===e)return[(t+n)/2];const i=(n-t)/(e-1);return Array.from({length:e},(e,n)=>t+i*n)}const i$=1e4;function o$(e,t,n){const i=(new ro).data(e.map(e=>({id:`pc-title-${e.key}`,text:e.text}))).x((t,n)=>e[n].x).y((t,n)=>e[n].y).width((t,n)=>e[n].width).height((t,n)=>e[n].height).config(t);return n&&i.locale(n),i}function a$(e,t,n){if(!e.length)return[];const i=e.map((e,t)=>({key:`${t}`,text:e,x:0,y:0,width:i$,height:i$}));return o$(i,{...t,padding:0},n)._textData().map(e=>Math.ceil(Math.max(0,...e.widths)))}function r$(e,t,n){if(!e.length)return 0;const i=o$(e.map(e=>({...e,height:i$})),{...t,padding:0},n)._textData();return Math.ceil(Math.max(0,...i.map(e=>e.lines.length*e.lH)))}function s$(e,t,n){return e.length?o$(e,{...t,padding:0},n).toScene().children.map(e=>{const t={...e,interactive:!1,interactionGroup:"axis"};return delete t.datum,delete t.index,t}):[]}function c$(e,t){const n=e.domain.slice();return("numeric"===e.type?"horizontal"===t!==e.reverse:e.reverse)?n.reverse():n}function l$(e){if(!e)return{};const t={...e};return delete t.domain,delete t.reverse,delete t.title,t}function h$(e,t){const n=e.schema.axisConfig??{};return{fontColor:Ga(e),fontSize:12,textAnchor:"horizontal"===t?"middle":"end",verticalAlign:"horizontal"===t?"bottom":"middle",...n.titleConfig??{}}}function u$(e,t,n){const i=e.schema.dimensionConfig??{},o=(new hi).orient("horizontal"===n?"left":"bottom").align("start");o.renderMode("compute").select(null),o.config(Jp(e,{})).config(e.schema.axisConfig??{}).config(l$(i[t.key])),o.gridSize(0).title(!1);const a=o.scale();return"categorical"===t.type&&"point"!==a&&"band"!==a&&o.scale("point"),"numeric"!==t.type||"point"!==a&&"band"!==a||o.scale("linear"),o.domain(c$(t,n)),o}function d$(e,t){let n=0,i=t;for(const o of e){const e=o._d3Scale?.range()??[0,t];n=Math.max(n,Math.min(...e)),i=Math.min(i,Math.max(...e))}return i>n?[n,i]:[0,t]}function f$(e,t,n){const i=e=>{const t=e.children,n={...e,interactionGroup:"axis",interactive:!1};return delete n.datum,t&&(n.children=t.map(i)),n},o=e.toScene();return i({type:"group",key:`pc-axis-${t}`,transform:n,children:o.children})}function m$(e,t,n,i,o){const a=e._d3Scale,r="numeric"===t.type&&a&&"function"==typeof a.invert?e=>Number(a.invert(e-i)):void 0;return{dim:t,offset:n,start:i+o[0],end:i+o[1],position:n=>{const o=e._getPosition((e=>"categorical"===t.type?String(e):e)(n));return"number"==typeof o&&Number.isFinite(o)?i+o:NaN},invert:r}}function p$(e,t,n,i,o){return!t.length||n<=0||i<=0?{axes:[],nodes:[]}:"vertical"===o?function(e,t,n,i){const o=t.length,a=h$(e,"vertical"),r=e.schema.locale,s=a$(t.map(e=>e.title),a,r),c=Math.min(Math.max(0,...s)+4,.25*n),l=c?c+8:0,h=Math.max(0,n-l),u=Math.max(20,i/o*.5),d=t.map(t=>u$(e,t,"vertical").width(h).height(u).maxSize(u));d.forEach(e=>e.measure());const f=d.map(e=>e.outerBounds().height||0),m=r$(t.slice(0,1).map(e=>({key:e.key,text:"M",x:0,y:0,width:c||1,height:0})),a,r),p=n$(o,Math.max(4,m/2),i-Math.max(4,f[o-1])),g=o>1?p[1]-p[0]:i,y=d$(d,h),x=[],b=d.map((e,n)=>{e.range(y).render();const i=ni(e),o=i?i.points[0][1]:0;return x.push(f$(e,t[n].key,{x:l,y:p[n]-o})),m$(e,t[n],p[n],l,y)}),_=c?t.map((e,t)=>({key:e.key,text:e.title,x:0,y:p[t]-g/2,width:c,height:g})).filter(e=>e.text):[];return x.push(...s$(_,a,r)),{axes:b,nodes:x}}(e,t,n,i):function(e,t,n,i){const o=t.length,a=h$(e,"horizontal"),r=e.schema.locale,s=a$(t.map(e=>e.title),a,r),c=Math.max(30,n/o*.6),l=t.map(t=>u$(e,t,"horizontal").height(i).width(c).maxSize(c));l.forEach(e=>e.measure());const h=l.map(e=>e.outerBounds().width||0);let u=o>1?n/o:n,d=[],f=0,m=0;for(let e=0;e<2;e++)d=s.map(e=>Math.min(e+4,Math.max(u-8,40))),f=Math.max(h[0],d[0]/2,4),m=Math.max(d[o-1]/2,4),u=o>1?(n-f-m)/(o-1):n-f-m;const p=n$(o,f,n-m),g=t.map((e,t)=>({key:e.key,text:e.title,x:p[t]-d[t]/2,y:0,width:d[t],height:0})).filter(e=>e.text),y=r$(g,a,r),x=y?y+8:0;g.forEach(e=>e.height=y);const b=Math.max(0,i-x);l.forEach(e=>e.height(b).measure());const _=d$(l,b),k=[],v=l.map((e,n)=>{e.range(_).render();const i=ni(e),o=i?i.points[0][0]:h[n];return k.push(f$(e,t[n].key,{x:p[n]-o,y:x})),m$(e,t[n],p[n],x,_)});return k.push(...s$(g,a,r)),{axes:v,nodes:k}}(e,t,n,i)}function g$(e,t,n="horizontal"){return t.map(t=>{const i=e[t.key];if(UM(i))return null;const o=t.position(i);return"number"==typeof o&&Number.isFinite(o)?"horizontal"===n?[t.offset,o]:[o,t.offset]:null})}function y$(e,t="linear",n="horizontal"){const i="bump"===t?"horizontal"===n?y.curveBumpX:y.curveBumpY:y.curveLinear;return y.line().defined(e=>null!==e).x(e=>e[0]).y(e=>e[1]).curve(i)(e)??""}function x$(e){const t=e.schema.dimensions;if(Array.isArray(t))return t.map(String);const n=e._groupByRaw,i=(Array.isArray(n)?n:[n]).filter(e=>"string"==typeof e);return XM(e._data??[],["id",...i])}function b$(e){return"vertical"===e?"vertical":"horizontal"}function _$(e,t,n,i){const o=e.end-e.start,{dim:a}=e,r={id:`${n.left},${n.top}|${t}|${a.key}`,key:a.key,title:a.title,orient:t,type:a.type,domain:a.domain,position:e.position,invert:e.invert,alongStart:e.start};return"horizontal"===t?{...r,x:n.left+e.offset-i/2,y:n.top+e.start,width:i,height:o}:{...r,x:n.left+e.start,y:n.top+e.offset-i/2,width:o,height:i}}const k$=({viz:e})=>{var t;const n=(t=e.ctx).brushQueue??(t.brushQueue=[]),i=e._filteredData??[],o=x$(e);if(e.ctx.dimensions=[],e.ctx.axisNodes=[],!i.length||!o.length)return{shapeData:[]};const a=JM(o,i,e.schema.dimensionConfig??{},e.ctx.sharedDomains);e.ctx.dimensions=a;const r=b$(e.schema.orient),s="bump"===e.schema.curve?"bump":"linear",{width:c,height:l}=ie(e),h=p$(e,a,c,l,r);e.ctx.axisNodes=h.nodes;const u=e.schema.brushConfig??{},d="number"==typeof u.width?u.width:20;for(const t of h.axes)n.push(_$(t,r,e._margin,d));const f=h.axes.map(e=>({key:e.dim.key,offset:e.offset,position:e.position})),m=new Map;return{shapeData:i.map((t,n)=>{const i=`${e._id(t,n)}`,o=m.get(i)??0;return m.set(i,o+1),{data:t,i:n,id:o?`${i}-${o}`:i,d:y$(g$(t,f,r),s,r)}})}};function v$(e){return 2===e.length&&e.every(e=>KM(e))}function w$(e,t){if(v$(t)){if(!KM(e))return!1;const[n,i]=t[0]<=t[1]?t:[t[1],t[0]];return e>=n&&e<=i}return null!=e&&t.includes(String(e))}function S$(e,t){if(!t)return!0;for(const n of Object.keys(t))if(!w$(e[n],t[n]))return!1;return!0}function C$(e){return Boolean(e&&Object.keys(e).length)}function M$(e,t){const n=Math.min(e[0],e[1]),i=Math.max(e[0],e[1]);if("numeric"===t.type){if(!t.invert)return null;const e=t.invert(n),o=t.invert(i);return KM(e)&&KM(o)?e<=o?[e,o]:[o,e]:null}const o=t.domain.filter(e=>{const o=t.position(e);return o>=n&&o<=i}).map(String);return o.length?o:null}function $$(e,t,n=6){if(v$(e)){if("numeric"!==t.type)return null;const n=t.position(e[0]),i=t.position(e[1]);return KM(n)&&KM(i)?n<=i?[n,i]:[i,n]:null}const i=new Set(e.map(String)),o=t.domain.filter(e=>i.has(String(e))).map(e=>t.position(e)).filter(KM);return o.length?[Math.min(...o)-n,Math.max(...o)+n]:null}const A$="d3plus-parallel-brushes",z$="d3plus-parallel-brush",D$=new WeakMap;function F$(e){return"horizontal"===e.orient?e.height:e.width}function B$(e,t){if(!e)return null;const n=$$(e,t);if(!n)return null;const i=F$(t),o=Math.max(0,Math.min(i,n[0]-t.alongStart)),a=Math.max(0,Math.min(i,n[1]-t.alongStart));return a>o?[o,a]:null}function L$(e,n){const i=D$.get(e)?.clearLabel,o=t.select(e).attr("tabindex",n?0:null);o.selectAll(":scope > title").remove(),n&&i&&o.insert("title",":first-child").text(i)}function P$(e,n,i,o){const a=D$.get(n);if(!a)return;const r=a.target.key,s={...e.schema.brushes??{}};i?s[r]=i:delete s[r],e.schema.brushes=s;const c=n.parentNode;c&&t.select(c).selectAll(`g.${z$}`).each(function(e){const a=D$.get(this);a&&e.key===r&&(L$(this,Boolean(i)),(this!==n||o)&&t.select(this).call(a.brush.move,B$(i??void 0,a.target)))});const l=e.schema.on?.brush;"function"==typeof l&&l.call(e,s),e._scheduleSceneRepaint()}function R$(e,t){const n=D$.get(t),i=e.schema.brushes??{};return!(!n||!(n.target.key in i))&&(n.active=!1,P$(e,t,null,!0),!0)}function E$(e,n,i){const o=e._select&&"function"==typeof e._select.node?e._select.node():null;if(!o||"function"!=typeof o.querySelector)return;const a=!1!==e.schema.brushing&&!e._ssr&&n.length>0,r=t.select(o).selectAll(`:scope > g.${A$}`).data(a?[0]:[]);if(r.exit().remove(),!a)return;const s=r.enter().append("g").attr("class",`d3plus-viz-brush ${A$}`).merge(r),c=Array.from(new Map(n.map(e=>[e.id,e])).values()),l=s.selectAll(`g.${z$}`).data(c,e=>e.id);l.exit().remove();const h=e.schema.brushes??{},u=t=>e.schema.translate(t);l.enter().append("g").attr("class",z$).merge(l).each(function(n){const o=t.select(this);let a=D$.get(this);if(!a){const t="horizontal"===n.orient?p.brushY():p.brushX();a={brush:t,target:n,signature:"",active:!1,clearLabel:""},D$.set(this,a);const i=this;t.on("start brush end",t=>function(e,t,n){const i=D$.get(t);if(!i||!n.sourceEvent)return;const o=i.target;i.active="end"!==n.type;const a=n.selection;P$(e,t,a&&Math.abs(a[1]-a[0])>=1?M$([a[0]+o.alongStart,a[1]+o.alongStart],o):null,"end"===n.type&&"categorical"===o.type)}(e,i,t)),o.on("dblclick.clear",t=>{t.preventDefault(),t.stopPropagation(),R$(e,i)}).on("keydown.clear",t=>{"Escape"===t.key&&R$(e,i)&&(t.preventDefault(),t.stopPropagation())})}if(a.target=n,a.clearLabel=`${n.title}: ${u("Double-click or Escape to Clear")}`,o.attr("transform",`translate(${n.x},${n.y})`),a.active)return;const r=`${n.width}x${n.height}`;a.signature!==r&&(a.brush.extent([[0,0],[n.width,n.height]]),o.call(a.brush),a.signature=r),function(e,t,n){const i=e.selectAll("rect.selection"),o=[["fill",t.fill],["fill-opacity",t.fillOpacity],["stroke",t.stroke],["stroke-width",t.strokeWidth]];for(const[e,t]of o)null!=t&&i.attr(e,`${t}`);e.selectAll("rect.overlay").attr("aria-label",n)}(o,i,`${n.title}: ${u("Drag to Filter")}`),o.call(a.brush.move,B$(h[n.key],n)),L$(this,n.key in h)})}function N$(e,t,n){if(UM(n))return"";const i=e.schema.dimensionConfig??{},o=i[t]?.tickFormat;return"function"==typeof o?`${o(n)}`:KM(n)?d.formatAbbreviate(n,e.schema.locale):String(n)}function T$(e,t){return(e.ctx.dimensions??[]).map(n=>[n.title,N$(e,n.key,t[n.key])])}const O$="pc-line-",W$="::hit";function j$(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.min(1,Math.max(0,e)):t$(t)}function H$(e,t,n,i){const o=i.map(n=>`${n.title} ${N$(e,n.key,t[n.key])}`).join(", ");return`${e._drawLabel(t,n)}${o?`: ${o}`:""}.`}const I$=({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.axisNodes??[];if(!n.length)return i;const o=e.ctx.dimensions??[],a=au(e,"Line"),r=j$(e.schema.lineOpacity,n.length),s=[];return n.forEach(t=>{if(!t.d)return;const{data:n,i:i}=t,c=`${O$}${t.id}`,l=tu(a.strokeOpacity,n,i);s.push({type:"path",shapeType:"Line",key:c,d:t.d,datum:n,index:i,paint:{fill:"none",stroke:tu(a.stroke,n,i),strokeWidth:tu(a.strokeWidth,n,i),strokeOpacity:"number"==typeof l?l:r,strokeDasharray:tu(a.strokeDasharray,n,i),opacity:tu(a.opacity,n,i)},aria:{label:H$(e,n,i,o)}}),s.push({type:"path",shapeType:"Line",key:`${c}${W$}`,d:t.d,datum:n,index:i,paint:{fill:"none",stroke:"transparent",strokeWidth:8},aria:{hidden:!0}})}),[...s,...i]},G$=e=>"string"==typeof e.key&&e.key.includes(O$),V$=e=>"string"==typeof e.key&&e.key.endsWith(W$),q$=e=>"number"==typeof e.z&&e.z>0;function Y$(e,t){if(G$(e))return t(e);const n=e.children;return n&&n.length?{...e,children:n.map(e=>Y$(e,t))}:e}function K$(e){if(G$(e))return!V$(e)&&q$(e)?1:0;const t=e.children;return t?t.reduce((e,t)=>e+K$(t),0):0}function U$(e,t){const n=C$(t.brushes),i=1===K$(e);return n||i?Y$(e,e=>{const o={...e.paint??{}};if(n&&!S$(e.datum,t.brushes)){if(!V$(e)){const e="number"==typeof o.strokeOpacity?o.strokeOpacity:1;o.strokeOpacity=t.inactiveOpacity??.3*e,"string"==typeof o.stroke&&(o.stroke=r.colorGrayscale(o.stroke))}const n={...e,paint:o,interactive:!1};return delete n.z,n}return i&&q$(e)&&!V$(e)?(o.strokeOpacity=1,{...e,paint:o}):e}):e}function X$(e){const t={};for(const[n,i]of Object.entries(e))t[n]="function"==typeof i?i():i;return t}const Q$={name:"ParallelCoordinates",layoutStage:k$,emit:I$,decorateScene:function(e,t){const n=X$(e.schema.brushConfig??{}),i=e.ctx.brushQueue;i&&(e.ctx.brushQueue=void 0,E$(e,i,n));const o=U$(t.root,{brushes:e.schema.brushes,inactiveOpacity:"number"==typeof n.inactiveOpacity?n.inactiveOpacity:void 0});return o===t.root?t:{...t,root:o}},facet:{aspect:1.5,axes:"all",share:(e,t)=>e$(x$(e),t.flat(),e.schema.dimensionConfig??{}),panel:(e,t)=>{const n=e.ctx.sharedDomains;return e.ctx.sharedDomains=t.shared?t.scales:void 0,()=>{e.ctx.sharedDomains=n}}},ctx:{},fields:[{key:"brushes",default:{}},{key:"brushing",default:!0},{key:"curve",default:"linear"},{key:"dataCutoff",default:2e3},{key:"dimensions"},{key:"lineOpacity",default:"auto"},{key:"orient",default:"horizontal"},{key:"zoom",default:!1},{key:"axisConfig",merge:!0,default:{}},{key:"brushConfig",merge:!0,factory:e=>({fill:()=>Ga(e),fillOpacity:.12,stroke:()=>Ga(e),strokeWidth:1,width:20})},{key:"dimensionConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,factory:e=>({Line:{stroke:(t,n)=>{const i=e.schema.shapeConfig.fill;return"function"==typeof i?i(t,n):i},strokeWidth:1.5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:t=>T$(e,t)})}]};var Z$=xf(Q$);function J$(e){return{barConfig:{stroke:()=>Ga(e),strokeWidth:1},gridConfig:{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),strokeWidth:1},shapeConfig:{fill:N("none"),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ga(e),strokeWidth:N(1)}}}function eA(e){return[()=>e.schema.translate("Value"),(t,n)=>{const i=Number(e.schema.value(t,n));return Number.isFinite(i)?d.formatAbbreviate(i,e.schema.locale):""}]}function tA(e,t,n,o){const a=au(e,"Path"),r=t.filter(e=>e.arc.outerRadius>e.arc.innerRadius&&e.arc.endAngle>e.arc.startAngle),s=r.map(t=>{const r=iu(a,t.data,t.i);return{type:"path",key:`${n}-${e._ids(t.data,t.i).join("-")}-${t.slot}`,d:i.arcPath(t.arc),arc:t.arc,datum:t.data,index:t.i,paint:{...r,opacity:r.opacity??1},aria:{label:o(t)}}}),c=qy(a,s,e=>[r[e].data,r[e].i]);return[...s,...c]}function nA(e,t,n){const i=t.flatMap(t=>n(e,t)).filter(Number.isFinite);return{extent:i.length?[Math.min(...i),Math.max(...i)]:[]}}function iA(e,t){const n=e.ctx.polarSharedExtent,i=t.scales;return e.ctx.polarSharedExtent=t.shared&&i?i.extent:void 0,()=>{e.ctx.polarSharedExtent=n}}function oA(e){const t=e.ctx.polarSharedExtent;return Array.isArray(t)?t:[]}function aA(e){return{aspect:1,scales:"independent",share:(t,n)=>nA(t,n,e),panel:iA}}const rA=1e-9;function sA(e,t,n,i,o,a=10){const r=Math.abs(Math.cos(e)),s=Math.abs(Math.sin(e));let c=1/0;return r>rA&&(c=Math.min(c,(i/2-n/2*s)/r-t-a)),s>rA&&(c=Math.min(c,(o/2-n/2*r)/s-t-a)),c}function cA(e){const{labels:t,width:n,height:i,measure:o,wrap:a}=e,r=e.padding??10,s=e.maxLines??2,c=Math.max(0,Math.min(n,i)/2),l=c*(e.minRadiusShare??.5),h=t.map(e=>o(e)),u=function(e,t,n,i=10){let o=Math.min(t,n)/2;for(const a of e){const e=Math.abs(Math.cos(a.angle)),r=Math.abs(Math.sin(a.angle));e>rA&&(o=Math.min(o,(t/2-a.height/2*r)/e-i-a.width)),r>rA&&(o=Math.min(o,(n/2-a.height/2*e)/r-i-a.width))}return Math.max(0,o)}(t.map((e,t)=>({angle:e.angle,width:h[t],height:e.lineHeight})),n,i,r);if(u>=l)return{radius:u,labels:t.map((e,t)=>({wrapWidth:h[t]+1,width:h[t],height:e.lineHeight,lines:1,truncated:!1}))};const d=e=>t.map((t,o)=>{if(h[o]<=sA(t.angle,e,t.lineHeight,n,i,r))return{wrapWidth:h[o]+1,width:h[o],height:t.lineHeight,lines:1,truncated:!1};const c=sA(t.angle,e,t.lineHeight*s,n,i,r),l=Math.max(0,c),u=a(t,l,s);return{wrapWidth:l,width:Math.max(0,...u.widths),height:Math.max(1,u.lines.length)*t.lineHeight,lines:u.lines.length,truncated:u.truncated}}),f=e=>e.every(e=>!e.truncated);let m=l,p=d(m);if(!f(p))return{radius:l,labels:p};let g=c;for(let e=0;e<16&&g-m>.5;e++){const e=(m+g)/2,t=d(e);f(t)?(m=e,p=t):g=e}return{radius:m,labels:p}}function lA(e,t){const n=Array.isArray(t)?t.filter(Number.isFinite):[],i=e.filter(Number.isFinite).concat(n),o=Math.min(0,...i),a=Math.max(0,...i);if(Array.isArray(t)){return{domain:[o,a],ticks:Array.from(new Set(n)).sort((e,t)=>e-t)}}const r=Math.max(1,Math.round(t)),c=s.scaleLinear().domain([o,a]).nice(r),[l,h]=c.domain();return{domain:[l,h],ticks:c.ticks(r)}}function hA(e,t,n){const i=t[1]-t[0];return i?(e-t[0])/i*n:0}const uA={"stroke-width":"strokeWidth","stroke-opacity":"strokeOpacity","stroke-dasharray":"strokeDasharray"};function dA(e,t){const n={...e};for(const[e,i]of Object.entries(t??{}))n[uA[e]??e]=i;return n}const fA=(e,t,n)=>"function"==typeof e?e(t,n):e;function mA(e,t,n){const i={fill:"none"},o=fA(e.stroke,t,n);"string"==typeof o&&(i.stroke=o);const a=Number(fA(e.strokeWidth,t,n));Number.isFinite(a)&&(i.strokeWidth=a);const r=Number(fA(e.strokeOpacity,t,n));Number.isFinite(r)&&(i.strokeOpacity=r);const s=Number(fA(e.opacity,t,n));Number.isFinite(s)&&(i.opacity=s);const c=fA(e.strokeDasharray,t,n),l=(Array.isArray(c)?c:"string"==typeof c?c.split(/[\s,]+/):[]).map(Number).filter(Number.isFinite);return l.length&&(i.strokeDasharray=l),i}const pA=2*Math.PI,gA=(e,t,i,o)=>{const a=e.schema.axisConfig,r=(new ro).config({...nw,...a.shapeConfig?.labelConfig??{}}).schema,s={data:i,i:o,text:t},c=Number(r.fontSize(s,o))||10;return{fontFamily:String(n.fontExists(r.fontFamily(s,o))||"sans-serif"),fontSize:c,fontWeight:r.fontWeight(s,o),lineHeight:Number(r.lineHeight(s,o))||1.2*c}};function yA(e,{domain:t,ticks:n},i,o=e=>hA(e,t,i),a="radar"){const r=e.schema.axisConfig,s=n.map(e=>({value:e,r:o(e)}));return function(e,t,n,i,o,a="radar"){if(!(t>0))return[];const r=e.filter(e=>e.r>0&&e.r<t),s=[...r,{value:n,r:t}].map((e,t)=>({type:"circle",key:t===r.length?`${a}-ring-outer`:`${a}-ring-${e.value}`,interactive:!1,cx:0,cy:0,r:e.r,paint:mA(t===r.length?o:i,e,t)}));return[{type:"group",key:`${a}-radial-circles`,interactive:!1,children:s}]}(s,i,t[1],dA({},r.gridConfig),dA({},r.barConfig),a)}function xA(e,{domain:t,ticks:i},o,r,s="radar"){if(!e.schema.levelLabels)return[];const c=e.schema.levelLabelConfig??{},l=c.fontSize??10,h=c.fontWeight??400,u=a.fontFamilyStringify(c.fontFamily??e.schema.fontFamily??a.fontFamily),f={"font-family":u,"font-size":l,"font-weight":h},m=e.schema.levelFormat,p=function(e){const{ticks:t,domain:n,radius:i,angle:o,format:a,measure:r,fontSize:s}=e,c=e.toRadius??(e=>hA(e,n,i)),l=o*Math.PI/180,h=Math.sin(l),u=-Math.cos(l),d=-u,f=h,m=d>1e-6?"start":d<-1e-6?"end":"middle",p=(e,t,n,i)=>(Math.abs(n)*e+Math.abs(i)*t)/2,g=t.filter(e=>e>=n[0]&&e<=n[1]).map(e=>{const t=c(e),n=a(e),i=r(n),o=s,l=3+p(i,o,d,f),g=t-2-p(i,o,h,u);return{value:e,text:n,r:t,x:g*h+l*d,y:g*u+l*f,width:i,height:o,anchor:m}}),y=Math.max(0,...g.map(e=>2*p(e.width,e.height,h,u)));let x=1/0;for(let e=1;e<g.length;e++)x=Math.min(x,g[e].r-g[e-1].r);const b=x>0?Math.max(1,Math.ceil((y+2)/x)):g.length;return g.filter((e,t)=>t%b===0)}({ticks:i,domain:t,radius:o,angle:Number(e.schema.levelLabelAngle)||0,format:t=>"function"==typeof m?String(m(t)):d.formatAbbreviate(t,e.schema.locale),measure:e=>n.textWidth(e,f),fontSize:l,toRadius:r});return function(e,t,n="radar"){if(!e.length)return[];const i=[];for(const o of e){const e="start"===o.anchor?-o.width/2:"end"===o.anchor?o.width/2:0;i.push({type:"text",key:`${n}-level-label-${o.value}`,interactive:!1,x:0,y:0,transform:{x:o.x+e,y:o.y},lines:[{text:o.text,x:0,y:.35*t.fontSize,width:o.width}],font:{family:t.fontFamily,size:t.fontSize,weight:t.fontWeight,anchor:o.anchor,baseline:"alphabetic"},paint:{fill:t.fontColor,opacity:t.fontOpacity}})}return[{type:"group",key:`${n}-level-labels`,interactive:!1,children:i}]}(p,{fontColor:c.fontColor??Ga(e),fontFamily:u,fontOpacity:c.fontOpacity??1,fontSize:l,fontWeight:h},s)}const bA=1e-9;function _A(e,t,n,i,o=6){const a=Math.sin(e),r=-Math.cos(e);return{x:(t+o)*a+a*n/2-n/2,y:(t+o)*r+r*i/2-i/2,width:n,height:i}}function kA(e,t,n,i=6){let o=Math.min(t,n)/2;for(const a of e){const e=Math.abs(Math.sin(a.angle)),r=Math.abs(Math.cos(a.angle));e>bA&&(o=Math.min(o,(t/2-a.width/2*(1+e))/e-i)),r>bA&&(o=Math.min(o,(n/2-a.height/2*(1+r))/r-i))}return Math.max(0,o)}function vA(e,t,n,i=6){const o=Math.abs(Math.sin(e));return o<=bA?n:Math.max(0,2*(n/2-(t+i)*o)/(1+o))}const wA=(e,t,n=2)=>e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n;function SA(e,t,n=6,i=2){if(e.length<2)return!1;const o=e.map(e=>({angle:e.angle,p:_A(e.angle,t,e.width,e.height,n)})).sort((e,t)=>e.angle-t.angle);for(let e=0;e<o.length;e++){const t=o[(e+1)%o.length];if(t!==o[e]&&wA(o[e].p,t.p,i))return!0}return!1}function CA(e){const{angles:t,widths:n,lineHeight:i,width:o,height:a}=e,r=e.padding??6,s=Math.max(0,Math.min(o,a)/2)*(e.minRadiusShare??.5),c=kA(t.map((e,t)=>({angle:e,width:n[t],height:i})),o,a,r);return c>=s?{radius:c,labels:n.map(e=>({width:e,height:i,lines:1}))}:{radius:s,labels:t.map((e,t)=>{const a=vA(e,s,o,r);return n[t]<=a?{width:n[t],height:i,lines:1}:{width:a,height:2*i,lines:2}})}}function MA(e){const t=(180*(e-Math.PI/2)/Math.PI%360+360)%360;return Math.sin(e)<-1e-9?{rotate:t-180,anchor:"end"}:{rotate:t,anchor:"start"}}function $A(e,t,i,o,r=!0){const s=Math.max(0,Math.min(i,o)/2);if(!r||!t.length)return{radius:s,labels:[]};const c=e.schema.outerPadding,l=t.map((t,n)=>gA(e,t.text,t.data,n)),h=t.map((e,t)=>n.textWidth(e.text,(e=>({"font-family":l[e].fontFamily,"font-size":l[e].fontSize,"font-weight":l[e].fontWeight}))(t))),u=Math.max(...l.map(e=>e.lineHeight)),d=Math.max(0,i-4),f=Math.max(0,o-4),m="number"==typeof c?Math.max(0,s-c):void 0,p=CA({angles:t.map(e=>e.angle),widths:h.map(e=>(e=>Math.max(e+2,12))("number"==typeof c?Math.min(e,c):e)),lineHeight:u+2,width:d,height:f}),g=m??p.radius,y=t.map((e,t)=>({angle:e.angle,width:p.labels[t].width,height:p.labels[t].height}));if(!SA(y,g)){const e=t.map((e,t)=>{const n=y[t],i=_A(e.angle,g,n.width,n.height);return{__d3plus__:!0,data:e.data,id:e.key,text:e.text,x:0,y:0,rotate:0,textAnchor:(a=Math.sin(e.angle),a>.3?"start":a<-.3?"end":"middle"),verticalAlign:(o=-Math.cos(e.angle),o<-.3?"bottom":o>.3?"top":"middle"),labelBounds:i};var o,a});return{radius:g,labels:e}}return function(e,{fonts:t,widths:n,innerW:i,innerH:o,fixed:r,outerPadding:s}){const c=cA({labels:e.map((e,n)=>({text:e.text,angle:e.angle-Math.PI/2,lineHeight:t[n].lineHeight,i:n})),width:i,height:o,padding:6,measure:e=>n[e.i],wrap:(e,n,i)=>a.textWrap().fontFamily(t[e.i].fontFamily).fontSize(t[e.i].fontSize).fontWeight(t[e.i].fontWeight).lineHeight(t[e.i].lineHeight).width(n).height(t[e.i].lineHeight*i).maxLines(i)(e.text)}),l=r??c.radius,h=e.map((e,n)=>{const{rotate:i,anchor:o}=MA(e.angle),a=Math.max(12,"number"==typeof s?s:c.labels[n].wrapWidth),r=2*t[n].lineHeight,h="start"===o?6:-a-6;return{__d3plus__:!0,data:e.data,id:e.key,text:e.text,x:l*Math.sin(e.angle),y:-l*Math.cos(e.angle),rotate:i,textAnchor:o,verticalAlign:"middle",labelBounds:{x:h,y:-r/2,width:a,height:r},rotateAnchor:[-h,r/2]}});return{radius:l,labels:h}}(t,{fonts:l,widths:h,innerW:d,innerH:f,fixed:m,outerPadding:c})}function AA(e,t,n){if(!t.length)return[];const i=e.schema.axisConfig,o=iw({data:t,label:e=>e.text,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.rotate,id:e=>`${n}-label-${e.id}`,labelBounds:e=>e.labelBounds,labelConfig:{...i.shapeConfig?.labelConfig??{},verticalAlign:e=>e.data?.verticalAlign??"middle"}});for(const e of o)e.interactive=!1;return o.length?[{type:"group",key:`${n}-labels`,interactive:!1,children:o}]:[]}function zA(e,t,n,i,o){return{rings:yA(e,t,n,i,o),labels:xA(e,t,n,i,o)}}function DA(e,t,n,i,o="sqrt"){const a=t[1]-t[0],r=Number.isFinite(e)&&a?(e-t[0])/a:0,s=Math.max(0,Math.min(1,r));return"linear"===o?n+s*(i-n):Math.sqrt(n*n+s*(i*i-n*n))}function FA(e,t=0,n=2*Math.PI){const i=Math.max(0,Math.floor(e)),o=i?n/i:0;return Array.from({length:i},(e,n)=>({startAngle:t+n*o,endAngle:t+(n+1)*o,angle:t+(n+.5)*o}))}function BA(e){const t=new Map;return e.map(({slot:e,value:n})=>{const i=t.get(e)??0,o=i+(Number.isFinite(n)&&n>0?n:0);return t.set(e,o),{slot:e,y0:i,y1:o}})}function LA(e,t,n){return e>0?e:t>0&&n>0?t/n:0}function PA(e,t,n=void 0){const i=lA(e,t),[o,a]=n??[],r="number"==typeof o&&Number.isFinite(o),c="number"==typeof a&&Number.isFinite(a);if(!r&&!c)return i;const l=r?o:i.domain[0],h=c?a:i.domain[1];if(!(h>l))return i;const u=Array.isArray(t)?i.ticks.filter(e=>e>=l&&e<=h):s.scaleLinear().domain([l,h]).ticks(Math.max(1,Math.round(t)));return{domain:[l,h],ticks:u}}function RA(e,t){const n=Number("function"==typeof e?e(t):e);return!Number.isFinite(n)||n<=0?0:Math.min(n,.95*t)}function EA(e,t,n,i){const o=Math.max(0,Math.min(.95,i.inset)),a=e.endAngle-e.startAngle;return{innerRadius:t,outerRadius:n,startAngle:e.startAngle+a*o/2,endAngle:e.endAngle-a*o/2,padAngle:LA(i.padAngle,i.padPixel,Math.hypot(t,n))}}function NA(e,t,n){const i=e.schema.value,o=h.groups(t.map((e,t)=>({d:e,i:t})),e=>n(e.d,e.i)),a=new Map(o.map(([e],t)=>[e,t])),r=t.map((e,t)=>Number(i(e,t))),s=BA(t.map((e,t)=>({slot:a.get(n(e,t)),value:r[t]}))),c=o.map((e,t)=>Math.max(0,...s.filter(e=>e.slot===t).map(e=>e.y1)));return{bySlot:o,values:r,stack:s,tops:c}}function TA(e,t,n){return NA(e,t,n).tops}function OA(e,t){const{width:n,height:a}=ie(e),r=t.rows??e._filteredData??[],s=e.schema.aggs,{bySlot:c,values:l,stack:h,tops:u}=NA(e,r,t.slotOf),d=PA(u.concat(oA(e)),e.schema.levels,e.schema.domain),f=(e=>(Number(e.schema.startAngle)||0)*Math.PI/180)(e),m=FA(c.length,f,t.sweep).map((e,t)=>({...e,key:c[t][0]})),p=$A(e,m.map((e,n)=>{const i=c[n][1].map(e=>e.d);return{key:e.key,text:t.slotLabel(e.key,i),angle:e.angle,data:1===i.length?i[0]:o.merge(i,s)}}),Math.max(0,n-4),Math.max(0,a-4)),g=Math.max(0,p.radius),y=RA(e.schema.innerRadius,g),x=e=>DA(e,d.domain,y,g,t.scale),b={inset:t.slotPadding,padAngle:Number(e.schema.padAngle)||0,padPixel:Number(e.schema.padPixel)||0},_=r.map((e,t)=>{const n=h[t],i=m[n.slot];return{__d3plus__:!0,data:e,i:t,slot:i.key,value:l[t],y0:n.y0,y1:n.y1,arc:EA(i,x(n.y0),x(n.y1),b)}}),k=m.map(e=>EA(e,y,g,b)),v=zA(e,d,g,x,t.key),w=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[];t.trackPaint&&w.push(function(e,t,n,o){return{type:"group",key:`${e}-tracks`,interactive:!1,children:n.map((n,a)=>({type:"path",key:`${e}-track-${t[a].key}`,interactive:!1,d:i.arcPath(n),arc:n,paint:o}))}}(t.key,m,k,t.trackPaint)),w.push(...v.rings,...AA(e,p.labels,t.key),...v.labels);const S={inner:y,outer:g,levels:d,scale:t.scale,slots:m,tracks:k};return e.ctx.polar=S,{wedges:_,frame:S}}function WA(e){const t=e.schema.metric;return"function"==typeof t?(e,n)=>`${t(e,n)}`:(t,n)=>e._ids(t,n).join("-")}const jA=(e,t)=>TA(e,t,WA(e)),HA=({viz:e})=>{const t=e.schema.metric,{wedges:n}=OA(e,{key:"polararea",slotOf:WA(e),slotLabel:(n,i)=>"function"!=typeof t&&i.length?e._drawLabel(i[0],0):n,scale:"linear"===e.schema.radialScale?"linear":"sqrt",slotPadding:0,sweep:2*Math.PI});return{shapeData:n}},IA=({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i="function"==typeof e.schema.metric;return tA(e,n,"polararea",t=>{const n=e._drawLabel(t.data,t.i),o=d.formatAbbreviate(t.value,e.schema.locale);return i?`${n}, ${t.slot}, ${o}.`:`${n}, ${o}.`})},GA={name:"PolarArea",layoutStage:HA,emit:IA,insetRegion:Uu,chartTransform:e=>{const{width:t,height:n}=ie(e);return oe(e,t,n)},chartBodyRect:e=>{const t=e.ctx.polar?.outer??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:aA(jA),ctx:{},fields:[{key:"discrete",default:"metric"},{key:"domain"},{key:"innerRadius",default:0},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"metric",coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):void 0},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"radialScale",default:"sqrt"},{key:"startAngle",default:0},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"legend",coerce:"const",factory:cw},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:J$},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>{const[t,n]=eA(e);return{tbody:[[(n,i)=>{const o=e.schema.metric;return"function"==typeof o?`${o(n,i)}`:t()},n]]}}},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})}]};var VA=xf(GA);const qA=({viz:e})=>{const t=e._filteredData;if(!t)return{shapeData:[]};const i=e.schema.start,a=e.schema.end,r=e._id,s=e.schema.axisConfig,c="time"===s?.scale,l=t.map((e,t)=>({__d3plus__:!0,data:e,end:c?n.date(a(e,t)):a(e,t),i:t,id:r(e,t),start:c?n.date(i(e,t)):i(e,t)})).filter(e=>Number(e.end)-Number(e.start)>0).sort((e,t)=>Number(e.start)-Number(t.start));let u;if(e.schema.groupBy.length>1&&e._drawDepth>0){const t=[];for(let n=0;n<e._drawDepth;n++)t.push(t=>e.schema.groupBy[n](t.data,t.i));u=o.nestGroups(l,t)}else u=[{values:l}];const d=(e=>{let t=0;return e.forEach(e=>{let n=[];e.values.forEach(e=>{n=n.map(t=>!(!1!==t&&t<=e.start)&&t);const i=n.indexOf(!1);i<0?(e.lane=t+n.length,n.push(e.end)):(n[i]=e.end,e.lane=t+i)}),t+=n.length}),t})(u);return((e,t,n)=>{const i={domain:[h.min(t,e=>Number(e.start))??0,h.max(t,e=>Number(e.end))??0],height:e.schema.height-e._margin.top-e._margin.bottom,width:e.schema.width-e._margin.left-e._margin.right},o=e.ctx.axisTest,a=e.ctx.axis;o.config(i).config(e.schema.axisConfig).measure(),a.config(i).config(e.schema.axisConfig).renderMode("compute").select(void 0).render();const r=a.toScene();var s;r&&((s=e)._chartScene||(s._chartScene=[])).push({type:"group",key:"priestley-axis",transform:{x:e._margin.left,y:e._margin.top},children:r.children??[]});const c=B.scaleBand().domain(h.range(0,n,1).map(String)).paddingInner(e.schema.paddingInner).paddingOuter(e.schema.paddingOuter).rangeRound([e.schema.height-e._margin.bottom-o.outerBounds().height-o.schema.padding,e._margin.top+o.schema.padding]);e.ctx.xScale=a._d3Scale,e.ctx.yScale=c,e.ctx.bandWidth=c.bandwidth()})(e,l,d),{shapeData:l}},YA={name:"Priestley",layoutStage:qA,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.xScale,o=e.ctx.yScale,a=e.ctx.bandWidth,s=au(e,"Rect"),c=n.map((t,n)=>{const r=tu(s.fill,t.data,n),c=tu(s.stroke,t.data,n),l=tu(s.strokeWidth,t.data,n),h=`${e._drawLabel(t.data,n)}, ${t.start} - ${t.end}.`,u=Math.abs(i(t.end)-i(t.start)),d=u>2?u-2:u,f=i(t.start)+(i(t.end)-i(t.start))/2-d/2,m=(o(String(t.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${t.id}-${n}`,transform:{x:f,y:m},x:0,y:-a/2,width:d,height:a,datum:t.data,paint:{fill:nu(s,t.data,n,r),stroke:c,strokeWidth:l},aria:{label:h}}}),l=iw({data:n,label:(t,i)=>e._drawLabel(n[i].data,i),x:(e,t)=>{const o=n[t];return i(o.start)+(i(o.end)-i(o.start))/2},y:(e,t)=>(o(String(n[t].lane))??0)+a/2,aes:(e,t)=>{const o=n[t],r=Math.abs(i(o.end)-i(o.start));return{width:r>2?r-2:r,height:a}},rotate:N(0),id:(e,t)=>`priestley-label-${n[t].id}-${t}`,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;return{x:-i/2,y:-o/2,width:i,height:o}},labelConfig:{fontColor:t=>{const n=t.data??t,i=tu(s.fill,n.data,n.i);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:!1,textAnchor:"start",verticalAlign:"top",...ru(e,"Rect")}}),h=qy(s,c,e=>[n[e].data,e]);return[...c,...h,...l]},chartTransform:()=>{},setup:e=>{e.schema.aggs.start||(e.schema.aggs.start=h.min),e.schema.aggs.end||(e.schema.aggs.end=h.max)},ctx:{axis:(new hi).align("end").orient("bottom"),axisTest:(new hi).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"end",default:T("end"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{const n="function"==typeof t?null:t;n&&!e.schema.aggs[n]&&(e.schema.aggs[n]=h.max)}},{key:"start",default:T("start"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{const n="function"==typeof t?null:t;n&&!e.schema.aggs[n]&&(e.schema.aggs[n]=h.min)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e.schema.start(t,n),o=e.schema.end(t,n);return`${e._drawLabel(t,n)}, ${i} - ${o}.`}})}]};var KA=xf(YA);function UA(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function XA(e,t,n){const i=Array.isArray(n)?n.map(String):[];return e.forEach((e,n)=>{const o=`${t(e,n)}`;i.includes(o)||i.push(o)}),i}function QA(e,t){return e.length>0&&`${t}`===e[0]?-1:1}function ZA(e,t){return e.reduce((e,n,i)=>e+(UA(t(n,i))??0),0)}function JA(e,t,n){const i=new Map;return e.forEach((e,o)=>{const a=`${n(e,o)}`;i.set(a,(i.get(a)??0)+(UA(t(e,o))??0))}),i}function ez(e,t){const{category:n,side:i,value:o,comparison:a,frame:r}=t,s=new Map,c=new Map;return e.forEach((e,t)=>{const l=`${r?r(e,t):""}\0${n(e,t)}\0${i(e,t)}`;s.set(l,(s.get(l)??0)+Math.abs(UA(o(e,t))??0)),a&&c.set(l,(c.get(l)??0)+Math.abs(UA(a(e,t))??0))}),Math.max(0,...s.values(),...c.values())}function tz(e){return e>0?[-e,e]:[-1,1]}function nz(e,t=0){const n=Math.abs(e);return n<=2*t?0:n}function iz(e,t=()=>0){return n=>e("number"==typeof n?nz(n,t()):n)}function oz(e,t,n){const i=e.slice().sort((e,t)=>e.y-t.y);if(!i.length)return[];const o=n/2,a=[[t,i[0].y-o]];for(const e of i)a.push([e.x,e.y-o],[e.x,e.y+o]);return a.push([t,i[i.length-1].y+o]),a}function az(e,t){const n=Array.from(new Set(e)).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);return Number.isFinite(i)?i:t}function rz(e){return Array.isArray(e)?e.map(Number):"string"==typeof e&&e.trim()?e.trim().split(/[\s,]+/).map(Number):"number"==typeof e?[e]:void 0}function sz(e,t,n){return"function"==typeof e?e(t,n):e}function cz(e,t){const{left:n,right:i,top:o,height:a}=t,r=[[n,f.clamp(t.inner[0],n,i)],[f.clamp(t.inner[1],n,i),i]];return e.slice(0,2).map((e,t)=>({text:e,x:r[t][0],y:o,width:Math.max(0,r[t][1]-r[t][0]),height:a}))}function lz(e,t,n){const i=e.slice(),o=i.findIndex(e=>e.key===bx);if(o>=0&&t.length){const e=i[o];"group"===e.type&&(i[o]={...e,children:[...e.children,...t]})}else i.push(...t);return i.push(...n),i}function hz(e,t){const n=e._xFunc,i=e._yFunc,o=e._plotArea;if(!(n&&i&&o&&e._filteredData?.length))return{outlines:[],overlays:[]};const a=t.comparison?function(e){const{sides:t,categories:n,data:i,category:o,side:a,comparison:r,divisor:s,x:c,y:l,fallbackStep:h,config:u}=e,d=e.inset??0,f=az(n.map(e=>l(e)),h);return t.flatMap((e,h)=>{const m=new Map;if(i.forEach((t,n)=>{if(`${a(t,n)}`!==e)return;const i=UA(r(t,n));if(void 0===i)return;const c=`${o(t,n)}`;m.set(c,(m.get(c)??0)+Math.abs(i)/(s||1))}),!m.size)return[];const p=QA(t,e),g=c(p*d),y=n.map(e=>({y:l(e),x:c(p*((m.get(`${e}`)??0)+d))})),x={fill:"none",stroke:sz(u.stroke,e,h),strokeWidth:sz(u.strokeWidth,e,h),strokeOpacity:sz(u.strokeOpacity,e,h)},b=rz(sz(u.strokeDasharray,e,h));return b&&(x.strokeDasharray=b),[{type:"line",key:`pyramid-comparison-${h}`,points:oz(y,g,f),curve:"linear",paint:x,interactive:!1,interactionGroup:"axis"}]})}({sides:t.sides,categories:e._yAxis?.domain()??[],data:e._filteredData,category:e._y,side:t.side,comparison:t.comparison,divisor:t.divisor,x:n,y:i,fallbackStep:o.height,config:e.schema.comparisonConfig,inset:t.inset}):[],r=[n(-t.inset),n(t.inset)],s=e._plotInsetTop??0,c=t.showTitles&&s>0?function(e,t,n){return e.renderMode("compute").select(void 0).data(t.map((e,t)=>({...e,id:`pyramid-side-${t}`}))).config(n).render(),[{type:"group",key:"pyramid-side-titles",interactionGroup:"axis",children:e.toScene().children??[]}]}(t.titleBox,cz(t.labels,{left:o.x,right:o.x+o.width,inner:r,top:e._margin.top-(e._chartTransform?.y??e._margin.top),height:s}),{...e.schema.fontFamily?{fontFamily:e.schema.fontFamily}:{},...e.schema.sideTitleConfig}):[];return{outlines:a,overlays:[...t.gutter?t.gutter(r):[],...c]}}function uz(e,t,n){const{outlines:i,overlays:o}=hz(e,n);return function(e,t,n){if(!t.length&&!n.length)return e;const i=e.root.children.find(e=>"viz-chart-cells"===e.key),o=i&&"children"in i?i.children.find(e=>"viz-zoom"===e.key):void 0,a=o&&"children"in o?o.children.find(e=>"viz-chart-body"===e.key):void 0;return a&&"group"===a.type?(a.children=lz(a.children,t,n),e):e}(t,i,o)}function dz(e){return 1e-9*(e>0?e:1)}function fz(e){return(t,n)=>{Lp(t,n);const i=e();if(i)for(const e of t)for(const t of e){const e=t[0]<0?-i:i;t[0]+=e,t[1]+=e}}}function mz(e,t,n){const i=i=>{const o=e[i];return"function"==typeof o?o(t,n):o},o=i("fontFamily")??a.fontFamily;return{family:a.fontFamilyStringify(o),size:Number(i("fontSize"))||12,weight:i("fontWeight")??400,padding:Number(i("padding"))||0}}function pz(e,t,i=n.textWidth){let o=0,a=0;return e.forEach((e,n)=>{const r=t[n],s=i(e,{"font-family":r.family,"font-size":r.size,"font-weight":r.weight});o=Math.max(o,s),a=Math.max(a,r.padding)}),Math.ceil(o+2*a)}function gz(e,t){const n=e.map(()=>!1);let i;e.forEach((e,o)=>{(void 0===i||Math.abs(e-i)>=t)&&(n[o]=!0,i=e)});const o=e.length-1;if(o>0&&!n[o]){n[o]=!0;for(let i=o-1;i>=0&&Math.abs(e[o]-e[i])<t;i--)n[i]=!1}return n}function yz(e){return{...e._yAxis?.shapeConfig()?.labelConfig??{},...e._yConfig?.shapeConfig?.labelConfig??{}}}function xz(e,t){const n=e._yConfig?.tickFormat;return"function"==typeof n?`${n(t)}`:`${t}`}const bz=e=>1.2*e.size+2*e.padding;function _z(e,t,n,i,o){if("center"!==e)return{x:{...o.x},y:{...o.y}};return{x:{break:[[-t,t],...Array.isArray(i)?Array.isArray(i[0])?i:[i]:[]],breakConfig:{gap:n,lines:!1,mask:!1,size:0,space:n,stroke:"transparent"}},y:{barConfig:{stroke:"transparent"},tickSize:0,ticks:[]}}}const kz=new WeakMap,vz=e=>e.ctx.pyramid,wz=e=>e.schema.groupBy[0],Sz=(e,t)=>`${d.formatAbbreviate(100*t,e.schema.locale)}%`;function Cz(e){const t=vz(e),n=function(e){return(t,n)=>{const i=vz(e),o=i.value(t,n),a=UA(o);if(void 0===a)return o;const r=e.schema.percent?i.total?Math.abs(a)/i.total:0:Math.abs(a);return QA(i.sides,wz(e)(t,n))*r}}(e);t.value=e._x,Object.defineProperty(e,"_x",{configurable:!0,enumerable:!0,get:()=>n,set:e=>{e!==n&&(t.value=e)}})}function Mz(e,t){const n=e._xConfig,i=n.tickFormat;void 0===i||i===t.tickFormat?(n.tickFormat=t.tickFormat=iz(function(e){return e.schema.percent?t=>Sz(e,t):t=>d.formatAbbreviate(t,e.schema.locale)}(e),()=>t.inset),t.wrapped.add(n.tickFormat)):"function"!=typeof i||t.wrapped.has(i)||(n.tickFormat=iz(i,()=>t.inset),t.wrapped.add(n.tickFormat))}function $z(e,t,n){const i=e._xConfig,o=void 0!==i.domain&&(a=i.domain,r=t.domain,Array.isArray(a)&&Array.isArray(r)&&a.length===r.length&&a.every((e,t)=>e===r[t]));var a,r;if(void 0!==i.domain&&!o)return;if(!e.schema.symmetric||Sf(e,"x"))return o&&delete i.domain,void(t.domain=void 0);i.domain=t.domain=tz(n+t.inset);const s=e._plotAxisDefaults??{};e._plotAxisDefaults={...s,x:{...s.x,rounding:"outside"}}}function Az(e,t,n){var i;const o=e.schema.categoryPosition;(i=t).restore??(i.restore=function(e){return{y:{barConfig:{...e._yAxis.barConfig()},tickSize:e._yAxis.tickSize()},x:{breakConfig:{...e._xAxis.breakConfig()}}}}(e));const a="center"===o;t.inset=a?dz(n):0;let r=0;if(a){const t=function(e){const t=e._y;return Array.from(new Set(e._data.map((e,n)=>t(e,n))))}(e),n=yz(e),i=t.map((e,t)=>mz(n,e,t));r=pz(t.map(t=>xz(e,t)),i)}e._plotAxisDefaults=_z(o,t.inset,r,e.schema.xBreak,t.restore)}function zz(e){const t=vz(e);t.sides=XA(e._data,wz(e),e.schema.sides);const n=e._legendData||e._filteredData||[];t.total=ZA(n,t.value);const i=e.schema.comparison;t.comparisonTotal=i?ZA(n,i):0,Mz(e,t);const o=function(e,t){const n=!!e._axisPersist,i=n?e._data:e._filteredData,o=n&&e.schema.time?e.schema.time:void 0,a=(t,n)=>{if(!e.schema.percent)return t;const a=o?JA(i,t,o):void 0;return(e,i)=>{const r=a?a.get(`${o(e,i)}`)??0:n,s=UA(t(e,i));return void 0!==s&&r?s/r:0}},r=e.schema.comparison;return ez(i,{category:e._y,side:wz(e),value:a(t.value,t.total),comparison:r?a(r,t.comparisonTotal):void 0,frame:o})}(e,t);Az(e,t,o),$z(e,t,o),function(e,t){const n=e._xConfig,i=e._xTitle;e.schema.percent?void 0!==n.title&&n.title!==i&&n.title!==t.title||(n.title=t.title=e.schema.translate("Percent of Total")):void 0!==t.title&&(n.title===t.title&&(n.title=i),t.title=void 0)}(e,t),e._plotInsetTop=function(e){if(!e.schema.sideTitles)return 0;const t=e.schema.sideTitleConfig,n="number"==typeof t.fontSize?t.fontSize:14,i="number"==typeof t.padding?t.padding:0;return Math.ceil(1.2*n+2*i)}(e)}function Dz(e,t){const n=wz(e);return t.map(t=>{const i=e._data.findIndex((e,i)=>`${n(e,i)}`===t);return i>=0?e._drawLabel(e._data[i],i,0):t})}function Fz(e){const t=vz(e);return{sides:t.sides,labels:Dz(e,t.sides),side:wz(e),comparison:e.schema.comparison,divisor:e.schema.percent?t.comparisonTotal:1,titleBox:t.titleBox,showTitles:!!e.schema.sideTitles,inset:t.inset,gutter:t.inset?n=>function(e,t,n){const i=e._yFunc,[o,a]=n;if(!(i&&e._yAxis&&a>o))return[];const r=e._yAxis.domain()??[],s=yz(e),c=r.map(e=>i(e)),l=r.map((e,t)=>mz(s,e,t)),h=gz(c,Math.max(0,...l.map(bz))),u=az(c,e._plotArea?.height??0);return function(e,t,n){return e.renderMode("compute").select(void 0).data(t).config({fontColor:n,fontFamily:e=>e.font.family,fontSize:e=>e.font.size,fontWeight:e=>e.font.weight,textAnchor:"middle",verticalAlign:"middle"}).render(),[{type:"group",key:"pyramid-categories",interactionGroup:"axis",children:e.toScene().children??[]}]}(t,r.flatMap((t,n)=>{if(!h[n])return[];const i=Math.max(u,1.5*l[n].size);return[{id:`pyramid-category-${n}`,text:xz(e,t),x:o,y:c[n]-i/2,width:a-o,height:i,font:l[n]}]}),"string"==typeof s.fontColor?s.fontColor:Ga(e))}(e,t.labelBox,n):void 0}}const Bz={name:"Pyramid",paintDriven:!0,thresholdFunction:(e,t)=>t,defaults:{groupPadding:1},setup:e=>{e.ctx.pyramid={value:e._x,sides:[],total:0,comparisonTotal:0,wrapped:new WeakSet,titleBox:new ro,inset:0,labelBox:new ro},Cz(e),e._stackOffset=fz(()=>vz(e).inset),e._stackGroup=()=>"group",e._stackOrder=hM((t,n)=>e._ids(t,n).slice(1,e._drawDepth+1).join("_")),e.schema.color=(t,n)=>{const i=e.schema.groupBy;return i[Math.max(0,Math.min(e._drawDepth??0,i.length-1))](t,n)},e.schema.shapeConfig.Bar={...e.schema.shapeConfig.Bar,label:!1},e.schema.shapeConfig.ariaLabel=(t,n)=>{const i=e._xConfig.tickFormat;return`${e._drawLabel(t,n)}, ${e._y(t,n)}: ${i(e._x(t,n))}.`};const t=e._preDraw.bind(e);e._preDraw=()=>{t(),zz(e)}},decorateScene:(e,t)=>e._facetPanels?t:uz(e,t,Fz(e)),facet:{scene:(e,t)=>function(e,t,n){const{outlines:i,overlays:o}=hz(e,n);return i.length||o.length?lz(t,i,o):t}(e,t,Fz(e))},ctx:{},fields:[{key:"baselineBreak",default:!1},{key:"categoryPosition",default:"center"},{key:"comparison",coerce:e=>{if("string"!=typeof e)return e||void 0;const t=Be(e);return kz.set(t,e),t}},{key:"comparisonConfig",merge:!0,factory:e=>({stroke:()=>Ga(e),strokeDasharray:"4 3",strokeOpacity:1,strokeWidth:1.5})},{key:"discrete",default:"y"},{key:"percent",default:!1},{key:"sideTitles",default:!0},{key:"sideTitleConfig",merge:!0,factory:e=>({fontColor:()=>Ga(e),fontSize:14,fontWeight:600,padding:2,textAnchor:"middle",verticalAlign:"middle"})},{key:"sides"},{key:"stacked",default:!0},{key:"symmetric",default:!0},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>function(e,t,n){const i=vz(e),o=UA(i.value(t,n));if(void 0===o)return[];const a=[],r=!!e.schema.percent;if(r){const t=e._xKey;a.push(["string"==typeof t?t:e.schema.translate("Value"),d.formatAbbreviate(Math.abs(o),e.schema.locale)])}else i.total&&a.push([e.schema.translate("Percent of Total"),Sz(e,Math.abs(o)/i.total)]);const s=e.schema.comparison,c=s?UA(s(t,n)):void 0;if(s&&void 0!==c){const t=kz.get(s)??e.schema.translate("Comparison");a.push([t,r?Sz(e,i.comparisonTotal?Math.abs(c)/i.comparisonTotal:0):d.formatAbbreviate(Math.abs(c),e.schema.locale)])}return a}(e,t,n)})}]};var Lz=xf(Bz,Sb);const Pz=2*Math.PI,Rz=({viz:e})=>{const{width:i,height:r}=ie(e),s=e.schema.metric,c=e.schema.value,l=e._filteredData,u=h.groups(l,s),d=h.groups(l,e._id,s),f=d.flatMap(([,e])=>e.map(([,e])=>h.sum(e,(e,t)=>c(e,t)))),m=lA(f,e.schema.levels),{domain:p}=m;if(!f.length||p[0]===p[1])return e.ctx.groupData=[],e.ctx.pathConfig={},{shapeData:[]};const{radius:g,polarAxis:y}=function(e,t,i,r){const s=t.length,c=e.schema.aggs,l=e.schema.outerPadding,h=t.map(([t,n],i)=>{const a=o.merge(n,c),r=gA(e,String(t),a,i);return{key:t,data:a,font:r,text:String(t),angle:pA/s*i,lineHeight:r.lineHeight}});let u,d;if("number"==typeof l)u=Math.max(0,Math.min(i,r)/2-l),d=h.map(()=>({wrapWidth:l}));else{const e=cA({labels:h,width:i-4,height:r-4,measure:({text:e,font:t})=>n.textWidth(e,{"font-family":t.fontFamily,"font-size":t.fontSize,"font-weight":t.fontWeight}),wrap:({text:e,font:t},n,i)=>a.textWrap().fontFamily(t.fontFamily).fontSize(t.fontSize).fontWeight(t.fontWeight).lineHeight(t.lineHeight).width(n).height(t.lineHeight*i).maxLines(i)(e)});u=e.radius,d=e.labels}const f=h.map(({key:e,data:t,font:n,angle:i},o)=>{const a=2*n.lineHeight,r=d[o].wrapWidth,c=parseInt(String(360-360/s*o/90),10)%4+1;let l=360/s*o,h="start",f=10;return 2!==c&&3!==c||(f=-r-10,h="end",l+=180),{__d3plus__:!0,data:t,i:o,id:e,key:e,angle:l,textAnchor:h,labelBounds:{x:f,y:-a/2,width:r,height:a},rotateAnchor:[-f,a/2],x:u*Math.cos(i),y:u*Math.sin(i)}}).sort((e,t)=>Number(e.key)-Number(t.key));return{radius:u,polarAxis:f}}(e,u,i,r);(Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[]).push(...yA(e,m,g),...function(e,t){const n=e.schema.axisConfig,i=[],o=iw({data:t,label:e=>e.id,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.angle||0,id:e=>e.id,labelBounds:e=>e.labelBounds,labelConfig:n.shapeConfig?.labelConfig??{}});o.length&&i.push({type:"group",key:"radar-axis-labels",children:o});const a=au(e,"Path",n.shapeConfig??{}),r=t.map((e,t)=>({type:"path",key:`radar-spoke-${e.id}`,interactive:!1,d:`M0,0 ${e.x},${e.y}`,paint:iu(a,e,t)}));return r.length&&i.push({type:"group",key:"radar-axis-spokes",interactive:!1,children:r}),i}(e,y),...xA(e,m,g));const x=u.length,b=d.map(([t,n])=>{const i=n.map(([,e],t)=>{const n=hA(h.sum(e,(e,t)=>c(e,t)),p,g),i=Pz/x*t;return{x:n*Math.cos(i),y:n*Math.sin(i)}}),a=`M ${i[0].x} ${i[0].y} ${i.map(e=>`L ${e.x} ${e.y}`).join(" ")} L ${i[0].x} ${i[0].y}`,r=e.schema.aggs;return{__d3plus__:!0,arr:n.map(([,e])=>o.merge(e,r)),id:t,points:i,d:a,data:o.merge(n.map(([,e])=>o.merge(e,r)),r)}}),_=((e,n,i)=>{const o=au(e,"Path"),a=Object.keys(o.on??{});o.on={};for(const r of a)o.on[r]=(o,a,s,c)=>{const l=o.points.map(e=>e.x+n/2),u=o.points.map(e=>e.y+i/2),d=t.pointer(c,e._select.node()),f=l.map(e=>Math.abs(e-d[0])),m=u.map(e=>Math.abs(e-d[1])),p=f.map((e,t)=>e+m[t]);e.schema.on[r].call(e,o.arr[p.indexOf(h.min(p))],a,s,c)};return o})(e,i,r);return e.ctx.groupData=b,e.ctx.pathConfig=_,{shapeData:b}},Ez={name:"Radar",layoutStage:Rz,emit:({viz:e})=>{const t=e.ctx.groupData,n=e.ctx.pathConfig;if(!t||!n||!t.length)return[];const i=[];for(let o=0;o<t.length;o++){const a=t[o],r=a.data??a,s=iu(n,r,o);i.push({type:"path",key:`radar-${a.id}`,d:a.d,datum:r,paint:s,aria:{label:`${e._drawLabel(r,o)}.`}})}const o=qy(n,i,e=>[t[e].data??t[e],e]);return[...i,...o]},chartTransform:e=>{const{width:t,height:n}=ie(e);return oe(e,t,n)},chartBodyRect:e=>{const{width:t,height:n}=ie(e);return{x:-t/2,y:-n/2,width:t,height:n}},facet:{aspect:1},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabelConfig",default:{},merge:!0},{key:"levelLabels",default:!0},{key:"levels",default:6},{key:"metric",default:T("metric"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"outerPadding",default:"auto"},{key:"shape",default:N("Path"),coerce:"const"},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"axisConfig",merge:!0,factory:e=>({barConfig:{stroke:()=>Ga(e),strokeWidth:1},gridConfig:{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),strokeWidth:1},shapeConfig:{fill:N("none"),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ga(e),strokeWidth:N(1)}})}]};var Nz=xf(Ez);function Tz(e,t,n,i){const o=Math.max(0,Math.floor(e));if(!(o&&n>t))return[];const a=(n-t)/o,r=Math.max(0,Math.min(.95,i));return Array.from({length:o},(e,t)=>{const i=n-t*a;return{inner:i-a*(1-r),outer:i}})}function Oz(e,t,n,i=0){if(!(e>0&&t>0))return 0;let o=t;return n<Math.PI/2&&(o=Math.min(o,e*Math.tan(Math.max(0,n)))),Math.max(0,o-i)}function Wz(e,t,n){const i=Math.sin(e),o=-Math.cos(e),a=i-n*Math.cos(e),r=o-n*Math.sin(e);return Ub(Kb(e,t),{x0:Math.min(i,a),x1:Math.max(i,a),y0:Math.min(o,r),y1:Math.max(o,r)})}const jz=(e,t)=>tu((e.schema.axisConfig.shapeConfig?.labelConfig??{}).fontColor,t,0)??Ga(e);function Hz(e){const t=Number(e.schema.maxAngle??270)||270;return Math.max(1,Math.min(360,t))*Math.PI/180}const Iz=Math.PI/6;function Gz(e){return 2*Math.PI-Hz(e)>=Iz-1e-9}function Vz(e,t,i){const o=function(e,t){const n=e.schema.axisConfig.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?Math.min(n,.9*t):Math.max(8,Math.min(14,.6*t))}(e,i);return t.map((t,i)=>{const a=e._drawLabel(t,i),r=gA(e,a,t,i),s=n.textWidth(a,{"font-family":r.fontFamily,"font-size":o,"font-weight":r.fontWeight});return{d:t,i:i,text:a,font:r,size:o,width:s}})}function qz(e,t){const{width:o,height:a}=ie(e),r=e.schema.value,s=t.map((e,t)=>Number(r(e,t))),c=(Number(e.schema.startAngle)||0)*Math.PI/180,l=c+Hz(e),h=Gz(e),u=e.schema.ticks,d="number"==typeof u?u:Vb(c,l),f=Gb(s.concat(oA(e)),[],e.schema.domain,d),m=qb(f,u,!1,d).major,p=e=>Ib(e,f,c,l),g=function(e,t,i){const o=e.schema.tickFormat,a={},r=t.map((t,r)=>{const s=`${o(t)}`,c=gA(e,s,a,r),l={"font-family":c.fontFamily,"font-size":c.fontSize,"font-weight":c.fontWeight};return{t:t,text:s,font:c,angle:i(t),width:n.textWidth(s,l)}}),s=jz(e,a);return{margin:r.length?Math.max(...r.map(e=>Math.max(e.width,e.font.fontSize)))+6:0,nodes:e=>{const t=r.map(t=>_A(t.angle,e,t.width,t.font.fontSize)),n=t.length,i=n>1&&wA(t[0],t[n-1])?n-1:n;return r.slice(0,i).map((e,n)=>{const i=t[n];return{type:"text",key:`radialbar-tick-${n}`,interactive:!1,x:0,y:0,transform:{x:i.x+i.width/2,y:i.y+i.height/2},lines:[{text:e.text,x:0,y:0,width:e.width}],font:{family:e.font.fontFamily,size:e.font.fontSize,weight:e.font.fontWeight,anchor:"middle",baseline:"middle"},paint:{fill:s}}})}}}(e,m,p),{outer:y,cx:x,cy:b}=function(e,t,n){const{width:i,height:o,margin:a,start:r,end:s}=n,c=Math.max(0,i-2*a),l=Math.max(0,o-2*a),h=Number(e.schema.trackPadding)||0,u=e=>Xb(c,l,Wz(r,s,e));let d=u(0);for(let n=0;n<2&&t.length&&d.radius>0;n++){const n=RA(e.schema.innerRadius,d.radius),i=Tz(t.length,n,d.radius,h)[0];d=u((Math.max(0,...Vz(e,t,i.outer-i.inner).map(e=>e.width))+6)/d.radius)}return{outer:d.radius,cx:d.cx-c/2,cy:d.cy-l/2}}(e,h?t:[],{width:Math.max(0,o-4),height:Math.max(0,a-4),margin:g.margin,start:c,end:l}),_=RA(e.schema.innerRadius,y),k={inner:_,outer:y,domain:f,start:c,end:l,ticks:m,cx:x,cy:b},v=Tz(t.length,_,y,Number(e.schema.trackPadding)||0),w=p(Math.max(f[0],Math.min(f[1],0))),S=t.map((t,n)=>{const i=p(s[n]);return{__d3plus__:!0,data:t,i:n,slot:e._ids(t,n).join("-"),value:s[n],y0:0,y1:s[n],arc:{innerRadius:v[n].inner,outerRadius:v[n].outer,startAngle:Math.min(w,i),endAngle:Math.max(w,i)}}}),C=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[];return!1!==e.schema.track&&C.push(function(e,t,n,o){const a=e.schema.trackConfig??{};return{type:"group",key:"radialbar-tracks",interactive:!1,children:t.map((t,r)=>{const s={innerRadius:n[r].inner,outerRadius:n[r].outer,startAngle:o.start,endAngle:o.end};return{type:"path",key:`radialbar-track-${e._ids(t,r).join("-")}`,interactive:!1,d:i.arcPath(s),arc:s,paint:iu(a,t,r)}})}}(e,t,v,k)),C.push(...function(e,t,n){const i=dA({},e.schema.axisConfig.gridConfig),o=t.ticks.map((e,o)=>{const a=n(e),[r,s]=[Math.sin(a),-Math.cos(a)];return{type:"path",key:`radialbar-grid-${o}`,interactive:!1,d:`M${t.inner*r},${t.inner*s}L${t.outer*r},${t.outer*s}`,paint:mA(i,{value:e,r:t.outer},o)}});return o.length?[{type:"group",key:"radialbar-grid",interactive:!1,children:o}]:[]}(e,k,p)),m.length&&C.push({type:"group",key:"radialbar-ticks",interactive:!1,children:g.nodes(y)}),h&&C.push(...function(e,t,n,i){const o=2*Math.PI-(n.end-n.start),a=i.length?i[0].outer-i[0].inner:0,r=[];if(Vz(e,t,a).forEach(({d:t,i:a,text:s,font:c,size:l})=>{const h=i[a],u=(h.inner+h.outer)/2,d=Oz(u,n.outer,o,6);if(l<6||d<2*l)return;const f=C_(s,c.fontFamily,l,d,6,c.fontWeight);r.push({type:"text",key:`radialbar-label-${e._ids(t,a).join("-")}`,interactive:!1,x:0,y:0,transform:{x:-6,y:-u},lines:[{text:f.text,x:0,y:0,width:f.width}],font:{family:c.fontFamily,size:f.size,weight:c.fontWeight,anchor:"end",baseline:"middle"},paint:{fill:jz(e,t)}})}),!r.length)return[];const s=180*n.start/Math.PI;return[{type:"group",key:"radialbar-labels",interactive:!1,transform:s?{rotate:s}:void 0,children:r}]}(e,t,k,v)),e.ctx.polar=k,{wedges:S,frame:k}}function Yz(e){const t=(e._filteredData??[]).slice(),n=e.schema.sort;return"function"==typeof n?t.sort(n):t}const Kz=e=>(t,n)=>e._ids(t,n).join("-"),Uz=(e,t)=>{if("angle"===e.schema.discrete)return TA(e,t,Kz(e));const n=e.schema.value;return t.map((e,t)=>Number(n(e,t)))},Xz=({viz:e})=>{const t=Yz(e);if("angle"===e.schema.discrete){const n=Number(e.schema.maxAngle??360)||360,i=e.schema.trackConfig??{},{wedges:o}=OA(e,{key:"radialbar",rows:t,slotOf:Kz(e),slotLabel:(t,n)=>n.length?e._drawLabel(n[0],0):"",scale:"linear",slotPadding:Number(e.schema.trackPadding)||0,sweep:Math.max(1,Math.min(360,n))*Math.PI/180,trackPaint:!1!==e.schema.track&&t.length?iu(i,t[0],0):void 0});return{shapeData:o}}const{wedges:n}=qz(e,t);return{shapeData:n}},Qz=({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o="angle"===e.schema.discrete,a=e.ctx.polar;return[...n.map((t,n)=>{const r=o?{...a.tracks[n],padAngle:0}:{innerRadius:t.arc.innerRadius,outerRadius:t.arc.outerRadius,startAngle:a.start,endAngle:a.end};return{type:"path",key:`radialbar-${e._ids(t.data,t.i).join("-")}-${t.slot}::hit`,d:i.arcPath(r),datum:t.data,index:t.i,paint:{fill:"transparent"}}}),...tA(e,n,"radialbar",t=>`${e._drawLabel(t.data,t.i)}, ${d.formatAbbreviate(t.value,e.schema.locale)}.`)]},Zz={name:"RadialBar",layoutStage:Xz,emit:Qz,insetRegion:Uu,chartTransform:e=>{const{width:t,height:n}=ie(e),i=oe(e,t,n),o=e.ctx.polar;return{x:(i.x??0)+(o?.cx??0),y:(i.y??0)+(o?.cy??0)}},chartBodyRect:e=>{const t=e.ctx.polar?.outer??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:aA(Uz),ctx:{},fields:[{key:"discrete",default:"radius"},{key:"domain"},{key:"innerRadius",default:e=>e/4},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"maxAngle"},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"sort",factory:e=>(t,n)=>{const i=e.schema.value;return i(n)-i(t)}},{key:"startAngle",default:0},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"track",default:!0},{key:"trackPadding",default:.25},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"legend",coerce:"const",factory:e=>cw(e,e=>"angle"===e.schema.discrete||Gz(e))},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:e=>G(J$(e),{gridConfig:{stroke:()=>!1===e.schema.track?Zn(e._select?.node(),e.schema.colorDefaults):n.backgroundColor(e._select?.node())}})},{key:"trackConfig",merge:!0,factory:e=>({fill:()=>xS(e).track})},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[eA(e)]})}]};var Jz=xf(Zz);const eD=2*Math.PI,tD=({viz:e})=>{const{rowValues:t,columnValues:n,shapeData:i}=xM.bind(e)(e._filteredData),{width:o,height:a}=ie(e);if(!t.length||!n.length)return e.ctx.radialMatrixWidth=o,e.ctx.radialMatrixHeight=a,{shapeData:[]};e.ctx.radialMatrixWidth=o,e.ctx.radialMatrixHeight=a;const r=100,s=(h.min([a-100,o-200])??0)/2,c=n.slice().reverse();c.unshift(c.pop());const l=c.length,u=c.map((e,t)=>{const n=t/l*eD,i=Math.round(180*n/Math.PI),o=Math.floor((i+90)/90%4+1),a=[0,180].includes(i)?-50:[2,3].includes(o)?-100:0,r=[90,270].includes(i)?-25:[2,1].includes(o)?-50:0;return{key:e,angle:i,quadrant:o,radians:n,x:s*Math.sin(n+Math.PI)+a,y:s*Math.cos(n+Math.PI)+r}}),d=e.schema.columnConfig;((e,t,n,i,o)=>{const a=e.ctx.columnLabels;a.renderMode("compute").select(void 0).data(t).x(e=>e.x).y(e=>e.y).text(e=>e.key).width(n).height(i).config(o).render();const r=a.toScene();var s;r&&((s=e)._chartScene||(s._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:r.children??[]})})(e,d.labels instanceof Array?u.filter(e=>d.labels.includes(e.key)):u,r,50,d.shapeConfig?.labelConfig);const f=(0,e.schema.innerRadius)(s),m=(s-f)/t.length,p=u.length>1?u[1].radians-u[0].radians:eD,g=t.slice().reverse(),y=new Map;g.forEach((e,t)=>y.set(e,t));const x=new Map;n.forEach((e,t)=>x.set(e,t));const b=e.schema.cellPadding,_=L.arc().padAngle(b/s).innerRadius(e=>f+(y.get(e.row)??0)*m+b/2).outerRadius(e=>f+((y.get(e.row)??0)+1)*m-b/2).startAngle(e=>u[x.get(e.column)??0].radians-p/2).endAngle(e=>u[x.get(e.column)??0].radians+p/2);return e.ctx.arcData=_,{shapeData:i}},nD=(e,t)=>`${e}`.localeCompare(`${t}`),iD={name:"RadialMatrix",layoutStage:tD,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.arcData,o=au(e,"Path"),a=e.schema.colorScale,r=n.map((t,n)=>{const r=tu(o.fill,t,n),s=tu(o.stroke,t,n),c=tu(o.strokeWidth,t,n),l=a?`, ${a(t.data??t,n)}`:"";return{type:"path",key:`rm-${e._ids(t,n).join("-")}`,d:i(t),datum:t,paint:{fill:nu(o,t,n,r),stroke:s,strokeWidth:c},aria:{label:`${t.row}, ${t.column}${l}.`}}});return[...r,...qy(o,r,e=>[n[e],e])]},chartTransform:e=>oe(e,e.ctx.radialMatrixWidth,e.ctx.radialMatrixHeight),chartBodyRect:e=>{const t=e.ctx.radialMatrixWidth??0,n=e.ctx.radialMatrixHeight??0;return{x:-t/2,y:-n/2,width:t,height:n}},setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),Ra(o)||Ra(n))return;const r=ze.bind(e)("row",n,i),s=ze.bind(e)("column",n,i);e.hover((t,n)=>ze.bind(e)("row",t,n)===r||ze.bind(e)("column",t,n)===s)}},facet:{aspect:1},ctx:{columnLabels:new ro},fields:[{key:"cellPadding",default:2},{key:"column",default:T("column"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"row",default:T("row"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:nD},{key:"rowSort",default:nD},{key:"innerRadius",default:e=>e/5,coerce:e=>"function"==typeof e?e:N(e)},{key:"columnConfig",merge:!0,factory:e=>({shapeConfig:{labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},padding:5,textAnchor:e=>[0,180].includes(e.angle)?"middle":[2,3].includes(e.quadrant)?"end":"start",verticalAlign:e=>[90,270].includes(e.angle)?"middle":[2,1].includes(e.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:e=>(t,n)=>`${ze.bind(e)("row",t,n)} / ${ze.bind(e)("column",t,n)}`}]};var oD=xf(iD);function aD(e,t={}){const n=e.filter(e=>Number.isFinite(e)).sort((e,t)=>e-t);if(!n.length)return null;const i=f.kernelDensity(n,t);return{values:n,n:n.length,min:n[0],q1:h.quantileSorted(n,.25),median:h.quantileSorted(n,.5),q3:h.quantileSorted(n,.75),max:n[n.length-1],mean:h.mean(n),curve:i,peak:i.reduce((e,t)=>Math.max(e,t[1]),0)}}function rD(e,t){const n=new Map;e.forEach((e,i)=>{if(!e)return;const o=t.value(e,i),a=null==o||""===o?NaN:Number(o);if(!Number.isFinite(a))return;const r=t.key(e,i);let s=n.get(r);s||n.set(r,s={first:e,rows:[],values:[]}),s.rows.push(e),s.values.push(a)});const i=[];return n.forEach((e,n)=>{const o=aD(e.values,t.density);o&&i.push({key:n,first:e.first,summary:{...o,rows:e.rows,observed:e.values}})}),i}function sD(e,t="area"){if("width"===t)return e=>e.peak>0?1/e.peak:0;if("count"===t){const t=e.reduce((e,t)=>Math.max(e,t.peak*t.n),0);return e=>t>0?e.n/t:0}const n=e.reduce((e,t)=>Math.max(e,t.peak),0);return()=>n>0?1/n:0}function cD(e,t){const n=e.slice();if("ascending"!==t&&"descending"!==t)return n;const i="ascending"===t?1:-1;return n.map((e,t)=>({g:e,i:t})).sort((e,t)=>i*(e.g.summary.median-t.g.summary.median)||e.i-t.i).map(({g:e})=>e)}function lD(e,t){if(!e.length||t<e[0][0]||t>e[e.length-1][0])return 0;let n=0,i=e.length-1;for(;i-n>1;){const o=n+i>>1;e[o][0]<=t?n=o:i=o}const[o,a]=e[n],[r,s]=e[i];return r===o?Math.max(a,s):a+(s-a)*(t-o)/(r-o)}const hD="__d3plusDensity";function uD(e){for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function dD(e){const t=uD(e);return t?t[hD]:void 0}function fD(e){return`density-${e.id}`}function mD(e){const t=e.schema.groupBy,n=[e.schema.facet,e.schema.time].filter(Boolean);return(e,i)=>[...t,...n].map(t=>`${t(e,i)}`).join("\0")}function pD(e){const t=e.ctx.density;e._data!==t.rows&&(t.raw=e._data),e._sourceData=t.raw;const n=t.layout.valueAxis(e),i="x"===n?"y":"x",o=e.schema.groupBy,a=jS(e.schema.value),r=rD(t.raw,{value:e.schema.value,key:mD(e),density:e.schema.densityConfig}),s=cD(r,e.schema.medianSort),c=sD(r.map(e=>e.summary),e.schema.densityScale),l=r.every(e=>o.every(t=>void 0===t(e.first,0))),h=a??e.schema.translate("Value");t.categories=new Map,t.rows=e._data=s.map((e,r)=>{const s={...e.first};a&&delete s[a],l&&(s.id=h);const u=l?h:`${o[0](e.first,0)}`;return t.categories.has(u)||t.categories.set(u,t.categories.size),s[i]=u,s[n]=e.summary.median,s[hD]={summary:e.summary,order:r,scale:c(e.summary)},s});const u={x:e._xConfig,y:e._yConfig};t.titleAxis&&t.titleAxis!==n&&HS(u[t.titleAxis],t.title,void 0),HS(u[n],t.titleAxis===n?t.title:void 0,a),t.title=a,t.titleAxis=n}function gD({data:e,x:t,y:n,x2:i,y2:o}){if(i||o)return[t,n];const a=this.ctx.density,r=a.layout.valueAxis(this),s="x"===r?t:n,c="x"===r?n:t,l=s.domain().slice(),h=l[0]>l[1];h&&l.reverse(),e.forEach(e=>{const t=dD(e)?.summary.curve;t&&t.length&&(l[0]=Math.min(l[0],t[0][0]),l[1]=Math.max(l[1],t[t.length-1][0]))}),h&&l.reverse(),s.domain(l);const[u,d]=a.layout.categoryPadding(this);return c.padding&&c.padding(u),c.align&&c.align(d),[t,n]}function yD(e,t){e.ctx.density={raw:[],rows:[],layout:t,categories:new Map},e._buffer={...e._buffer,Area:gD},e._plotShapeEmitters={...e._plotShapeEmitters,Area:t.emit},e._sharedHover=()=>{};const n=function(e){return(t,n)=>{const i=e.ctx.density,o="x"===i.layout.valueAxis(e)?"y":"x",a=e=>i.categories.get(`${uD(e)?.[o]}`)??0;return i.layout.reverse?a(n)-a(t):a(t)-a(n)}}(e),i=e._preDraw.bind(e);e._preDraw=()=>{pD(e);const o="x"===t.valueAxis(e)?"y":"x",a="x"===o?"y":"x";e.schema[`${a}Sort`]===n&&(e.schema[`${a}Sort`]=void 0),e.schema[`${o}Sort`]||(e.schema[`${o}Sort`]=n),i()}}function xD(e,t,n){const i=t=>d.formatAbbreviate(t,e.schema.locale),o=t=>e.schema.translate(t),a=dD(t);if(!a){const a=Number(e.schema.value(uD(t),n));return Number.isFinite(a)?[[jS(e.schema.value)??o("Value"),i(a)]]:[]}const r=a.summary;return[[o("Observations"),i(r.n)],[o("Maximum"),i(r.max)],[o("Upper Quartile"),i(r.q3)],[o("Median"),i(r.median)],[o("Lower Quartile"),i(r.q1)],[o("Minimum"),i(r.min)]]}function bD(){return[{key:"densityScale",default:"area"},{key:"medianSort",default:!1},{key:"shape",default:N("Area"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"value",default:WS("value"),coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:N(e)}]}function _D(e){return[{key:"densityConfig",merge:!0,default:{kernel:"gaussian",points:80,cut:e}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>xD(e,t,n)})}]}function kD(e,t,n){return n?n.rotate?null:(e-(n[t]??0))/(n.scale??1):e}function vD(e,t,n){const o=(e,a)=>{if("group"===e.type){const n=n=>{const i=a(n);return null===i?null:kD(i,t,e.transform)};return void e.children.forEach(e=>o(e,n))}if("path"!==e.type)return;const r=n.get(`${e.key}`.replace(/::hit$/,""));if(void 0===r)return;const s=a(r),c=null===s?null:kD(s,t,e.transform);null!==c&&Number.isFinite(c)&&(e.enterD=i.flattenPath(e.d,t,c))};e.forEach(e=>o(e,e=>e))}function wD(e,t){e.forEach(e=>{if("group"===e.type)wD(e.children,t);else if("rect"===e.type){const{x:n,y:i,width:o,height:a}=e;e.enterRect="x"===t?{x:n+o/2,y:i,width:0,height:a}:{x:n,y:i+a/2,width:o,height:0}}})}function SD(e,t,n){return Math.abs(e)/Math.max(1,t-1+2*n)}function CD(e,t){const{position:n,step:i,gap:o,split:a}=t,r=Math.max(1,i>o?i-o:i),s=new Map;e.forEach((e,t)=>{s.has(e)||s.set(e,[]),s.get(e).push(t)});const c=new Array(e.length);return s.forEach((e,t)=>{const i=n(t),o=e.length;if(a&&2===o)return c[e[0]]={center:i,half:r/2,side:"start"},void(c[e[1]]={center:i,half:r/2,side:"end"});const s=r/o,l=o>1?Math.min(2,s/4):0;e.forEach((e,t)=>{c[e]={center:i-r/2+s*(t+.5),half:Math.max(.5,(s-l)/2),side:"both"}})}),c}function MD(e,t,n){return e.map(([e,i])=>({value:e,extent:i*t*n}))}function $D(e,t){const{center:n,side:i}=e;return["end"===i?n:n-t,"start"===i?n:n+t]}function AD(e){const t=Number(e.schema.overlap);return Number.isFinite(t)&&t>0?t:0}function zD(e){return e>0?[e/2,1]:[0,.5]}const DD=(e,t)=>{const{viz:n,values:i,x:o,y:a,yRange:r,yDomain:s}=e,c=AD(n),l=s,h=l.map(e=>a(e,"y")).sort((e,t)=>e-t);let u=SD(r[r.length-1]-r[0],l.length,zD(c)[0]);for(let e=1;e<h.length;e++)u=Math.min(u,h[e]-h[e-1]);const d=c*u,f=i.filter(e=>dD(e)).map(e=>({row:e,base:a(e.y,"y")})).sort((e,t)=>e.base-t.base),m=[];f.forEach(({row:e,base:t})=>{const n=dD(e);n.summary.curve.forEach(([i,a])=>{m.push({...e,id:fD(e),__pos:o(i),__base:t,__top:t-a*n.scale*d})})});const p=e=>e.__pos,g=e=>e.__base,y={x:p,x0:p,x1:null,y:g,y0:g,y1:e=>e.__top},x=cx({...e,values:m,shapeConfig:{...e.shapeConfig,...y}},t);return vD(x,"y",new Map(f.map(({row:e,base:t})=>[fD(e),t]))),x},FD={name:"Ridgeline",paintDriven:!0,setup:e=>yD(e,{valueAxis:()=>"x",categoryPadding:e=>zD(AD(e)),reverse:!0,emit:DD}),ctx:{},fields:[{key:"discrete",default:"y"},{key:"overlap",default:1.5},...bD(),..._D(3),{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var BD=xf(FD,_b);function LD(e,t){const n=(h.min([t,e])||0)/2/3;return{width:e,height:t,ringWidth:n,primaryRing:n,secondaryRing:2*n}}function PD(e,t){const n=e.schema.sizeMin,i=e.schema.sizeMax;return Math.min(i??1/0,Math.max(n??0,t))}function RD(e,t,n,i,o,a){if(o.forEach(e=>e.ring=1),a.forEach(e=>e.ring=2),e._size){const r=[t,...o,...a];r.forEach(t=>t.size=Number(e._size(t.data,t.i)));const s=r.map(e=>e.size).filter(e=>Number.isFinite(e));if(s.length){const t=function(e,t,n,i){const{ringWidth:o,primaryRing:a,secondaryRing:r}=t,s=Math.sin(Math.PI/Math.max(n,2)),c=Math.max(1,Math.floor(h.min([o/4,a*s-1,r*s-1]))),l=Math.min(e.schema.sizeMax??1/0,c),u=Math.min(l/2,e.schema.sizeMin??3),d=h.extent(i),f=`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`;return B[f]().domain(d).range([d[0]===d[1]?l:u,l])}(e,n,i,s);return r.forEach(n=>n.r=Number.isFinite(n.size)?t(n.size):PD(e,0)),t}}const{ringWidth:r}=n,s=r/2,c=r/4;let l=s/2-4;s/2-4<8&&(l=h.min([s/2,8])||0);let u=c/2-4;return c/2-4<4&&(u=h.min([c/2,4])||0),u>r/10&&(u=r/10),u>l&&u>10&&(u=.75*l),l>1.5*u&&(l=1.5*u),o.forEach(t=>t.r=PD(e,Math.floor(l))),a.forEach(t=>t.r=PD(e,Math.floor(u))),null}function ED(e,t,n){if("object"==typeof n)return t[n.id];const i=t[n];if(i)return i;if(!isNaN(n)){const e=t[parseFloat(n)];if(e)return e}if("number"==typeof n){const i=e.schema.nodes&&e.schema.nodes[n];if(null==i)return;return"object"==typeof i&&t[i.id]||t[i]}}function ND(e,t,n,i,o){const{width:a,height:r,primaryRing:s,secondaryRing:c}=o;i.x=a/2,i.y=r/2,i.r=e.schema.sizeMin?h.max([e.schema.sizeMin,.65*s]):e.schema.sizeMax?h.min([e.schema.sizeMax,.65*s]):.65*s;const l=[i],u=[];(n[e.schema.center]||[]).forEach(t=>{const i=t.source.id===e.schema.center?t.target:t.source;i.edges=n[i.id].filter(t=>t.source.id!==e.schema.center||t.target.id!==e.schema.center),i.edge=t,l.push(i),u.push(i)}),u.sort((e,t)=>e.edges.length-t.edges.length);const d=[];let f=0;u.forEach(e=>{const t=e.id;e.edges=e.edges.filter(e=>!l.includes(e.source)&&e.target.id===t||!l.includes(e.target)&&e.source.id===t),f+=e.edges.length||1,e.edges.forEach(e=>{const{source:n,target:i}=e,o=i.id===t?n:i;l.push(o)})});const m=2*Math.PI;let p=0;u.forEach((e,t)=>{const n=e.edges,i=n.length||1,o=m/f*i;0===t&&(p-=o/2);const l=p+o/2-m/4;e.radians=l,e.x=a/2+s*Math.cos(l),e.y=r/2+s*Math.sin(l),p+=o,n.forEach((t,n)=>{const o=t.source.id===e.id?t.target:t.source,s=m/f,h=l-s*i/2+s/2+s*n;o.radians=h,o.x=a/2+c*Math.cos(h),o.y=r/2+c*Math.sin(h),d.push(o)})});const g=RD(e,i,o,f,u,d);return{nodes:[i].concat(u).concat(d),primaries:u,secondaries:d,radius:g}}function TD(e,t,i){const{ringWidth:o}=i;t.forEach(t=>{if(t.id===e.schema.center){const{bounds:o,inside:r}=function(e,t,i,o,r){const{primaryRing:s}=i;if(!e._size)return{bounds:{x:-s/2,y:-s/2,width:s,height:s},inside:!0};const c=t.r??0,l=c*Math.SQRT2;return l>=Math.max(0,...String(o??"").split(/\s+/).map(e=>n.textWidth(e,{"font-family":a.fontFamilyStringify(r),"font-size":9})))&&l>=12.6?{bounds:{x:-l/2,y:-l/2,width:l,height:l},inside:!0}:{bounds:{x:-s/2,y:c+3,width:s,height:s/2},inside:!1}}(e,t,i,e._drawLabel(t.data||t.node,t.i),e.schema.fontFamily);return t.labelBounds=o,void(t.labelInside=r)}const r=e.schema.shapeConfig.labelConfig,s=1.4*(r?.fontSize&&r.fontSize(t)||11),c=2*s,l=o-t.r;let h=t.radians*(180/Math.PI),u=t.r+5,d="start";(h<-90||h>90)&&(u=-t.r-l-5,d="end",h+=180),t.labelBounds={x:u,y:-s/2,width:l,height:c},t.rotate=h,t.textAnchor=d})}function OD(e){if(Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]),!e._filteredData.length&&!e.schema.nodes.length&&!e.schema.links.length)return null;const t=e._filteredData.reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{}),n=function(e,t){let n=e.schema.nodes;!n.length&&e.schema.links.length&&(n=Array.from(new Set(e.schema.links.reduce((e,t)=>e.concat([t.source,t.target]),[]))).map(e=>"object"==typeof e?e:{id:e}));const i=n.reduce((t,n,i)=>(t[e.schema.nodeGroupBy?e.schema.nodeGroupBy[e._drawDepth](n,i):e._id(n,i)]=n,t),{}),o=Array.from(new Set(Object.keys(t).concat(Object.keys(i)))).map((n,o)=>{const a=t[n],r=i[n];return void 0!==r&&{__d3plus__:!0,data:a||r,i:o,id:n,node:r,shape:void 0!==a&&void 0!==e.schema.shape(a)?e.schema.shape(a):e.schema.shape(r)}}).filter(e=>!!e),a=o.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=a;const r=e.schema.links.map(t=>({source:ED(e,a,t.source),target:ED(e,a,t.target),size:e.schema.linkSize(t)})).filter(e=>e.source&&e.target),s=r.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t),e),{});return{nodes:o,nodeLookup:a,links:r,linkMap:s}}(e,t);let i=n.nodeLookup[e.schema.center];return i||null==e.schema.center||isNaN(e.schema.center)||(i=n.nodeLookup[parseFloat(e.schema.center)]),i&&(e.schema.center=i.id),{data:t,graph:n,center:i}}const WD=({viz:e})=>{const t=e;t._sizeLegendFinal=null;const i=OD(t);if(!i)return t.ctx.nodeLookup={},t.ctx.linkLookup={},t.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const{graph:{nodeLookup:o,links:a,linkMap:s},center:c}=i;if(!c)return t.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const{width:l,height:u}=ie(t),d=[],f=LD(l,u),{nodes:m,primaries:p,secondaries:g,radius:y}=ND(t,0,s,c,f);return t._sizeLegendFinal=y,function(e,t,n,i,o,a,r,s){const{width:c,height:l,ringWidth:h,primaryRing:u,secondaryRing:d}=r;n.forEach(e=>{const r=e.edge;["source","target"].forEach(e=>{r[e]=t.find(t=>t.id===r[e].id)}),s.push(r),o[e.id].forEach(o=>{const r=o.source.id===e.id?o.target:o.source;if(r.id===a.id)return;let f=i.find(e=>e.id===r.id);if(f||(f=n.find(e=>e.id===r.id)),!f)return;o.spline=!0;const m=c/2,p=l/2,g=u+.5*(d-u);["source","target"].forEach((n,i)=>{const a=o[n],r=a.radians,s=a.ring,c=a.x,l=a.y,u=a.r,d=2===s?r+Math.PI:r;o[`${n}X`]=c+Math.cos(d)*u,o[`${n}Y`]=l+Math.sin(d)*u,o[`${n}BisectX`]=m+g*Math.cos(r),o[`${n}BisectY`]=p+g*Math.sin(r),o[n]=t.find(e=>e.id===a.id);const y=o[n];void 0===y.edges&&(y.edges={});const x=0===i?o.target.id:o.source.id,b=y.edges;y.id===e.id?b[x]={angle:e.radians+Math.PI,radius:h/2}:b[x]={angle:f.radians,radius:h/2}}),s.push(o)})})}(0,m,p,g,s,c,f,d),TD(t,m,f),function(e,t,i,o,a){e.ctx.linkLookup=o.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const s=h.extent(o,e=>e.size);if(s[0]!==s[1]){const n=h.min(t,e=>e.r),i=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(s).range([e.schema.linkSizeMin,n]);o.forEach(e=>{e.size=i(e.size)})}const c=au(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const l=t=>t.id===e.schema.center&&!1!==i[t.id]?.labelInside,u={label:n=>!!(t.length<=e.schema.dataCutoff||e._hover&&e._hover(n)||e._active&&e._active(n))&&e._drawLabel(n.data||n.node,n.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const o=t.data??t;if(o.id===e.schema.center&&!1!==i[o.id]?.labelInside){const t=tu(au(e,o.key??o.shape).fill,o.data??o,o.i);return r.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)",e.schema.colorDefaults)}return r.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:e=>l(e.data??e),padding:0,textAnchor:t=>{const n=t.data??t;return n.id!==e.schema.center||l(n)?i[n.id]?.textAnchor||au(e,n.key??n.shape).labelConfig.textAnchor:"middle"},verticalAlign:e=>l(e.data??e)?"middle":"top"},rotate:e=>i[e.id].rotate||0},d=Array.from(h.groups(t,e=>e.shape));e.ctx.ringsCtx={edges:a,nodeGroups:d,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:u}}(t,m,o,a,d),{shapeData:m}};function jD(e,t,n,i,o,a){const r=e.schema.arrows,s=`${t.source.id}-${t.target.id}-${a}`,c="string"==typeof i?i:void 0;if(!t.spline)return PM({arrows:r,arrowSize:e.schema.arrowSize,strokeWidth:o,datum:n,i:a,keyPrefix:`rings-arrow-${s}`,fill:c,source:t.source,target:t.target});const l=zM(r,n,a);if(!l.source&&!l.target)return[];const h=LM(e.schema.arrowSize,n,a,"number"==typeof o?o:1),u=[];if(l.target&&null!=t.targetX){const e=Math.atan2(t.targetY-t.targetBisectY,t.targetX-t.targetBisectX);u.push(RM({key:`rings-arrow-t-${s}`,datum:n,x:t.targetX,y:t.targetY,angle:e,size:h,fill:c}))}if(l.source&&null!=t.sourceX){const e=Math.atan2(t.sourceY-t.sourceBisectY,t.sourceX-t.sourceBisectX);u.push(RM({key:`rings-arrow-s-${s}`,datum:n,x:t.sourceX,y:t.sourceY,angle:e,size:h,fill:c}))}return u}function HD(e,t,n,i,o){const a=`rings-${e}-${t.id}`;if("Circle"===e)return{type:"circle",key:a,cx:0,cy:0,r:t.r,...i};if("Rect"===e){const e=Number(tu(n.width,i.datum,o)??2*t.r),r=Number(tu(n.height,i.datum,o)??2*t.r);return{type:"rect",key:a,x:-e/2,y:-r/2,width:e,height:r,...i}}return null}const ID={name:"Rings",layoutStage:WD,sizeLegendScale:(e,{width:t,height:n})=>function(e,t,n){if(!e._size)return null;const{nodeLookup:i}=e.ctx,o=OD(e);if(e.ctx.nodeLookup=i,!o||!o.center)return null;const{graph:a,center:r}=o;return ND(e,a.nodeLookup,a.linkMap,r,LD(t,n)).radius}(e,t,n),emit:({viz:e})=>{const t=e.ctx.ringsCtx;if(!t)return[];const n=[];if(t.edges&&t.edges.length)for(let i=0;i<t.edges.length;i++){const o=t.edges[i],a=o,r=iu(t.linkConfig,a,i);"number"==typeof o.size&&(r.strokeWidth=o.size);const s="number"==typeof o.size?`, ${o.size}`:"";n.push({type:"path",key:`rings-link-${o.source.id}-${o.target.id}`,d:t.linkD(o),datum:a,paint:r,aria:{label:`${ou(e,o.source,0)} to ${ou(e,o.target,0)}${s}.`}}),n.push(...jD(e,o,a,r.stroke,r.strokeWidth,i))}if(t.nodeGroups&&t.nodeGroups.length){const i=t.nodeShapeConfig;for(const[o,a]of t.nodeGroups){if(!a.length)continue;const r={...au(e,o),...t.nodeShapeConfig},s=[];for(let t=0;t<a.length;t++){const c=a[t],l=c.data??c,h=iu(r,l,c.i??t);void 0===h.vectorEffect&&(h.vectorEffect="non-scaling-stroke");const u=i.rotate?i.rotate(c):0,d=u?{x:c.x,y:c.y,rotate:u}:{x:c.x,y:c.y},f=e._size,m=f?`, ${f(l,c.i??t)}`:"",p=HD(o,c,r,{datum:l,paint:h,transform:d,aria:{label:`${ou(e,c,t)}${m}.`}},c.i??t);if(!p)continue;n.push(p);const g=Vy(r,p,l,c.i??t);g&&s.push(g)}if(n.push(...s),i.label&&i.labelBounds){const t=i.label,r=i.labelBounds,s=iw({data:a,label:(e,n)=>t(e,n),x:e=>e.x,y:e=>e.y,aes:e=>({r:e.r}),rotate:e=>i.rotate?i.rotate(e):0,id:e=>`rings-label-${e.id}`,labelBounds:(e,t)=>r(e),labelConfig:{...ru(e,o),...i.labelConfig}});n.push(...s)}}}return n},insetRegion:Uu,setup:e=>{!function(e){const t=e,n=(e,t,n,i)=>o.addToQueue.bind(e)(t,n,i);t.links=function(e,t){return arguments.length?(n(this,e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(n(this,e,t,"nodes"),this):this.schema.nodes},t.linkSize=function(e){return arguments.length?(this.schema.linkSize="function"==typeof e?e:N(e),this):this.schema.linkSize},t.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),Be(e))),this},t.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size},t.hover=ow}(e);const t=e;e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{if(n(i,o,a,r),e._focus&&e._focus===i.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(i,o,a,r),void(e._focus=void 0);const s=e.schema.nodeGroupBy&&e.schema.nodeGroupBy[e._drawDepth](i,o)?e.schema.nodeGroupBy[e._drawDepth](i,o):e._id(i,o),c=e.ctx.linkLookup[s]??[],l=e.ctx.nodeLookup[s];if(!l)return;const h=[l.id],u=[l.x-l.r,l.x+l.r],d=[l.y-l.r,l.y+l.r];c.forEach(e=>{h.push(e.id),e.x-e.r<u[0]&&(u[0]=e.x-e.r),e.x+e.r>u[1]&&(u[1]=e.x+e.r),e.y-e.r<d[0]&&(d[0]=e.y-e.r),e.y+e.r>d[1]&&(d[1]=e.y+e.r)}),t.hover((t,n)=>{const i=t;return i.source&&i.target?i.source.id===l.id||i.target.id===l.id:h.includes(e._ids(t,n)[e._drawDepth])})},e.schema.on["click.shape"]=t=>{e.hover?.(!1),e._tooltipClass?.data([]).render(),e.schema.center=t.id,e._margin={bottom:0,left:0,right:0,top:0},e._padding={bottom:0,left:0,right:0,top:0},Rd(e),Hd(e),e._sceneRenderer&&e._drawSceneToTarget(e.schema.duration)}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"center"},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>{const n=t;return t&&n.source&&n.target?`${n.source.id} → ${n.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)}})},{key:"links",default:[]},{key:"linkSize",default:N(1)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e._size,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#adb5bd",strokeWidth:1}})}]};var GD=xf(ID);const VD=(e,t)=>e.sourceLinks.length?e.depth:t-1;const qD=(e,t)=>e.y0-t.y0,YD=(e,t)=>qD(e.source,t.source)||e.index-t.index,KD=(e,t)=>qD(e.target,t.target)||e.index-t.index,UD=e=>e.value;function XD(e,t){const n=e.length;let i=new Set(e),o=new Set,a=0;for(;i.size;){for(const e of i)if(e[t]=a,"depth"===t)for(const{target:t}of e.sourceLinks)o.add(t);else for(const{source:t}of e.targetLinks)o.add(t);if(++a>n)throw new Error("circular link");i=o,o=new Set}}function QD(e,t,n,i){for(let o=1,a=t.length;o<a;++o){const a=t[o];for(const t of a){let i=0,o=0;for(const{source:n,value:a}of t.targetLinks){const r=a*(t.layer-n.layer);i+=oF(e,n,t)*r,o+=r}if(!(o>0))continue;const a=(i/o-t.y0)*n;t.y0+=a,t.y1+=a,nF(e,t)}void 0===e.sort&&a.sort(qD),JD(e,a,i)}}function ZD(e,t,n,i){for(let o=t.length-2;o>=0;--o){const a=t[o];for(const t of a){let i=0,o=0;for(const{target:n,value:a}of t.sourceLinks){const r=a*(n.layer-t.layer);i+=aF(e,t,n)*r,o+=r}if(!(o>0))continue;const a=(i/o-t.y0)*n;t.y0+=a,t.y1+=a,nF(e,t)}void 0===e.sort&&a.sort(qD),JD(e,a,i)}}function JD(e,t,n){const i=t.length>>1,o=t[i];tF(e,t,o.y0-e.py,i-1,n),eF(e,t,o.y1+e.py,i+1,n),tF(e,t,e.y1,t.length-1,n),eF(e,t,e.y0,0,n)}function eF(e,t,n,i,o){for(;i<t.length;++i){const a=t[i],r=(n-a.y0)*o;r>1e-6&&(a.y0+=r,a.y1+=r),n=a.y1+e.py}}function tF(e,t,n,i,o){for(;i>=0;--i){const a=t[i],r=(a.y1-n)*o;r>1e-6&&(a.y0-=r,a.y1-=r),n=a.y0-e.py}}function nF(e,{sourceLinks:t,targetLinks:n}){if(void 0===e.linkSort){for(const{source:e}of n)e.sourceLinks.sort(KD);for(const{target:e}of t)e.targetLinks.sort(YD)}}function iF(e,t){if(void 0===e.linkSort)for(const{sourceLinks:e,targetLinks:n}of t)e.sort(KD),n.sort(YD)}function oF(e,t,n){let i=t.y0-(t.sourceLinks.length-1)*e.py/2;for(const{target:o,width:a}of t.sourceLinks){if(o===n)break;i+=a+e.py}for(const{source:e,width:o}of n.targetLinks){if(e===t)break;i-=o}return i}function aF(e,t,n){let i=n.y0-(n.targetLinks.length-1)*e.py/2;for(const{source:o,width:a}of n.targetLinks){if(o===t)break;i+=a+e.py}for(const{target:e,width:o}of t.sourceLinks){if(e===n)break;i-=o}return i}const rF=({viz:e})=>{const t=e,{width:n,height:i}=ie(t),o=Array.isArray(t.schema.nodes)&&t.schema.nodes.length>0,a=Array.isArray(t.schema.links)&&t.schema.links.length>0;if(!o&&!a)return t.ctx.nodeLookup={},t.ctx.linkLookup={},{viz:e};let r;if(o)r=t.schema.nodes;else{const e=new Set,n=[];for(const i of t.schema.links){const o=i[t.schema.linksSource];e.has(o)||(e.add(o),n.push(o));const a=i[t.schema.linksTarget];e.has(a)||(e.add(a),n.push(a))}r=n.map(e=>({id:e}))}const s=r.map((e,n)=>({__d3plus__:!0,data:e,i:n,id:t.schema.nodeId(e,n),node:e,shape:"Rect"})),c=s.reduce((e,t,n)=>(e[String(t.id)]=n,e),{});t.ctx.nodeLookup=c;const l=a?t.schema.links.map((e,n)=>({source:c[String(e[t.schema.linksSource])],target:c[String(e[t.schema.linksTarget])],value:t.schema.value(e,n)})):[];t.ctx.linkLookup=l.reduce((e,t)=>(e[t.source]||(e[t.source]=[]),e[t.source].push(t.target),e[t.target]||(e[t.target]=[]),e[t.target].push(t.source),e),{}),t.ctx.sankey.nodeAlign(t.schema.nodeAlign).nodePadding(t.schema.nodePadding).nodeWidth(t.schema.nodeWidth).nodes(s).nodeSort(t.schema.nodeSort).links(l).linkSort(t.schema.linkSort).iterations(t.schema.iterations).size([n,i])();const u=Array.from(h.groups(s,e=>e.shape));return t.ctx.sankeyCtx={links:l,nodeGroups:u,pathFn:t.ctx.path},{shapeData:s}};function sF(e,t,n,i,o){const a=[],r=zM(e.schema.arrows,n,i);if(r.source||r.target){const s="number"==typeof t.width?t.width:2,c=tu(e.schema.arrowSize,n,i),l="number"==typeof c?c:Math.max(8,Math.min(s,28)),h="string"==typeof o.stroke?o.stroke:void 0;r.target&&"number"==typeof t.y1&&a.push(RM({key:`sankey-arrow-t-${t.source.id}-${t.target.id}`,datum:n,x:t.target.x0,y:t.y1,angle:0,size:l,fill:h,opacity:1})),r.source&&"number"==typeof t.y0&&a.push(RM({key:`sankey-arrow-s-${t.source.id}-${t.target.id}`,datum:n,x:t.source.x1,y:t.y0,angle:Math.PI,size:l,fill:h,opacity:1}))}return a}const cF={center:e=>e.targetLinks.length?e.depth:e.sourceLinks.length?h.min(e.sourceLinks,e=>e.target.depth)-1:0,justify:VD,left:e=>e.depth,right:(e,t)=>t-1-e.height};const lF={name:"Sankey",layoutStage:rF,emit:({viz:e})=>{const t=e.ctx.sankeyCtx;if(!t)return[];const n=[],i=e.schema.shapeConfig?.Path??{};if(t.links&&t.links.length)for(let o=0;o<t.links.length;o++){const a=t.links[o],r=a,s=iu(i,r,o);n.push({type:"path",shapeType:"Link",key:`sankey-link-${a.source.id??""}-${a.target.id??""}`,d:t.pathFn(a),datum:r,paint:s,aria:{label:`${ou(e,a.source,0)} to ${ou(e,a.target,0)}, ${a.value}.`}}),n.push(...sF(e,a,r,o,s))}if(t.nodeGroups&&t.nodeGroups.length)for(const[i,o]of t.nodeGroups){if(!o.length)continue;const t=au(e,i),a=n.length;for(let a=0;a<o.length;a++){const r=o[a],s=r.data??r,c=iu(t,s,r.i??a),l={label:`${ou(e,r,a)}.`};if("Rect"===i)n.push({type:"rect",key:`sankey-${i}-${r.id}`,x:r.x0,y:r.y0,width:r.x1-r.x0,height:r.y1-r.y0,datum:s,paint:c,aria:l});else if("Circle"===i){const e=Number(tu(t.r,s,r.i??a)??0);n.push({type:"circle",key:`sankey-${i}-${r.id}`,cx:(r.x0+r.x1)/2,cy:(r.y0+r.y1)/2,r:e,datum:s,paint:c,aria:l})}}n.push(...qy(t,n.slice(a),e=>{const t=o[e];return[t.data??t,t.i??e]}))}return n},setup:e=>{const t=e;!function(e){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),e._focus&&e._focus===n.id)return e.hover(!1),e.schema.on.mouseenter.bind(e)(n,i,o,a),void(e._focus=void 0);const r=n;if(r.source&&r.target){const t=r.source.id,n=r.target.id;return void e.hover((i,o)=>{if(i.source&&i.target)return i.source.id===t&&i.target.id===n;const a=e.schema.nodeId(i,o);return a===t||a===n})}const s=e.schema.nodeId(n,i),c=e.ctx.nodeLookup[String(s)],l=e.ctx.nodeLookup,h=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[c]??[],d=[s];u.forEach(e=>d.push(h[e])),e.hover((t,n)=>t.source&&t.target?t.source.id===s||t.target.id===s:d.includes(e.schema.nodeId(t,n)))}}(t),t.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:cF[e],this):this.schema.nodeAlign},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:Be(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:Be(e),this):this.schema.value},t.hover=ow},ctx:{sankey:function(){const e={x0:0,y0:0,x1:1,y1:1,dx:24,dy:8,py:8,align:VD,sort:void 0,linkSort:void 0,iterations:6};let t=[],n=[];const i=()=>{const i=t,o=n;!function(e,t,n){for(const[e,n]of t.entries())n.index=e,n.sourceLinks=[],n.targetLinks=[];const i=new Map(t.map((e,t)=>[t,e])),o=e=>{const t=i.get(e);if(!t)throw new Error("missing: "+e);return t};for(const[e,t]of n.entries()){t.index=e;const n=t;"object"!=typeof n.source&&(t.source=o(n.source)),"object"!=typeof n.target&&(t.target=o(n.target)),t.source.sourceLinks.push(t),t.target.targetLinks.push(t)}if(null!=e.linkSort)for(const{sourceLinks:n,targetLinks:i}of t)n.sort(e.linkSort),i.sort(e.linkSort)}(e,i,o);for(const e of i)e.value=void 0===e.fixedValue?Math.max(h.sum(e.sourceLinks,UD),h.sum(e.targetLinks,UD)):e.fixedValue;return XD(i,"depth"),XD(i,"height"),function(e,t){const n=function(e,t){const n=h.max(t,e=>e.depth)+1,i=(e.x1-e.x0-e.dx)/(n-1),o=new Array(n);for(const a of t){const t=Math.max(0,Math.min(n-1,Math.floor(e.align(a,n))));a.layer=t,a.x0=e.x0+t*i,a.x1=a.x0+e.dx,o[t]?o[t].push(a):o[t]=[a]}if(e.sort)for(const t of o)t.sort(e.sort);return o}(e,t);e.py=Math.min(e.dy,(e.y1-e.y0)/(h.max(n,e=>e.length)-1)),function(e,t){const n=h.min(t,t=>(e.y1-e.y0-(t.length-1)*e.py)/h.sum(t,UD));for(const i of t){let t=e.y0;for(const o of i){o.y0=t,o.y1=t+o.value*n,t=o.y1+e.py;for(const e of o.sourceLinks)e.width=e.value*n}t=(e.y1-t+e.py)/(i.length+1);for(let e=0;e<i.length;++e){const n=i[e];n.y0+=t*(e+1),n.y1+=t*(e+1)}iF(e,i)}}(e,n);for(let t=0;t<e.iterations;++t){const i=Math.pow(.99,t),o=Math.max(1-i,(t+1)/e.iterations);ZD(e,n,i,o),QD(e,n,i,o)}}(e,i),function(e){for(const t of e){let e=t.y0,n=e;for(const n of t.sourceLinks)n.y0=e+n.width/2,e+=n.width;for(const e of t.targetLinks)e.y1=n+e.width/2,n+=e.width}}(i),{nodes:i,links:o}};return i.nodeAlign=t=>(e.align=t,i),i.nodeSort=t=>(e.sort=t,i),i.nodeWidth=t=>(e.dx=+t,i),i.nodePadding=t=>(e.dy=e.py=+t,i),i.nodes=e=>(t=e,i),i.links=e=>(n=e,i),i.linkSort=t=>(e.linkSort=t,i),i.size=t=>(e.x1=+t[0],e.y1=+t[1],i),i.iterations=t=>(e.iterations=+t,i),i}(),path:y.linkHorizontal().source(e=>[e.source.x1,e.y0]).target(e=>[e.target.x0,e.y1])},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"iterations",default:6},{key:"links",default:T("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:T("nodes")},{key:"nodeAlign",default:VD},{key:"nodeId",default:T("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeWidth",default:30},{key:"value",default:N(1)},{key:"shape",default:N("Rect"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>{const e=e=>Math.max(1,Math.abs(e.source.y1-e.source.y0)*(e.value/e.source.value)-2);return{Path:{fill:"none",hoverStyle:{"stroke-width":e},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:e},Rect:{}}}},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};var hF=xf(lF);var uF=xf({name:"StackedArea",paintDriven:!0,ctx:{},fields:[{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:vb}]},kb);const dF=2*Math.PI;function fF(e,t,n="equal",i){const o=Math.max(0,e);if(t<1)return[[0,o]];const a=t+1,r=void 0!==i&&Number.isFinite(i)?Math.min(Math.max(0,i),o):"area"===n?o*Math.sqrt(1/a):o/a,s=e=>"area"===n?Math.sqrt(r*r+(o*o-r*r)*e/t):r+(o-r)*e/t,c=[[0,r]];for(let e=1;e<=t;e++)c.push([s(e-1),s(e)]);return c}function mF(e,t,n,i){const o=n.endAngle-n.startAngle||1,a=e=>Math.min(dF,Math.max(0,(e-n.startAngle)/o*dF)),r=t-n.depth,s=i[i.length-1]?.[1]??0,[c,l]=r<0?[0,0]:i[r]??[s,s];return{innerRadius:c,outerRadius:l,startAngle:a(e.startAngle),endAngle:a(e.endAngle)}}function pF(e,t,n){if(t)return t;if(!n)return 0;const i=Math.sqrt(e.innerRadius**2+e.outerRadius**2);return i?n/i:0}function gF(e){return e<=180?e-90:e-270}function yF(e){return e>90&&e<270?e-180:e>=270?e-360:e}const xF=2*Math.PI;function bF(e){const{radii:t,...n}=e;return iC({...n,breadth:xF},e=>{const[n,i]=t[e.depth]??[0,0];return{startAngle:e.x0,endAngle:e.x1,innerRadius:n,outerRadius:i}})}const _F=aC;const kF=({viz:e})=>{const{width:t,height:n}=ie(e);e.ctx.sunburstWidth=t,e.ctx.sunburstHeight=n,e.ctx.sunburstNodes=new Map,e.ctx.sunburstGhosts=[];const i=function(e){return rC(e,"sunburstPass",()=>{const t={laid:e.ctx.sunburstLaid,radii:e.ctx.sunburstRadii,origin:e.ctx.sunburstZoomOrigin};return e.ctx.sunburstZoomOrigin=void 0,t})}(e),o=e._filteredData??[];if(!o.length)return e.ctx.sunburstLaid=[],e.ctx.sunburstRadii=void 0,e.ctx.sunburstEnterArcs=new Map,e.ctx.sunburstOuterRadius=0,{shapeData:[]};const a=e.schema.shapeConfig??{},r="number"==typeof a.strokeWidth?a.strokeWidth:1,s=Math.max(0,Math.min(t,n)/2-3*r/2),c=_F(e),l=e.schema.groupBy.slice(c.level+1,e._drawDepth+1),h=fF(s,l.length,e.schema.ringSize,function(e,t){const n=e.schema.innerRadius,i="function"==typeof n?n(t):n;return"number"==typeof i&&Number.isFinite(i)?i:void 0}(e,s)),u=bF({data:o,keys:l,firstLevel:c.level+1,focusPath:c.path,sum:e.schema.sum,sort:e.schema.sort,aggs:e.schema.aggs,radii:h}),{laid:d,radii:f,origin:m}=i;e.ctx.sunburstGhosts=m&&d?function(e,t,n,i){return sC(e,t).map(e=>({id:e.id,datum:e.datum,i:e.i,level:e.level,arc:mF(e,e.depth,n,i)}))}(d,u,m,h):[],e.ctx.sunburstEnterArcs=d&&f?function(e,t,n){return lC(e,t,(e,t)=>mF(e,e.depth,{startAngle:t.startAngle,endAngle:t.endAngle,depth:t.depth},n))}(d,u,f):new Map,e.ctx.sunburstLaid=u,e.ctx.sunburstRadii=h;const p=e.ctx.sunburstNodes;for(const e of u)wr(e.datum,e.share),p.set(e.datum,e);return e.ctx.sunburstOuterRadius=s,{shapeData:u}},vF=2*Math.PI,wF=1e-6;function SF(e,t){const n=t.rotate*Math.PI/180,i=Math.cos(n),o=Math.sin(n),a=t.width/2,r=t.height/2,s=(e,n)=>[t.x+e*i-n*o,t.y+e*o+n*i],c=[s(-a,-r),s(a,-r),s(a,r),s(-a,r)];if(c.some(([t,n])=>Math.hypot(t,n)>e.outerRadius+wF))return!1;if(e.innerRadius>0){const n=-t.x*i-t.y*o,s=t.x*o-t.y*i;if(Math.hypot(Math.max(Math.abs(n)-a,0),Math.max(Math.abs(s)-r,0))<e.innerRadius-wF)return!1}const l=e.endAngle-e.startAngle;if(l>=vF-wF)return!0;const h=[...c];if(l>Math.PI)for(let e=1;e<8;e++){const t=e/8;h.push(s(2*a*t-a,-r),s(2*a*t-a,r),s(-a,2*r*t-r),s(a,2*r*t-r))}return h.every(t=>function(e,[t,n]){const i=((Math.atan2(t,-n)-e.startAngle)%vF+vF)%vF;return i<=e.endAngle-e.startAngle+wF||i>=vF-wF}(e,t))}function CF(e,t,n,i,o){const a=a=>SF(e,{x:t,y:n,width:a,height:o,rotate:i});if(!a(wF))return 0;let r=0,s=2*e.outerRadius;for(let e=0;e<16;e++){const e=(r+s)/2;a(e)?r=e:s=e}return r}function MF(e,t,n,i,o,a){const{padding:r,lineHeight:s,maxLines:c}=a;for(let a=1;a<=c;a++){const c=a*s*o+2*r,l=CF(e,t[0],t[1],n,c);if(l<=2*r)return null;if(jC(i,o,l-2*r)<=a)return{width:l,height:c}}return null}function $F(e,t,n,i,o={}){const a=EC(o),r=HC(o=>Boolean(MF(e,t,n,i,o,a)),a.fontMin,a.fontMax);if(null===r)return null;return{fontSize:r,...MF(e,t,n,i,r,a)}}function AF(e,t,n={}){const i=e.endAngle-e.startAngle;if(!(t.words.length&&i>0&&e.outerRadius>e.innerRadius))return null;const o=EC(n);if(e.innerRadius<=0&&i>=vF-wF){const n=$F(e,[0,0],0,t,o);return n?{orientation:"center",x:0,y:0,rotate:0,...n}:null}const a=(e.startAngle+e.endAngle)/2,r=(e.innerRadius+e.outerRadius)/2,s=[r*Math.sin(a),-r*Math.cos(a)],{tangential:c,radial:l}={tangential:yF(h=(180*a/Math.PI%360+360)%360),radial:gF(h)};var h;const u=$F(e,s,c,t,o),d=$F(e,s,l,t,o),f=(e,t,n)=>({orientation:e,x:s[0],y:s[1],rotate:t,...n});return u&&(!d||u.fontSize>=d.fontSize)?f("tangential",c,u):d?f("radial",l,d):null}function zF(e,t,n){const i=0===e.depth;return{innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,padAngle:i?0:pF(e,t,n)}}function DF(e,t){return e._drawLabel(t.datum,t.i??0,t.level)}const FF=TC;const BF={out:.06,in:.06},LF={prefix:"sunburst",origin:e=>({startAngle:e.startAngle,endAngle:e.endAngle,depth:e.depth})},PF={name:"Sunburst",layoutStage:kF,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o=au(e,"Path"),a=Number(e.schema.padAngle)||0,s=Number(e.schema.padPixel)||0,c=e.schema.sum,l=e.schema.locale,h=function(e,t){return CC(e.schema,t,{color:e.ctx.sunburstDefaultColor,fill:e.ctx.sunburstDefaultFill},"Path")}(e,o),u=e.ctx.sunburstEnterArcs??new Map,f=n.map(t=>{const n=t.i??0,r=zF(t,a,s),f=h(t);return{type:"path",key:`sunburst-${t.id}`,d:i.arcPath(r),arc:r,enterArc:u.has(t.id)?{...u.get(t.id),padAngle:0}:void 0,datum:t.datum,paint:{fill:nu(o,t.datum,n,f),stroke:tu(o.stroke,t.datum,n),strokeWidth:tu(o.strokeWidth,t.datum,n),opacity:tu(o.opacity,t.datum,n)??1},aria:{label:`${e._drawLabel(t.datum,n,t.level)}, ${c(t.datum)}, ${d.formatAbbreviate(100*t.share,l)}%`}}}),m=qy(o,f,e=>[n[e].datum,n[e].i??0]),p=function(e,t){return(e.ctx.sunburstGhosts??[]).map(e=>{const n={...e.arc,padAngle:0};return{type:"path",key:`sunburst-${e.id}`,d:i.arcPath(n),arc:n,paint:{fill:t(e),opacity:1}}})}(e,h),g=ru(e,"Path")??{},y="number"==typeof g.fontMin?g.fontMin:8,x="number"==typeof g.fontMax?g.fontMax:24,b=function(e,t,n,i){const{fontMin:o,fontMax:a,padAngle:r,padPixel:s}=i,c=new Map;for(const i of t){const t=WC(DF(e,i),i.datum,n),l=AF(zF(i,r,s),t,{fontMin:o,fontMax:a});l&&c.set(i,l)}return c}(e,n,g,{fontMin:y,fontMax:x,padAngle:a,padPixel:s}),_=iw({data:n.filter(e=>b.has(e)),label:t=>DF(e,t),x:e=>b.get(e).x,y:e=>b.get(e).y,rotate:e=>b.get(e).rotate,aes:()=>({}),id:e=>`sunburst-${e.id}`,datum:e=>e.datum,labelBounds:e=>{const{width:t,height:n}=b.get(e);return{x:-t/2,y:-n/2,width:t,height:n}},labelConfig:{fontMax:x,fontMin:y,split:NC,fontResize:!0,padding:0,textAnchor:"middle",verticalAlign:"middle",fontColor:t=>{let n=t;for(;n&&n.__d3plus__&&n.data;)n=n.data;const i=e.ctx.sunburstNodes.get(n),o=i?h(i):void 0;return r.colorContrast(o??"rgb(255, 255, 255)",e.schema.colorDefaults)},...g}});for(const e of _)e.fadeSwap=BF;return[...p,...f,...m,..._]},insetRegion:Uu,thresholdFunction:gC,chartTransform:e=>oe(e,e.ctx.sunburstWidth,e.ctx.sunburstHeight),chartBodyRect:e=>{const t=e.ctx.sunburstOuterRadius??0;return{x:-t,y:-t,width:2*t,height:2*t}},setup:e=>vC(e,LF),facet:{aspect:1},ctx:{},fields:[{key:"innerRadius"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"ringSize",default:"equal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...wC})},{key:"sort",default:yC,decorate:xC},{key:"sum",default:T("value"),coerce:bC,onSet:_C},{key:"shapeConfig",merge:!0,factory:e=>({Path:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:kC},{key:"legend",coerce:"const",factory:cw}]};var RF=xf(PF);function EF(e,t){return o.merge(t.values.map(t=>t.key&&t.values?EF(e,t):t),e.schema.aggs)}function NF(e,t,n){const i=e.ctx.tree.separation(e.schema.separation).size([t,n])(A.hierarchy({key:"root",values:o.nest(e._filteredData,e.schema.groupBy.slice(0,e._drawDepth+1))},e=>e.key&&e.values?e.values:null).sort(e.schema.sort)).descendants().filter(t=>(t.depth??0)<=e.schema.groupBy.length&&!!t.parent);return i.forEach((t,n)=>{const i=t.data;i.key&&i.values&&(t.data=EF(e,i)),t.__d3plus__=!0,t.i=n,t.data.depth=t.depth}),i}const TF=({viz:e})=>{const t=e.schema.orient,i="vertical"===t,a="horizontal"===t,r=i?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,c=a?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,l=i?"left":"top",u=NF(e,c,r),{labelHeight:d,labelWidths:f}=function(e,t,n,i,a,r,c){let l=e.schema.shapeConfig.r;if("function"!=typeof l){const e=l;l=()=>e}const u=h.max(t,e=>1===e.depth?l(e.data,e.i):0),d=h.max(t,e=>e.children?0:l(e.data,e.i)),f=h.extent(t,e=>e.y),m=h.min([n?50:100,(f[1]-u-d)/(e.schema.groupBy.length+1)]);e.ctx.labelHeight=m;const p=o.nest(t,e=>e.depth).map(t=>{const n=t.values;return n.reduce((t,i,o)=>{const r=o<n.length-1?n[o+1].x:a+e._margin[c],s=o?n[o-1].x:e._margin[c];return h.min([t,r-i.x,i.x-s])},a)});e.ctx.labelWidths=p;const g=s.scaleLinear().domain(f).range([u+m,r-d-m]);return t.forEach(e=>{const t=g(e.y);i?(e.y=e.x,e.x=t):e.y=t}),{labelHeight:m,labelWidths:p}}(e,u,i,a,c,r,l);return function(e,t,i,a,r,s){const c=e.schema.shapeConfig,l=t.filter(e=>(e.depth??0)>1).map(e=>n.assign({},e)),h=function(e,t,n,i,o){const a=e.schema.label;return{id:(t,n)=>e._ids(t.data,n)[(t.depth??1)-1],label:(t,n)=>{if(a)return a(t.data,n);const i=e._ids(t.data,n).slice(0,t.depth??1);return i[i.length-1]},labelConfig:{fontResize:!1,textAnchor:t=>{const n=t.data??t;return i?"middle":n.children&&n.depth!==e._drawDepth+1?"end":"start"},verticalAlign:e=>{const t=e.data??e;return i?1===t.depth?"bottom":"top":"middle"}},hitArea:(a,r,s)=>{const c=t,l=s.r??(i?s.height/2:s.width/2),h=n[(a.depth??1)-1];return{width:i?h:2*l+h,height:o?c:2*l+c,x:i?-h/2:a.children&&a.depth!==e.schema.groupBy.length?-(l+h):-l,y:o?-c/2:a.children&&a.depth!==e.schema.groupBy.length?-(l+t):-l}},labelBounds:(o,a,r)=>{const s=t,c=i?"height":"width",l=r.r??(i?r.height/2:r.width/2),h=n[(o.depth??1)-1],u=i?"width":"height",d=i?"x":"y",f=i?"y":"x";return{[u]:h,[c]:s,[d]:-h/2,[f]:o.children&&o.depth!==e.schema.groupBy.length?-(l+s):l}}}}(e,i,a,r,s),u=e.schema.shape,d=o.nest(t,e=>u(e.data)),f=d.map(e=>e.key),m=(e.ctx.previousShapes??[]).filter(e=>!f.includes(e)),p=d.concat(m.map(e=>({key:e,values:[]})));e.ctx.linksData=l,e.ctx.linkD=e=>{let t=c.r;"function"==typeof t&&(t=t(e.data,e.i));const n=(e.parent.x??0)-(e.x??0)+(r?0:t),i=(e.parent.y??0)-(e.y??0)+(r?t:0),o=r?0:-t,a=r?-t:0;return r?`M${o},${a}C${o},${(a+i)/2} ${n},${(a+i)/2} ${n},${i}`:`M${o},${a}C${(o+n)/2},${a} ${(o+n)/2},${i} ${n},${i}`},e.ctx.shapeGroups=p,e.ctx.shapeConfig=h,e.ctx.previousShapes=f}(e,u,d,f,i,a),{shapeData:u}};function OF(e,t,n){const i=t.data??t,o=t.i??0,a=t.x??0,r=t.y??0;switch(e){case"Circle":{const e=Number(tu(n.r,i,o)??0);return{geom:{type:"circle",cx:a,cy:r,r:e},aes:{r:e}}}case"Rect":{const e=Number(tu(n.width,i,o)??0),t=Number(tu(n.height,i,o)??0);return{geom:{type:"rect",x:a-e/2,y:r-t/2,width:e,height:t},aes:{width:e,height:t}}}case"Path":return{geom:{type:"path",d:String(tu(n.d,i,o)??"")},aes:{}};default:return null}}const WF={name:"Tree",layoutStage:TF,emit:({viz:e})=>{const t=e.ctx.linksData,n=e.ctx.linkD,i=e.ctx.shapeGroups,o=e.ctx.shapeConfig;if(!i||!o)return[];const a=[];if(t&&t.length&&n){const i=au(e,"Path");for(let o=0;o<t.length;o++){const r=t[o],s=r.data??r,c=iu(i,s,o),l=e._ids(s,o)[(r.depth??1)-1],h=r.x??0,u=r.y??0;a.push({type:"path",key:`tree-link-${l}`,d:n(r),datum:s,paint:c,transform:{x:h,y:u},aria:{label:`${e._drawLabel(s,r.i??o)}.`}})}}for(const{key:t,values:n}of i){if(!n.length)continue;const i={...au(e,t),...o},r=n,s=[];for(let n=0;n<r.length;n++){const c=r[n],l=c.data??c,h=OF(t,c,i);if(!h)continue;const u=o.id(c,n),d=iu(i,l,n),f={...h.geom,key:`tree-${t}-${u}`,datum:l,paint:d,aria:{label:`${e._drawLabel(l,n)}.`}};a.push(f);const m=Vy(i,f,l,n);m&&s.push(m)}a.push(...s);const c=iw({data:r,label:(e,t)=>o.label(e,t),x:e=>e.x??0,y:e=>e.y??0,aes:e=>OF(t,e,i)?.aes??{},rotate:N(0),id:(e,t)=>o.id(e,t),labelBounds:(e,t,n)=>o.labelBounds(e,t,n),labelConfig:{...ru(e,t),...o.labelConfig}});a.push(...c)}return a},insetRegion:Uu,ctx:{tree:A.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(e,t)=>e.parent===t.parent?1:2},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>(e.ctx.linksData&&e._chartScene,e._drawLabel(t,n)),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)}},Path:{fill:"none",stroke:()=>e.schema.colorDefaults.missing,strokeWidth:2},r:N(7),width:N(12),height:N(12)})},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>e._drawLabel(t,n,(t.depth??1)-1)})},{key:"legendTooltip",merge:!0,factory:e=>({title:ur.bind(e)})}]};var jF=xf(WF);const HF={fontSize:11,fontWeight:600,padding:3};function IF(e){if(!1===e.schema.groupLabels)return null;const t=e.schema.groupLabelConfig??{};return{...HF,fontFamily:e.schema.fontFamily,...t}}function GF(e){return Math.ceil(1.2*e.fontSize+2*e.padding)}function VF(e,t){const{drawDepth:n,padding:i,style:o}=e;return e=>{const a=e;if(!o||a.depth<1||a.depth>n||null==a.data.key||!function(e,t,n){return t>=2*GF(n)&&e>=3*n.fontSize+2*n.padding}(a.x1-a.x0,a.y1-a.y0,o))return i;const r=GF(o);return t.set(a,r),r+i}}function qF(e){return e.ancestors().reverse().slice(1).map(e=>`${e.data.key}`).join("/")}const YF=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const{width:n,height:i}=ie(e),a=o.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),r=A.hierarchy({values:a},e=>e.values).sum(e.schema.sum).sort(e.schema.sort),s=e.schema.layoutPadding,c=new Map,l=IF(e),h=e.ctx.treemap.padding(s).paddingTop(VF({drawDepth:e._drawDepth,padding:s,style:l},c)).size([n,i]).tile(e.schema.tile)(r),u=[];h.children&&function n(i){for(const a of i){if(a.depth<=e._drawDepth){n(a.children??[]);continue}const i=a.data,r=i.values??[],s=1===r.length?t.indexOf(r[0]):void 0,c=a;c.__d3plus__=!0,c.id=i.key,c.i=void 0!==s&&s>-1?s:void 0,c.data=o.merge(r,e.schema.aggs),c.x=a.x0+(a.x1-a.x0)/2,c.y=a.y0+(a.y1-a.y0)/2,u.push(c)}}(h.children);const d=e.schema.sort;u.slice().sort(d).forEach((e,t)=>{e.data.rank=t});const f=h.value;!function(e,t){for(const[n,i]of e){const e=n.leaves().map(e=>e.data),a=o.merge(e,t.aggs);delete a._isAggregation,delete a._threshold,delete a[zr],a[Ge]=n.depth-1;const r=t.label?t.label(a,0):void 0;null!=r&&!1!==r&&""!==r&&(a[Ve]=`${r}`),wr(a,(n.value??0)/t.total),n.groupHeader={__d3plus__:!0,data:a,depth:n.depth-1,id:qF(n),x0:n.x0,y0:n.y0,x1:n.x1,y1:Math.min(n.y1,n.y0+i)}}}(c,{aggs:e.schema.aggs,label:l?.label,total:f});const m=e.schema.sum;return u.forEach(e=>{const t=m(e.data)/f;e.share=t,wr(e.data,t)}),{shapeData:u}};function KF(e,t,n){if(!t.length)return[];const i=new Map,o=t=>{let o=i.get(t);return void 0===o&&(o=tu(n.fill,t.data,0)??function(e,t,n){const i=()=>x.interpolateRgb(Ia(e),Ga(e))(.7);if(e.schema.colorScale)return i();const o=au(e,"Rect"),a=l.color(`${tu(o.fill,t,n)}`);return a?a.darker(.8).formatHex():i()}(e,t.data,0),i.set(t,o)),o},a=e.schema.sum,s=t=>e._drawLabel(t.data,0,t.depth),c=t.map(t=>({type:"rect",key:`treemap-group-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:o(t)},aria:{label:`${s(t)}, ${a(t.data)}, ${d.formatAbbreviate(100*Cr(t.data),e.schema.locale)}%`}})),h=new Map(t.map(e=>[e.data,e])),u=iw({data:t,label:e=>s(e),x:e=>e.x0,y:e=>e.y0,aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:N(0),id:e=>`group-${e.id}`,datum:e=>e.data,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;return{x:0,y:0,width:i,height:o}},labelConfig:{fontColor:i=>{const a=h.get(i.data)??t[0];return tu(n.fontColor,a.data,0)??r.colorContrast(o(a),e.schema.colorDefaults)},...n.fontFamily?{fontFamily:n.fontFamily}:{},fontResize:!1,fontSize:n.fontSize,fontWeight:n.fontWeight,maxLines:1,padding:n.padding,textAnchor:"start",verticalAlign:"middle"}});for(const e of u)e.shapeType="Label";return[...c,...u]}const UF={treemapBinary:A.treemapBinary,treemapDice:A.treemapDice,treemapResquarify:A.treemapResquarify,treemapSlice:A.treemapSlice,treemapSliceDice:A.treemapSliceDice,treemapSquarify:A.treemapSquarify},XF=e=>!!e.children&&1===e.children.length&&!0===e.children[0].data._isAggregation,QF={name:"Treemap",layoutStage:YF,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.schema.locale,o=e._drawLabel,a=au(e,"Rect"),s=n.map(t=>{const n=tu(a.fill,t.data,t.i),r=tu(a.stroke,t.data,t.i),s=tu(a.opacity,t.data,t.i),c=tu(a.strokeWidth,t.data,t.i);return{type:"rect",key:`treemap-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:nu(a,t.data,t.i,n),stroke:"string"==typeof r||null==r?r:String(r),opacity:s,strokeWidth:c},aria:{label:`${o(t.data,t.i??0)}, ${e.schema.sum(t.data)}, ${d.formatAbbreviate(100*t.share,i)}%`}}}),c=iw({data:n,label:e=>{const t=e;return[o(t.data,t.i??0),`${d.formatAbbreviate(100*t.share,i)}%`]},x:e=>{const t=e;return t.x0+(t.x1-t.x0)/2},y:e=>{const t=e;return t.y0+(t.y1-t.y0)/2},aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:N(0),id:e=>e.id,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;let a=Math.min(32,.5*(o-10));return a<8&&(a=0),[{width:i,height:o-a,x:-i/2,y:-o/2},{width:i,height:a+10,x:-i/2,y:o/2-a-10}]},labelConfig:{fontMax:32,textAnchor:e=>e&&0===e.l?"start":"middle",verticalAlign:e=>e&&0===e.l?"top":"bottom",fontColor:t=>{const n=t&&t.data?t.data:t,i=tu(a.fill,n,n.i);return"string"==typeof i?r.colorContrast(i,e.schema.colorDefaults):void 0},...ru(e,"Rect")}});for(const e of c)e.shapeType="Label";const l=qy(a,s,e=>[n[e].data,n[e].i]),h=IF(e),u=h?KF(e,function(e){const t=new Set;for(const n of e){let e=n.parent;for(;e;e=e.parent)e.groupHeader&&t.add(e.groupHeader)}return[...t].sort((e,t)=>e.depth-t.depth)}(n),h):[];return[...s,...l,...c,...u]},thresholdFunction:(e,t)=>QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)}),ctx:{treemap:A.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"groupLabels",default:!0},{key:"groupLabelConfig",default:{},merge:!0},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0),decorate:(e,t)=>{const n=t;return(e,t)=>{const i=XF(e),o=XF(t);return i&&!o?1:!i&&o?-1:n(e,t)}}},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"tile",default:A.treemapSquarify,coerce:e=>{if("string"!=typeof e)return e;const t=`treemap${e.charAt(0).toUpperCase()}${e.slice(1)}`;return UF[t]??A.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i="number"==typeof t.rank?`${t.rank+1}. `:"",o=e.schema.sum;return`${i}${e._drawLabel(t,n)}, ${o(t,n)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:e=>{const t=e.schema.sum;return(e,n)=>t(n)-t(e)}},{key:"legend",coerce:"const",factory:cw}]};var ZF=xf(QF);function JF(e){const t=Array.isArray(e)?e:[e];return new Set(t.filter(e=>"box"===e||"quartiles"===e||"points"===e))}function eB(e){const t=e=>{e.interactive=!1;const n=e.children;n&&n.forEach(t)};return e.forEach(t),e}function tB(e,t,n){const i=e.value(t);return e.vertical?{x:n,y:i}:{x:i,y:n}}function nB(e,t,i,o){const{viz:a}=e,r=t.map(e=>e.slot.half*("both"===e.slot.side?.16:.08)),s=Math.max(3,Math.min(10,Math.min(...r))),c=i.vertical,l=a._select&&"function"==typeof a._select.node?a._select.node():null,h=l?n.backgroundColor(l):"#fff",u=t.map(({row:e,meta:t,slot:n})=>{const r=`density-box-${e.id}`,l="both"===n.side?n.center:n.center+("start"===n.side?-1:1)*Math.min(4,n.half/4),u=t.summary.values.map((e,t)=>({...tB(i,e,l),id:r,i:t})),d=eu("Box").renderMode("compute").config({id:e=>e.id,orient:c?"vertical":"horizontal",rectWidth:s,rectConfig:{fill:o,stroke:o,strokeWidth:0},medianConfig:{fill:h},outlierConfig:{Circle:{fill:o,r:1.5,strokeWidth:0}},whiskerConfig:{endpoint:"Rect",endpointConfig:{Rect:{fill:o,height:c?1:s/2,width:c?s/2:1}},lineConfig:{stroke:o,strokeWidth:1}}}).config(a.schema.innerConfig?.box??{}).data(u);return d.render(),{type:"group",key:r,children:su(d)}});return wD(u,c?"x":"y"),eB(u)}function iB(e,t,n,i){const{viz:o}=e,a=o.schema.innerConfig?.quartiles??{},r=(e,o)=>{const r=[],s=new Map;t.forEach(({row:t,meta:i,slot:o})=>{e.forEach(e=>{const a=i.summary[e],c=lD(i.summary.curve,a)*i.scale*o.half,[l,h]=$D(o,c),u=`density-${e}-${t.id}`;s.set(u,o.center),r.push({id:u,...tB(n,a,l)},{id:u,...tB(n,a,h)})})});const c=eu("Line").renderMode("compute").config({stroke:i,strokeWidth:1,strokeDasharray:o,curve:"linear"}).config(a).data(r);c.render();const l=su(c);return vD(l,n.vertical?"x":"y",s),eB(l)};return[...r(["q1","q3"],"4 3"),...r(["median"],"0")]}function oB(e,t,n){const{viz:i,events:o}=e,a=i.schema.innerConfig?.points??{},r="number"==typeof a.r?a.r:2.5,s=Im(t.map(({meta:e})=>e.summary.observed.map(e=>({value:n.value(e),r:r}))),{padding:.5,extent:Math.max(1,Math.min(...t.map(e=>e.slot.half*("both"===e.slot.side?.8:.4)))),overflow:"shrink"}),c=[];t.forEach(({row:e,meta:t,slot:i},o)=>{const a="both"===i.side?0:("start"===i.side?-1:1)*i.half*.45;t.summary.observed.forEach((r,l)=>{const h=t.summary.rows[l];c.push({__d3plus__:!0,data:h,i:l,id:`density-point-${e.id}-${l}`,...tB(n,r,i.center+a+s.offsets[o][l])})})});const l=eu("Circle").renderMode("compute").config(au(i,"Circle")).config({r:r*s.scale,label:!1,x:e=>e.x,y:e=>e.y}).config(a).data(c);return i._wirePlotShapeEvents(l,"Circle",o),l.render(),su(l)}function aB(e,t,n){const i=JF(e.viz.schema.inner);if(!t.length||!i.size)return[];const o=Ga(e.viz),a=(e,t)=>t.length?[{type:"group",key:`violin-${e}`,children:t}]:[];return[...i.has("points")?a("points",oB(e,t,n)):[],...i.has("quartiles")?a("quartiles",iB(e,t,n,o)):[],...i.has("box")?a("box",nB(e,t,n,o)):[]]}const rB=(e,t)=>{const{viz:n,values:i,x:o,y:a,xRange:r,yRange:s,xDomain:c,yDomain:l}=e,h="y"!==n.schema.discrete,u=h?o:a,d=h?a:o,f=h?"x":"y",m=h?r:s,p=h?c:l,g=p.map(e=>u(e,f)).sort((e,t)=>e-t);let y=SD(m[m.length-1]-m[0],p.length,.5);for(let e=1;e<g.length;e++)y=Math.min(y,g[e]-g[e-1]);const x=i.filter(e=>dD(e)),b=CD(x.map(e=>`${e[f]}`),{position:e=>u(e,f),step:y,gap:n._groupPadding??0,split:Boolean(n.schema.split)}),_=x.map((e,t)=>({row:e,meta:dD(e),slot:b[t]})),k=[];_.forEach(({row:e,meta:t,slot:n})=>{MD(t.summary.curve,t.scale,n.half).forEach(t=>{const[i,o]=$D(n,t.extent);k.push({...e,id:fD(e),__pos:d(t.value),__low:i,__high:o})})});const v=e=>e.__pos,w=e=>e.__low,S=e=>e.__high,C=h?{x:w,x0:w,x1:S,y:v,y0:v,y1:null}:{x:v,x0:v,x1:null,y:S,y0:S,y1:w},M=cx({...e,values:k,shapeConfig:{...e.shapeConfig,...C}},t);return vD(M,f,new Map(_.map(({row:e,slot:t})=>[fD(e),t.center]))),M.concat(aB(e,_,{vertical:h,value:e=>d(e)}))},sB={name:"Violin",paintDriven:!0,defaults:{groupPadding:16},setup:e=>yD(e,{valueAxis:e=>"y"===e.schema.discrete?"x":"y",categoryPadding:()=>[.5,.5],emit:rB}),ctx:{},fields:[{key:"discrete",default:"x"},{key:"inner",default:"box"},{key:"split",default:!1},...bD(),..._D(2),{key:"innerConfig",merge:!0,default:{box:{},quartiles:{},points:{}}},{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var cB=xf(sB,_b);const lB=e=>Number.isFinite(e)&&e>0?e:0;function hB(e,t){const n=e.map(lB),i=n.reduce((e,t)=>e+t,0),o=Math.max(0,Math.round(lB(t)));if(!i||!o)return n.map(()=>0);const a=n.map(e=>e/i*o),r=a.map(Math.floor);let s=o-r.reduce((e,t)=>e+t,0);const c=a.map((e,t)=>({i:t,r:e-r[t],v:n[t]})).filter(e=>e.v>0).sort((e,t)=>t.r-e.r||t.v-e.v||e.i-t.i);for(let e=0;s>0&&c.length;e=(e+1)%c.length)r[c[e].i]++,s--;return r}function uB(e,{cells:t,unit:n}){if(void 0!==n&&lB(n)){const t=e.map(lB).reduce((e,t)=>e+t,0);return hB(e,Math.round(t/n))}return hB(e,t)}function dB(e,{rows:t,columns:n,fillDirection:i,unit:o}){const a=Math.max(1,Math.round(lB(t))||1),r=Math.max(1,Math.round(lB(n))||1);if(void 0===o||!lB(o))return{rows:a,columns:r};const s=Math.max(1,e);return"column"===i?{rows:a,columns:Math.ceil(s/a)}:{rows:Math.ceil(s/r),columns:r}}function fB(e,{rows:t,columns:n,fillDirection:i,fillStart:o}){let a="column"===i?e%t:Math.floor(e/n),r="column"===i?Math.floor(e/t):e%n;return o.startsWith("bottom")&&(a=t-1-a),o.endsWith("right")&&(r=n-1-r),{row:a,column:r}}function mB(e,t,{rows:n,columns:i,padding:o}){const a=lB(e),r=lB(t),s=Math.max(1,n),c=Math.max(1,i);let l=lB(o),h=Math.min((a+l)/c,(r+l)/s);l>.4*h&&(l=.4*Math.min(a/c,r/s),h=Math.min((a+l)/c,(r+l)/s));const u=Math.max(0,h-l);return{size:u,padding:l,x:(a-(c*u+(c-1)*l))/2,y:(r-(s*u+(s-1)*l))/2}}const pB=["top-left","top-right","bottom-left","bottom-right"];function gB(e){const t=e.schema.fillStart,n=Number(e.schema.unit);return{fillDirection:"column"===e.schema.fillDirection?"column":"row",fillStart:pB.includes(t)?t:"top-left",unit:n>0&&Number.isFinite(n)?n:void 0}}const yB=({viz:e})=>{const t=e._filteredData??[];if(!t.length)return{shapeData:[]};const n=e.schema.sum,i=e.schema.sort,o=t.map((e,t)=>t);"function"==typeof i&&o.sort((e,n)=>i(t[e],t[n])||e-n);const a=o.map(e=>Number(n(t[e],e))),r=a.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0),s=a.map(e=>r&&Number.isFinite(e)&&e>0?e/r:0);o.forEach((e,n)=>wr(t[e],s[n]));const{fillDirection:c,fillStart:l,unit:h}=gB(e),u=dB(0,{rows:Number(e.schema.rows),columns:Number(e.schema.columns),fillDirection:c}),d=uB(a,{cells:u.rows*u.columns,unit:h}),f=dB(d.reduce((e,t)=>e+t,0),{...u,fillDirection:c,unit:h}),{width:m,height:p}=ie(e),g=mB(m,p,{...f,padding:Number(e.schema.cellPadding)||0}),y=g.size+g.padding,x=[];let b=0;return o.forEach((n,i)=>{const o=t[n],a=e._ids(o,n).join("-"),r=s[i];for(let e=0;e<d[i];e++,b++){const t=fB(b,{...f,fillDirection:c,fillStart:l});x.push({__d3plus__:!0,data:o,i:n,id:`${a}-${e}`,k:b,n:e,...t,x:g.x+t.column*y,y:g.y+t.row*y,size:g.size,share:r})}}),e.ctx.waffleTotal=r,e.ctx.waffleGrid=f,e.ctx.waffleGeometry=g,{shapeData:x}};function xB(e,t){const{x:n,y:i,size:o}=e;if("circle"===t)return{type:"circle",cx:n+o/2,cy:i+o/2,r:o/2};const a={type:"rect",x:n,y:i,width:o,height:o};if("rounded"!==t)return a;const r=.25*o;return{...a,rx:r,ry:r}}function bB(e){return"rounded"===e||"circle"===e?e:"square"}function _B(e,t){return null!=e&&Number.isFinite(e)?`${d.formatAbbreviate(100*e,t)}%`:""}function kB(e,t){const n=e.schema.sum;if(t._isColorScaleBucket)return Pa(e,t.color,n);const i=Mr(t),o=Cr(i);return Number.isFinite(o)?o:$r(i,e._legendData||[],e=>n(e,0))}function vB(e){const t=()=>e.schema.locale;return[[()=>e.schema.translate("Value"),(n,i,o)=>{if(o&&o._isColorScaleBucket)return"";const a=e.schema.sum,r=Number(a(n,i));return Number.isFinite(r)?d.formatAbbreviate(r,t()):""}],[()=>e.schema.translate("Share"),(n,i,o)=>_B(kB(e,o??{}),t())]]}const wB=e=>!0===e._isAggregation,SB={name:"Waffle",layoutStage:yB,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=bB(e.schema.cellShape),o=au(e,"circle"===i?"Circle":"Rect"),a=e.schema.icon,r=e.schema.sum,s=e.schema.locale,c=(e,t)=>a?tu(a,e,t):void 0,l=n.map(t=>{const{data:n,i:a}=t,l=c(n,a),h=tu(o.fill,n,a),u=l?{fill:"transparent"}:{fill:nu(o,n,a,h),stroke:tu(o.stroke,n,a),strokeWidth:tu(o.strokeWidth,n,a)},f=0===t.n?`${e._drawLabel(n,a)}, ${r(n,a)}, ${d.formatAbbreviate(100*t.share,s)}%`:void 0;return{...xB(t,i),key:`waffle-${t.id}`,index:a,datum:n,paint:{...u,opacity:tu(o.opacity,n,a)},aria:f?{label:f}:{hidden:!0}}}),h=qy(a?{...o,backgroundImage:(e,t)=>c(e,t)||tu(o.backgroundImage,e,t),backgroundImageFit:(e,t)=>c(e,t)?"contain":tu(o.backgroundImageFit,e,t)}:o,l,e=>[n[e].data,n[e].i]);return[...l,...h]},insetRegion:Uu,thresholdFunction:(e,t)=>QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)}),facet:{aspect:1},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellShape",default:"square"},{key:"columns",default:10},{key:"fillDirection",default:"row"},{key:"fillStart",default:"top-left"},{key:"icon"},{key:"rows",default:10},{key:"sort",factory:e=>(e=>(t,n)=>{const i=e.schema.sum;return i(n)-i(t)})(e),decorate:(e,t)=>{const n=t;return(e,t)=>{const i=wB(e),o=wB(t);return i&&!o?1:!i&&o?-1:n(e,t)}}},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"unit"},{key:"zoom",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:vB(e)})},{key:"legendTooltip",merge:!0,factory:e=>({tbody:vB(e)})},{key:"legendSort",factory:e=>(e=>(t,n)=>{const i=e.schema.sort;return"function"==typeof i?i(t,n):0})(e)}]};var CB=xf(SB);const MB={increase:"Increase",decrease:"Decrease",total:"Total"};function $B(e,t,n){const i=t[`${e}Color`];if("string"==typeof i&&i)return i;const o={...r.colorDefaults,...n};return"increase"===e?o.on:"decrease"===e?o.off:o.sequential}function AB(e,t){return"total"===e.kind?t(e.end):e.change>0?`+${t(e.change)}`:t(e.change)}const zB=e=>"total"===e.kind?e.end>=0:e.change>=0,DB={height:20,width:56,minWidth:64,gap:2};function FB(e,t,n){const i=zB(e),{gap:o}=DB;if(n){const e=Math.max(t.width,DB.minWidth),n=DB.height;return{x:-e/2,y:i?-t.height-n-o:t.height+o,width:e,height:n}}const a=DB.width;return{x:i?t.width+o:-t.width-a-o,y:-t.height/2,width:a,height:t.height}}function BB(e,t){const n=zB(e);return t?{textAnchor:"middle",verticalAlign:n?"bottom":"top"}:{textAnchor:n?"start":"end",verticalAlign:"middle"}}function LB(e,t,n){return e&&"total"!==e.kind?[[n("Running Total"),t(e.end)]]:[]}function PB(e,t){return({data:n,x:i,y:o,x2:a})=>{if(a||!t.labels())return[i,o];const r=t.vertical(),s=r?o:i,c=n.map(t=>t.data?e(t.data):void 0).filter(e=>!!e),l=s.range(),h=Math.abs(l[l.length-1]-l[0]);if(!c.length||!h)return[i,o];const u=s.domain().slice();r&&u.reverse();const d=r?DB.height+DB.gap:DB.width+DB.gap,f=function(e,t,n){let[i,o]=e;const a=Math.min(Math.max(n,0),.45);if(!a||!t.length)return[i,o];let r=-1/0,s=1/0;for(const e of t)zB(e)?r=Math.max(r,e.end):s=Math.min(s,e.end);for(let e=0;e<8;e++){const e=o-i;Number.isFinite(r)&&(o=Math.max(o,r+a*e)),Number.isFinite(s)&&(i=Math.min(i,s-a*e))}return[i,o]}([u[0],u[1]],c,d/h);return r&&f.reverse(),s.domain(f),[i,o]}}function RB(e,t,n){const i=[],o=e=>{if("rect"===e.type&&"Bar"===e.shapeType&&e.datum?.data){const o=e.datum.data,a=t(o),r=n?(e.transform?.x??0)+(e.x??0):(e.transform?.y??0)+(e.y??0),s=(n?e.width:e.height)??0;a&&Number.isFinite(r)&&Number.isFinite(s)&&i.push({step:a,datum:o,lo:r,hi:r+s})}e.children?.forEach(o)};return e.forEach(o),i}function EB(e,t,n){const i=new Map;for(const t of e){let e=i.get(t.step.series);e||i.set(t.step.series,e=new Map),e.has(t.step.index)||e.set(t.step.index,t)}const o=[];return i.forEach(e=>{e.forEach(i=>{const a=e.get(i.step.index-1);if(!a||!i.step.joins)return;const r=t(a.step.end);if(!Number.isFinite(r))return;const s=i.lo+i.hi>=a.lo+a.hi,c=s?a.hi:a.lo,l=s?i.lo:i.hi;o.push(n?{from:a,x1:c,y1:r,x2:l,y2:r}:{from:a,x1:r,y1:c,x2:r,y2:l})})}),o}function NB(e,t,n){return"function"==typeof e?e(t,n):e}function TB(e,t){return e.map((e,n)=>{const i=e.from.datum,o={fill:"none",stroke:NB(t.stroke,i,n),strokeWidth:NB(t.strokeWidth,i,n),strokeOpacity:NB(t.strokeOpacity,i,n)},a=rz(NB(t.strokeDasharray,i,n));return a&&(o.strokeDasharray=a),{type:"line",key:`waterfall-connector-${e.from.step.series}-${e.from.step.index}`,points:[[e.x1,e.y1],[e.x2,e.y2]],curve:"linear",paint:o,interactive:!1,interactionGroup:"axis"}})}const OB=["increase","decrease","total"],WB=e=>"number"==typeof e&&Number.isFinite(e)?e:void 0;function jB(e,t){const n=Number(e instanceof Date?+e:e)-Number(t instanceof Date?+t:t);return Number.isNaN(n)?0:n}function HB(e,t,n){const i=e.values.filter(e=>void 0!==e),o=i.reduce((e,t)=>e+t,0),{series:a,index:r}=n;if(e.subtotal){const n=i.length?o:t;return{series:a,index:r,category:e.category,kind:"total",start:0,end:n,change:n-t,joins:r>0&&(s=n,c=t,Math.abs(s-c)<=1e-9*Math.max(1,Math.abs(s),Math.abs(c)))}}var s,c;if(i.length)return{series:a,index:r,category:e.category,kind:o<0?"decrease":"increase",start:t,end:t+o,change:o,joins:r>0}}function IB(e,t){const{category:n,series:i,value:o,subtotal:a,sort:r}=t,s=new Map;e.forEach((e,t)=>{const o=`${i(e,t)}`,a=n(e,t),r=a instanceof Date?""+ +a:`${a}`;let c=s.get(o);c||s.set(o,c=new Map);const l=c.get(r);l?l.rows.push([e,t]):c.set(r,{category:a,rows:[[e,t]]})});const c=new Map;return s.forEach((e,t)=>{const n=Array.from(e.values());!function(e,t){t?e.sort((e,n)=>t(e.rows[0][0],n.rows[0][0])):e.sort((e,t)=>jB(e.category,t.category))}(n,r);let i=0,s=0;for(const e of n){const n=HB({category:e.category,values:e.rows.map(([e,t])=>WB(o(e,t))),subtotal:!!a&&e.rows.some(([e,t])=>!!a(e,t))},i,{series:t,index:s});n&&(i=n.end,s++,e.rows.forEach(([e])=>c.set(e,n)))}}),c}function GB(e){const t=new Set;for(const n of e)n&&t.add(n.kind);return OB.filter(e=>t.has(e))}function VB(e,t){return void 0===WB(e)&&t&&"total"===t.kind?t.end:e}function qB(e){return t=>{for(const n of t){const t=n.key;for(const i of n){const n=(i.data??[]).find(e=>e.id===t),o=n&&n.data?e(n.data):void 0;o&&(i[0]=Math.min(o.start,o.end),i[1]=Math.max(o.start,o.end))}}}}const YB="__d3plusWaterfallKind",KB=e=>e.ctx.waterfall,UB=e=>"y"===e.schema.discrete?"y":"x",XB=e=>"x"===UB(e)?"y":"x";function QB(e){for(;e&&(e.__d3plus__||e.__d3plusShape__)&&e.data;)e=e.data;return e}function ZB(e,t,n){const i="function"==typeof e.schema.facet?e.schema.facet:void 0,o=n&&"function"==typeof e.schema.time?e.schema.time:void 0,a=KB(e).accessors[UB(e)],r=o&&t.length&&o(t[0],0)!==a(t[0],0)?o:void 0;return(t,n)=>{const o=[e._ids(t,n).slice(0,(e._drawDepth??0)+1).join("_")];return i&&o.unshift(`${i(t,n)}`),r&&o.unshift(`${r(t,n)}`),o.join("|")}}function JB(e){const t=e.schema[`${UB(e)}Sort`];return"function"==typeof t&&t!==KB(e).ySort?t:void 0}const eL=e=>e instanceof Date?""+ +e:`${e}`;function tL(e){const t=KB(e),n=e.schema.ySort;void 0===n||n===t.ySort?"y"===UB(e)?e.schema.ySort=t.ySort=function(e,t){const n=n=>e.get(eL(t(n,0)))??-1;return(e,t)=>n(t)-n(e)}(function(e,t){const n=new Map;e.forEach((e,i)=>{const o=t(e,i),a=eL(o);n.has(a)||n.set(a,o)});const i=Array.from(n.entries()).sort((e,t)=>jB(e[1],t[1]));return new Map(i.map(([e],t)=>[e,t]))}(e._data||[],t.accessors.y),t.accessors.y):t.ySort&&(e.schema.ySort=t.ySort=void 0):t.ySort=void 0}function nL(e,t,n){const i=KB(e);if(!t||!t.length||i.laidOut.has(t))return;i.laidOut.add(t);IB(t,{category:i.accessors[UB(e)],series:ZB(e,t,n),value:i.accessors[XB(e)],subtotal:e.schema.subtotal,sort:JB(e)}).forEach((e,t)=>i.steps.set(t,e))}function iL(e,t){const n=QB(t);if(n)return nL(e,e._filteredData,!1),e._axisPersist&&nL(e,e._data,!0),KB(e).steps.get(n)}function oL(e,t){const n=QB(t);if(!n)return;const i=n[YB];return"string"==typeof i?i:iL(e,n)?.kind}function aL(e){const t=QB(e)?.[YB];return"string"==typeof t?t:void 0}function rL(e){const t=e[`_${XB(e)}Config`];return t&&"function"==typeof t.tickFormat?t.tickFormat:t=>d.formatAbbreviate(t,e.schema.locale)}const sL=new WeakSet;const cL=(e,t)=>{const n=oL(e,t);return n?e.schema.translate(MB[n]):void 0},lL=e=>"x"===UB(e);const hL={name:"Waterfall",paintDriven:!0,thresholdFunction:(e,t)=>t,setup:e=>{e.ctx.waterfall={accessors:{x:e._x,y:e._y},steps:new WeakMap,laidOut:new WeakSet},function(e){const t=KB(e);["x","y"].forEach(n=>{const i=`_${n}`,o=e[i];sL.has(o)||(t.accessors[n]=o);const a=(i,o)=>{const a=t.accessors[n](i,o);return XB(e)!==n||void 0!==WB(a)?a:VB(a,iL(e,i))};sL.add(a),Object.defineProperty(e,i,{configurable:!0,enumerable:!0,get:()=>a,set:e=>{sL.has(e)||(t.accessors[n]=e)}})})}(e),e._stackOffset=qB(t=>iL(e,t)),e._stackGroup=(t,n)=>e._ids(t,n).slice(0,e._drawDepth+1).join("_"),e._stackShares=!1,e.schema.color=t=>oL(e,t),function(e){const t=e.schema.shapeConfig.fill;e.schema.shapeConfig.fill=(n,i)=>{const o=oL(e,n);return o?$B(o,e.schema,e.schema.colorDefaults):t(n,i)};const n=(t,n,i)=>{const o=iL(e,t);return o?BB(o,lL(e))[n]:i},i=e.schema.shapeConfig.Bar??{};e.schema.shapeConfig.Bar={...i,ariaLabel:(t,n)=>{const i=iL(e,t);return i?`${i.category}, ${cL(e,t)}: ${AB(i,rL(e))}.`:e._drawLabel(QB(t),n)},label:t=>{const n=iL(e,t);return!!n&&AB(n,rL(e))},labelBounds:(t,n,i)=>{const o=iL(e,t);return!!o&&FB(o,i,lL(e))},labelConfig:{...i.labelConfig??{},fontColor:()=>Ga(e),fontResize:!1,fontSize:12,fontStroke:"transparent",fontStrokeWidth:0,padding:0,textAnchor:e=>n(e,"textAnchor","middle"),verticalAlign:e=>n(e,"verticalAlign","middle")}}}(e),function(e){const t=(t,n)=>cL(e,t)??e._drawLabel(t,n),n=e.schema.legendConfig;e.schema.legendConfig={...n,label:t,shapeConfig:{...n.shapeConfig??{},ariaLabel:t}},e.schema.legendSort=(t,n)=>OB.indexOf(oL(e,t))-OB.indexOf(oL(e,n)),delete e.schema.on["click.legend"];const i=e.schema.on.mouseenter;e.schema.on.mouseenter=function(t,n,o,a){const r=aL(t);if(!r)return i.call(this,t,n,o,a);1!==e.schema.shapeConfig.hoverOpacity&&e.hover(t=>oL(e,t)===r)}}(e),e._buffer={...e._buffer,Bar:PB(t=>iL(e,t),{vertical:()=>lL(e),labels:()=>!1!==e.schema.shapeConfig.Bar?.label})},e._plotUnderlay=(t,n,i)=>{if(!e.schema.connectors)return[];const o=lL(e);return TB(EB(RB(t,t=>iL(e,t),o),o?e=>i(e):e=>n(e),o),e.schema.connectorConfig)};const t=e._preDraw.bind(e);e._preDraw=()=>{!function(e){const t=KB(e);t.steps=new WeakMap,t.laidOut=new WeakSet}(e),tL(e),t();const n=e._filteredData||[];e._legendData=GB(n.map(t=>iL(e,t))).map(e=>({[YB]:e}))}},ctx:{},fields:[{key:"connectors",default:!0},{key:"decreaseColor"},{key:"increaseColor"},{key:"legend",coerce:"const",factory:()=>(e,t)=>t.length>1},{key:"stacked",default:!0},{key:"subtotal",coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:void 0},{key:"totalColor"},{key:"connectorConfig",merge:!0,factory:e=>({stroke:()=>Ga(e),strokeDasharray:"",strokeOpacity:.6,strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>function(e,t,n){const i=QB(t);if(aL(i))return cL(e,i)??"";const o=e._drawLabel(i,n);return"undefined"===o?cL(e,i)??o:o}(e,t,n),tbody:t=>LB(iL(e,t),rL(e),e.schema.translate)})}]};var uL=xf(hL,Sb);e.Area=Io,e.AreaPlot=kb,e.Axis=hi,e.AxisBottom=ui,e.AxisLeft=di,e.AxisRight=fi,e.AxisTop=mi,e.BOTTOM_RIGHT_CONTRIBUTORS=Td,e.Bar=Vo,e.BarChart=Sb,e.BaseClass=$e,e.Beeswarm=Mb,e.Box=Sa,e.BoxWhisker=Wb,e.Bullet=E_,e.BumpChart=T_,e.CANDLESTICK_SHAPE=qv,e.CONNECTOR_KEY_SUFFIX=fw,e.Calendar=Bk,e.Candlestick=ew,e.Chord=rw,e.Circle=Uo,e.ColorScale=Gi,e.DEFAULT_AGGS=tv,e.DEFAULT_BAND_OPACITY=Am,e.DENSITY=hD,e.DOMAIN_CLIP_KEY=wy,e.Donut=dw,e.Dumbbell=ww,e.END_LABEL_AXIS_CONFIG=Hg,e.FACET_ASPECT=Re,e.FACET_PADDING=20,e.FACET_TITLE_DEFAULTS=Pe,e.FanChart=Mw,e.Funnel=yS,e.Gauge=_S,e.Geomap=TS,e.Histogram=XS,e.INSET_PRIORITY=Va,e.Icicle=XC,e.Image=Ma,e.LABEL_COMBOS=ud,e.Legend=bi,e.Line=ya,e.LinePlot=Sw,e.Lollipop=lM,e.MARK_TYPES=Qe,e.Marimekko=yM,e.Matrix=wM,e.Message=Ji,e.NO_SIDES=hd,e.Network=HM,e.Pack=YM,e.ParallelCoordinates=Z$,e.Path=Aa,e.Pie=uw,e.Plot=_b,e.PolarArea=VA,e.Priestley=KA,e.Pyramid=Lz,e.RADIAL_BAR_MIN_LABEL_GAP=Iz,e.RESET=O,e.RESOLVES_RESET=j,e.Radar=Nz,e.RadialBar=Jz,e.RadialMatrix=oD,e.Rect=Yo,e.Ridgeline=BD,e.Rings=GD,e.STEM_KEY_SUFFIX=QC,e.Sankey=hF,e.Shape=jo,e.SizeLegend=Zi,e.StackedArea=uF,e.Sunburst=RF,e.TOP_LEFT_CONTRIBUTORS=Ah,e.TextBox=ro,e.Timeline=yo,e.Tooltip=Mo,e.Tree=jF,e.Treemap=ZF,e.VIOLIN_PADDING=.5,e.VOLUME_DEFAULTS=_v,e.Violin=cB,e.Viz=yf,e.Waffle=CB,e.Waterfall=uL,e.Whisker=_a,e.absoluteFormat=iz,e.accessor=T,e.addDays=G_,e.aggregateFunctionFields=av,e.alignAxisLine=Qg,e.alignInsets=gd,e.allotEndLabelWidths=Kg,e.applyAxisBreaks=hn,e.applyBarWidths=ym,e.applyBulletLayout=w_,e.applyCalendarLayout=Sk,e.applyChordLayout=tw,e.applyFunnelLayout=qw,e.applyGaugeLayout=t_,e.applyGeomapLayout=DS,e.applyIcicleLayout=PC,e.applyLineStates=U$,e.applyMatrixLayout=bM,e.applyNetworkLayout=AM,e.applyPackLayout=IM,e.applyPaddedDomains=Zm,e.applyParallelLayout=k$,e.applyPieLayout=lw,e.applyPolarAreaLayout=HA,e.applyPriestleyLayout=qA,e.applyRadarLayout=Rz,e.applyRadialBarLayout=Xz,e.applyRadialMatrixLayout=tD,e.applyRingsLayout=WD,e.applySankeyLayout=rF,e.applySunburstLayout=kF,e.applySwarmLanes=Km,e.applyTreeLayout=TF,e.applyTreemapLayout=YF,e.applyWaffleLayout=yB,e.autoForecastStart=function(e){const t=am(Array.from(rm(e).values()));return t?t.value:null},e.autoLineOpacity=t$,e.axisBarNodes=fn,e.axisDomain=c$,e.axisPositions=n$,e.backContribution=Bc,e.backdropDecor=nx,e.backgroundImageNode=Vy,e.backgroundImageNodes=qy,e.bandAxisDefaults=bv,e.bandOpacityTargets=Pm,e.bandPolygon=by,e.bandRows=yg,e.bandStep=az,e.barKey=dm,e.barSpanAxisConfig=km,e.barWidthAccessor=fm,e.barWidthLabel=vm,e.barWidthTooltipRows=wm,e.baselineBreakAxisConfig=ep,e.baselineBreakStyle=cn,e.baselineDomainAxis=wf,e.beeswarmDef=Cb,e.betweenPoints=Uf,e.binData=GS,e.blockDays=Z_,e.blockGrid=rk,e.blockMonths=J_,e.blockWeeks=Q_,e.bottomRightClearance=nc,e.bottomRightControlsBox=Zs,e.bottomRightControlsDrop=tc,e.bottomRightControlsFeature=Wd,e.bottomRightControlsInset=ec,e.bottomRightControlsShortfall=ic,e.boundOrValue=Em,e.breakGap=dn,e.breakLineNodes=gy,e.breakLinePaint=py,e.breakStyle=sn,e.breakTickValues=un,e.broadcastLegend=pt,e.broadcastLink=dt,e.brokenBarScene=mn,e.brokenScale=on,e.brokenScaleTicks=an,e.brushFromPixels=M$,e.brushTarget=_$,e.bulletAxis=r_,e.bulletBands=n_,e.bulletDef=R_,e.bulletExtents=b_,e.bulletStack=f_,e.calendarBlocks=X_,e.calendarDateFormat=vk,e.calendarDateSpecifier=nk,e.calendarDayKey=H_,e.calendarDef=Fk,e.calendarEmit=zk,e.calendarFormatter=tk,e.calendarInsets=mk,e.calendarLabelStyle=kk,e.calendarLayout=gk,e.calendarOrient=_k,e.calendarPalette=Ck,e.calendarPeriod=bk,e.calendarTimeLocale=ek,e.candleAriaLabel=Iv,e.candleChange=Nk,e.candleDirection=Ek,e.candlePath=Hk,e.candleTexture=Uv,e.candleTooltipRows=Hv,e.candleWidth=Wk,e.candlestickBuffer=uv,e.candlestickDef=Jv,e.canvasTooCoarse=$l,e.categoryGaps=xw,e.categoryStep=SD,e.cellCornerRadius=hk,e.chordDef=aw,e.clampBarConfig=op,e.clearPanelSlots=Ac,e.clearStrip=R$,e.clipToPlotArea=Fy,e.closestFreeOffset=Tm,e.coerceFacet=Ee,e.colorScaleFeature=fu,e.colorValue=Mk,e.columnHighlight=Lk,e.compareCategories=jB,e.compareFacetValues=qh,e.comparisonOutline=oz,e.computeAxisLayout=function(e){return Vn(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.computeFilteredData=Ih,e.computeSizeLegend=Ki,e.computeTimeFilter=Hh,e.confidenceBands=Bm,e.configOpenDomain=kf,e.configPrep=Ae,e.configWarnings=function(e){if(!arguments.length)return ue;ue=!!e},e.connectorBars=RB,e.connectorNodes=TB,e.connectorSegments=EB,e.connectorStroke=kw,e.constant=N,e.conversionModes=Yw,e.conversionRates=Ow,e.cornerControlsHeight=wu,e.cornerPlacements=Su,e.curveFactory=If,e.curvePolyline=Yy,e.dashArray=rz,e.dateExtent=U_,e.daysBetween=I_,e.defaultCalendarDate=Dk,e.defaultSizeLegendValues=Yi,e.densityAt=lD,e.densityGroups=rD,e.densityMeta=dD,e.densityShapeId=fD,e.densityStats=aD,e.densityTooltipRows=xD,e.densityWidthScale=sD,e.detectDimensions=XM,e.dimensionAxisConfig=l$,e.dimensionDomain=ZM,e.dimensionTitleStyle=h$,e.dimensionTooltipRows=T$,e.dimensionType=QM,e.discreteDirection=Jy,e.discreteOrder=im,e.discreteRank=om,e.domainEnds=Vg,e.drawChart=Rd,e.drawFacets=Pd,e.drawWithInset=rd,e.dumbbellDef=vw,e.dumbbellEmit=yw,e.dumbbellSpans=mw,e.emitCandlesticks=Xv,e.emitEndLabels=Zg,e.emitFillBetween=Qf,e.emitForecast=tx,e.emitInner=aB,e.emitLineBands=Oy,e.emitVolume=Ev,e.endLabelSpace=Yg,e.expandArea=yd,e.extraBandValues=Nm,e.facetActive=Ie,e.facetAreaMargin=Cd,e.facetBodyNode=wd,e.facetDimensions=cd,e.facetFilteredData=Xh,e.facetGrid=ld,e.facetGroups=Uh,e.facetKey=Gh,e.facetOuterAxes=je,e.facetPanelAt=Mc,e.facetPanelNode=Sd,e.facetScalesShared=He,e.facetTimeFilter=Qh,e.facetTitleBand=Dd,e.facetTitleNodes=vd,e.facetTitleStyle=Ad,e.facetTitleTexts=zd,e.fanChartDef=Cw,e.fillBetweenDefaults=Yf,e.fillBetweenPairs=Kf,e.finiteValue=Pk,e.firstValue=Xk,e.fitCalendar=ok,e.fitFontSize=Kw,e.fitInset=nd,e.fitSwarms=Im,e.fittedArea=sd,e.forEachSceneRow=Ze,e.forecastDashOr=ox,e.forecastDefaults=nm,e.forecastLineDash=ix,e.forecastRow=sm,e.forecastRows=ax,e.forecastStart=lm,e.formatChange=Wv,e.formatDimensionValue=N$,e.formatFacetValue=Zh,e.formatPrice=Ov,e.formatShare=_B,e.frameTotals=JA,e.frozenAxis=ry,e.funnelCurve=Gw,e.funnelDef=gS,e.funnelEmit=hS,e.funnelFacetHooks=mS,e.funnelFacetPanel=fS,e.funnelLabelNodes=rS,e.funnelOrder=jw,e.funnelOrient=Iw,e.funnelStages=Vw,e.funnelTooltipRows=pS,e.gapComparator=bw,e.gaugeDef=bS,e.geomapDef=NS,e.getTopLeftContributions=zh,e.groupFacets=Kh,e.growFromLine=vD,e.growRectsFromCenter=wD,e.gutterAxisDefaults=_z,e.gutterInset=dz,e.gutterStackOffset=fz,e.gutterWidth=pz,e.hasBrushes=C$,e.hasColorValue=$k,e.hasFullConfigDomain=Cf,e.hasOpenUserEnd=Af,e.hasUserDomain=Sf,e.histogramDef=US,e.icicleBands=$C,e.icicleCollapse=zC,e.icicleDef=UC,e.icicleLabelBox=IC,e.icicleLayout=BC,e.icicleRect=AC,e.icicleRootEdge=DC,e.icicleStagger=FC,e.inheritedFillStyle=em,e.innerSet=JF,e.insetBackground=Qa,e.insetComponentOffset=Ja,e.insetFrame=Xa,e.insetOrient=Ua,e.insetPlacementFor=Ka,e.insetStyle=qa,e.installDensity=yD,e.installFluent=ee,e.installVolumeStrip=Lv,e.isAggregatedBranch=JS,e.isBrokenScale=en,e.isDomainClip=Ly,e.isExpandOffset=uM,e.isFluentAccessor=Z,e.isInsetPending=Ya,e.isMissing=UM,e.isNumeric=KM,e.isNumericRange=v$,e.isOneSided=_f,e.keyedAccessor=qk,e.kindColor=$B,e.labelAlign=BB,e.labelBarWidth=mm,e.labelBox=FB,e.labelExpansions=fd,e.labelGutter=md,e.labelKey=dd,e.labelMetrics=TC,e.labelOverhang=xd,e.labelPadding=dk,e.labelSizeCap=aS,e.labelsXEnds=Gg,e.largestRadius=eM,e.largestRemainder=hB,e.largestValue=zw,e.lastValue=Qk,e.layerOpacities=Rm,e.layoutAxes=p$,e.layoutBarSpans=gm,e.layoutCandles=Kv,e.layoutEndLabels=Ug,e.legendFeature=Th,e.legendLabelsWhole=Ph,e.lineAriaLabel=H$,e.lineBoxes=Qw,e.lineCurve=Gf,e.linePoints=g$,e.lineRows=function(e){const t=e.find(([e])=>"Line"===e);return t?t[1]:[]},e.linkAs=ht,e.linkKeys=st,e.linkMembers=function(e){return Array.from(Je.get(e)??[])},e.linkPredicate=lt,e.linkValues=ct,e.linkedColorDefaults=rt,e.listAxis=rb,e.lollipopBuffer=tM,e.lollipopDef=cM,e.lollipopEmit=aM,e.marimekkoAxisDefaults=fM,e.marimekkoDef=gM,e.marimekkoFacetAxes=mM,e.marimekkoFixedAxes=pM,e.marimekkoPercentText=dM,e.markBoxes=Ku,e.maskBreaks=_y,e.maskPath=xy,e.matrixDef=vM,e.maxValue=Zk,e.measureAxis=Vn,e.measureBars=pm,e.measureEndLabels=qg,e.measureFacetTitles=kd,e.mergeBranch=nC,e.mergeConfig=G,e.mergeConfigBag=Y,e.minValue=Jk,e.monotoneSlopes=Fw,e.monthLabelWeek=ck,e.monthOutlinePath=sk,e.narrowName=ik,e.neckConfig=sS,e.neckPaint=cS,e.nestPartition=ZS,e.nestSunburst=ZS,e.networkDef=jM,e.normalizeBreaks=tn,e.ohlcAccessors=lv,e.ohlcBarPath=Ik,e.ohlcExtent=Tk,e.openEnd=ap,e.openEndAxisConfig=zf,e.outsideBaselineBreak=np,e.packDef=qM,e.panelAxisConfig=hb,e.panelBase=pd,e.panelLabels=Md,e.panelTitle=Bd,e.parallelCoordinatesDef=Q$,e.parallelDimensionKeys=x$,e.parallelEmit=I$,e.parallelOrient=b$,e.parallelPath=y$,e.parseCalendarDate=j_,e.partitionFocus=aC,e.partitionLayout=iC,e.partitionLineage=oC,e.partitionShadeAmount=SC,e.partitionSort=eC,e.partitionSplit=NC,e.percentText=Zw,e.periodDate=mv,e.periodSpacing=Ok,e.pieDef=hw,e.pixelCenter=jk,e.pixelsFromBrush=$$,e.placeEndLabels=Xg,e.planFunnelLabels=Xw,e.planLabel=Uw,e.planStageLabels=iS,e.plotAxisConfig=Jm,e.plotAxisRounding=Mf,e.plotEmit=xx,e.plotFacetHooks=mb,e.plotFacetInsets=fb,e.plotFacetPanel=db,e.plotPaint=function(e,t){return _x(e,t).nodes},e.polarAreaDef=GA,e.polarAreaDomainValues=jA,e.polarAreaEmit=IA,e.polarAreaSlotOf=WA,e.polarAxisConfig=J$,e.polarBoxesOverlap=wA,e.polarCategoryLayout=$A,e.polarCategoryNodes=AA,e.polarFacetHooks=aA,e.polarFacetPanel=iA,e.polarHorizontalLayout=CA,e.polarInnerRadius=RA,e.polarLabelFitRadius=kA,e.polarLabelPlacement=_A,e.polarLabelRoom=vA,e.polarLabelsCollide=SA,e.polarLevelNodes=zA,e.polarLevels=PA,e.polarPadAngle=LA,e.polarRadius=DA,e.polarSharedExtent=oA,e.polarSlotArc=EA,e.polarSlotTops=TA,e.polarSlots=FA,e.polarSpokeRotation=MA,e.polarStack=BA,e.polarValueRow=eA,e.polarWedgeLayout=OA,e.polarWedgeNodes=tA,e.prefixKeys=bd,e.priestleyDef=YA,e.profileKnots=Bw,e.profileSlice=Rw,e.pyramidDef=Bz,e.pyramidExtent=ez,e.pyramidSides=XA,e.pyramidStackOrder=hM,e.pyramidTotal=ZA,e.radarDef=Ez,e.radialBarDef=Zz,e.radialBarDomainValues=Uz,e.radialBarEmit=Qz,e.radialBarFootprint=Wz,e.radialBarLabelRoom=Oz,e.radialBarRows=Yz,e.radialBarSweep=Hz,e.radialBarTrackLabels=Gz,e.radialBarTrackLayout=qz,e.radialBarTracks=Tz,e.radialMatrixDef=iD,e.rangeText=bg,e.readOhlc=Rk,e.registerLink=ot,e.renderAxes=hy,e.reserveBottomRight=Od,e.resolveBaselineBreak=ln,e.resolveBrushStyle=X$,e.resolveConfidenceBands=Fm,e.resolveDimensions=JM,e.resolveFacetAxes=Oe,e.resolveFacetConfig=Ne,e.resolveLineOpacity=j$,e.resolveLink=it,e.resolveSaveConfig=vl,e.resolveSpec=Fh,e.resolveSwarm=Ym,e.resolveWeekStart=K_,e.resolvesReset=K,e.ridgeOverlap=AD,e.ridgelineDef=FD,e.ridgelineEmit=DD,e.ridgelinePadding=zD,e.ringsDef=ID,e.roundOpenEnd=rp,e.roundPlotOpenEnds=cp,e.roundedDomain=On,e.rowBands=Lm,e.rowDate=yk,e.rowLegend=cw,e.rowPasses=S$,e.rowsExtent=xk,e.runLayout=xu,e.runPostDrawFeatures=Hd,e.runStages=ne,e.runVizPipeline=jd,e.sankeyDef=lF,e.saveChart=Al,e.saveContribution=Ul,e.saveFilename=bl,e.saveFormats=xl,e.savePixelRatio=Ml,e.sceneInsetRegion=Uu,e.searchContribution=wh,e.secondaryAxisRounding=$f,e.segmentWidth=Lw,e.seriesForecastStarts=rm,e.shareFunnelLabelSize=uS,e.shareFunnelScale=dS,e.sharePlotScales=cb,e.sharePolarScale=nA,e.shareRow=sw,e.sharedDomains=e$,e.sharedScaleMax=Hw,e.sideClip=Xf,e.sideControlsDrop=vu,e.sideSign=QA,e.sideTitleBoxes=cz,e.sizeLegendContribution=Nd,e.sliceExtent=Tw,e.slicePath=Nw,e.slotEdge=ex,e.slotPosition=ak,e.snapMagnitude=nz,e.sortByMedian=cD,e.sortFacetValues=Yh,e.splitDash=Uy,e.splitLength=Ky,e.stageAria=lS,e.stageBoxes=eS,e.stageLabelSize=oS,e.stageLines=Jw,e.stageSpans=$w,e.stageWidths=Dw,e.startOfDay=W_,e.stemFromBar=ZC,e.stemPoints=JC,e.stepLabel=AB,e.stepValue=VB,e.stripLength=F$,e.stripSelection=B$,e.stripSize=Cv,e.subtitleFeature=$u,e.sumValue=ev,e.summarizeBeforePreDraw=pD,e.sunburstDef=PF,e.sunburstFocus=_F,e.sunburstLabelBox=AF,e.sunburstLabelMetrics=FF,e.sunburstLayout=bF,e.sunburstPadAngle=pF,e.sunburstRadii=fF,e.sunburstSplit=NC,e.svgForSave=Cl,e.swarmExtent=Wm,e.swarmFitScale=Hm,e.swarmHidesAxis=Um,e.swarmLayout=Om,e.swarmPlacements=Xm,e.symmetricDomain=tz,e.syncBrushDom=E$,e.syncDefaultAggs=ov,e.syncGapSort=_w,e.tableViewContribution=gl,e.thinBands=gz,e.timelineFeature=Au,e.titleFeature=Mu,e.titleHeight=r$,e.titleNodes=s$,e.titleWidths=a$,e.toFacetValue=Vh,e.topLeftControlsFeature=Dh,e.totalFeature=zu,e.treeDef=WF,e.treemapDef=QF,e.trendForecastStart=cm,e.unionExtent=sb,e.unregisterLink=at,e.unwrapBreakMasks=vy,e.unwrapDomainClips=Py,e.unwrapRow=uD,e.userAxisDomain=Df,e.userDomainBreaksBaseline=tp,e.valueAxis=bf,e.valueAxisExtent=ip,e.valueDirection=Zf,e.valuePasses=w$,e.violinDef=sB,e.violinEdges=$D,e.violinEmit=rB,e.violinOutline=MD,e.violinSlots=CD,e.vizDraw=tf,e.vizPostThresholdCtx=uf,e.vizPreDraw=df,e.volumeAccessor=kv,e.volumeAriaLabel=Gv,e.volumeScale=Mv,e.volumeStripRect=Pv,e.waffleCellGeometry=mB,e.waffleCellGeometryNode=xB,e.waffleCellPosition=fB,e.waffleCellShape=bB,e.waffleCounts=uB,e.waffleDef=SB,e.waffleFillOptions=gB,e.waffleGrid=dB,e.waffleShare=kB,e.waffleTooltipRows=vB,e.waterfallDef=hL,e.waterfallKinds=GB,e.waterfallStackOffset=qB,e.waterfallStep=HB,e.waterfallSteps=IB,e.waterfallTooltipRows=LB,e.weekIndex=q_,e.weekdayLabelSlots=lk,e.weekdayNames=fk,e.weekdaySlot=V_,e.widenDomain=hv,e.withFacetPanel=$c,e.wrapLineCount=jC,e.xAxisRounding=eg,e.zoomSizeLegendScale=Ui});
|
|
7
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@d3plus/color"),require("@d3plus/data"),require("d3-color"),require("d3-selection"),require("@d3plus/dom"),require("@d3plus/render"),require("@d3plus/text"),require("d3-scale"),require("@d3plus/locales"),require("d3-zoom"),require("@d3plus/math"),require("d3-array"),require("d3-brush"),require("d3-transition"),require("@d3plus/format"),require("@floating-ui/dom"),require("d3-time-format"),require("d3-time"),require("d3-shape"),require("d3-interpolate"),require("d3-delaunay"),require("@d3plus/export"),require("d3-chord"),require("d3-tile"),require("d3-geo"),require("topojson-client"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-hexbin"),require("d3-contour"),require("d3-hierarchy"),require("d3-force"),require("d3-polygon")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","@d3plus/color","@d3plus/data","d3-color","d3-selection","@d3plus/dom","@d3plus/render","@d3plus/text","d3-scale","@d3plus/locales","d3-zoom","@d3plus/math","d3-array","d3-brush","d3-transition","@d3plus/format","@floating-ui/dom","d3-time-format","d3-time","d3-shape","d3-interpolate","d3-delaunay","@d3plus/export","d3-chord","d3-tile","d3-geo","topojson-client","d3-geo-projection","d3-composite-projections","d3-hexbin","d3-contour","d3-hierarchy","d3-force","d3-polygon"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus=t.d3plus||{},t.d3plus,t.d3plus,t.d3,t.d3,t.d3plus,t.d3plus,t.d3plus,t.d3,t.d3plus,t.d3,t.d3plus,t.d3,t.d3,t.d3,t.d3plus,t.FloatingUIDOM,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3plus,t.d3,t.d3,t.d3,t.topojson,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,i,o,r,a,s,c,l,h,u,d,f,m,p,g,y,x,b,k,_,v,w,M,S,C,$,A,z,D,L,F,N){"use strict";function B(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var E=B(c),R=B(b),P=B(S),T=B(A);const O=new WeakMap;function W(t){const e=function(){return t};return O.set(e,{value:t}),e}function j(t){return"function"==typeof t?O.get(t):void 0}function H(t,e){return void 0===e?e=>e[t]:n=>void 0===n[t]?e:n[t]}const I=new WeakMap;function G(t){const e=H(t);return"string"==typeof t&&I.set(e,t),e}function q(t){return"function"==typeof t?I.get(t):void 0}const V=Object.freeze({background:"#ffffff",text:e.colorDefaults.dark,textMuted:"#767676",axis:e.colorDefaults.dark,gridline:e.colorGray[200],accent:"#228be6",hidden:"#aaa",link:e.colorGray[500],colorScale:Object.freeze({max:e.colorDefaults.sequential,mid:e.colorDefaults.light,min:e.colorDefaults.off}),tooltip:Object.freeze({background:e.colorDefaults.light,text:e.colorDefaults.dark,border:"rgba(0, 0, 0, 0.25)",shadow:"0 1px 5px rgba(0, 0, 0, 0.25)",divider:"rgba(0, 0, 0, 0.1)"}),overlay:Object.freeze({background:"rgba(255, 255, 255, 0.75)",text:"rgba(0, 0, 0, 0.75)",border:"rgba(0, 0, 0, 0.25)"}),table:Object.freeze({background:"#fff",text:e.colorGray[900],header:"#fff",border:"#ccc",rule:"#e0e0e0"})}),K=Object.freeze({background:e.colorGray[900],text:e.colorDefaults.light,textMuted:e.colorGray[500],axis:e.colorDefaults.light,gridline:e.colorGray[800],accent:"#4dabf7",hidden:e.colorGray[600],link:e.colorGray[700],colorScale:Object.freeze({max:"#4dabf7",mid:e.colorGray[800],min:"#ff6b6b"}),tooltip:Object.freeze({background:e.colorGray[800],text:e.colorDefaults.light,border:"rgba(255, 255, 255, 0.2)",shadow:"0 1px 5px rgba(0, 0, 0, 0.6)",divider:"rgba(255, 255, 255, 0.15)"}),overlay:Object.freeze({background:"rgba(24, 25, 28, 0.75)",text:"rgba(255, 255, 255, 0.85)",border:"rgba(255, 255, 255, 0.25)"}),table:Object.freeze({background:e.colorGray[900],text:e.colorDefaults.light,header:e.colorGray[900],border:e.colorGray[700],rule:e.colorGray[800]})});function Y(t){const e=i.lab(t).l;return Number.isFinite(e)&&e<50}function U(t,e){const n=i.rgb(t);return n.opacity=e,n.formatRgb()}const X=t=>"object"==typeof t&&null!==t&&!Array.isArray(t);function Q(t,n={dark:!1},i={}){if("light"===t||"dark"===t||X(t)){const e=X(t)?t:{},n="dark"===t||"dark"===e.base||!e.base&&"string"==typeof e.background&&Y(e.background),i=n?K:V,{colorScale:o,tooltip:r,overlay:a,table:s,...c}=e;return delete c.base,Object.freeze({...i,...c,colorScale:{...i.colorScale,...o},tooltip:{...i.tooltip,...r},overlay:{...i.overlay,...a},table:{...i.table,...s},dark:n,painted:!0})}const o=n.dark?K:V,r=n.background??o.background,a=i.dark||e.colorDefaults.dark,s=e.colorContrast(r,i);return Object.freeze({...o,background:r,text:s,axis:s,gridline:s===a?e.colorGray[200]:e.colorGray[800],dark:n.dark,painted:!1})}function Z(t,e,n){if(!t)return n;const i=e(t);return i===e(V)?n:i}function J(t,e,n){return Z(t,t=>t.colorScale[e],n)}function tt(t,n,i,o=!1){return t?.dark?e.colorRampDark(n,i,{background:t.background,ordinal:o}):e.colorRamp(n,i,{ordinal:o})}function et(t,e,n){const i={...t};for(const t of Object.keys(n))void 0!==n[t]&&i[t]===e[t]&&(i[t]=n[t]);return i}const nt="D3PLUS-COMMON-RESET";function it(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}const ot=Symbol("d3plus.resolvesReset");function rt(t){return it(t)?at({},t):Array.isArray(t)?t.slice():t}function at(t,e,n){for(const i of Object.keys(e)){const o=e[i],r=it(n)?n[i]:void 0;if(o===nt)void 0===r?delete t[i]:t[i]=rt(r);else if(it(o)){const e=t[i];t[i]=at(it(e)?e:{},o,r)}else t[i]=rt(o)}return t}function st(t,e,n){return at(rt(t),e,n)}function ct(t){return t===nt||it(t)&&Object.values(t).some(ct)}function lt(t,e){if("function"==typeof t.coerce)return t.coerce(e);switch(t.coerce){case"accessor":return"function"==typeof e?e:"string"==typeof e?H(e):W(e);case"const":return"function"==typeof e?e:W(e);default:return e}}function ht(t,e,n,i){const o=ct(n)?t._defaultConfig?.()[e]:void 0;if(n===nt)return it(o)?st({},o):{};const r=arguments.length>3?i:t.schema[e];return st(it(r)?r:{},it(n)?n:{},o)}function ut(t,e){const n={};for(const i of e)"function"==typeof t[i]&&(n[i]=nt);return n}function dt(t,...e){for(const n of e){const e=t[n];if("function"!=typeof e)throw new Error(`resolvesReset: "${n}" is not a method`);e[ot]=!0}}function ft(t,e,n){return n===nt?rt(t._defaultConfig?.()[e]):ht(t,e,n)}const mt=new WeakMap;function pt(t,e,n){let i=mt.get(t);if(i||mt.set(t,i=new Map),n===nt)return void i.delete(e);if(!it(n))return;let o=i.get(e);o||i.set(e,o=new Set);for(const[t,e]of Object.entries(n))e===nt||void 0===e?o.delete(t):o.add(t)}const gt=Symbol("d3plus.fluentAccessor"),yt=new WeakMap;function xt(t){return"function"==typeof t&> in t}function bt(t,e){for(let n=t;n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return!xt(t.value)}return!1}function kt(t,e,n={}){t.schema||(t.schema={});for(const i of e){const e=i.key,o=e in n;if("default"in i||void 0!==i.factory){const n="default"in i?i.default:i.factory(t);let o=lt(i,n);i.decorate&&(o=i.decorate(t,o));const r=t.schema[e],a=i.merge&&it(o)?st(it(r)?r:{},o):o;t.schema[e]=a,i.onSet?.(t,a)}else if(o&&void 0===t.schema[e]){const o=lt(i,n[e]);t.schema[e]=o,i.onSet?.(t,o)}}const i=Object.getPrototypeOf(t);if(!i)return;let o=yt.get(i);if(o||yt.set(i,o=new WeakSet),!o.has(e)){o.add(e);for(const t of e){if(bt(i,t.key))continue;const e=t.key;i[e]=function(...n){if(!n.length)return this.schema[e];const i=lt(t,n[0]);t.merge&&pt(this,e,i);const o=t.merge?ft(this,e,i):i;return this.schema[e]=o,t.onSet?.(this,o),this},t.merge&&(i[e][ot]=!0),Object.defineProperty(i[e],gt,{value:!0})}}}const _t={drawDepth:"_drawDepth",id:"_id",ids:"_ids",drawLabel:"_drawLabel",timeFilter:"_timeFilter",filteredData:"_filteredData",legendData:"_legendData"};function vt(t,e){let n=t;const i=t.viz;for(const t of e){const e=t(n);n=Object.assign({},n,e);for(const t of Object.keys(e)){const n=_t[t],o=e[t];n&&void 0!==o&&(i[n]=o)}}return n}function wt(t){return{width:t.schema.width-t._margin.left-t._margin.right,height:t.schema.height-t._margin.top-t._margin.bottom}}function Mt(t,e,n){return{x:t._margin.left+e/2,y:t._margin.top+n/2}}function St(t){const{width:e,height:n}=wt(t);return{type:"rect",x:t._margin.left,y:t._margin.top,width:e,height:n}}function Ct(t,e,n,i){if(function(t){return!0===t.paintDriven}(e))throw new Error(`runChartDraw cannot drive ${e.name} — it's a paint-driven chart (ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely on Plot._paint to populate _chartScene imperatively; their _draw should NOT call runChartDraw.`);t._chartScene=[];const o=vt({viz:t},[n]);if(!Array.isArray(t._chartScene))throw new Error(`runChartDraw: stage for ${e.name} replaced viz._chartScene with a non-array value (got ${typeof t._chartScene}). Stages should use \`(v._chartScene ||= []).push(...)\` rather than reassigning.`);const r=t._chartScene.slice(),a=e.emit(o);t._chartScene=[...r,...a],t._chartTransform=i?i(t):function(t){return{x:t._margin.left,y:t._margin.top}}(t),t._chartClip=e.chartClip?e.chartClip(t):void 0,t._bodyRect=e.chartBodyRect?e.chartBodyRect(t):{x:0,y:0,...wt(t)}}const $t=t=>Number(r.date(Number(t)));function At(t,e,n,i){const o=t._xFunc,a=t._yFunc,s=t._x,c=t._y,l=t._id,h=t.schema.time;if(!(o&&a&&s&&c&&t._data&&h))return[];const u=function(t){const e=new Set,n=t=>!0===t||"number"==typeof t&&t>0,i=t=>{for(const o of t)!n(o.trailPersist)||"circle"!==o.type&&"rect"!==o.type||e.add(o.key),"group"===o.type&&i(o.children)};return i(t.root.children),e}(e);if(!u.size)return[];const d=new Set;t._data.forEach((t,e)=>d.add($t(h(t,e))));const f=[...d].filter(t=>t>n&&t<i).sort((t,e)=>t-e);if(!f.length)return[];const m=new Map;t._data.forEach((t,e)=>{const n=l(t,e);if(!u.has(n))return;let i=m.get(n);i||m.set(n,i=new Map),i.set($t(h(t,e)),{d:t,i:e})});const p=e=>t._yTime?r.date(e):e;return f.map(e=>({sequence:e,positions:[...u].flatMap(n=>{const i=m.get(n)?.get(e);return i?[{key:n,x:o((l=s(i.d,i.i),t._xTime?r.date(l):l)),y:a(p(c(i.d,i.i)))}]:[];var l})})).filter(t=>t.positions.length>0)}const zt=new WeakSet,Dt=new Set,Lt=new WeakMap;let Ft=!0;function Nt(t){return zt.add(t),t}function Bt(t){return"object"==typeof t&&null!==t&&zt.has(t)}function Et(t,e){Rt(`${t} received unknown property "${e}".`)}function Rt(t){Ft&&!Dt.has(t)&&(Dt.add(t),console.warn(t))}function Pt(t,e,n){if(!Ft)return;let i=Lt.get(t);i||Lt.set(t,i=new Set),i.has(e)||(i.add(e),console.warn(n))}const Tt=["d3plus-render-svg","d3plus-render-canvas"];function Ot(t){return(t?.elements?.()??[]).filter(t=>"svg"===t.localName||"canvas"===t.localName)}const Wt=new WeakMap;function jt(t){const e=(Array.isArray(t)?t:[t]).flatMap(t=>"string"==typeof t?t.split(/\s+/).filter(Boolean):[]);return Array.from(new Set(e))}function Ht(t,e,n=[]){const i=jt(e);for(const e of Wt.get(t)??[])i.includes(e)||n.includes(e)||t.classList.remove(e);for(const e of i)t.classList.add(e);Wt.set(t,i)}function It(t){for(const{el:e,keep:n}of t._classNameTargets())Ht(e,t.schema.className,n)}const Gt=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");function qt(t){const e=t.constructor;return Object.prototype.hasOwnProperty.call(e,"_displayName")?e._displayName:e.name}function Vt(t,e){if(!it(t)||!ct(t))return t;const n={...t},i=r.isObject(e)?e:{};for(const t of Object.keys(n))t.startsWith("_")||(n[t]===nt?void 0===i[t]?delete n[t]:n[t]=i[t]:n[t]=Vt(n[t],i[t]));return n}const Kt=new Set(["config","constructor","destroy","layout","measure","parent","render","renderMode","toCanvas","toSVGString","toScene","zoomBrush","zoomIn","zoomOut","zoomReset"]);function Yt(t){let e=[];do{e=e.concat(Object.getOwnPropertyNames(t)),t=Object.getPrototypeOf(t)}while(t&&t!==Object.prototype);return e.filter(t=>0!==t.indexOf("_")&&!Kt.has(t))}function Ut(t,e,n){if(!n.has(t)){n.add(t),t.schema.colorDefaults={...t.schema.colorDefaults,...e};for(const i of[...Object.values(t),...Object.values(t.ctx)])i instanceof Xt&&Ut(i,e,n)}}class Xt{config(t){const e=this._defaultConfig();if(arguments.length){for(const n in t)if({}.hasOwnProperty.call(t,n))if(n in this){const i=t[n],o=this[n];i===nt&&"on"===n?this.schema.on=e[n]:o[ot]?o.call(this,i):i===nt?o.call(this,e[n]):o.call(this,Vt(i,e[n]))}else Bt(t)||Et(`${qt(this)}.config()`,n);return this}{const t={};return Yt(Object.getPrototypeOf(this)).forEach(e=>{t[e]=this[e]()}),t}}_defaultConfig(){if(!this._configDefault){const t={};Yt(Object.getPrototypeOf(this)).forEach(e=>{const n=this[e]();n!==this&&(t[e]=r.isObject(n)?r.assign({},n):n)}),this._configDefault=t}return this._configDefault}locale(t){return arguments.length?(this.schema.locale=l.findLocale(t),this):this.schema.locale}className(t){return arguments.length?(this.schema.className=t,It(this),this):this.schema.className}_classNameTargets(){return Ot(this._sceneRenderer).map(t=>({el:t,keep:Tt}))}colorDefaults(t){if(!arguments.length)return this.schema.colorDefaults;const{scale:e,...n}=t??{},i={...n};return Array.isArray(e)?i.scale=c.scaleOrdinal().range(e):e&&(i.scale=e),Ut(this,i,new WeakSet),this}on(t,e){return 2===arguments.length?(this.schema.on[t]=e,this):arguments.length?"string"==typeof t?this.schema.on[t]:(this.schema.on=Object.assign({},this.schema.on,t),this):this.schema.on}parent(t){return arguments.length?(this.schema.parent=t,this):this.schema.parent}translate(t){return arguments.length?(this.schema.translate=t,this):this.schema.translate}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ht(this,"shapeConfig",t),this):this.schema.shapeConfig}constructor(){this.schema={},this.ctx={},this.schema.colorDefaults={...e.colorDefaults},this.schema.locale="en-US",this.schema.on={},this.schema.parent={},this.schema.translate=(t,e=this.schema.locale)=>{const n=l.translateLocale[e],i=t;return n&&n[i]?n[i]:t},this._uuid=crypto.randomUUID()}}function Qt(){if("undefined"==typeof window||"function"!=typeof window.matchMedia)return!1;try{return!!window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function Zt(t){const e=t.schema.reducedMotion;return!0===e||!1!==e&&Qt()}function Jt(t){return Zt(t)?0:Number(t.schema.duration)||0}function te(t=this.schema.shapeConfig,e="shape",n=!1){const i={duration:Jt(this),on:{}},o=t=>(e,n,i,o)=>{if(!t)return t;let r;for(;e.__d3plus__;)r&&(e.__d3plusParent__=r),r=e,n=e.i,e=e.data||e.feature;return t.bind(this)(e,n,i||r,o)},r=(t,n)=>{for(const i in n)({}.hasOwnProperty.call(n,i)&&!i.includes(".")||i.includes(`.${e}`))&&(t.on[i]=o(n[i]))},a=t=>t.map(t=>t instanceof Array?a(t):"object"==typeof t?s({},t):"function"==typeof t?o(t):t),s=(t,e)=>{for(const n in e)({}).hasOwnProperty.call(e,n)&&("on"===n?r(t,e[n]):"sort"===n?t[n]=e[n]:"function"==typeof e[n]?t[n]=o(e[n]):e[n]instanceof Array?t[n]=a(e[n]):"object"==typeof e[n]?(t[n]||(t[n]={}),t[n].on={},s(t[n],e[n])):t[n]=e[n]);return t};return s(i,t),this.schema.on&&r(i,this.schema.on),n&&t[n]&&(s(i,t[n]),t[n].on&&r(i,t[n].on)),Nt(i)}function ee(t,e,n){return e[t]||this.schema[t](e,n)}function ne(t){const e=t._select,n=e&&"function"==typeof e.node?e.node():null;if(!(n instanceof Element))return;const i=n,o=t.schema.width??400,r=t.schema.height??200;t._sceneRenderer?t._sceneRenderer.resize(o,r):(t._sceneRenderer=new a.SvgRenderer,t._sceneRenderer.mount({container:i,width:o,height:r}));const s={root:{type:"group",key:"root",children:[t.toScene()]},width:o,height:r};t._sceneRenderer.drawScene(s,{duration:0}),It(t)}Xt._displayName="BaseClass",dt(Xt.prototype,"shapeConfig");const ie={fontSize:12,fontWeight:600,padding:4,textAnchor:"middle"},oe=4/3;function re(t){return"function"==typeof t?t:"string"==typeof t&&t?G(t):void 0}function ae(t){const e=t??{},n=t=>"number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0;return{columns:n(e.columns),rows:n(e.rows),padding:"number"==typeof e.padding&&e.padding>=0?e.padding:20,sort:e.sort??"ascending",scales:"shared"===e.scales||"independent"===e.scales?e.scales:void 0,axes:ce(e.axes),title:!1===e.title||"function"==typeof e.title?e.title:void 0,titleConfig:{...ie,...e.titleConfig??{}}}}const se=t=>"outer"===t||"all"===t;function ce(t){if(se(t))return t;if(!t||"object"!=typeof t)return;const{x:e,y:n}=t,i={};return se(e)&&(i.x=e),se(n)&&(i.y=n),i.x||i.y?i:void 0}function le(t,e){return"object"==typeof t?t[e]:t}function he(t,e,n,i){const o="function"==typeof n.axes?n.axes(t):n.axes,r=n.fixedAxes?n.fixedAxes(t):{},a=t=>"outer"===(le(e.axes,t)??le(o,t)??"outer")&&(i||!!r[t]);return{x:a("x"),y:a("y")}}function ue(t,e){return"shared"===(t.scales??e.scales??"shared")}function de(t){return"function"==typeof t.schema.facet}const fe="__d3plusGroupDepth",me="__d3plusGroupLabel";function pe(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function ge(t){const e=pe(t),n=e?e[fe]:void 0;return"number"==typeof n?n:void 0}function ye(t,e,n){const i=pe(e);return t.slice(0,n+1).map(t=>t(i,0))}function xe(t,e,n,i){const o=pe(n);return!!o&&e.every((e,n)=>{const r=t[n](o,i);return r===e||Array.isArray(r)&&r.includes(e)})}function be(t,e,n){return n.some((n,i)=>!xe(t,e,n,i))}function ke(t){return"legend"===t.kind}function _e(t){if(t)for(let e=t.length-1;e>=0;e--){const n=t[e];if(!ke(n))return n}}function ve(t){const e=_e(t);return e&&t.splice(t.lastIndexOf(e),1),e}function we(t,e){return t.length===e.length&&t.every(t=>e.includes(t))}function Me(t){return{kind:"legend",hidden:[...t._hidden],solo:[...t._solo]}}function Se(t,e){var n;return!!t.schema.legendHistory&&((!we(e.hidden,t._hidden)||!we(e.solo,t._solo))&&(((n=t)._history??(n._history=[])).push(e),!0))}function Ce(t,e){t._hidden=[...e.hidden],t._solo=[...e.solo]}function $e(t){if(!t._hidden.length&&!t._solo.length)return;const e={hidden:t._hidden,solo:t._solo};return t._hidden=[],t._solo=[],e}function Ae(t){if(t._history){t._history=t._history.filter(t=>!ke(t));for(const e of t._history)delete e.legend}}const ze=new Set(["rect","circle","line","area","path"]);function De(t,e){const n=new Set,i=t=>{if(ze.has(t.type)&&void 0!==t.datum){const i=t.datum,o=i&&i.data?i.data:i;if(void 0!==o&&!n.has(o)){n.add(o);const i="number"==typeof t.index?t.index:"number"==typeof o.i?o.i:0;e(o,i,t)}}const o=t.children;o&&o.forEach(i)};t.forEach(i)}const Le=new Map,Fe=new Map,Ne=new Set,Be=new WeakMap;function Ee(t){const e=t.schema.link;if(!e)return null;const n="string"==typeof e?{group:e}:e;if(!n.group)return null;const i="function"==typeof n.by?n.by:"string"==typeof n.by?H(n.by):(e,n)=>t._id?.(e,n);return{group:n.group,by:i,hover:!1!==n.hover,active:!1!==n.active,highlight:!1!==n.highlight,legend:!1!==n.legend,color:!1!==n.color}}function Re(t){Pe(t);const e=Ee(t);if(!e)return;let n=Le.get(e.group);n||Le.set(e.group,n=new Set),n.add(t),t._linkGroup=e.group}function Pe(t){const e=t._linkGroup;if(void 0===e)return;const n=Le.get(e);n&&(n.delete(t),n.size||(Le.delete(e),Fe.delete(e))),t._linkGroup=void 0}function Te(t){const e=t.schema.colorDefaults,n=t._linkGroup;if(void 0===n||e.scale!==t._autoColorScale)return e;if(!Ee(t)?.color)return e;let i=Fe.get(n);return i||(i=c.scaleOrdinal().range(e.scale.range()),Fe.set(n,i)),{...e,scale:i}}function Oe(t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(t instanceof Date?""+ +t:`${t}`);return n}function We(t,e,n){const i=new Set,o=(t,o)=>{if(n(t,o))for(const n of Oe(e(t,o)))i.add(n)},r=t._chartScene;return r&&r.length?De(r,o):(t._filteredData??[]).forEach(o),i}function je(t,e){return(n,i)=>Oe(t.by(n,i)).some(t=>e.has(t))}function He(t,e){Be.set(t,e)}function Ie(t,e,n){if(Ne.has(e.group))return;const i=Le.get(e.group);if(i&&!(i.size<2)){Ne.add(e.group);try{for(const e of i){if(e===t)continue;const i=Ee(e);i&&n(e,i)}}finally{Ne.delete(e.group)}}}function Ge(t,e,n){const i=Be.get(t);if(Be.delete(t),void 0===n)return;const o=Ee(t);if(!o||!o[e])return;const r="function"==typeof n?i??n:null;let a=null;Ie(t,o,(n,i)=>{if(!i[e])return;const s=n[e];s&&(r&&!a&&(a=We(t,o.by,r)),s.call(n,!!a&&je(i,a)))})}function qe(t,e,n){const i=t._id(e,n);return Array.isArray(i)?i:[i]}function Ve(t,e,n){const i=new Set;return n.length?((t._legendData??[]).forEach((o,r)=>{if(qe(t,o,r).some(t=>n.includes(t)))for(const t of Oe(e.by(o,r)))i.add(t)}),i):i}function Ke(t){const e=Ee(t);if(!e||!e.legend)return;const n=Ve(t,e,t._hidden),i=Ve(t,e,t._solo);Ie(t,e,(t,e)=>{if(!e.legend||!t._legendData?.length)return;const o=[],r=[];t._legendData.forEach((a,s)=>{const c=Oe(e.by(a,s)),l=qe(t,a,s),h=t=>{for(const e of l)t.includes(e)||t.push(e)};i.size&&c.some(t=>i.has(t))?h(r):n.size&&c.length&&c.every(t=>n.has(t))&&h(o)});const a=(t,e)=>t.length===e.length&&t.every(t=>e.includes(t));a(o,t._hidden)&&a(r,t._solo)||(t._hidden=r.length?[]:o,t._solo=r,t.render?.())})}function Ye(t){const e=t.schema.shapeConfig;return Boolean(t._hoverOutline)||1!==e?.hoverOpacity}function Ue(t){const e=globalThis.requestIdleCallback;"function"==typeof e?e(t,{timeout:2e3}):setTimeout(()=>t(void 0),1)}const Xe=()=>"undefined"!=typeof performance?performance.now():Date.now();class Qe{get size(){return this.jobs.size}has(t){return this.jobs.has(t)}add(t,e){this.jobs.has(t)||(this.jobs.set(t,e),this.wake())}keep(t){for(const e of[...this.jobs.keys()])t.has(e)||this.jobs.delete(e)}clear(){this.jobs.clear(),this.before.length=0}beforeNext(t){this.before.push(t),this.wake()}wake(){this.waiting||(this.waiting=!0,Ue(t=>this.turn(t)))}turn(t){this.waiting=!1;const e=Xe(),n=Math.min(12,t?t.timeRemaining():12);for(const t of this.before.splice(0))t();for(const[t,i]of this.jobs){const o=n-(Xe()-e);if(i.step(o)&&this.jobs.get(t)===i&&this.jobs.delete(t),Xe()-e>=n)break}(this.jobs.size||this.before.length)&&this.wake()}constructor(){this.jobs=new Map,this.before=[],this.waiting=!1}}const Ze=new WeakMap;function Je(t){let e=Ze.get(t);return e||Ze.set(t,e=new Qe),e}function tn(t){Ze.get(t)?.clear()}const en={},nn=new WeakMap;function on(){return"undefined"!=typeof IntersectionObserver}function rn(t,e,n,i=0,r){const a=function(t){return!t||"undefined"!=typeof window&&t===window?null:"string"==typeof t?o.select(t).node():"undefined"!=typeof Element&&t instanceof Element?t:null}(e),s=a||en;let c=nn.get(s);if(!c){const t=new Map,e=new IntersectionObserver(e=>{e.forEach(e=>{t.get(e.target)?.forEach(t=>{clearTimeout(t.timer),t.timer=void 0,e.isIntersecting?t.delay>0?t.timer=setTimeout(t.onVisible,t.delay):t.onVisible():t.onHidden?.()})})},{root:a,rootMargin:"25% 0px"});c={targets:t,io:e},nn.set(s,c)}const{targets:l,io:h}=c,u={delay:i,onHidden:r,onVisible:n};let d=l.get(t);return d||l.set(t,d=new Set),d.add(u),h.unobserve(t),h.observe(t),()=>{clearTimeout(u.timer),d.delete(u),d.size||(l.delete(t),h.unobserve(t))}}function an(t){tn(t),null!=t._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(t._sceneRepaintRAF),t._sceneRepaintRAF=void 0),t._sceneRenderer&&"function"==typeof t._sceneRenderer.destroy&&(t._sceneRenderer.destroy(),t._sceneRenderer=void 0)}function sn(t){if(!(t.schema.detectVisible&&t.schema.detectVisibleUnload&&on()))return t._unloadUnobserve?.(),void(t._unloadUnobserve=void 0);t._unloadUnobserve||(t._unloadUnobserve=rn(t._select.node(),t.schema.scrollContainer,()=>function(t){t._unloaded&&(t._unloaded=!1,t._instantNextDraw=!0,t._forceVisible=!0,t.render())}(t),0,()=>function(t){if(t._unloaded)return;t._unloaded=!0,t._resizePoll=clearTimeout(t._resizePoll);const e=t._select.node()?.parentNode;e&&t._resizeObserver?.unobserve(e),t._tooltipClass.data([]).render(),an(t),t._select.selectAll("g.data-table").remove()}(t)))}function cn(t){return t instanceof Array?t.some(n.isData):n.isData(t)}function ln(t){const e=JSON.stringify(t)??"";let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return`${e.length}:${(n>>>0).toString(36)}`}function hn(t,e,i){return new Promise((t,o)=>{let r;const a={_cache:!1,_data:[],config:t=>{r=t}},s=function(t){return(t instanceof Array?t:[t]).map(t=>{if(!n.isData(t))return t;if("string"==typeof t)return{url:t,cache:"no-cache"};const e=t;return"cache"in e?e:{...e,cache:"no-cache"}})}(e);n.load.call(a,s,i,"data",(e,n)=>{e?o(e):t({data:n??[],config:r})})})}function un(t){t._dataPollStop?.(),t._dataPollStop=void 0,t._dataPollFor=void 0}function dn(t){const e=t.schema.dataFormat;return"function"==typeof e?e:void 0}function fn(t){return[t.schema.dataPollingInterval,t._userData,dn(t),t.schema.detectVisible,t.schema.scrollContainer]}function mn(t,e){const n=t._userData,i=dn(t),o=t._select?.node()?.ownerDocument;let r=!1;const a=function(t){let e,n=!1,i=!1,o=!1,r=!1;const a=()=>{e=setTimeout(c,t.interval)},s=()=>{o=!1,i=!0,Promise.resolve().then(t.fetch).then(e=>{n||(r=!1,t.onData(e))},e=>{n||(r||t.onError(e),r=!0)}).catch(e=>{n||t.onError(e)}).finally(()=>{i=!1,n||a()})};function c(){e=void 0,n||(t.paused()?o=!0:s())}return a(),{stop(){n=!0,clearTimeout(e),e=void 0},resume(){n||!o||i||t.paused()||s()}}}({interval:e,fetch:()=>hn(0,n,i),onData:e=>function(t,{data:e,config:n}){const i=ln(e);i!==t._dataSignature&&(t._dataSignature=i,n&&t.config(n),t._data=e,t.schema.timeFilter||(t._timelineSelection=!1),t.render())}(t,e),onError:t=>{console.warn("d3plus: dataPollingInterval could not refresh the data; keeping the last data and retrying.",t)},paused:()=>r||"hidden"===o?.visibilityState}),s=()=>{"hidden"!==o?.visibilityState&&a.resume()};o?.addEventListener("visibilitychange",s);const c=t.schema.detectVisible&&on()?rn(t._select.node(),t.schema.scrollContainer,()=>{r=!1,a.resume()},0,()=>{r=!0}):void 0;t._dataPollFor=fn(t),t._dataPollStop=()=>{a.stop(),o?.removeEventListener("visibilitychange",s),c?.()}}function pn(t){const e=t.schema.dataPollingInterval,n="number"==typeof e&&e>0&&isFinite(e);if(n&&!cn(t._userData)&&Rt(`${qt(t)}: dataPollingInterval only polls data loaded from a URL.`),!n||t._ssr||!cn(t._userData))return void un(t);const i=fn(t),o=t._dataPollFor;o&&o.every((t,e)=>t===i[e])||(un(t),mn(t,e))}const gn=["data","links","nodes","topojson"];function yn(t){return gn.includes(t)}function xn(t,e){const n=t.schema[`${e}Format`];return"function"==typeof n?n:void 0}function bn(t,e,n,i){if(!i)return n;const o=i(n);if("data"===e&&it(o)){const{data:e,...n}=o;return t.config?.(n),e||[]}return o||[]}function kn(t,e,n){`_${e}`in t?t[`_${e}`]=n:t.schema[e]=n}function _n(t,e,i){var o;const r=i[0];i.length>1&&(t.schema[`${e}Format`]=i[1]),n.addToQueue.call(t,r,void 0,e),((o=t)._loaders??(o._loaders={}))[e]={source:r,applied:void 0}}function vn(t){const e=t._loaders;if(!e)return;const i=t._queue??[];for(const o of gn){const r=e[o];if(!r||i.some(t=>t[3]===o))continue;const a=xn(t,o);r.applied!==a&&(cn(r.source)?n.addToQueue.call(t,r.source,void 0,o):(kn(t,o,bn(t,o,r.source,a)),r.applied=a))}}function wn(t,e,n){if(!yn(e))return n;const i=xn(t,e),o=t._loaders?.[e];return o&&(o.applied=i),i}function Mn(...t){return t.map(t=>"topojson"===t?{key:"topojsonFormat",onSet:t=>{t._zoomSet=!1}}:{key:`${t}Format`})}function Sn(t){let e=t._select?.node()?.parentNode??null;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e instanceof HTMLElement?e:null}function Cn(t){return!!t._focus&&(t.active(!1),t._focus=void 0,t._zoomToBounds(null),!0)}function $n([t,e],n){return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function An(t,e){const{kind:n,width:i,height:r,duration:a,ocean:s}=e,c=`d3plus-${"generic"===n?"zoom":n}`,l="geomap"===n&&s||"transparent",h=function(t,e){const n="geomap"!==e||"canvas"!==t._renderer||t._ssr?null:Sn(t);if(!n)return t._select;n.style.isolation="isolate";const i=o.select(n).selectAll(":scope > svg.d3plus-geomap-underlay").data([0]);return i.enter().insert("svg",":first-child").attr("class","d3plus-geomap-underlay").style("position","absolute").style("top","0").style("left","0").style("z-index","-1").style("overflow","hidden").style("pointer-events","none").merge(i).attr("width",t.schema.width).attr("height",t.schema.height)}(t,n),u=t._container&&t._container.classed(c)?t._container.node():null;u&&u.parentNode!==h.node()&&h.node().insertBefore(u,h.node().firstChild),h!==t._select?t._select.selectAll(":scope > svg.d3plus-geomap").remove():function(t){const e=Sn(t);e&&e.querySelector(":scope > svg.d3plus-geomap-underlay")?.remove()}(t);let d=h.selectAll(`:scope > svg.${c}`).data([0]);if(d=d.enter().insert("svg",":first-child").attr("class",c).attr("opacity",0).attr("width",i).attr("height",r).attr("x",t._margin.left).attr("y",t._margin.top).style("background-color",l).merge(d),t._container=d,d.transition().duration(a).attr("opacity",1).attr("width",i).attr("height",r).attr("x",t._margin.left).attr("y",t._margin.top),"generic"===n){let e=d.selectAll(`g.${c}-zoomGroup`).data([0]);e=e.enter().append("g").attr("class",`${c}-zoomGroup`).merge(e),t._zoomGroup=e}else if("network"===n){const e=d.selectAll(`rect.${c}-hitArea`).data([0]);e.enter().append("rect").attr("class",`${c}-hitArea`).merge(e).attr("width",i).attr("height",r).attr("fill","transparent").on("click",()=>Cn(t));const{left:n,top:o}=t._margin;t._backgroundClick=e=>{$n(e,{x:n,y:o,width:i,height:r})&&Cn(t)};let a=d.selectAll(`g.${c}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${c}-zoomGroup`).merge(a),t._zoomGroup=a}else{const e=d.selectAll(`rect.${c}-ocean`).data([0]);e.enter().append("rect").attr("class",`${c}-ocean`).merge(e).attr("width",i).attr("height",r).attr("fill",s||"transparent");let n=d.selectAll(`g.${c}-tileGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-tileGroup`).merge(n),t._tileGroup=n;let o=d.selectAll(`g.${c}-zoomGroup`).data([0]);o=o.enter().append("g").attr("class",`${c}-zoomGroup`).merge(o),t._zoomGroup=o}}function zn(t){const e=t.interactionPoints;if(e&&e.length>1){const t=[];for(let n=1;n<e.length;n++)t.push([Math.abs(e[n].x-e[n-1].x),Math.abs(e[n].y-e[n-1].y)]);return t}const n=function(t){switch(t.type){case"rect":case"image":return[t.width,t.height];case"circle":return[2*t.r,2*t.r];case"path":{const e=u.pathBounds(t.d);return[e.width,e.height]}case"line":{const e=u.pathBounds(a.linePath(t));return[e.width,e.height]}case"area":{const e=u.pathBounds(a.areaPath(t));return[e.width,e.height]}default:return null}}(t);return n?[n]:[]}function Dn(t,...e){return"function"==typeof t?t(...e):t}function Ln(t,e,n,i=Dn(t?.labelConfig?.fontSize??12,e,n)){const o=t?.labelConfig?.lineHeight??t?.lineHeight,r=void 0===o?void 0:Dn(o,e,n);return"number"==typeof r&&r>0?r:1.2*i}const Fn=t=>t.trim().replace(/^(['"])(.*)\1$/,"$2");function Nn(t,e){const n=(Array.isArray(t)?t:t.split(",")).map(Fn).filter(Boolean);if(!e)return s.fontFamilyStringify(n);const i=Fn(e),o=n.indexOf(i);return s.fontFamilyStringify(o<0?[i,...n]:n.slice(o))}function Bn(t,e){let n=0;if("number"==typeof t)n=t;else if("string"==typeof t){const i=parseFloat(t);Number.isFinite(i)&&(n=t.trim().endsWith("%")?i/100*e:i)}return Math.max(0,Math.min(e,Number.isFinite(n)?n:0))}function En(t){if(!t)return null;if(!0===t)return{top:0,right:0,bottom:0,left:0};const e=t.padding;return r.parseSides(e??0)}function Rn(t){return t.replace(/<[^>]+>/g,"")}function Pn(t,e,n){return t.map((t,i)=>{const o=e?.[i];if(!o)return t;const a=function(t,e){const n=e.map(Rn);if(t.map(t=>t.text).join("")!==n.join(""))return null;const i=n.map(()=>[]);let o=0,r=0;for(const e of t){let t=e.text;for(;t;){for(;o<n.length-1&&r>=n[o].length;)o++,r=0;const a=Math.min(t.length,n[o].length-r)||t.length;i[o].push({...e,text:t.slice(0,a)}),t=t.slice(a),r+=a}}return i}(o,t.map(t=>t.text));return a?t.map((t,e)=>{const i=a[e],o=i.reduce((t,e,o)=>{const a=o===i.length-1?e.text.trimEnd():e.text;return t+r.textWidth(a,{...n,"font-weight":e.style?.weight??n["font-weight"],"font-style":e.style?.style??"normal"})},0);return{text:t.text,width:o,runs:i}}):null})}function Tn(t){const e={};for(const n of t.split(";")){const[t,i]=n.split(":").map(t=>t.trim());t&&i&&("font-weight"===t?e.weight=/^\d+$/.test(i)?Number(i):i:"font-style"===t&&(e.style="italic"===i?"italic":"normal"))}return void 0===e.weight&&void 0===e.style?void 0:e}function On(t,e,n){let i=t.trimEnd().replace(/&([^;&]*)/g,(t,e)=>"amp"===e?t:`&${e}`).replace(/<([^A-z^/]+)/g,(t,e)=>`<${e}`).replace(/<$/g,"<").replace(/(<[^>^/]+>)([^<^>]+)$/g,(t,e,n)=>`${e}${n}${e.replace("<","</")}`).replace(/^([^<^>]+)(<\/[^>]+>)/g,(t,e,n)=>`${n.replace("</","<")}${e}${n}`),o=n;o&&!i.startsWith("<")&&(i=`<${o}>${i}`,i.includes(`</${o}>`)||(i+=`</${o}>`));const r=/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g,a=[];let s,c=0;for(;null!==(s=r.exec(i));){s.index>c&&a.push({text:i.slice(c,s.index)});const n=s[1],r=s[2],l=e[n];l?(o=!t.includes(`</${n}>`)&&n,a.push({text:r,style:Tn(l)})):a.push({text:r}),c=s.index+s[0].length}return c<i.length&&a.push({text:i.slice(c)}),!a.length&&i&&a.push({text:i}),{runs:a,openTag:o}}function Wn(t,e,n,i){const{lineData:o,line:r,fS:a,lH:s,w:c,h:l,vA:h,style:u,wrap:d,kept:f,padding:m,path:p}=i,g=r*s,y=t.schema.rotate(e,n);let x=p||0===y?"top"===h?0:"middle"===h?l/2-g/2:l-g:0;p?x=0:x-=.1*s;const b=function(t,e){let n=null;if(t.schema.html){const i=t.schema.html;let o=!1;const r=[];let a=!1;for(const t of e){const{runs:e,openTag:n}=On(t,i,o);r.push(e),o=n,e.some(t=>t.style)&&(a=!0)}a&&(n=r)}return n}(t,o),k=t.schema.textAnchor(e,n),_=f.length===o.length,v=(t,e)=>o.map((n,i)=>_?t[f[i]]??e:e);return{aH:t.schema.ariaHidden(e,n),data:e,i:n,lines:o,lineRuns:b,hardBreaks:v(d.hardBreaks,!0),lineWords:"justify"===k?Pn(v(d.lineWords,[]),b,u):null,fC:t.schema.fontColor(e,n),fStroke:t.schema.fontStroke(e,n),fSW:t.schema.fontStrokeWidth(e,n),fF:Nn(t.schema.fontFamily(e,n),u["font-family"]),fO:t.schema.fontOpacity(e,n),fW:u["font-weight"],id:t.schema.id(e,n),pE:t.schema.pointerEvents(e,n),tA:k,vA:t.schema.verticalAlign(e,n),widths:v(d.widths,0),truncated:d.truncated,fS:a,lH:s,w:c,h:l,r:y,x:t.schema.x(e,n)+(p?0:m.left),y:t.schema.y(e,n)+(p?0:x+m.top),path:p?{d:p.d,side:p.side,offset:p.offset}:null,pad:m,yP:x,hit:En(t.schema.hitbox(e,n))}}const jn={hardBreaks:[],lines:[],lineWords:[],nextWord:0,sentence:"",truncated:!1,widths:[],words:[]};function Hn(t,e,n){const i=t;let o=t.schema.text(e,n);if(void 0===o)return null;o=`${o}`.trim();const c=t.schema.fontResize(e,n),l=t.schema.lineHeight(e,n)/t.schema.fontSize(e,n);let h=c?t.schema.fontMax(e,n):t.schema.fontSize(e,n),u=c?h*l:t.schema.lineHeight(e,n),f=1,m=[],p=[],g=jn;const y={"font-family":r.fontExists(t.schema.fontFamily(e,n)),"font-size":h,"font-weight":t.schema.fontWeight(e,n),"line-height":u},x=r.parseSides(t.schema.padding(e,n)),b=function(t,e,n){const i=t.schema.textPath(e,n);if("string"!=typeof i||!i.trim())return null;const o=a.samplePath(i).total;return o?{d:i,side:"right"===t.schema.side(e,n)?"right":"left",offset:Bn(t.schema.startOffset(e,n),o),length:o}:null}(t,e,n),{w:k,h:_}=function(t,e,n,i,o,r){const a=t.schema.height(e,n)-(i.top+i.bottom);return o?{w:o.length-o.offset,h:Math.max(a,r+1)}:{w:t.schema.width(e,n)-(i.left+i.right),h:a}}(t,e,n,x,b,u),v=t.schema.shape(e,n),w=s.textWrap().fontFamily(y["font-family"]).fontSize(h).fontWeight(y["font-weight"]).lineHeight(u).maxLines(b?1:t.schema.maxLines(e,n)).height(_).overflow(t.schema.overflow(e,n)).shape(v).width(k).split(t.schema.split).ellipsis((e,n)=>t.schema.ellipsis(e,n)).truncateWord(!!t.schema.truncateWord(e,n)),M=t.schema.fontMax(e,n),S=t.schema.fontMin(e,n),C=t.schema.verticalAlign(e,n),$=t.schema.split(o,n);return k>(c?S:0)&&(_>u||c&&_>S*l)&&(c&&(h=function(t,e,n,i,o,a,s){const c=r.textWidth(o,a),l=1.165+e/n*.1,h=e*n*("circle"===s?Math.PI/4:1),u=d.max(c),f=d.sum(c,t=>t*i)*l;if(u>e||f>h){const n=Math.sqrt(h/f),i=e/u,o=d.min([n,i]);t=Math.floor(t*o)}const m=Math.floor(.8*n);return t>m&&(t=m),t}(h,k,_,u,$,y,v)),function t(){const e=()=>{f<1&&(m=[i.schema.ellipsis("",f)])};if(c&&(h=d.max([h,S]),h=d.min([h,M]),u=h*l,w.fontSize(h).lineHeight(u),y["font-size"]=h,y["line-height"]=u),g=w(o),p=g.lines.flatMap((t,e)=>""!==t?[e]:[]),m=p.map(t=>g.lines[t]),f=m.length,g.truncated)if(c){if(h--,h<S)return h=S,void e();t()}else e()}()),m.length?Wn(t,e,n,{lineData:m,line:f,fS:h,lH:u,w:k,h:_,vA:C,style:y,wrap:g,kept:p,padding:x,path:b}):null}function In(t,e){return 0===t.r||"top"===t.vA?(e+1)*t.lH-(t.lH-t.fS):"middle"===t.vA?(t.h+t.fS)/2-(t.lH-t.fS)+(e-t.lines.length/2+.5)*t.lH:t.h-2*(t.lH-t.fS)-(t.lines.length-(e+1))*t.lH+2*Math.cos(Math.PI*t.r/180)}function Gn(t,e,n){const i=t.lines.length-1,o=a.alignLines(t.tA,e,t.lines.map((e,n)=>({width:t.widths[n]??0,words:t.lineWords?.[n]??void 0,paragraphEnd:n===i||t.hardBreaks[n]})),n),r=t.lines.map((e,n)=>{const{x:i,width:r,wordX:a}=o.lines[n],s=t.lineWords?.[n],c=a&&s?s.flatMap((t,e)=>(t.runs??[{text:t.text}]).map((t,n)=>n?t:{...t,x:a[e]})):t.lineRuns?.[n]??void 0;return c?{text:e,x:i,width:r,runs:c}:{text:e,x:i,width:r}});return{anchor:o.anchor,lines:r}}function qn(t,e,n){return{family:t.fF,size:t.fS,weight:t.fW,anchor:e,baseline:"alphabetic",dir:n?"rtl":"ltr"}}function Vn(t){return{fill:t.fC,opacity:t.fO,...t.fStroke&&"transparent"!==t.fStroke?{stroke:t.fStroke}:{},...t.fSW?{strokeWidth:t.fSW}:{}}}function Kn(t,e){return{x:t.x,y:t.y,rotate:t.r,rotateAnchor:e}}function Yn(t,e){const{anchor:n,lines:i}=Gn(t,t.w,e);if(t.path){const e=t.path.offset;return{anchor:n,lines:i.map(t=>({...t,x:t.x+e,y:0}))}}const o=function(t,e,n){return"start"!==e||n?0:2*Math.sin(Math.PI*t.r/180)}(t,n,e);return{anchor:n,lines:i.map((e,n)=>({...e,x:e.x+o,...e.runs&&o?{runs:e.runs.map(t=>void 0===t.x?t:{...t,x:t.x+o})}:{},y:In(t,n)}))}}function Un(t,e,n){const{anchor:i,lines:o}=Yn(t,n),r="true"===t.aH||!0===t.aH;return{type:"text",key:t.id,id:`d3plus-textBox-${s.strip(t.id)}`,datum:t.data,index:t.i,x:0,y:0,width:t.w,height:t.h,lines:o,font:qn(t,i,n),paint:Vn(t),transform:Kn(t,e),aria:r?{hidden:!0}:void 0,interactive:"none"!==t.pE,...t.path?{path:{d:t.path.d,side:t.path.side}}:{},...t.truncated?{truncated:!0}:{}}}function Xn(t,e,n){const i=Un(t,e,n),o=function(t,e){const n=t.hit;if(!n)return null;let i,o,r,s;if(t.path){const{points:e}=a.textPathSamples({d:t.path.d,side:t.path.side}),n=e.map(t=>t[0]),c=e.map(t=>t[1]);i=Math.min(...n)-t.fS,o=Math.min(...c)-t.fS,r=Math.max(...n)-i+t.fS,s=Math.max(...c)-o+t.fS}else i=-t.pad.left,o=-(t.yP+t.pad.top),r=t.w+t.pad.left+t.pad.right,s=t.h+t.pad.top+t.pad.bottom;return{type:"rect",key:`${t.id}::hit`,datum:t.data,index:t.i,x:i-n.left,y:o-n.top,width:r+n.left+n.right,height:s+n.top+n.bottom,paint:{fill:"transparent"},transform:Kn(t,e),aria:{hidden:!0},interactive:"none"!==t.pE}}(t,e);return o?[o,i]:[i]}function Qn(t){return`${t.replace(/[.,\s]+$/,"")}...`}const Zn={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"},Jn=(t,e)=>e?Qn(t):"",ti=[{key:"ariaHidden",coerce:"const",default:W("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:Jn},{key:"fontColor",coerce:"const",default:W("black")},{key:"fontFamily",coerce:"const",default:W(s.fontFamily)},{key:"fontMax",coerce:"const",default:W(50)},{key:"fontMin",coerce:"const",default:W(8)},{key:"fontOpacity",coerce:"const",default:W(1)},{key:"fontResize",coerce:"const",default:W(!1)},{key:"fontSize",coerce:"const",default:W(10)},{key:"fontStroke",coerce:"const",default:W("transparent")},{key:"fontStrokeWidth",coerce:"const",default:W(0)},{key:"fontWeight",coerce:"const",default:W(400)},{key:"height",coerce:"const",default:H("height",200)},{key:"hitbox",coerce:"const",default:W(!1)},{key:"id",coerce:"const",default:(t,e)=>t.id||`${e}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:W(null)},{key:"overflow",coerce:"const",default:W(!1)},{key:"padding",coerce:"const",default:W(0)},{key:"pointerEvents",coerce:"const",default:W("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:W(0)},{key:"rotateAnchor",coerce:"const",default:t=>[t.w/2,t.h/2]},{key:"shape",coerce:"const",default:t=>t.__d3plusWrapShape__??"square"},{key:"side",coerce:"const",default:W("left")},{key:"split",coerce:"identity",default:s.textSplit},{key:"startOffset",coerce:"const",default:W(0)},{key:"text",coerce:"const",default:H("text")},{key:"textAnchor",coerce:"const",default:W("start")},{key:"textPath",coerce:"const",default:W(!1)},{key:"truncateWord",coerce:"const",default:W(!1)},{key:"verticalAlign",coerce:"const",default:W("top")},{key:"width",coerce:"const",default:H("width",200)},{key:"x",coerce:"const",default:H("x",0)},{key:"y",coerce:"const",default:H("y",0)}];class ei extends Xt{_textData(){return this._data.reduce((t,e,n)=>{const i=Hn(this,e,n);return i&&t.push(i),t},[])}toScene(){const t=r.rtl();return{type:"group",key:"textBox-group",children:this._textData().flatMap(e=>Xn(e,this.schema.rotateAnchor(e,e.i),t))}}render(t){if("compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;if(void 0===this._select&&"undefined"!=typeof document){const t=o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(t)}if(this._select){const t=this._select,e=t&&"function"==typeof t.node?t.node():t;if(e){const t=this.toScene(),n=t.children.reduce((t,e)=>Math.max(t,(e.transform?.x??0)+(e.width??0)),0),i=t.children.reduce((t,e)=>Math.max(t,(e.transform?.y??0)+(e.height??0)),0),o="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():null,r=o&&o.width||Number(e.getAttribute("width"))||e.clientWidth||0,s=o&&o.height||Number(e.getAttribute("height"))||e.clientHeight||0,c=Math.max(r,n)||400,l=Math.max(s,i)||300;for(;e.firstChild;)e.removeChild(e.firstChild);const h={root:t,width:c,height:l},u=new a.SvgRenderer;u.mount({container:e,width:c,height:l}),u.drawScene(h),this._sceneRenderer=u,It(this)}}return t&&setTimeout(t,0),this}data(t){return arguments.length?(this._data=t,this):this._data}html(t){return arguments.length?(this.schema.html="boolean"==typeof t?!!t&&Zn:t,this):this.schema.html}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){super(),kt(this,ti),this.schema.lineHeight=(t,e)=>1.2*this.schema.fontSize(t,e),this.schema.html=Zn}}function ni(t,e,n,i){const{orient:o}=e.schema;return t.data(e.schema.title&&!e._dropTitle?[{text:e.schema.title}]:[]).height(i).rotate("left"===o?-90:"right"===o?90:0).text(t=>t.text).verticalAlign("middle").width(n[n.length-1]-n[0]).truncateWord((e,n)=>function(t,e,n){const i=t.schema.text(e,n);if(void 0===i)return!1;const[o]=t.schema.split(`${i}`.trim(),n);if(!o)return!1;const a=o.endsWith(s.softHyphen)?`${o.slice(0,-1)}-`:o,c=r.parseSides(t.schema.padding(e,n));return r.textWidth(a,{"font-family":r.fontExists(t.schema.fontFamily(e,n)),"font-size":t.schema.fontSize(e,n),"font-weight":t.schema.fontWeight(e,n)})>t.schema.width(e,n)-c.left-c.right}(t,e,n)).config(te.bind(e)(e.schema.titleConfig))}function ii(t){let e=(t%360+360)%360;return e>180&&(e-=360),e>90?e-=180:e<-90&&(e+=180),0===e?0:e}function oi(t){return"number"==typeof t&&Number.isFinite(t)?ii(t):-90}ei._displayName="TextBox";const ri={rotate:!1,angle:0,slant:!1};const ai=t=>"top"===t?30:-30;function si(t){return"number"==typeof t?Number.isFinite(t)&&0!==ii(t):!0===t}function ci(t,e){return!(!si(t)||"number"!=typeof t)&&(!e||90!==Math.abs(ii(t)))}function li(t,e){const n=Math.abs(t)*Math.PI/180;return e?n:Math.PI/2-n}function hi(t){return"bottom"===t?{x:0,y:1}:"top"===t?{x:0,y:-1}:"left"===t?{x:-1,y:0}:{x:1,y:0}}function ui(t,e){const n=e*Math.PI/180,i=hi(t),o=Math.cos(n)*i.x+Math.sin(n)*i.y;return Math.abs(o)<1e-9?"middle":o<0?"end":"start"}function di(t,e,n,i,o,r){const a=e*Math.PI/180,s=Math.cos(a),c=Math.sin(a),l=-Math.sin(a),h=Math.cos(a),u=hi(t),d=ui(t,e),f=Math.abs(l*u.x+h*u.y),m=u.x*(r+i/2*f),p=u.y*(r+i/2*f),g="end"===d?n:"start"===d?0:n/2,y=i/2,x=(t,e)=>({x:m+(t-g)*s+(e-y)*l,y:p+(t-g)*c+(e-y)*h}),b=x(n/2,o/2);return{x:b.x-n/2,y:b.y-o/2,width:n,height:o,corners:[x(0,0),x(n,0),x(n,i),x(0,i)]}}function fi(t,e,n,i){const o="top"===t||"bottom"===t,r=di(t,e,n,i,i,0).corners.map(t=>o?t.x:t.y);return[Math.max(0,-Math.min(...r)),Math.max(0,Math.max(...r))]}function mi(t,e,n,i,o){const r=li(t,e),a=Math.sin(r);return a<1e-9?{width:i,height:n}:{width:Math.max(0,(n-o*Math.cos(r))/a),height:Math.max(o,i*a)}}function pi(t,e){const{scale:n}=t.schema;return"time"===n||gi(n)&&e.length>0&&e.every(t=>t instanceof Date||!isNaN(t))}function gi(t){return["band","ordinal","point"].includes(t)}function yi(t=s.textSplit){return(e,n)=>t(e,n).reduce((t,e)=>{const n=t.length-1;return n>=0&&t[n].endsWith(s.softHyphen)?t[n]=t[n].slice(0,-1)+e:t.push(e),t},[])}const xi=yi();function bi(t,e){if(t.truncated)return{fits:!1,result:t};if(!t.lines.slice(0,-1).some(t=>t.endsWith("-")))return{fits:!0,result:t};const n=e();return n.truncated?{fits:!1,result:t}:{fits:!0,result:n}}function ki(t){if(t._theme)return t._theme.background;const e=t._select,n=e&&"function"==typeof e.node?e.node():null;return n?r.backgroundColor(n):"rgb(255, 255, 255)"}function _i(t,n={}){return e.colorContrast(t,n)===(n.dark||e.colorDefaults.dark)?e.colorGray[200]:e.colorGray[800]}function vi(t){return t._theme?.text??e.colorContrast(ki(t),t.schema.colorDefaults)}function wi(t){return t._theme?.axis??vi(t)}function Mi(t){return t._theme?.gridline??_i(ki(t),t.schema.colorDefaults)}function Si(t,n){if(!n)return e.colorLegible(t);const o=i.hsl(t);return Number.isFinite(o.l)?(o.l<.65&&(o.l=.65),o.toString()):t}const Ci=t=>"function"==typeof t._preDraw;function $i(t,e,n=new WeakSet){if(!n.has(t)){n.add(t),t._theme=e;for(const i of[...Object.values(t),...Object.values(t.ctx)])i instanceof Xt&&!Ci(i)&&$i(i,e,n)}}function Ai(t){return()=>wi(t)}function zi(t){return{angle:30,gap:5,lineConfig:{},lines:!0,mask:!0,size:10,space:36,stroke:Ai(t),"stroke-width":1}}const Di=t=>t&&t.length?Qn(`${t}`):"";function Li(t,e){const n=e?t.height:t.width;return function(t,e){return"function"==typeof t?t(e):t}(t.maxSize,n)}function Fi(t,e){const{maxSize:n}=t.schema;return"function"==typeof n&&(t.schema.maxSize=n(e)),t}function Ni(t,...e){return t._softMaxSize=!e.some(t=>!!t&&"object"==typeof t&&void 0!==t.maxSize),t}function Bi(t,e){if(t._softMaxSize)return!1;const n=Li(t.schema,e);return void 0!==n&&Number.isFinite(n)}function Ei(t,e,n,i,o){if(!o.keepShare){const n=t.width(i)(e);if(o.ownSpace||n.lines.some(t=>""!==t))return{res:n,cut:!1}}const r=function(t,e,n){return t.width(n).truncateWord(!0).ellipsis(t.ellipsis()??Di)(e)}(t,e,n);return{res:r,cut:r.lines.length>0}}function Ri(t,e,n,i){const o=Li(t.schema,e);return e?d.min([o,t.schema.height])-n-i-t._margin.top-t._margin.bottom:d.min([o,t.schema.width])-n-i-t._margin.left-t._margin.right}function Pi(t,e,n,i){const{horizontal:o,hBuff:r,p:a,tickFormat:c}=n,{d:l,fF:h,fP:u,fS:f,lineHeight:m,rotate:p,space:g,angle:y,slant:x}=e,b=p?"width":"height",k=p?"height":"width",_=c(l),v=d.min([Li(t.schema,o),t.schema.width]),w=e.room??Ri(t,o,r,a),M=x?mi(y,o,w,g,m):void 0,S=i&&function(t,e,n){const{fF:i,fP:o,fS:r,lineHeight:a,rotate:s,space:c,angle:l,slant:h,room:u}=e;return JSON.stringify([t,i,o,r,a,s,h&&l,h&&n.slantWidth,c,u,n.keepShare])}(_,e,n),C=S?i.get(S):void 0;if(C)return{...C,lines:C.lines.slice(),widths:C.widths.slice()};const $=s.textWrap().fontFamily(h).fontSize(f).lineHeight(m).ellipsis(function(t){const e=t?.labelConfig?.ellipsis;return"function"==typeof e?e:"string"==typeof e?()=>e:Di}(t.schema.shapeConfig));let A,z;M?$.split(xi).width(Math.min(M.width,n.slantWidth??1/0)).height(M.height):($[k](o?g:w),$[b](o?w-(p?0:u):g));let D=!1;return n.wholeLine?($.width(t.schema.width-2*a),A=$(_),z=!A.truncated&&A.lines.filter(t=>""!==t).length<=1):(A=$(_),M&&n.strict&&(A=function(t,e,n,i){const o=li(i.angle,i.horizontal),r=Math.sin(o),a=Math.cos(o),s=t.lineHeight(),c=t=>t.lines.filter(t=>""!==t).length,l=t=>{const e=c(t);return Math.ceil(Math.max(0,...t.widths.slice(0,e)))*r+Math.ceil(e*s)*a<=i.depth};if(!c(n)||l(n))return n;t.ellipsis(t.ellipsis()??Di);for(let o=c(n)-1;o>=1;o--){const h=(i.depth-Math.ceil(o*s)*a)/r;if(t.height(o*s).width(Math.max(0,Math.min(i.width,h))),n=t(e),c(n)&&l(n))return n}return n}($,_,A,{angle:y,horizontal:o,depth:Math.floor(w-(o?u:0)),width:Math.min(M.width,n.slantWidth??1/0)})),z=bi(A,()=>$.split(xi)(_)).fits,p||!`${_}`.trim()||A.lines.some(t=>""!==t)||({res:A,cut:D}=o?Ei($,_,g,v-2*a,n):Ei($,_,w,w,{keepShare:!0}))),A.fits=z,A.cut=D,A.lines=A.lines.filter(t=>""!==t),A.width=A.lines.length?Math.ceil(d.max(A.widths)):0,A.height=A.lines.length?Math.ceil(A.lines.length*$.lineHeight())+u:0,S&&i.set(S,{lines:A.lines.slice(),widths:A.widths.slice(),width:A.width,height:A.height,fits:z,cut:D}),A}function Ti(t,e,n){if(e<2)return n;const i=t.map(({text:t,fontFamily:i,fontSize:o,lineHeight:a})=>{const c={"font-family":i,"font-size":o},l=r.textWidth(`${t}`,c),h=`${t}`.split(/\s+/).filter(Boolean),u=Math.max(0,...h.map(t=>r.textWidth(t,c))),d=s.textWrap().fontFamily(i).fontSize(o).lineHeight(a).split(xi).height(a*(e+1));return function(t,e,n,i,o=1.08){for(let r=Math.max(1,n);r<i;r*=o)if(t(r)<=e)return Math.ceil(r);return i}(e=>d.width(e)(`${t}`).lines.filter(t=>""!==t).length,e,Math.max(u+1,l/e),n)});return Math.min(n,Math.max(0,...i))}function Oi(t,e){const n=t.lines.length,i=n?(n-1)*t.lineHeight+t.fS:0;if(t.slant){const n=Math.sin(li(t.angle,e));return n<1e-9?t.width:i/n}return Boolean(t.rotate)!==e?t.width:i}function Wi(t,e,n,i,o=n){const r=t=>e[t.i]-2*t.fP,a=t=>ji(t.position,o),s=new Set(t.filter(t=>!t.fits)),c=(e,n,i)=>{for(let o=e+n;o>=0&&o<t.length;o+=n)if(!(t[o].truncated||i&&s.has(t[o])))return t[o]},l=(t,e)=>{const n=[c(t.i,-1,e),c(t.i,1,e)].filter(t=>void 0!==t).map(e=>2*(Math.abs(e.position-t.position)-(t=>s.has(t)?Math.min(t.width,r(t)):t.width)(e)/2-t.fP)),o=Math.floor(n.length?Math.min(...n):a(t));return o>r(t)&&i(t,o),t.fits};let h=Math.min(...n);const u=t.map(t=>{const e=Math.max(0,2*(t.position-h));return h+=e,e});[...s].sort((t,e)=>u[e.i]-u[t.i]).forEach(t=>{s.delete(t),l(t,!1)||l(t,!0),t.truncated=!t.fits}),t.every(t=>t.truncated)&&t.forEach(t=>{const e=Math.floor(Math.min(r(t),a(t)));e<=0||(i(t,e,!0),t.truncated=!t.lines.length)})}function ji(t,e){const n=Math.min(...e),i=Math.max(...e);return Math.max(0,2*Math.min(t-n,i-t))}function Hi(t,e,n){let i=1;const o=n=>t.some((i,o)=>o>=n&&o%n===0&&function(t,e,n){return Math.abs(e.position-t.position)-(Oi(t,n)+Oi(e,n))/2<e.fP}(t[o-n],i,e));for(;i<t.length&&o(i);)i++,n?.(i,!1);i>1&&n?.(i,!0),t.forEach((t,e)=>t.truncated=e%i!==0)}function Ii(t,e){const n=t.slice().reverse();t.forEach(i=>{const{fP:o,i:r,position:a}=i,s=t=>Oi(t,e);let c=r?n.find(t=>t.i<r&&!t.truncated):void 0;if(r===t.length-1)for(;c&&a-s(i)/2-o<c.position+s(c)/2;)c.truncated=!0,c=n.find(t=>t.i<r&&!t.truncated);i.truncated=!!c&&a-s(i)/2-o<c.position+s(c)/2})}function Gi(t,e){const{range:n,p:i,height:o,margin:r,measured:a}=e,s=a&&a[0]===n[0]&&a[a.length-1]===n[n.length-1];return!t.schema.title||t._dropTitle||s||(r[t.schema.orient]=function(t,e,n){const i=ni((new ei).renderMode("compute"),t,e,n),[o]=i._textData();return o?.lines.some(t=>t)?Math.ceil(o.lines.length*o.lH)+t.schema.padding:0}(t,n,t.schema[o]-t.schema.tickSize-2*i)),n}function qi(t,e,n,i){n||"number"==typeof t.schema.fixedSize||e.some(t=>t.rotate||t.slant)||function(t,e){const n=()=>d.max(t,t=>t.width)||0;let i=n();for(;;){t.forEach(t=>t.room=i),t.filter(t=>!t.fits).forEach(t=>{const{lines:n,widths:i,width:o,height:r,cut:a}=e(t);Object.assign(t,{lines:n,widths:i,width:o,height:r,cut:a})});const o=n();if(o>=i)return;i=o}}(e,i)}function Vi(t,e){const{labels:n,rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:c,offset:l=1,ownSpace:h,regrow:u,strict:f}=e,m=o&&!t._labelRotation&&pi(t,n);t._shownLabels=n;const p={horizontal:o,hBuff:r,p:a,tickFormat:c,wholeLine:m,ownSpace:h,strict:f};let g=function(t,e){const{fontSize:n}=t.schema.shapeConfig.labelConfig,i=t.schema.shapeConfig.labelConfig.fontFamily||s.fontFamily,o=t.schema.shapeConfig.labelConfig.padding,r=t._labelRotation?t._labelAngle:0,a=!!t._labelRotation&&t._labelSlant;return e.map((e,s)=>{const c="function"==typeof i?i(e,s):i,l="function"==typeof o?o(e,s):o,h="function"==typeof n?n(e,s):n,u=t._getPosition(e);return{d:e,i:s,fF:c,fP:l,fS:h,lineHeight:Ln(t.schema.shapeConfig,e,s,h),position:u,rotate:t._labelRotation,angle:r,slant:a}})}(t,n);const y=function(t,e,n){return"band"===t.schema.scale?t._d3Scale.bandwidth():e.reduce((i,o,r)=>{const{position:a}=o,s=r?a-(a-e[r-1].position):1===e.length?n[0]:a-(e[r+1].position-a),c=Math.abs(a-s),l=r==e.length-1?1===e.length?n[1]:a+(a-e[r-1].position):a-(a-e[r+1].position),h=Math.abs(a-l),u="point"===t.schema.scale?1:2;return d.max([d.max([c,h])*u,i])},0)}(t,g,i);p.slantWidth=function(t,e,n){const i=e[0];if(!i?.slant)return;const{horizontal:o,hBuff:r,p:a,tickFormat:s,space:c}=n,l=mi(i.angle,o,Ri(t,o,r,a),c-2*i.fP,i.lineHeight);return Ti(e.map(t=>({text:s(t.d),fontFamily:t.fF,fontSize:t.fS,lineHeight:t.lineHeight})),(h=l.height,u=i.lineHeight,Math.max(1,Math.min(3,Math.floor(h/u+1e-9)))),l.width);var h,u}(t,g,{...p,space:y});const x=h?function(t,e){return t.length<2?t.map(()=>Math.abs(e[e.length-1]-e[0])):t.map((e,n)=>{const i=[t[n-1],t[n+1]].filter(t=>void 0!==t).map(t=>Math.abs(e-t));return Math.min(...i)})}(g.map(t=>t.position),i):void 0,b=new Map,k=(e,n=(x?x[e.i]:y)-2*e.fP,i=!1)=>{e.space=n;const{lines:r,widths:a,width:s,height:c,fits:l,cut:h}=Pi(t,e,i?{...p,keepShare:i}:p,b);return o&&!e.rotate?e.space=Math.max(e.space,Math.ceil(s)):!o&&!e.rotate&&c-e.fP>e.space&&(e.space=Math.ceil(c)),Object.assign(e,{lines:r,widths:a,width:s,height:c,fits:l,cut:h})};g=g.map(t=>k(t));const _=(e,n=e)=>{t._shownLabels=e.map(t=>t.d),n.forEach(t=>k(t))};return gi(t.schema.scale)?Hi(g,o,m?(t,e)=>{const n=g.filter((e,n)=>n%t===0);_(n,e?g:n)}:void 0):x&&o&&!t._labelRotation?Wi(g,x,t._d3Scale.range(),k,i):m?function(t,e,n){let i=t;for(let o=0;o<4;o++){Ii(t,e);const o=t.filter(t=>!t.truncated);if(o.length===i.length&&o.every((t,e)=>t===i[e]))return;i=o,n(i,t)}}(g,o,_):Ii(g,o),!u||o||t._labelRotation||(function(t,e,n){const i=t.filter(t=>!t.truncated);if(i.length===t.length)return;const o=i.map((t,e)=>{const o=[i[e-1],i[e+1]].filter(t=>void 0!==t).map(e=>Math.abs(e.position-t.position)),r=Math.min(ji(t.position,n),...o);return Math.floor(r-t.fP)});i.forEach((t,n)=>{!t.fits&&o[n]>t.space&&e(t,o[n])})}(g,k,i),t._thinForLines&&function(t,e,n){const i=t.length,o=t.filter(t=>!t.truncated);if(i<3||o.every(t=>t.fits))return;const r=t=>t.map((e,i)=>{const o=[t[i-1],t[i+1]].filter(t=>void 0!==t).map(t=>Math.abs(t.position-e.position)),r=o.length?Math.min(...o):0;return Math.max(n,Math.floor(r-e.fP))}),a=t=>{const n=r(t).map((n,i)=>e(t[i],n));return{set:t,lines:Math.min(...n.map(t=>t.lines.length)),whole:n.every(t=>t.fits)}},s=e=>Array.from({length:e},(n,o)=>t[Math.round(o*(i-1)/(e-1))]);let c=a(o);for(let t=o.length-1;t>=2&&!c.whole;t--){const e=a(s(t));(e.whole||e.lines>c.lines)&&(c=e)}const l=new Set(c.set),h=r(c.set);t.forEach(t=>{t.truncated=!l.has(t)}),c.set.forEach((t,n)=>e(t,h[n]))}(g,k,Math.min(...g.map(t=>t.space)))),qi(t,g,o,e=>Pi(t,e,p,b)),l>1&&function(t=[],e){let n=0;t.forEach(i=>{const o=t[i.i-1],r=i.rotate&&e||!i.rotate&&!e?"width":"height",a=i.rotate&&e||!i.rotate&&!e?"height":"width";o?o.position+o[a]/2>i.position-i[a]/2&&(n?(i.offset=o[r],n=0):n=1):n=1})}(g,o),g}function Ki(t,e){return t.slant?function(t,e,n,i){const o=li(t,e);return n*Math.sin(o)+i*Math.cos(o)}(t.angle,e,t.width,t.height-t.fP)+(e?t.fP:0):t[t.rotate||!e?"width":"height"]}function Yi(t,e,n){let i=0;return t.forEach(t=>{if(!t.lines.length)return void(t.truncated=!0);Math.ceil(Ki(t,e)+(t.offset??0))<=n||(t.truncated||i++,Object.assign(t,{truncated:!0,lines:[],widths:[],width:0,height:0}))}),i}const Ui=t=>"function"==typeof t&&"brokenSpec"in t;function Xi(t,e,n){if(!Array.isArray(t)||!t.length)return[];const i=(Array.isArray(t[0])?t:[t]).filter(t=>Array.isArray(t)&&2===t.length).map(t=>t.map(Number)).filter(t=>t.every(Number.isFinite)&&t[0]!==t[1]).map(t=>t[0]<t[1]?[t[0],t[1]]:[t[1],t[0]]).sort((t,e)=>t[0]-e[0]),o=[];for(const t of i){const e=o[o.length-1];e&&t[0]<=e[1]?e[1]=Math.max(e[1],t[1]):o.push([t[0],t[1]])}return o.filter(([t,i])=>t>e&&i<n)}function Qi(t){const[e,n]=t.domain,i=Math.min(e,n),o=Math.max(e,n),r=e<=n?t.range[0]:t.range[1],a=e<=n?t.range[1]:t.range[0],s=Math.sign(a-r)||1,c=t.breaks.reduce((t,[e,n])=>t+n-e,0),l=(Math.abs(a-r)-t.breaks.length*t.space)/(o-i-c),h=[i],u=[r];let d=i;for(const[e,n]of t.breaks){const i=u[u.length-1]+s*l*(e-d);h.push(e,n),u.push(i,i+s*t.space),d=n}return h.push(o),u.push(a),{values:h,pixels:u}}function Zi(t){let{values:e,pixels:n}=Qi(t),i=c.scaleLinear().domain(e).range(n);const o=e=>{const n=+e,o=(e=>{const n=t.edge;if(!n)return;const i=(e-n.value)/(n.edge-n.value);return i<1?i<=0?n.position:n.position+i*(n.edgePosition-n.position):void 0})(n);return void 0!==o?o:i(n)},r=()=>{({values:e,pixels:n}=Qi(t)),i=c.scaleLinear().domain(e).range(n)};return o.brokenSpec=t,o.domain=e=>void 0===e?t.domain.slice():(t.domain=Array.from(e,Number),r(),o),o.range=e=>void 0===e?t.range.slice():(t.range=Array.from(e,Number),r(),o),o.copy=()=>Zi({...t,breaks:t.breaks.map(t=>[t[0],t[1]])}),o.invert=e=>{const n=t.edge;if(n){const t=(e-n.position)/(n.edgePosition-n.position);if(t<=0)return n.value;if(t<1)return n.value+t*(n.edge-n.value)}return i.invert(e)},o.segments=()=>{const i=[];for(let t=0;t<e.length;t+=2)i.push({domain:[e[t],e[t+1]],range:[n[t],n[t+1]]});return t.domain[0]>t.domain[1]?i.reverse().map(t=>({domain:[t.domain[1],t.domain[0]],range:[t.range[1],t.range[0]]})):i},o.ticks=n=>c.scaleLinear().domain([e[0],e[e.length-1]]).ticks(n).filter(e=>!t.breaks.some(([t,n])=>e>t&&e<n)),o}function Ji(t,e,n){const i=new Set,o=[],r=t=>{const e=Number(t);i.has(e)||(i.add(e),o.push(t))},a=new Set(t.brokenSpec.breaks.flat());for(const i of t.segments()){const t=c.scaleLinear().domain(i.domain).range(i.range),o=e(t);o.forEach(r);const s=o.map(Number);i.domain.filter(t=>a.has(t)&&!s.includes(t)).forEach(e=>{n&&!n(e,s,t)||r(e)})}return o}const to=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function eo(t,e="breakConfig"){return no(t.schema[e])}function no(t){const e=t||{};return{angle:to(e.angle,30),gap:Math.max(0,to(e.gap,5)),size:Math.max(0,to(e.size,10)),space:Math.max(0,to(e.space,36)),mask:!1!==e.mask,lines:!1!==e.lines}}const io=t=>eo(t,"baselineBreakConfig");function oo(t,e){const{baseline:n,baselineBreak:i,scale:o}=t.schema;if(!i||"linear"!==o||!t._d3Scale)return null;if("number"!=typeof n||!Number.isFinite(n))return null;const r=t._d3Scale.domain().map(Number);if(2!==r.length||r.some(t=>!Number.isFinite(t)))return null;const a=Math.min(r[0],r[1]),s=Math.max(r[0],r[1]);if(a===s||n>=a&&n<=s)return null;const c=n<a?a:s,l=r[0]===c?0:1,h=e[l],u=e[1-l],{space:d}=io(t);if(!d||Math.abs(u-h)<=2*d)return null;return{value:n,position:h,edge:c,edgePosition:h+Math.sign(u-h)*d}}function ro(t,e,n,i=n){if(!e)return n;const o=t/(e+2);return o>=n?n:o>=Math.min(i,n)?o:null}function ao(t,e){if(t._baselineBreak=oo(t,e),t._breaks=[],"linear"!==t.schema.scale||!t._d3Scale)return;const n=t._baselineBreak,i=t._d3Scale.domain().map(Number),o=e.slice(0,2).map(t=>n&&t===n.position?n.edgePosition:t),r=eo(t);let a=Xi(t.schema.break,Math.min(...i),Math.max(...i));const s=t.schema.breakConfig||{},c=ro(Math.abs(o[1]-o[0]),a.length,r.space,Math.max(0,to(s.spaceMin,r.space)));null===c&&(a=[]);const l=c??r.space;if(!n&&!a.length)return;const h=Zi({domain:i,range:o,breaks:a,space:l,edge:n});t._d3Scale=h;const u="number"==typeof t.schema.baseline?t.schema.baseline:0;n&&t._breaks.push({start:n.value,end:n.edge,startPosition:n.position,endPosition:n.edgePosition,baseline:!0,mask:io(t).mask}),a.forEach(([e,n])=>{const[i,o]=Math.abs(n-u)<Math.abs(e-u)?[n,e]:[e,n];t._breaks.push({start:i,end:o,startPosition:h(i),endPosition:h(o),baseline:!1,mask:r.mask,...l<r.space?{fit:l/r.space}:{}})})}function so(t,e,n=!0){const i=e.filter(e=>{const n=Number(e);return!t.some(t=>n>Math.min(t.start,t.end)&&n<Math.max(t.start,t.end))});return n&&t.forEach(t=>{t.baseline&&!i.some(e=>Number(e)===t.start)&&i.push(t.start)}),i}function co(t,e){const{gap:n}=eo(t,e.baseline?"baselineBreakConfig":"breakConfig"),i=n*(e.fit??1),o=(e.startPosition+e.endPosition)/2;return[o-i/2,o+i/2]}function lo(t,e,n){const i=n(t.schema.barConfig),o=t._breaks||[];return o.length?ho(t,o,e,i,n):[{type:"line",key:"bar",points:e,paint:i}]}function ho(t,e,n,i,o){const r=t._position.horizontal,a=r?0:1,s=n[0][1-a],c=(t,e)=>r?[t,e]:[e,t],l=n.map(t=>t[a]),h=e.find(t=>t.baseline);h&&l.push(h.startPosition);const u=Math.min(...l),d=Math.max(...l),f=["top","left"].includes(t.schema.orient)?-1:1,m=e.map(e=>co(t,e)).sort((t,e)=>t[0]-e[0]),p=[];let g=u;m.forEach(([t,e])=>{p.push([g,t]),g=e}),p.push([g,d]);const y=h?h.startPosition<=u?0:p.length-1:-1,x=y>0;let b=0;const k=p.map(([t,e],n)=>{const o=n===y?"bar-baseline":b++?"bar-"+(b-1):"bar",r=[c(t,s),c(e,s)];return{type:"line",key:o,points:x?r.reverse():r,paint:i}});y>0&&k.unshift(...k.splice(y,1));let _=0;return e.forEach(e=>{const n=e.baseline?"baselineBreakConfig":"breakConfig",{angle:i,size:r}=eo(t,n),a=o(t.schema[n]),l=Math.sign(e.endPosition-e.startPosition),h=i*Math.PI/180,u=Math.sin(h)*r,d=Math.cos(h)*r,m=t=>[c(t,s),c(t-l*u,s+f*d)],p=e.baseline?"baseline-break":"break-"+_++,[g,y]=co(t,e),[x,b]=l<0?[y,g]:[g,y];k.push({type:"line",key:`${p}-0`,points:m(x),paint:a},{type:"line",key:`${p}-1`,points:m(b),paint:a})}),k}const uo=864e5;function fo(t){if(t instanceof Date)return+t;if("number"!=typeof t&&"string"!=typeof t)return NaN;const e=r.date(t);return e instanceof Date?+e:NaN}function mo(t){return"weekends"===t||"object"==typeof(e=t)&&null!==e&&!Array.isArray(e)&&("days"in t?Array.isArray(t.days)&&t.days.every(t=>Number.isInteger(t)&&t>=0&&t<=6):"hours"in t?(n=t.hours,Array.isArray(n)&&2===n.length&&n.every(t=>"number"==typeof t&&t>=0&&t<=24)):"values"in t?Array.isArray(t.values):"bounds"in t&&(Array.isArray(t.bounds)&&2===t.bounds.length&&t.bounds.every(t=>Number.isFinite(fo(t)))));var e,n}function po(t){if(!t)return[];return(Array.isArray(t)?t:[t]).filter(mo)}const go=t=>"object"==typeof t&&"boolean"==typeof t.marker?t.marker:"object"==typeof t&&"bounds"in t;function yo(t,e,n,i){const o=n?x.utcDay:x.timeDay;let r=o.floor(new Date(t));for(;+r<=e;){const t=o.offset(r,1);i(r,t),r=t}}function xo(t,e,n){const i=new Date(+t),o=Math.floor(e),r=Math.round(60*(e-o));return n?i.setUTCHours(o,r,0,0):i.setHours(o,r,0,0),+i}function bo(t,e,n,i=!1){if(!(e<=n))return[];const o=t.flatMap(t=>function(t,e,n,i){const o=[];if("weekends"===t||"days"in t){const r=new Set("weekends"===t?[0,6]:t.days);yo(e,n,i,(t,e)=>{r.has(i?t.getUTCDay():t.getDay())&&o.push([+t,+e])})}else if("hours"in t){const[r,a]=t.hours;if(r===a)return o;yo(e-uo,n,i,(t,e)=>{const n=xo(t,r,i),s=xo(r<a?t:e,a,i);s>n&&o.push([n,s])})}else if("values"in t){const e=i?x.utcDay:x.timeDay;t.values.forEach(t=>{const n=fo(t);if(!Number.isFinite(n))return;const i=e.floor(new Date(n));o.push([+i,+e.offset(i,1)])})}else{const[e,n]=t.bounds.map(fo);e!==n&&o.push(e<n?[e,n]:[n,e])}return o}(t,e,n,i).map(([e,n])=>({start:e,end:n,marker:go(t)}))).filter(t=>t.end>e&&t.start<=n).sort((t,e)=>t.start-e.start),r=[];for(const t of o){const e=r[r.length-1];e&&t.start<=e.end?(e.end=Math.max(e.end,t.end),e.marker=e.marker||t.marker):r.push({...t})}return r}function ko(t,e){let n=0,i=t.length-1,o=-1;for(;n<=i;){const r=n+i>>1;t[r].start<=e?(o=r,n=r+1):i=r-1}return o}function _o(t,e,n,i=!1){const o=bo(t,e,n,i);return r=>{const a=+r;if(!Number.isFinite(a))return!1;if(a<e||a>n)return vo(t,a,i);const s=ko(o,a);return s>=0&&a<o[s].end}}function vo(t,e,n=!1){const i=+e;return bo(t,i,i,n).some(t=>t.start<=i&&i<t.end)}function wo(t,e,n,i=!1){if(!(e<n))return 0;const o=bo(t,e,n,i).reduce((t,i)=>t+Math.max(0,Math.min(n,i.end)-Math.max(e,i.start)),0);return n-e-o}function Mo(t,e=!1){const n=Date.UTC(2001,0,1);return wo(t,n,n+8*uo,e)<=0}function So(t,e,n,i=!1){if(!n||!Number.isFinite(n)||Mo(t,i))return e;const o=n>0;let r=Math.abs(n),a=e,s=Math.max(2*r,7*uo);for(let e=0;e<32;e++){const e=o?a:a-s,n=o?a+s:a,c=bo(t,e,n,i);for(const t of o?c:c.reverse()){const e=o?t.start-a:a-t.end;if(e>0&&(o?r<e:r<=e))return o?a+r:a-r;e>0&&(r-=e),(o?t.end>a:t.start<a)&&(a=o?t.end:t.start)}const l=o?n-a:a-e;if(l>0&&r<=l)return o?a+r:a-r;l>0&&(r-=l,a=o?n:e),s*=2}return a}const Co=t=>"function"==typeof t&&"rangeBreaks"in t,$o=(t,e,n)=>Co(t)?t.visible(e,n):+n-+e,Ao=(t,e,n)=>Co(t)?t.offset(e,n):new Date(+e+n);function zo(t,e,n,i,o){const[r,a]=e,s=Math.min(r,a),c=Math.max(r,a),[l,h]=n,u=r<=a?l:h,d=r<=a?h:l,f=Math.sign(d-u)||1,m=Math.abs(d-u),p=bo(t,s,c,i),g=p.map(t=>({...t,start:Math.max(t.start,s),end:Math.min(t.end,c)})).filter(t=>t.end>t.start),y=m-g.filter(t=>t.marker&&t.start>s&&t.end<c).length*o>=2*o?o:0,x=g.map(t=>({...t,space:t.marker&&t.start>s&&t.end<c?y:0})),b=x.reduce((t,e)=>t+e.end-e.start,0),k=c-s-b,_=x.reduce((t,e)=>t+e.space,0),v=!(k>0),w=v?0:(m-_)/k,M=[];let S=s,C=0;return x.forEach(t=>{C+=(t.start-S)*w,M.push(C),C+=t.space,S=t.end}),{lo:s,hi:c,start:u,dir:f,length:m,rate:w,all:p,gaps:x,at:M,empty:v}}function Do(t,e={}){const n=Boolean(e.utc),i=Math.max(0,e.space??0);let o=[+new Date(2e3,0,1),+new Date(2e3,0,2)],r=[0,1],a=zo(t,o,r,n,i);const s=()=>{a=zo(t,o,r,n,i)},l=e=>{const i=+e;if(!Number.isFinite(i))return NaN;const{start:o,dir:s,empty:c}=a;return c?(r[0]+r[1])/2:o+s*function(t,e,n,i){const{lo:o,hi:r,length:a,rate:s,gaps:c,at:l}=t;if(i<o)return-wo(e,i,o,n)*s;if(i>r)return a+wo(e,r,i,n)*s;const h=ko(c,i);if(h<0)return(i-o)*s;const u=c[h];return i<u.end?l[h]+u.space*(i-u.start)/(u.end-u.start):l[h]+u.space+(i-u.end)*s}(a,t,n,i)};l.rangeBreaks=t,l.domain=t=>void 0===t?o.map(t=>new Date(t)):(o=Array.from(t,t=>+t).slice(0,2),s(),l),l.range=t=>void 0===t?r.slice():(r=Array.from(t,Number).slice(0,2),s(),l),l.copy=()=>Do(t,e).domain(o).range(r),l.invert=e=>function(t,e,n,i){const{lo:o,hi:r,start:a,dir:s,rate:c,gaps:l,at:h,empty:u}=t;if(u||!c)return new Date(o);const f=(i-a)*s;if(f<0)return new Date(So(e,o,f/c,n));const m=d.bisectRight(h,f)-1;let p;if(m<0)p=o+f/c;else{const t=l[m],e=f-h[m];p=e<t.space?t.start+e/t.space*(t.end-t.start):t.end+(e-t.space)/c}return new Date(p>r?So(e,r,p-r,n):p)}(a,t,n,e),l.gaps=()=>a.gaps.map(t=>({...t})),l.isHidden=e=>{const i=+e,{lo:o,hi:r,all:s}=a;if(i<o||i>r)return bo(t,i,i,n).some(t=>t.start<=i&&i<t.end);const c=ko(s,i);return c>=0&&i<s[c].end},l.visible=(e,i)=>{const o=+e,r=+i;return o<=r?wo(t,o,r,n):-wo(t,r,o,n)},l.offset=(e,i)=>new Date(So(t,+e,i,n));const h=()=>(n?c.scaleUtc:c.scaleTime)().domain([a.lo,a.hi]);return l.ticks=(t=10)=>{const e=function(t,e,n,i){const{lo:o,hi:r,all:a,gaps:s,empty:c}=t;if(c)return o!==r||i.isHidden(o)?[]:[o];const l=r-o-s.reduce((t,e)=>t+e.end-e.start,0),h=Math.max(1,Math.round(e*(r-o)/l)),u=n.ticks(h).map(Number),f=new Map;for(const t of u){const e=ko(a,t),n=e>=0&&t<a[e].end,i=n?a[e].end:t;i<=r&&f.set(i,n||!0===f.get(i))}const m=u.slice(1).map((t,e)=>t-u[e]),p=m.length?d.quantile(m,.5)/2:0,g=[...f].filter(([,t])=>t).map(([t])=>t);return[...f].filter(([t,e])=>e||!g.some(e=>Math.abs(i.visible(e,t))<=p)).map(([t])=>t).sort((t,e)=>t-e)}(a,t,h(),l).map(t=>new Date(t));return o[0]>o[1]&&e.reverse(),e},l.tickFormat=(t,e)=>h().tickFormat(t,e),l}function Lo(t){if(null==t)return;const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:void 0}function Fo(t){return t.map(Lo).filter(t=>void 0!==t)}function No(t){if("time"!==t.schema.scale)return t._data??[];const e=function(t,e){const n=po(t.schema.rangeBreaks);if(!n.length||!e.length)return e;const[i,o]=d.extent(e,Number),r=_o(n,i,o);return e.filter(t=>!r(t))}(t,Fo(t._data??[])),n=(t.schema.domain??[]).map(Lo);if(n.length<2||n.some(t=>void 0===t))return e;const[i,o]=d.extent(n);return e.filter(t=>t>=i&&t<=o)}function Bo(t,e){const[n,i]=d.extent(e.domain()).map(Number);return t.filter(t=>+t>=n&&+t<=i)}function Eo(t){return t.schema.timeLocale||l.locale[t.schema.locale]||l.locale["en-US"]}function Ro(t){const{_scaleData:e,schema:{domain:n}}=t,i=t._d3Scale,o=i?.range?i.range():[];return Go(t,"timeReference",[e,n,i,...o],()=>{const o=!e.length&&i?t._getLabels():[];return Fo(e.length?e:o.length>1?o:n).sort((t,e)=>+t-+e)})}function Po(t,e){const n=Eo(t),i=function(t){return"time"===t.schema.scale?Ro(t):jo(t)}(t);return(i.length?Go(t,"dateLabel",[i,n],()=>p.dateFullFormatter(i,To(n)))(e):p.formatDateFull(e,[e],To(n))).replace(/^Q/,n.quarter)}function To(t){let e=Oo.get(t);return e||Oo.set(t,e=y.timeFormatLocale(t).format),e}const Oo=new WeakMap,Wo=t=>t instanceof Date&&!isNaN(+t);function jo(t){const{_scaleData:e,schema:{domain:n}}=t;return Go(t,"dateCategories",[n,e],()=>{const t=t=>Array.isArray(t)?t.filter(Wo):[],i=t(n),o=i.length?i:t(e),r=new Set;return o.filter(t=>!r.has(+t)&&!!r.add(+t)).sort((t,e)=>+t-+e)})}function Ho(t){const e=t._shownLabels;if(!e)return;const n=Io.get(t);if(n&&n[0]===e)return n[1];const i=Fo(e).sort((t,e)=>+t-+e);return Io.set(t,[e,i]),i}const Io=new WeakMap;function Go(t,e,n,i){const o=n.flatMap(t=>Array.isArray(t)?[t,t.length]:[t]);let r=qo.get(t);r||qo.set(t,r=new Map);const a=r.get(e);if(a&&a.fingerprint.length===o.length&&a.fingerprint.every((t,e)=>t===o[e]))return a.value;const s=i();return r.set(e,{fingerprint:o,value:s}),s}const qo=new WeakMap;function Vo(t){const e=t._d3Scale;if("time"!==t.schema.scale||!e)return;const n=po(t.schema.rangeBreaks);if(!n.length)return;const{space:i,mask:o}=eo(t),r=Do(n,{space:i});r.domain(e.domain()),r.range(e.range()),t._d3Scale=r,r.gaps().filter(t=>t.space>0).forEach(e=>t._breaks.push({start:e.start,end:e.end,startPosition:r(e.start),endPosition:r(e.end),baseline:!1,mask:o}))}function Ko(t,e){const n=t._d3Scale;return Co(n)?e.filter(t=>!n.isHidden(Number(t))):e}function Yo(t){const e=new Set;return t.map(t=>x.timeDay.floor(t)).filter(t=>!e.has(+t)&&!!e.add(+t)).sort((t,e)=>+t-+e)}function Uo(t){let e;return n=>{const i=function(t,e){const n=t._d3Scale,i=Number(e instanceof Date?+e:e);if(!Co(n)||!Number.isFinite(i))return;const o=x.timeDay.floor(new Date(i));return+o!==i&&0===n.visible(o,i)?o:void 0}(t,n);if(!i)return;const o=Ro(t);return e&&e.dates===o&&e.format===y.timeFormat||(e={dates:o,format:y.timeFormat,label:p.dateFormatter(Yo(o),y.timeFormat)}),e.label(i,Ho(t))}}const Xo=t=>"number"==typeof t&&t>=1e3&&t<=2999;function Qo(t){return t.length>0&&t.every(t=>Xo(t)&&Number.isInteger(t))}function Zo(t){const e=t.schema.domain??[];return!(!e.length||!e.every(Xo))&&Qo(t._scaleData.length?t._scaleData:e)}function Jo(t,e="en-US"){return p.formatAbbreviate(t,e,"~f")}const tr=t=>t<0||Object.is(t,-0),er=t=>Math.pow(10,Math.floor(Math.log10(Math.abs(t))))*Math.pow(-1,tr(t)?1:0),nr=t=>Math.pow(10,Math.ceil(Math.log10(Math.abs(t))))*Math.pow(-1,tr(t)?1:0),ir=t=>{const e=`${t}`;if(e.includes("e-")||"0"===e)return 0;const n=e.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(n)return+`${n[1]}${+n[2]+1}`;const i=e.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return i?+`${i[1]}${+i[2]}`:t};function or(t,e,n){const i=t=>{if(o){if(!t)return 0;const e=`${t}`.match(/0\.(0*)/);if(e)return+`0.${Array(e[1].length+1).fill(0).join("")}1`}return`${Math.round(Math.abs(t))}`.length},o=t.every(t=>Math.abs(t)<1),r=[i(t[0]),i(t[1])].filter(Boolean).sort();if(!r.length)return;const a=t.some(t=>tr(t))&&t.some(t=>t>0),s=1===r.length?r[0]:r[0]>1&&r[0]===r[1]?r[0]-1:"outside"!==e&&a?d.max(r):r[0]+(r[1]-r[0])/2;let c=s<1?ir(s):+`1${Array(Math.floor(ir(s))-1).fill(0).join("")}`;c>=Math.abs(t[1]-t[0])&&(c/=2);const l=t[1]<t[0],h=[Math["outside"===e?l?"ceil":"floor":l?"floor":"ceil"](t[0]/c)*c,Math["outside"===e?l?"floor":"ceil":l?"ceil":"floor"](t[1]/c)*c];return"log"===n&&(0===h[0]&&(h[0]=t[0]),0===h[1]&&(h[1]=t[1])),h.map(ir)}const rr=["linear","log","pow","sqrt"];function ar(t,e,n){if(["linear","pow","sqrt"].includes(n))return or(t,e,n);if("log"===n){const i=[],o=t[1]<t[0];i[0]=("outside"===e?tr(t[0])?o?er:nr:o?nr:er:tr(t[0])?o?nr:er:o?er:nr)(t[0]),i[1]=("inside"===e?tr(t[1])?o?er:nr:o?nr:er:(tr(t[1]),o?er:nr))(t[1]);const r=i[1]<i[0];return i[0]!==i[1]&&i.some(t=>Math.abs(t)>10)&&r===o?i:or(t,e,n)}}const sr=(t,e)=>t<0?-Math.pow(-t,e):Math.pow(t,e);function cr(t,e){return t.map(t=>{const n=Math.min(...e.map(e=>Math.abs(e-t)).filter(t=>t>0));return function(t,e){if(!(e>0&&Number.isFinite(e)))return t;let n=Math.floor(Math.log10(Math.max(Math.abs(t),e)))+1;for(;n>-30;n--)for(const i of[5,2,1]){const o=i*Math.pow(10,n),r=Math.round(t/o)*o;if(Math.abs(r-t)<=e)return+r.toPrecision(12)}return t}(t,n/3)})}function lr(t,e,n){let i,o,r;const a=(n,i)=>(r&&r.dates===n&&r.format===y.timeFormat||(r={dates:n,format:y.timeFormat,label:p.dateFormatter(n,y.timeFormat)}),r.label(i,Ho(t)).replace(/^Q/g,e.quarter)),s=Uo(t),c=t.schema.tickFormat;return c?e=>c.call(t,e):e=>{if(Wo(e)&&(t=>["band","ordinal","point"].includes(t.schema.scale))(t))return a(o??(o=jo(t)),e);if(isNaN(e)||["band","ordinal","point"].includes(t.schema.scale))return e;if("time"===t.schema.scale)return s(e)??a(Ro(t),e);if("linear"===t.schema.scale&&"smallest"===t.schema.tickSuffix){const n="object"==typeof t.schema.locale?t.schema.locale:l.formatLocale[t.schema.locale],{separator:i,suffixes:o}=n,r=e>=1e3?o[t._tickUnit+8]:"",a=e/Math.pow(10,3*t._tickUnit);return`${p.formatAbbreviate(a,n,`,.${a.toString().length}r`)}${i}${r}`}{const o="inside"===t.schema.rounding?function(t,e,n){const i=Number(t),[o,r]=d.extent(e,Number),[a,s]=d.extent(n,Number);if(void 0!==o&&void 0!==a)return i===o&&a<=o?"min":i===r&&s>=r?"max":void 0}(e,n(),t.schema.domain):void 0,r="min"===o?t.schema.roundingInsideMinPrefix:"max"===o?t.schema.roundingInsideMaxPrefix:"",a="min"===o?t.schema.roundingInsideMinSuffix:"max"===o?t.schema.roundingInsideMaxSuffix:"";i??(i=Zo(t));return`${r}${i?Jo(e,t.schema.locale):p.formatAbbreviate(e,t.schema.locale)}${a}`}}}function hr(t){const{labels:e}=t.schema;return Array.isArray(e)&&e.length&&e.every(Array.isArray)?e:void 0}function ur(t,e,n,i){const o=function(t,e,n){let i=n?n.slice():[],[o,r]=e;t.schema.range&&(void 0!==t.schema.range[0]&&(o=t.schema.range[0]),void 0!==t.schema.range[t.schema.range.length-1]&&(r=t.schema.range[t.schema.range.length-1])),(void 0===i[0]||i[0]<o)&&(i[0]=o),(void 0===i[1]||i[1]>r)&&(i[1]=r);const a=r-o;if("ordinal"===t.schema.scale&&t.schema.domain.length>i.length)if(n===t.schema.range){const e=t.schema.domain.length+1;i=d.range(e).map(t=>i[0]+a*(t/(e-1))).slice(1,e),i=i.map(t=>t-i[0]/2)}else{const e=t.schema.domain.length,n=i[1]-i[0];i=d.range(e).map(t=>i[0]+n*(t/(e-1)))}return i}(t,e,void 0!==i?i:t.schema.range),r=`scale${t.schema.scale.charAt(0).toUpperCase()}${t.schema.scale.slice(1)}`,a=t.schema.domain.slice();var s;if(t._d3Scale=E[r]().domain("time"===t.schema.scale?function(t){const e=t.schema.domain.map(Lo),n=t._scaleData;return e.some(t=>void 0===t)&&n.length?d.extent(n):e}(t):a).range(o),"pow"===t.schema.scale&&t._d3Scale.exponent&&t._d3Scale.exponent("number"==typeof(s=t.schema.exponent)&&Number.isFinite(s)&&s>0?s:1),"none"!==t.schema.rounding){const e=ar(a,t.schema.rounding,t.schema.scale);e&&t._d3Scale.domain(e)}t.schema.reverse&&t._d3Scale.domain(t._d3Scale.domain().slice().reverse()),t._d3Scale.padding&&t._d3Scale.padding(t.schema.scalePadding),t._d3Scale.align&&t._d3Scale.align(t.schema.scaleAlign),t._d3Scale.paddingInner&&t._d3Scale.paddingInner(t.schema.paddingInner),t._d3Scale.paddingOuter&&t._d3Scale.paddingOuter(t.schema.paddingOuter),t._d3ScaleNegative=null,"log"===t.schema.scale&&function(t){const e=t._d3Scale.domain(),n=t._scaleData;if(0===e[0]){const t=d.min([d.min(n),Math.abs(e[1])]);e[0]=0===t||1===t?1e-6:t<=1?er(t):1,tr(e[1])&&(e[0]*=-1)}else if(0===e[e.length-1]){const t=d.min([d.min(n),Math.abs(e[0])]);e[e.length-1]=0===t||1===t?1e-6:t<=1?er(t):1,tr(e[0])&&(e[e.length-1]*=-1)}const i=t._d3Scale.range();if(tr(e[0])&&tr(e[e.length-1]))t._d3ScaleNegative=t._d3Scale.copy().domain(e).range(i),t._d3Scale=null;else if(e[0]>0&&e[e.length-1]>0)t._d3Scale.domain(e).range(i);else{const o=e.map(t=>Math.log10(Math.abs(t))).map(t=>t||-1e-6),r=o[0]/d.sum(o)*(i[1]-i[0]);let a=d.min([d.min(n.filter(t=>t>=0)),Math.abs(e[1])]);1===a&&(a=1e-6);let s=d.min([d.min(n.filter(tr)),Math.abs(e[0])]);1===s&&(s=1e-6);const c=0===a?1e-6:a<=1?er(a):1,l=0===s?-1e-6:s<=1?er(s):1,h=d.min([Math.abs(c),Math.abs(l)]);t._d3ScaleNegative=t._d3Scale.copy(),(tr(e[0])?t._d3Scale:t._d3ScaleNegative).domain([tr(e[0])?h:-h,e[1]]).range([i[0]+r,i[1]]),(tr(e[0])?t._d3ScaleNegative:t._d3Scale).domain([e[0],tr(e[0])?-h:h]).range([i[0],i[0]+r])}}(t),ao(t,o),Vo(t);const{ticks:c,labels:l}=function(t){const e=hr(t),n=e?e[Math.min(t._labelSet??0,e.length-1)]:t.schema.labels,i=t.schema.ticks||(e?n:void 0);let o=(i?"time"===t.schema.scale?Fo(i):i:(t._d3Scale?t._d3Scale.ticks:t._d3ScaleNegative?.ticks)?t._getTicks():t.schema.domain).slice(),r=(n?"time"===t.schema.scale?Fo(n):n:(t._d3Scale?t._d3Scale.ticks:t._d3ScaleNegative?.ticks)?t._getLabels():o).slice();return"time"===t.schema.scale&&(o=o.map(Number),r=r.map(Number)),o=Ko(t,o),r=Ko(t,r),t._breaks.length&&(o=so(t._breaks,o),r=so(t._breaks,r,!n)),o=o.sort((e,n)=>t._getPosition(e)-t._getPosition(n)),r=r.sort((e,n)=>t._getPosition(e)-t._getPosition(n)),{ticks:o,labels:r}}(t);!function(t,e){if("linear"===t.schema.scale&&"smallest"===t.schema.tickSuffix){const n=e.filter(t=>t>=1e3);if(n.length>0){const e=Math.min(...n);let i=1;for(;i&&i<7&&e/Math.pow(10,3*i)>=1;)t._tickUnit=i,i+=1}}}(t,l);const h=function(t,e,n){const i=[];return t._availableTicks=e,e.forEach((e,o)=>{let r=n({id:e,tick:!0},o);"Circle"===t.schema.shape&&(r*=2);const a=t._getPosition(e);!i.length||Math.abs(u.closest(a,i.filter(t=>!1!==t))-a)>2*r?i.push(a):i.push(!1)}),e=e.filter((t,e)=>!1!==i[e]),t._visibleTicks=e,e}(t,c,n);return{range:o,ticks:h,labels:l}}function dr(t){const e=Eo(t);y.timeFormatDefaultLocale(e);const{width:n,height:i,x:o,y:r,horizontal:a,opposite:s}=t._position,c=t.schema.padding,l=[c,t.schema[n]-c],h=function(t,e){const n="Circle"===t.schema.shape?t.schema.shapeConfig.r:"Rect"===t.schema.shape?t.schema.shapeConfig[e]:t.schema.shapeConfig.strokeWidth;return"function"!=typeof n?()=>n:n}(t,n),u=t._margin={top:0,right:0,bottom:0,left:0};!function(t){qo.delete(t)}(t),t._scaleData=No(t);let f=[],m=[],p=[];const g=function(t,e,n){const i=lr(t,e,n),o=t.schema.rotatedTickFormat;return o?e=>(t._labelRotation?o:i)(e):i}(t,e,()=>f);t._labelFormat=g;const x=e=>({range:m,ticks:p,labels:f}=ur(t,l,h,e));t._labelSet=0,x();const b=Gi(t,{range:m,p:c,height:i,margin:u}),{hBuff:k,wBuff:_}=function(t,e,n,i){let o="Circle"===t.schema.shape?"function"==typeof t.schema.shapeConfig.r?t.schema.shapeConfig.r({tick:!0}):t.schema.shapeConfig.r:"Rect"===t.schema.shape?"function"==typeof t.schema.shapeConfig[i]?t.schema.shapeConfig[i]({tick:!0}):t.schema.shapeConfig[i]:t.schema.tickSize,r=n({tick:!0});return"Rect"===t.schema.shape&&(o/=2),"Circle"!==t.schema.shape&&(r/=2),{hBuff:o,wBuff:r}}(t,0,h,i),v=!gi(t.schema.scale)&&yr(t,f,g),w={rangeOuter:l,horizontal:a,hBuff:k,p:c,tickFormat:g,rescale:x,ownSpace:a&&v,regrow:!a&&v,strict:Bi(t,a)},M=t._labelRotationSetting;mr(t,function(t,e){return si(t)?{rotate:!0,angle:oi(t),slant:ci(t,e)}:ri}(M,a));let S=pr(t,{range:m,labels:f},w);const C=hr(t)?.length??0;for(let e=1;e<C&&xr(S);e++)t._labelSet=e,S=pr(t,x(),w);void 0===M&&a&&(S=function(t,e,n){const{labels:i,tickFormat:o,ownSpace:r,rangeOuter:a,relayout:s}=n,c=pi(t,i),l=yr(t,i,o)?t=>xr(t):c?t=>t.length&&!t[0].fits?1:0:void 0,h=l?l(e):0;if(!l||!h||r&&2*h<e.length)return e;let u={turn:ri,misses:h,data:e},d=ri;for(const e of[{rotate:!0,angle:ai(t.schema.orient),slant:!0},{rotate:!0,angle:-90,slant:!1}]){mr(t,d=e);const n=s(),i=l(n)+(c&&n[0]?.truncated?1:0)+(e.slant&&fr(t,n,a).some(t=>t>1)?1:0);if(i<u.misses&&(u={turn:e,misses:i,data:n}),!i)break}return u.turn===d?u.data:(mr(t,u.turn),s())}(t,S,{labels:f,tickFormat:g,ownSpace:w.ownSpace,rangeOuter:l,relayout:()=>pr(t,x(),w)})),function(t,e,n){const i=new Set(e.filter(t=>t.truncated).map(t=>t.d));i.size&&(t._visibleTicks=n.filter(t=>!i.has(t)))}(t,S,p),function(t,e){const n=t.schema.labelOffset?d.max(e,t=>t.offset||0):0;e.forEach(t=>t.offset=t.offset?n:0)}(t,S),function(t,e,n){const{horizontal:i,hBuff:o,p:r,strict:a}=n,s=Ri(t,i,o,r);t._limited=a?{dropped:Yi(e,i,s),room:s}:void 0}(t,S,w),t._labelOverflow=fr(t,S,m),Gi(t,{range:m,p:c,height:i,margin:u,measured:b});const $=d.max(S,t=>t.height)||0,A=function(t,e){const{textData:n,rangeOuter:i,hBuff:o,horizontal:r,p:a,width:s,height:c,x:l,y:h,opposite:u,margin:f}=e,m="Line"===t.schema.shape?0:o,p=t._limited?n.some(t=>t.lines.length):n.length>0,g=t._outerBounds={[c]:(d.max(n,t=>Math.ceil(Ki(t,r)+(t.offset??0)))||0)+(p?a:0),[s]:i[i.length-1]-i[0],[l]:i[0]};return g[c]="number"==typeof t.schema.fixedSize?t.schema.fixedSize:d.max([t.schema.minSize,g[c]]),t._labelSpace=g[c],f[t.schema.orient]+=o,f[u]=void 0!==t.schema.gridSize?d.max([t.schema.gridSize,m]):t.schema[c]-f[t.schema.orient]-g[c]-a,g[c]+=f[u]+f[t.schema.orient],g[h]="start"===t.schema.align?t.schema.padding:"end"===t.schema.align?t.schema[c]-g[c]-t.schema.padding:t.schema[c]/2-g[c]/2,g}(t,{textData:S,rangeOuter:l,hBuff:k,horizontal:a,p:c,width:n,height:i,x:o,y:r,opposite:s,margin:u});return{ticks:p,labels:f,range:m,textData:S,tickFormat:g,hBuff:k,wBuff:_,tickGet:h,labelHeight:$,bounds:A}}function fr(t,e,n){const i=e.filter(t=>!t.truncated&&t.slant);if(!i.length)return[0,0];const o=Math.min(n[0],n[n.length-1]),r=Math.max(n[0],n[n.length-1]),a=e=>fi(t.schema.orient,e.angle,e.width,e.height-e.fP),s=i[0],c=i[i.length-1];return[Math.max(0,a(s)[0]-(s.position-o)),Math.max(0,a(c)[1]-(r-c.position))]}function mr(t,e){t._labelRotation=e.rotate,t._labelAngle=e.angle,t._labelSlant=e.slant}function pr(t,e,n){const{rangeOuter:i,horizontal:o,hBuff:r,p:a,rescale:s,strict:c}=n;let{labels:l}=e;const h=(e=1)=>Vi(t,{...n,labels:l,offset:e});let u=h(),f=t.schema.labelOffset&&u.some(t=>t.truncated);if(f){const e=h(2);c&&!function(t,e,n){const i=d.max(t,t=>t.offset||0)||0;return t.every(t=>!t.lines.length||Math.ceil(Ki(t,n)+(t.offset?i:0))<=e)}(e,Ri(t,o,r,a),o)?f=!1:u=e}let[m,p]=e.range;for(let e=0;e<3;e++){const e=u.filter(t=>!t.truncated),n=[0,1].map(n=>{const r=e[n?e.length-1:0];if(!r)return 0;const{height:a,position:s,rotate:c,width:l}=r,h=n?i[1]:i[0],u=r.slant?fi(t.schema.orient,r.angle,l,a-r.fP)[n]:(c||!o?a:l)/2,d=n?h-s:s-h;return d>=u?0:u-d}),r=p-m-(i[1]-i[0])/2,a=n[0]+n[1],c=a>r&&e.some(t=>t.slant)?Math.max(0,r)/a:1,d=[m+n[0]*c,p-n[1]*c];if(t.schema.range&&(void 0!==t.schema.range[0]&&(d[0]=t.schema.range[0]),void 0!==t.schema.range[t.schema.range.length-1]&&(d[1]=t.schema.range[t.schema.range.length-1])),d[0]===m&&d[1]===p)break;const g=gr(u);if([m,p]=d,({labels:l}=s(d)),u=h(f?2:1),gr(u)===g&&!u.some(t=>t.slant))break}return u}function gr(t){const e=t.filter(t=>!t.truncated);return[e[0],e[e.length-1]].map(t=>t?`${t.d instanceof Date?+t.d:t.d}`:"").join(",")}function yr(t,e,n){const i=t=>!(t instanceof Date)&&isNaN(t);return gi(t.schema.scale)?e.some(i):Array.isArray(t.schema.labels)&&!!n&&e.some(t=>i(n(t)))}function xr(t){return t.filter(t=>!t.fits||t.truncated).length}function br(t){t._dropTitle=!1;const e=dr(t),n=t._limited;if(!n||!n.dropped&&n.room>=0)return e;if(!t.schema.title)return e;t._dropTitle=!0;const i=dr(t);return!t._limited?.dropped||n.room<0?i:(t._dropTitle=!1,dr(t))}function kr(t){return t?.axisTooltip}const _r=t=>t.replace(/\s+/g,"");function vr(t,e){return!("text"!==t.type||!t.truncated)&&_r(t.lines.map(t=>t.text).join(""))!==_r(e)}const wr=(t,e)=>!1!==t&&(e||null!=t);function Mr(t){return t.flatMap(t=>[t,...Mr(t.children??[])])}function Sr(t){const e=t.datum?.data;return e&&"object"==typeof e&&"tick"in e&&"id"in e?e:void 0}const Cr=["band","ordinal","point"],$r=t=>t instanceof Date?+t:t;function Ar(t){if(!Cr.includes(`${t.schema.scale}`))return t=>Number(t);const e=t._givenDomain().slice();t._domainEndFirst&&e.reverse();const n=new Map(e.map((t,e)=>[$r(t),e]));return t=>n.get($r(t))??e.length}function zr(t,e,n){if(!1===e)return;const i=Mr(t),o=new Map;for(const t of i){const n=Sr(t);if("text"!==t.type||!n||o.has(t.datum))continue;const i=`${n.text}`;o.set(t.datum,{part:"tick",value:n.id,index:0,text:i,truncated:vr(t,i),option:e})}const r=Array.from(o.values());n&&r.sort((t,e)=>n(t.value)-n(e.value)),r.forEach((t,e)=>t.index=e);for(const t of i){const n=o.get(t.datum);n&&wr(e,n.truncated)&&(t.axisTooltip=n)}}function Dr(t,e,n){if(!1===n)return;const i=Mr(t),o=`${e}`,r=i.some(t=>vr(t,o));if(!wr(n,r))return;const a={part:"title",value:e,index:0,text:o,truncated:r,option:n};for(const t of i)void 0!==t.datum&&(t.axisTooltip=a)}function Lr(t){const e={...t,interactionGroup:"axis"};return"group"===e.type?e.children=e.children.map(Lr):e.axisTooltip||(e.interactive=!1),e}function Fr(t,e,n,i=0){const o=e=>{if("function"==typeof e)try{return e.call(t,n,i)}catch{return}return e},r={},a=o(e.stroke);null!=a&&(r.stroke=String(a));const s=o(e["stroke-width"]);null!=s&&(r.strokeWidth=Number(s));const c=o(e["stroke-opacity"]);null!=c&&(r.strokeOpacity=Number(c));const l=o(e["stroke-linecap"]);null!=l&&(r.strokeLinecap=l);const h=o(e["stroke-dasharray"]);if(null!=h){const t=String(h).split(/[\s,]+/).map(Number).filter(t=>Number.isFinite(t));t.length&&(r.strokeDasharray=t)}const u=o(e.opacity);null!=u&&(r.opacity=Number(u));const d=o(e.fill);return null!=d&&(r.fill=String(d)),r}function Nr(t){if(!t._d3Scale&&!t._d3ScaleNegative)return null;const{height:e,x:n,y:i,opposite:o}=t._position,r=t._margin[o],a=["top","left"].includes(t.schema.orient)?t._outerBounds[i]+t._outerBounds[e]-r:t._outerBounds[i]+r,s="point"===t.schema.scale&&t._d3Scale.align?t._d3Scale.align():.5,c="band"===t.schema.scale?t._d3Scale.step()-t._d3Scale.bandwidth():"point"===t.schema.scale?t._d3Scale.step()*t._d3Scale.padding()*2*s:0,l="band"===t.schema.scale?t._d3Scale.step():"point"===t.schema.scale?t._d3Scale.step()*t._d3Scale.padding()*2*(1-s):0,h=(t._d3ScaleNegative?t._d3ScaleNegative.domain():[]).concat(t._d3Scale?t._d3Scale.domain():[]).sort((t,e)=>t-e);if(!h.length)return null;const u=t._getPosition(h[0])-c,d=t._getPosition(h[h.length-1])+l;return{points:"x"===n?[[u,a],[d,a]]:[[a,u],[a,d]]}}function Br(t){const{data:e,dataFilter:n,label:i,labelBounds:o,x:r,y:a,aes:s,rotate:c,id:l,datum:h}=t,u=[];return(n?n(e):e).forEach((t,n)=>{let d=t;t.nested&&void 0!==t.key&&t.values&&(d=t.values[0],n=e.indexOf(d));let f=i(d,n);if(o&&!1!==f&&null!=f){const e=o(d,n,s(t,n));if(!e)return;f.constructor!==Array&&(f=[f]);const i=d.__d3plusShape__?d.translate?d.translate[0]:r(d.data,d.i):r(d,n),m=d.__d3plusShape__?d.translate?d.translate[1]:a(d.data,d.i):a(d,n);d.__d3plusShape__&&(d=d.data,n=d.i);for(let t=0;t<f.length;t++){const o=e.constructor===Array?e[t]:Object.assign({},e),r=c(d,n),a=d.labelConfig;let s=a&&a.rotate?a.rotate:void 0!==e.angle?e.angle:0;s+=r;const p=0!==r?[-1*o.x||0,-1*o.y||0]:[o.width/2,o.height/2];u.push({__d3plus__:!0,data:h?h(d,n):d,height:o.height,l:t,id:`${l(d,n)}_${t}`,r:s,rotateAnchor:p,...o.shape?{__d3plusWrapShape__:o.shape}:{},text:f[t],width:o.width,x:i+o.x,y:m+o.y})}}}),u}const Er=["squares","nylon","waves","woven","crosses","caps","hexagons"],Rr=["background","fill","stroke"];function Pr(t,e,n,i={}){if(!t)return!1;const o=e();if("none"===o)return!1;const a=r.isObject(t)?{...t}:{texture:t};a.background||(a.background=o),a.stroke||i.stroke||(a.stroke=n()),Er.includes(a.texture)||"function"==typeof a.texture?(a.d=a.texture,a.texture="paths"):"grid"===a.texture&&(a.orientation||i.orientation||(a.orientation=["vertical","horizontal"]),a.texture="lines"),a.fill||"paths"===a.texture||(a.fill=a.stroke);for(const t of Rr){const e=a[t];e&&"object"==typeof e&&(a[t]=String(e))}const s=r.assign({},i,a);return"function"==typeof s.d&&(s.d=s.d(s.size||20)),JSON.stringify(s)}function Tr(t){let e=t;for(;e.__d3plus__&&e.data;)e=e.data;return e.__d3plusShape__?e.data:e}function Or(t,e){if("number"==typeof t.width&&"number"==typeof t.height){return{x:"number"==typeof t.x?t.x:-t.width/2,y:"number"==typeof t.y?t.y:-t.height/2,width:t.width,height:t.height}}if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0;return{x:e-t.r,y:n-t.r,width:2*t.r,height:2*t.r}}if("string"==typeof t.d){const e=u.pathBounds(t.d);return e.width>0&&e.height>0?e:null}return function(t){if(!t.length)return null;let e=1/0,n=1/0,i=-1/0,o=-1/0;for(const[r,a]of t)r<e&&(e=r),a<n&&(n=a),r>i&&(i=r),a>o&&(o=a);return!Number.isFinite(e)||i<=e||o<=n?null:{x:e,y:n,width:i-e,height:o-n}}(e)}function Wr(t,e,n,i,o,r){return`M${t+(o=Math.min(o,n/2))},${e}h${n-2*o}a${o},${r=Math.min(r,i/2)} 0 0 1 ${o},${r}v${i-2*r}a${o},${r} 0 0 1 ${-o},${r}h${-(n-2*o)}a${o},${r} 0 0 1 ${-o},${-r}v${-(i-2*r)}a${o},${r} 0 0 1 ${o},${-r}Z`}function jr(t,e){if("string"==typeof t.d)return{type:"path",d:t.d};if("number"==typeof t.width&&"number"==typeof t.height){const e="number"==typeof t.x?t.x:-t.width/2,n="number"==typeof t.y?t.y:-t.height/2,i="number"==typeof t.rx?t.rx:0,o="number"==typeof t.ry?t.ry:0;return i>0||o>0?{type:"path",d:Wr(e,n,t.width,t.height,i||o,o||i)}:{type:"rect",x:e,y:n,width:t.width,height:t.height}}if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0,i=t.r;return{type:"path",d:`M${e-i},${n}a${i},${i} 0 1,0 ${2*i},0a${i},${i} 0 1,0 ${-2*i},0Z`}}if(e.length>2){return{type:"path",d:`M${e.map(([t,e])=>`${t},${e}`).join("L")}Z`}}}function Hr(t,e,n){if("contain"!==n){const n=Or(t,e);return n?{box:n,clip:jr(t,e),preserveAspectRatio:"xMidYMid slice"}:null}let i;if("number"==typeof t.width&&"number"==typeof t.height)i=Or(t,e);else if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0,o=t.r/Math.SQRT2;i={x:e-o,y:n-o,width:2*o,height:2*o}}else{const n=function(t,e){return"string"==typeof t.d?u.path2polygon(t.d):e}(t,e),o=n.length>2?u.largestRect(n,{angle:0}):null;i=o?{x:o.cx-o.width/2,y:o.cy-o.height/2,width:o.width,height:o.height}:Or(t,e)}return i?{box:i,preserveAspectRatio:"xMidYMid meet"}:null}function Ir(t,e,n){return t.map((t,i)=>{const o={type:"image",key:`${t.key}-bgimage-img`,x:t.box.x,y:t.box.y,width:t.box.width,height:t.box.height,href:t.url,preserveAspectRatio:t.preserveAspectRatio,interactive:!1};return{type:"group",key:`${t.key}-bgimage`,children:[o],datum:t.datum,index:t.index,interactive:!1,paint:{opacity:t.opacity??1},...t.transform?{transform:t.transform}:{},...t.clip?{clip:t.clip}:{},...e?{z:n+i}:{}}})}function Gr(t){const e=Number(t);return Number.isFinite(e)?e:void 0}function qr(t){return null==t||""===t?void 0:String(t)}function Vr(t){if(null==t||"none"===t||""===t)return;if("number"==typeof t)return[t];const e=String(t).split(/[\s,]+/).map(Number).filter(t=>Number.isFinite(t));return e.length?e:void 0}const Kr=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:W("")},{key:"backgroundImage",coerce:"const",default:W(!1)},{key:"backgroundImageFit",coerce:"const",default:W("cover")},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:W("black")},{key:"fillOpacity",coerce:"const",default:W(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(t,e)=>void 0!==t.id?t.id:e},{key:"label",coerce:"const",default:W(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:W(1)},{key:"pointerEvents",coerce:"const",default:W("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:W("presentation")},{key:"rotate",coerce:"const",default:W(0)},{key:"rx",coerce:"const",default:W(0)},{key:"ry",coerce:"const",default:W(0)},{key:"scale",coerce:"const",default:W(1)},{key:"shapeRendering",coerce:"const",default:W("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:W("0")},{key:"strokeLinecap",coerce:"const",default:W("butt")},{key:"strokeOpacity",coerce:"const",default:W(1)},{key:"strokeWidth",coerce:"const",default:W(0)},{key:"textAnchor",coerce:"const",default:W("start")},{key:"texture",coerce:"const",default:W(!1)},{key:"vectorEffect",coerce:"const",default:W("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:W("top")},{key:"x",coerce:"accessor",default:H("x",0)},{key:"y",coerce:"accessor",default:H("y",0)}];class Yr extends Xt{_aes(t,e){return{}}_getTextureKey(t,e){const n=this._styleVal(this.schema.texture,t,e);return!!n&&Pr(n,()=>this._styleVal(this.schema.fill,t,e),()=>this._styleVal(this.schema.stroke,t,e),this.schema.textureDefault)}_nestWrapper(t){return(e,n)=>t(e.__d3plusShape__?e.data:e,e.__d3plusShape__?e.i:n)}_buildLabelData(){return Br({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(this):void 0,label:this.schema.label,labelBounds:this.schema.labelBounds?this.schema.labelBounds.bind(this):void 0,x:this.schema.x,y:this.schema.y,aes:this._aes.bind(this),rotate:this.schema.rotate,id:this.schema.id})}_styleVal(t,e,n){return"function"!=typeof t?t:e.nested&&void 0!==e.key&&e.values?t(e.data,e.i):t(e,n)}_sceneTransform(t,e){const n=Boolean(t.__d3plusShape__),i=n?t.data:t,o=n?t.i:e;let r,a;if(n&&t.translate){const[e,n]=String(t.translate).split(",").map(Number);r=e,a=n}else r=Number(this.schema.x(i,o)),a=Number(this.schema.y(i,o));return{x:r,y:a,scale:n&&void 0!==t.scale?Number(t.scale):Number(this.schema.scale(i,o)),rotate:n&&void 0!==t.rotate?Number(t.rotate):Number(this.schema.rotate(t.data||t,o))}}_scenePaint(t,e){const n=this._getTextureKey(t,e);return{fill:n?`pattern:${n}`:qr(this._styleVal(this.schema.fill,t,e)),fillOpacity:Gr(this._styleVal(this.schema.fillOpacity,t,e)),stroke:qr(this._styleVal(this.schema.stroke,t,e)),strokeWidth:Gr(this._styleVal(this.schema.strokeWidth,t,e)),strokeOpacity:Gr(this._styleVal(this.schema.strokeOpacity,t,e)),strokeDasharray:Vr(this._styleVal(this.schema.strokeDasharray,t,e)),strokeLinecap:qr(this._styleVal(this.schema.strokeLinecap,t,e)),vectorEffect:qr(this._styleVal(this.schema.vectorEffect,t,e)),shapeRendering:qr(this._nestWrapper(this.schema.shapeRendering)(t,e)),opacity:Gr(this._nestWrapper(this.schema.opacity)(t,e))}}_sceneGeometry(t,e){return null}toScene(){let t=this._data;this._dataFilter&&(t=this._dataFilter(t));const e=[],n=[],i=function(t,e){if(!e||t.length<2)return null;const n=t.map((t,e)=>e);n.sort((n,i)=>e(Tr(t[n]),Tr(t[i])));const i=new Array(t.length);return n.forEach((t,e)=>i[t]=e),i}(t,this.schema.sort);return t.forEach((t,o)=>{const r=this._sceneGeometry(t,o);if(!r)return;const a=this._nestWrapper(this.schema.id)(t,o),s=t.__d3plusShape__?t.data:t,c=this._sceneTransform(t,o),l=this._scenePaint(t,o),h=function(t,e,n,i){if(!t.__d3plusShape__||!Array.isArray(t.values))return{};const o=t.values,r=[];return o.forEach((t,o)=>{if("function"==typeof i&&!1===i(t,o))return;const a=Number(e(t,o)),s=Number(n(t,o));Number.isFinite(a)&&Number.isFinite(s)&&r.push({x:a,y:s,datum:t,index:"number"==typeof t.i?t.i:o})}),r.length?{interactionPoints:r}:{}}(t,this.schema.x,this.schema.y,this.schema.defined);if(this.schema.hitArea){const n=function(t,e,n,i,o,r,a,s,c){const l="function"==typeof t?t(e,n,i):t;if(!l)return null;if("number"!=typeof l.width&&"string"==typeof c)return{type:"path",d:c,key:`${o}::hit`,datum:r,index:n,shapeType:a,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof l["stroke-width"]?l["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:s,aria:{hidden:!0}};return"number"!=typeof l.width||"number"!=typeof l.height?null:{type:"rect",x:"number"==typeof l.x?l.x:-l.width/2,y:"number"==typeof l.y?l.y:-l.height/2,width:l.width,height:l.height,key:`${o}::hit`,datum:r,index:n,shapeType:a,paint:{fill:"transparent"},transform:s,aria:{hidden:!0}}}(this.schema.hitArea,t,o,this._aes(t,o),a,s,this._name,c,r.d);n&&e.push(i?{...n,...h,z:i[o]}:{...n,...h})}e.push({...r,key:a,datum:s,index:o,shapeType:this._name,paint:l,transform:c,aria:{role:qr(this._nestWrapper(this.schema.role)(t,o)),label:qr(this._nestWrapper(this.schema.ariaLabel)(t,o))},...h,...i?{z:i[o]}:{}});const u="none"!==l.fill&&this._nestWrapper(this.schema.backgroundImage)(t,o);if(u){const e=r,i=Hr(e,"string"!=typeof e.d&&"number"!=typeof e.width&&"number"!=typeof e.r?this._aes(t,o).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(t,o)?"contain":"cover");i&&n.push({key:a,index:o,datum:s,url:u,box:i.box,clip:i.clip,preserveAspectRatio:i.preserveAspectRatio,opacity:Gr(this._nestWrapper(this.schema.opacity)(t,o)),transform:c})}}),n.length&&e.push(...Ir(n,i,t.length)),{type:"group",key:`${this._name}-group`,children:e}}render(t){const e=this._labelClass;if(e&&"function"==typeof e.renderMode&&e.renderMode("compute"),this._labelClass.config(this.schema.labelConfig),this._labelClass.data(this._buildLabelData()),"compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;if(void 0===this._select&&"undefined"!=typeof document){const t=document.createElement("div");t.style.cssText="display:block;",document.body.appendChild(t),this.select(t)}if(this._select){const t=this._select,e=t&&"function"==typeof t.node?t.node():t;e&&function(t,e){const n="svg"===(e.tagName||"").toLowerCase(),i=n?Number(e.getAttribute("width")):e.clientWidth,o=n?Number(e.getAttribute("height")):e.clientHeight,[s,c]=i&&o?[i,o]:r.getSize(e),l=i||s||400,h=o||c||300,u=t.toScene(),d=[];t._labelClass&&"function"==typeof t._labelClass.toScene&&t._labelClass._data&&t._labelClass._data.length&&d.push(...t._labelClass.toScene().children);const f={root:{...u,children:[...u.children,...d]},width:l,height:h},m=t._sceneRenderer;if(m&&"function"==typeof m.destroy&&m.destroy(),!m)for(;e.firstChild;)e.removeChild(e.firstChild);const p=new a.SvgRenderer;p.mount({container:e,width:l,height:h}),p.drawScene(f),t._sceneRenderer=p,It(t)}(this,e)}return t&&setTimeout(t,0),this}active(t){return arguments.length&&void 0!==t?(this.schema.active=t,this):this.schema.active}activeStyle(t){return arguments.length?(this.schema.activeStyle=ht(this,"activeStyle",t),this):this.schema.activeStyle}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return arguments.length&&void 0!==t?(this.schema.hover=t,this):this.schema.hover}hoverStyle(t){return arguments.length?(this.schema.hoverStyle=ht(this,"hoverStyle",t),this):this.schema.hoverStyle}labelConfig(t){return arguments.length?(this.schema.labelConfig=ht(this,"labelConfig",t),this):this.schema.labelConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}sort(t){return arguments.length?(this.schema.sort=t??null,this):this.schema.sort}textureDefault(t){return arguments.length?(this.schema.textureDefault=ht(this,"textureDefault",t),this):this.schema.textureDefault}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(t="g"){super(),kt(this,Kr),this._data=[],this._labelClass=new ei,this._name="Shape",this._tagName=t,this._textureDefs={},this.schema.stroke=(t,e)=>{const n=i.color(this.schema.fill(t,e));return n?n.darker(1).formatHex():this.schema.fill(t,e)},this.schema.activeStyle={stroke:(t,e)=>{let n=this.schema.fill(t,e);["transparent","none"].includes(n)&&(n=this.schema.stroke(t,e));const o=i.color(n);return o?o.darker(1).toString():n},"stroke-width":(t,e)=>3*(this.schema.strokeWidth(t,e)||1)},this.schema.hoverStyle={stroke:(t,e)=>{let n=this.schema.fill(t,e);["transparent","none"].includes(n)&&(n=this.schema.stroke(t,e));const o=i.color(n);return o?o.darker(.5).toString():n},"stroke-width":(t,e)=>2*(this.schema.strokeWidth(t,e)||1)},this.schema.labelConfig={fontColor:(t,n)=>e.colorContrast(this.schema.fill(t,n),this.schema.colorDefaults),fontOpacity:(t,e)=>this.schema.opacity(t,e),fontResize:!0,fontMax:50,fontMin:8,fontSize:12,padding:5,textAnchor:"start",verticalAlign:"top"},this.schema.textureDefault={}}}Yr._displayName="Shape",dt(Yr.prototype,"activeStyle","hoverStyle","labelConfig","textureDefault");const Ur=[{key:"curve",coerce:"const",default:W("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class Xr extends Yr{_sceneGeometry(t){const e=Number(t.x),n=Number(t.y),i=String(this.schema.curve.bind(this)(this.config())),o=R[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`],r=t=>(n,i)=>t(n,i)-e,a=t=>(e,i)=>t(e,i)-n,s=R.area().defined(this.schema.defined).curve(o).x(r(this.schema.x)).x0(r(this.schema.x0)).y(a(this.schema.y)).y0(a(this.schema.y0));return this.schema.x1?s.x1(r(this.schema.x1)):s.x1(null),this.schema.y1?s.y1(a(this.schema.y1)):s.y1(null),{type:"path",d:s(t.values)||""}}_aes(t){const e=t.values.slice().sort((t,e)=>this.schema.y1?this.schema.x(t)-this.schema.x(e):this.schema.y(t)-this.schema.y(e)),n=e.map((t,e)=>[this.schema.x0(t,e),this.schema.y0(t,e)]),i=e.reverse().map((t,e)=>this.schema.y1?[this.schema.x(t,e),this.schema.y1(t,e)]:[this.schema.x1(t,e),this.schema.y(t,e)]);let o=n.concat(i);return n[0][1]>i[0][1]&&(o=o.reverse()),o.push(o[0]),{points:o}}_dataFilter(t){const e=d.groups(t,this.schema.id).map(([e,i])=>{const o={key:e,values:i};o.data=n.merge(o.values),o.i=t.indexOf(o.values[0]);const r=d.extent(o.values.map(this.schema.x).concat(o.values.map(this.schema.x0)).concat(this.schema.x1?o.values.map(this.schema.x1):[]));o.xR=r,o.width=r[1]-r[0],o.x=r[0]+o.width/2;const a=d.extent(o.values.map(this.schema.y).concat(o.values.map(this.schema.y0)).concat(this.schema.y1?o.values.map(this.schema.y1):[]));return o.yR=a,o.height=a[1]-a[0],o.y=a[0]+o.height/2,o.nested=!0,o.translate=[o.x,o.y],o.__d3plusShape__=!0,o});return e.key=t=>t.key,e}x(t){return arguments.length?(this.schema.x="function"==typeof t?t:W(t),this.schema.x0=this.schema.x,this):this.schema.x}x0(t){return arguments.length?(this.schema.x0="function"==typeof t?t:W(t),this.schema.x=this.schema.x0,this):this.schema.x0}x1(t){return arguments.length?(this.schema.x1="function"==typeof t?t:null===t?null:W(t),this):this.schema.x1}y(t){return arguments.length?(this.schema.y="function"==typeof t?t:W(t),this.schema.y0=this.schema.y,this):this.schema.y}y0(t){return arguments.length?(this.schema.y0="function"==typeof t?t:W(t),this.schema.y=this.schema.y0,this):this.schema.y0}y1(t){return arguments.length?(this.schema.y1="function"==typeof t?t:null===t?null:W(t),this):this.schema.y1}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),kt(this,Ur),this._name="Area",this.schema.labelBounds=(t,e,n)=>{const i=u.largestRect(n.points);return i?{angle:i.angle,width:i.width,height:i.height,x:i.cx-i.width/2-this.schema.x(t,e),y:i.cy-i.height/2-this.schema.y(t,e)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=H("x"),this.schema.x0=H("x"),this.schema.x1=null,this.schema.y=W(0),this.schema.y0=W(0),this.schema.y1=H("y")}}Xr._displayName="Area";const Qr=[{key:"height",coerce:"accessor",default:W(10)},{key:"width",coerce:"accessor",default:W(10)}];class Zr extends Yr{_sceneGeometry(t,e){const n=this._getWidth(t,e),i=this._getHeight(t,e);return{type:"rect",x:null!==this.schema.x1?this._getX(t,e):-n/2,y:null===this.schema.x1?this._getY(t,e):-i/2,width:n,height:i}}_aes(t,e){return{height:this._getHeight(t,e),width:this._getWidth(t,e)}}_applyPosition(t){t.attr("width",(t,e)=>this._getWidth(t,e)).attr("height",(t,e)=>this._getHeight(t,e)).attr("x",(t,e)=>null!==this.schema.x1?this._getX(t,e):-this._getWidth(t,e)/2).attr("y",(t,e)=>null===this.schema.x1?this._getY(t,e):-this._getHeight(t,e)/2)}_getHeight(t,e){return null!==this.schema.x1?this.schema.height(t,e):Math.abs(this.schema.y1(t,e)-this.schema.y(t,e))}_getWidth(t,e){return null===this.schema.x1?this.schema.width(t,e):Math.abs(this.schema.x1(t,e)-this.schema.x(t,e))}_getX(t,e){const n=null===this.schema.x1?this.schema.x(t,e):this.schema.x1(t,e)-this.schema.x(t,e);return n<0?n:0}_getY(t,e){const n=null!==this.schema.x1?this.schema.y(t,e):this.schema.y1(t,e)-this.schema.y(t,e);return n<0?n:0}x0(t){return arguments.length?(this.schema.x0="function"==typeof t?t:W(t),this.schema.x=this.schema.x0,this):this.schema.x0}x1(t){return arguments.length?(this.schema.x1="function"==typeof t?t:null===t?null:W(t),this):this.schema.x1}y0(t){return arguments.length?(this.schema.y0="function"==typeof t?t:W(t),this.schema.y=this.schema.y0,this):this.schema.y0}y1(t){return arguments.length?(this.schema.y1="function"==typeof t?t:null===t?null:W(t),this):this.schema.y1}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("rect"),kt(this,Qr),this._name="Bar",this.schema.labelBounds=(t,e,n)=>({width:n.width,height:n.height,x:null!==this.schema.x1?this._getX(t,e):-n.width/2,y:null===this.schema.x1?this._getY(t,e):-n.height/2}),Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=H("x"),this.schema.x0=H("x"),this.schema.x1=null,this.schema.y=W(0),this.schema.y0=W(0),this.schema.y1=H("y")}}Zr._displayName="Bar";const Jr=[{key:"height",coerce:"accessor",default:H("height")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:H("width")}];class ta extends Yr{_sceneGeometry(t,e){const n=Number(this.schema.width(t,e)),i=Number(this.schema.height(t,e)),o=this._styleVal(this.schema.rx,t,e),r=this._styleVal(this.schema.ry,t,e);return{type:"rect",x:-n/2,y:-i/2,width:n,height:i,...null==o?{}:{rx:Number(o)},...null==r?{}:{ry:Number(r)},...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(t,e){return{width:this.schema.width(t,e),height:this.schema.height(t,e)}}_applyPosition(t){t.attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>-this.schema.width(t,e)/2).attr("y",(t,e)=>-this.schema.height(t,e)/2)}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("rect"),kt(this,Jr),this._name="Rect",this.schema.labelBounds=(t,e,n)=>({width:n.width,height:n.height,x:-n.width/2,y:-n.height/2})}}ta._displayName="Rect";const ea=[{key:"r",coerce:"accessor",default:H("r")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0}];class na extends Yr{_applyPosition(t){t.attr("r",(t,e)=>this.schema.r(t,e)).attr("x",(t,e)=>-this.schema.r(t,e)/2).attr("y",(t,e)=>-this.schema.r(t,e)/2)}_sceneGeometry(t,e){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(t,e)),...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(t,e){return{r:this.schema.r(t,e)}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("circle"),kt(this,ea),this._name="Circle",this.schema.labelBounds=(t,e,n)=>({width:2*n.r,height:2*n.r,x:-n.r,y:-n.r,shape:"circle"}),this.schema.labelConfig=r.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}na._displayName="Circle";const ia=new Map([["Circle",na],["Rect",ta]]);const oa=t=>ia.has(t);function ra(t){return Array.isArray(t)?t:[t,t]}function aa(t,e){const n=d.quantile(t,.25),i=d.quantile(t,.5),o=d.quantile(t,.75),r=i=>function(t,e,n,i,o){const r=d.min(t),a=d.max(t);if("tukey"===e){const t=n?o+1.5*(o-i):i-1.5*(o-i);return n?t>a?a:t:t<r?r:t}return"extent"===e?n?a:r:"number"==typeof e?d.quantile(t,e):void 0}(t,e[i],i,n,o);return{first:n,median:i,third:o,lowerLimit:r(0),upperLimit:r(1)}}const sa=["fill","stroke","backgroundImage","backgroundImageFit","texture","textureDefault"],ca={fill:"white",stroke:"black"};function la(t,e){return Bt(t)?Nt(e):e}function ha(t){return"function"==typeof t?e=>t(e.data,e.i):t}function ua(t){const n="string"==typeof t?i.color(t):null;return n&&n.opacity?e.colorContrast(n.formatRgb(),{dark:"black",light:"white"}):"black"}function da(t){const e=new Set(t),n=new Set;return t.map(t=>{if(!n.has(t))return n.add(t),t;let i=1;for(;e.has(`${t}~${i}`);)i++;const o=`${t}~${i}`;return e.add(o),o})}const fa=["boxMin","boxQ1","boxMedian","boxQ3","boxMax"];function ma(t){if(null!=t&&!1!==t)return"function"==typeof t?t:"string"==typeof t?G(t):W(t)}function pa(t){return fa.some(e=>"function"==typeof t[e])}function ga(t,e){const n=function(t){return pa(t)?fa.filter(e=>"function"!=typeof t[e]):[]}(e);n.length&&Rt(`${t} draws precomputed boxes only when ${fa.join(", ")} are all set; missing ${n.join(", ")}.`)}const ya=t=>"number"==typeof t&&Number.isFinite(t),xa=t=>"number"==typeof t||t instanceof Date?+t:NaN;function ba(t,e,n){const i="function"==typeof t.boxOutliers?t.boxOutliers(e,n):void 0;return(Array.isArray(i)?i:[i]).map(xa).filter(ya)}function ka(t,e,n){const i=[];for(const o of fa){const r=t[o];if("function"!=typeof r)return null;const a=xa(r(e,n));if(!ya(a))return null;i.push(a)}i.sort((t,e)=>t-e);const o=ba(t,e,n),[r,a,s,c,l]=i;return{min:r,q1:a,median:s,q3:c,max:l,outliers:o}}function _a(t,e,n){const i=t,o=t.first,r=t.third-o;"vertical"===t.orient?(i.height=r,i.width=n,i.x=e,i.y=o+r/2):"horizontal"===t.orient&&(i.height=n,i.width=r,i.x=o+r/2,i.y=e)}function va(t,e,n){const i=t=>{const o={...t},r=function(t,e){const n=new Set;for(let i=t;i&&"object"==typeof i&&!n.has(i);i=i.data){const t=e.get(i);if(t)return t;n.add(i)}}(t.datum,n);return r&&(o.owners=[...t.owners??[],{shapeType:e,...r}]),"group"===t.type&&(o.children=t.children.map(i)),o};return t.map(i)}const wa=[{key:"curve",coerce:"const",default:W("linear")},{key:"defined",coerce:"identity",default:t=>t}];class Ma extends Yr{_dataFilter(t){const e=d.groups(t,this.schema.id).map(([e,i])=>{const o={key:e,values:i};o.data=n.merge(o.values),o.i=t.indexOf(o.values[0]);const r=d.extent(o.values,this.schema.x);o.xR=r,o.width=r[1]-r[0],o.x=r[0]+o.width/2;const a=d.extent(o.values,this.schema.y);return o.yR=a,o.height=a[1]-a[0],o.y=a[0]+o.height/2,o.nested=!0,o.translate=[o.x,o.y],o.__d3plusShape__=!0,o});return e.key=t=>t.key,e}_sceneGeometry(t){const e=Number(t.x),n=Number(t.y),i=String(this.schema.curve.bind(this)(this.config())),o=R[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`];return{type:"path",d:R.line().curve(o).defined(this.schema.defined).x((t,n)=>this.schema.x(t,n)-e).y((t,e)=>this.schema.y(t,e)-n)(t.values)||""}}_aes(t,e){return{points:t.values.map(t=>[this.schema.x(t,e),this.schema.y(t,e)])}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),kt(this,wa),this._name="Line",this._path=R.line(),this.schema.fill=W("none"),this.schema.stroke=W("black"),this.schema.strokeWidth=W(1),this.schema.hitArea=W({d:t=>this._path(t.values),fill:"none","stroke-width":10,transform:null})}}Ma._displayName="Line";const Sa={Circle:na,Rect:ta},Ca=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:H("endpoint","Rect")},{key:"length",coerce:"const",default:H("length",25)},{key:"orient",coerce:"const",default:H("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:H("x",0)},{key:"y",coerce:"const",default:H("y",0)}];class $a extends Xt{render(t){const e="compute"===this.schema.renderMode;void 0!==this._select||e||this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const n=t=>e?null:r.elem(t,{parent:this._select}).node();this._owned=new Map(this._data.map((t,e)=>[t,{datum:t,index:e}]));const i=da(this._data.map((t,e)=>`${t.id??e}`)),a=function(t,e){const n=[];return t._data.forEach((i,o)=>{const r=t.schema.orient(i,o),a=t.schema.x(i,o),s=t.schema.y(i,o);let c=a;"left"===r?c-=t.schema.length(i,o):"right"===r&&(c+=t.schema.length(i,o));let l=s;"top"===r?l-=t.schema.length(i,o):"bottom"===r&&(l+=t.schema.length(i,o)),n.push({__d3plus__:!0,data:i,i:o,id:e[o],x:a,y:s}),n.push({__d3plus__:!0,data:i,i:o,id:e[o],x:c,y:l})}),n}(this,i);this._line=(new Ma).data(a).renderMode(e?"compute":"full").select(n("g.d3plus-Whisker")).config(te.bind(this)(this.schema.lineConfig,"shape")).render();const s=function(t,e){return t._data.map((n,i)=>{const o={__d3plus__:!0};o.data=n,o.i=i,o.id=`${e[i]}-end`,o.endpoint=t.schema.endpoint(n,i),o.length=t.schema.length(n,i),o.orient=t.schema.orient(n,i);let r=t.schema.x(n,i);"left"===o.orient?r-=o.length:"right"===o.orient&&(r+=o.length);let a=t.schema.y(n,i);return"top"===o.orient?a-=o.length:"bottom"===o.orient&&(a+=o.length),o.x=r,o.y=a,o})}(this,i);return this._whiskerEndpoint=[],d.groups(s,t=>t.endpoint).forEach(([t,i])=>{this._whiskerEndpoint.push((new Sa[t]).data(i).renderMode(e?"compute":"full").select(n(`g.d3plus-Whisker-Endpoint-${t}`)).config(Nt({height:t=>"top"===t.orient||"bottom"===t.orient?5:20,width:t=>"top"===t.orient||"bottom"===t.orient?20:5})).config(te.bind(this)(this.schema.endpointConfig,"shape",t)).render())}),t&&setTimeout(t,this.schema.duration+100),this}toScene(){const t=[],e=e=>{const n=e&&"function"==typeof e.toScene?e.toScene():null;n&&Array.isArray(n.children)&&t.push(...n.children)};if(e(this._line),Array.isArray(this._whiskerEndpoint))for(const t of this._whiskerEndpoint)e(t);return{type:"group",key:"d3plus-Whisker-scene",children:va(t,"Whisker",this._owned)}}active(t){this._line&&this._line.active(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.active(t))}data(t){return arguments.length?(this._data=t,this):this._data}endpointConfig(t){return arguments.length?(this.schema.endpointConfig=ht(this,"endpointConfig",t),this):this.schema.endpointConfig}hover(t){this._line&&this._line.hover(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.hover(t))}lineConfig(t){return arguments.length?(this.schema.lineConfig=ht(this,"lineConfig",t),this):this.schema.lineConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),kt(this,Ca),this.schema.endpointConfig={Circle:{r:H("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[],this._owned=new Map}}$a._displayName="Whisker",dt($a.prototype,"endpointConfig","lineConfig");const Aa=t=>"function"==typeof t?t:H(t),za=[{key:"backgroundImage",coerce:"const"},{key:"backgroundImageFit",coerce:"const"},{key:"boxMax",coerce:ma},{key:"boxMedian",coerce:ma},{key:"boxMin",coerce:ma},{key:"boxOutliers",coerce:ma},{key:"boxQ1",coerce:ma},{key:"boxQ3",coerce:ma},{key:"fill",coerce:"const"},{key:"id",coerce:"accessor"},{key:"orient",coerce:"const",default:H("orient","vertical")},{key:"outlier",coerce:"const",default:H("outlier","Circle")},{key:"rectWidth",coerce:"const",default:W(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"stroke",coerce:"const"},{key:"texture",coerce:"const"},{key:"textureDefault",coerce:"identity"},{key:"whiskerMode",coerce:ra,default:["tukey","tukey"]},{key:"x",coerce:Aa,default:H("x",250)},{key:"y",coerce:Aa,default:H("y",250)}];function Da(t,[e,i],o,r){const a={key:e,values:i};a.data=n.merge(a.values),a.i=t._data.indexOf(a.values[0]),a.id=o,a.orient=t.schema.orient(a.data,a.i);const s=a.values.map("vertical"===a.orient?t.schema.y:t.schema.x);s.sort((t,e)=>t-e);const{first:c,median:l,third:h,lowerLimit:u,upperLimit:d}=aa(s,t.schema.whiskerMode);return Object.assign(a,{first:c,median:l,third:h}),void 0!==u&&Object.assign(a,{lowerLimit:u}),void 0!==d&&Object.assign(a,{upperLimit:d}),_a(a,e,t.schema.rectWidth(a.data,a.i)),function(t,e,n){e.values.forEach((i,o)=>{const r="vertical"===e.orient?t.schema.y(i,o):t.schema.x(i,o);if(r<e.lowerLimit||r>e.upperLimit){const a=t.schema.outlier(i,o);if(!oa(a))return;const s={__d3plus__:!0};s.data=i,s.i=o,s.id=`${e.id}-outlier-${o}`,s.outlier=a,"vertical"===e.orient?(s.x=e.x,s.y=r,n.push(s)):"horizontal"===e.orient&&(s.y=e.y,s.x=r,n.push(s))}})}(t,a,r),a.__d3plus__=!0,a}class La extends Xt{render(){const t="compute"===this.schema.renderMode;void 0!==this._select||t||this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const e=e=>t?null:r.elem(e,{parent:this._select}).node(),n=[],i=pa(this.schema)?function(t,e){const{schema:n}=t;ga("Box",n);const i=t._data.map((t,e)=>({row:t,i:e,stats:ka(n,t,e)})).filter(t=>t.stats),o=n.orient,r=i.map(({row:t,i:e})=>"vertical"===o(t,e)?n.x(t,e):n.y(t,e)),a=da(i.map(({row:t,i:e},i)=>`${(n.id?n.id(t,e):void 0)??r[i]}`));return t._owned=new Map,i.map(({row:i,i:s,stats:c},l)=>{const h=c,u={__d3plus__:!0,key:r[l],values:[i],data:i,i:s,id:a[l],orient:o(i,s),first:h.q1,median:h.median,third:h.q3,lowerLimit:h.min,upperLimit:h.max};_a(u,r[l],n.rectWidth(i,s));const d=e.length,f=n.outlier(i,s);oa(f)&&h.outliers.forEach((t,n)=>e.push(function(t,e,n,i){const o="vertical"===t.orient;return{__d3plus__:!0,data:t.data,i:t.i,id:`${t.id}-outlier-${i}`,outlier:e,x:o?t.x:n,y:o?n:t.y}}(u,f,t,n)));const m={datum:u,index:l};for(const n of[u,...e.slice(d)])t._owned.set(n,m);return u})}(this,n):function(t,e){const n=d.groups(t._data,(e,n)=>"vertical"===t.schema.orient(e,n)?t.schema.x(e,n):t.schema.y(e,n)),i=da(n.map(([e,n])=>{const i=n[0];return`${(t.schema.id?t.schema.id(i,t._data.indexOf(i)):void 0)??e}`}));return t._owned=new Map,n.map((n,o)=>{const r=e.length,a=Da(t,n,i[o],e),s={datum:a,index:o};for(const n of[a,...e.slice(r)])t._owned.set(n,s);return a})}(this,n),a=function(t,e){const n={...ca};for(const i of sa){const o=t[i];void 0===o||i in e||(n[i]=ha(o))}return la(e,{...n,...e})}(this.schema,te.bind(this)(this.schema.rectConfig,"shape"));this._box=(new ta).data(i).id(t=>`${t.id}-box`).x(t=>t.x).y(t=>t.y).renderMode(t?"compute":"full").select(e("g.d3plus-Box")).config(a).render(),this._median=(new ta).data(i).id(t=>`${t.id}-median`).x(t=>"vertical"===t.orient?t.x:t.median).y(t=>"vertical"===t.orient?t.median:t.y).height(t=>"vertical"===t.orient?1:t.height).width(t=>"vertical"===t.orient?t.width:1).renderMode(t?"compute":"full").select(e("g.d3plus-Box-Median")).config(function(t,e){if("fill"in e)return e;const n="function"==typeof t?(e,n)=>ua(t(e,n)):()=>ua(t);return la(e,{...e,fill:n})}(a.fill,te.bind(this)(this.schema.medianConfig,"shape"))).render();const s=function(t){const e=[];return t.forEach((t,n)=>{const i=t.x,o=t.y,r=t.first-t.lowerLimit,a=t.upperLimit-t.third;if("vertical"===t.orient){const s=o-t.height/2,c=o+t.height/2;e.push({__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-top`,x:i,y:s,length:r,orient:"top"},{__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-bottom`,x:i,y:c,length:a,orient:"bottom"})}else if("horizontal"===t.orient){const s=i+t.width/2,c=i-t.width/2;e.push({__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-right`,x:s,y:o,length:a,orient:"right"},{__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-left`,x:c,y:o,length:r,orient:"left"})}}),e}(i);return this._whisker=(new $a).data(s).renderMode(t?"compute":"full").select(e("g.d3plus-Box-Whisker")).config(te.bind(this)(this.schema.whiskerConfig,"shape")).render(),this._whiskerEndpoint=[],d.groups(n,t=>t.outlier).forEach(([n,i])=>{const o=function(t){return ia.get(t)}(n);var r,a;this._whiskerEndpoint.push((new o).data(i).renderMode(t?"compute":"full").select(e(`g.d3plus-Box-Outlier-${n}`)).config((r=this.schema,a=te.bind(this)(this.schema.outlierConfig,"shape",n),void 0===r.fill||"fill"in a?a:la(a,{...a,fill:ha(r.fill)}))).render())}),this}toScene(){const t=[],e=e=>{const n=e&&"function"==typeof e.toScene?e.toScene():null;n&&Array.isArray(n.children)&&t.push(...n.children)};if(e(this._box),e(this._median),e(this._whisker),Array.isArray(this._whiskerEndpoint))for(const t of this._whiskerEndpoint)e(t);return{type:"group",key:"d3plus-Box-scene",children:va(t,"Box",this._owned)}}active(t){this._box&&this._box.active(t),this._median&&this._median.active(t),this._whisker&&this._whisker.active(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.active(t))}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){this._box&&this._box.hover(t),this._median&&this._median.hover(t),this._whisker&&this._whisker.hover(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.hover(t))}medianConfig(t){return arguments.length?(this.schema.medianConfig=ht(this,"medianConfig",t),this):this.schema.medianConfig}outlierConfig(t){return arguments.length?(this.schema.outlierConfig=ht(this,"outlierConfig",t),this):this.schema.outlierConfig}rectConfig(t){return arguments.length?(this.schema.rectConfig=ht(this,"rectConfig",t),this):this.schema.rectConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}whiskerConfig(t){return arguments.length?(this.schema.whiskerConfig=ht(this,"whiskerConfig",t),this):this.schema.whiskerConfig}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),kt(this,za),this.schema.medianConfig={},this.schema.outlierConfig={Circle:{r:H("r",5)},Rect:{height:(t,e)=>"vertical"===this.schema.orient(t,e)?5:20,width:(t,e)=>"vertical"===this.schema.orient(t,e)?20:5}},this.schema.rectConfig={strokeWidth:W(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[],this._owned=new Map}}La._displayName="Box",dt(La.prototype,"medianConfig","outlierConfig","rectConfig","whiskerConfig");const Fa=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:H("height")},{key:"id",coerce:"identity",default:H("id")},{key:"opacity",coerce:"const",default:W(1)},{key:"pointerEvents",coerce:"const",default:W("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:H("url")},{key:"width",coerce:"accessor",default:H("width")},{key:"x",coerce:"const",default:H("x",0)},{key:"y",coerce:"const",default:H("y",0)}];class Na{config(t){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const e=t;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("function"==typeof this[t]?this[t](e[t]):this.schema[t]=e[t]);return this}render(t){if("compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;void 0===this._select&&this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const e=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),n=e.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(t,e)=>this.schema.x(t,e)+this.schema.width(t,e)/2).attr("y",(t,e)=>this.schema.y(t,e)+this.schema.height(t,e)/2),i=m.transition().duration(this.schema.duration),r=this;return n.merge(e).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(i).attr("opacity",this.schema.opacity).attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>this.schema.x(t,e)).attr("y",(t,e)=>this.schema.y(t,e)).each(function(t,e){const n=o.select(this),i=r.schema.url(t,e);if(!(0===i.indexOf("http://")||0===i.indexOf("https://"))||0===i.indexOf(window.location.hostname)){const t=new window.Image;t.src=i,t.crossOrigin="Anonymous",t.onload=function(){const e=document.createElement("canvas");e.width=t.width,e.height=t.height;e.getContext("2d").drawImage(t,0,0),n.attr("xlink:href",e.toDataURL("image/png"))}}}),e.exit().transition(i).attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>this.schema.x(t,e)).attr("y",(t,e)=>this.schema.y(t,e)).attr("opacity",0).remove(),t&&setTimeout(t,this.schema.duration+100),this}data(t){return arguments.length?(this._data=t,this):this._data}toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((t,e)=>({type:"image",key:`${this.schema.id(t,e)}`,x:this.schema.x(t,e),y:this.schema.y(t,e),width:this.schema.width(t,e),height:this.schema.height(t,e),href:this.schema.url(t,e),paint:{opacity:this.schema.opacity(t,e)},datum:t,index:e}))}}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){kt(this,Fa)}}const Ba=[{key:"d",coerce:"const",default:H("path")}];class Ea extends Yr{_sceneGeometry(t,e){return{type:"path",d:String(this.schema.d(t,e))}}_aes(t,e){return{points:u.path2polygon(this.schema.d(t,e))}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("path"),kt(this,Ba),this._name="Path",this.schema.labelBounds=(t,e,n)=>{const i=this.schema.labelConfig.rotate,o=u.largestRect(n.points,{angle:i?i(t,e):0});return!!o&&{angle:o.angle,width:o.width,height:o.height,x:o.cx-o.width/2,y:o.cy-o.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}Ea._displayName="Path";var Ra=Object.freeze({__proto__:null,Area:Xr,Bar:Zr,Box:La,Circle:na,Image:Na,Line:Ma,Path:Ea,Rect:ta,Shape:Yr,Whisker:$a});function Pa(t,e,n,i=.5){if(e.length<3)return!1;const o=e.map(n).sort((t,e)=>t-e),r=n(t);if(![r,...o].every(Number.isFinite))return!1;const a=o.length-1,s=Math.abs(r-o[0])<=Math.abs(r-o[a]),c=s?o[0]:o[a],l=s?o[1]:o[a-1],h=Math.abs(c-l);return!!h&&Math.abs(r-c)-h*i<=1e-9*h}const Ta=936e5;function Oa(t,e,n){const i=E.scaleLinear().domain([200,1200]).range([8,28]),o=t.range(),r=Math.abs(o[1]-o[0]);let a=Math.floor(i(r));if("time"===this.schema.scale)if(n.length){const t=d.extent(n),i=n.reduce((t,e,n,i)=>{if(n){const o=Math.abs(e-i[n-1]);o<t&&(t=o)}return t},1/0),o=Math.round((t[1]-t[0])/i);a=d.min([a*(e?2:.5),o])}else a=e?2*a:a/2;return Math.floor(a)}function Wa(t,e=!1){if(Ui(t))return Ji(t,t=>Wa.call(this,t,e),e?void 0:(t,e,n)=>!Pa(t,e,t=>n(t)));let n;const i=t.copy(),o="time"===this.schema.scale?Bo(this._scaleData,t):[];if(o.length){const e=d.extent(o),n=e.map(e=>t(e));i.domain(e).range(n)}const a=i.domain(),s=a[1]<a[0],c=Oa.call(this,i,e,o);if(e||"log"!==this.schema.scale){if(i.exponent&&1!==i.exponent())n=function(t,e,n,i=!1){const[o,r]=t.map(Number),a=Math.min(o,r),s=Math.max(o,r);if(!Number.isFinite(a)||!Number.isFinite(s)||a===s||!e)return a===s&&Number.isFinite(a)?[a]:[];const c=Math.max(1,Math.round(n)),l=sr(a,e),h=sr(s,e),u=t=>Array.from({length:t+1},(n,i)=>sr(l+(h-l)*i/t,1/e)),d=u(c),f=cr(d,d);let m=f;if(i){const t=u(2*c),e=t.filter((t,e)=>e%2);m=f.concat(cr(e,t))}const p=Array.from(new Set(m)).filter(t=>t>=a&&t<=s).sort((t,e)=>t-e);return r<o?p.reverse():p}(a,i.exponent(),Math.max(1,c/2),e);else if(n=i.ticks(c),!e&&!["log","time"].includes(this.schema.scale)&&n.length>1){const t=Math.abs(2*ir(n[1]-n[0]));n=n.filter(e=>{const n=Math.abs(e)%t,i=ir(n);return i!==n?!i||i===t:0===n})}}else{const t=a.map(t=>Math.log10(t)%1==0?t:(s?nr:er)(t)),e=t[1]<t[0],o=t.map(t=>(tr(t)?-1:1)*([-1,1].includes(t)||Math.abs(t)<1?1:Math.log10(Math.abs(t)))),r=Math.ceil((Math.abs(o[1]-o[0])+1)/(.65*c));n=r<=1&&o[0]===o[1]||e!==s?i.ticks(c).filter(t=>+`${t}`.replace("0.","")%2==0):d.range(o[0],o[1],o[1]<o[0]?-1:1).concat([o[1]]).filter(t=>Math.abs(t)%r===0).map(t=>+(""+(tr(t)?-1:1)*(t?Math.pow(10,Math.abs(t)):Math.sign(1/t)>0?1:-1)).replace(/9+/g,"1"))}if("time"===this.schema.scale&&this._scaleData.length){const t=this._scaleData.map(Number);n=n.filter(e=>{const n=+e;return t.find(t=>t>=n-Ta&&t<=n+Ta)})}return function(t,e,n,i,o){if(!1===t.schema.domainTicks)return e;const a=n[1]<n[0],s=e.map(Number),c=(t.schema.ticks??[]).map(e=>Number("time"===t.schema.scale?r.date(e):e)),l=t=>!e.map(Number).includes(Number(t))&&(!o||c.includes(Number(t))||!Pa(Number(t),s,t=>i(t))),h=n=>!t._d3ScaleNegative||tr(n)===e.some(t=>tr(t));return h(n[a?1:0])&&l(n[0])&&e.unshift(n[0]),h(n[a?0:1])&&l(n[1])&&e.push(n[1]),e}(this,n,a,i,!e)}function ja(t,e,n){const{x:i,y:o,width:r,height:a}=di(t.schema.orient,e.angle,e.width,e.height-e.fP,e.height,n);return{x:i,y:o,width:r,height:a}}function Ha(t,e,n){const{fP:i,fS:o,lineHeight:r,lines:a,width:s}=e,c=r*a.length;return{x:-s/2+((e.angle??-90)>0?-1:1)*(o/4),y:"bottom"===t.schema.orient?n+(s-c)/2+i:n-(s+c)/2-2*i,width:s,height:e.height}}const Ia=[{key:"align",coerce:"identity",default:"middle"},{key:"baseline",coerce:"identity",default:0},{key:"baselineBreak",coerce:"identity",default:!1},{key:"break",coerce:"identity",default:!1},{key:"domain",coerce:"identity",default:[0,10]},{key:"domainTicks",coerce:"identity",default:!0},{key:"duration",coerce:"identity",default:600},{key:"exponent",coerce:"identity",default:1},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"fixedSize",coerce:"identity"},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"rangeBreaks",coerce:"identity",default:!1},{key:"renderMode",coerce:"identity",default:"full"},{key:"reverse",coerce:"identity",default:!1},{key:"rotatedTickFormat",coerce:"identity"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scaleAlign",coerce:"identity",default:.5},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"tickTooltip",coerce:"identity"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"titleTooltip",coerce:"identity"},{key:"width",coerce:"identity",default:400}];class Ga extends Xt{_getDomain(){let t=[];this._d3ScaleNegative&&(t=this._d3ScaleNegative.domain()),this._d3Scale&&(t=t.concat(this._d3Scale.domain())),this._baselineBreak&&(t=t.concat([this._baselineBreak.value]));const e=["band","ordinal","point"].includes(this.schema.scale)?t:d.extent(t);return t[0]>t[1]?e.reverse():e}_givenDomain(t=!1){const e=(t?this._d3ScaleNegative:this._d3Scale).domain();return this.schema.reverse?e.slice().reverse():e}_getPosition(t){if("log"===this.schema.scale){if(0===t)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const e=tr(t)?this._d3ScaleNegative:this._d3Scale;return e?e(t):0}return this._d3Scale?this._d3Scale(t):0}_getRange(){let t=[];return this._d3ScaleNegative&&(t=this._d3ScaleNegative.range()),this._d3Scale&&(t=t.concat(this._d3Scale.range())),this._baselineBreak&&t.push(this._baselineBreak.position),t[0]>t[1]?d.extent(t).reverse():d.extent(t)}_getLabels(){let t=[];if(this._d3ScaleNegative&&(t=t.concat(Wa.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(t=t.concat(Wa.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(t.some(t=>tr(t))&&t.some(t=>t>0)){const e=d.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);t.includes(e)||t.splice(t.findIndex(t=>t>e),0,e),t.includes(-e)&&t.includes(e)&&t.splice(t.indexOf(-e),1)}}return t}_getTicks(){const t="time"===this.schema.scale&&this._d3Scale?Bo(this._scaleData,this._d3Scale):this._scaleData;if(["band","ordinal","point","time"].includes(this.schema.scale)&&t.length&&t.length<this.schema.width/4)return t;let e=[];return this._d3ScaleNegative&&(e=e.concat(Wa.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(e=e.concat(Wa.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&e.includes(-1)&&e.includes(1)&&e.splice(e.indexOf(-1),1),e}toScene(){return function(t){const e=[],n=t._gridLineData??[];(function(t){if(!t._gridLineData||!t._gridLineData.length)return[];const{height:e,x:n,y:i,opposite:o}=t._position,r=t._margin[o],a=["top","left"].includes(t.schema.orient)?t._outerBounds[i]+t._outerBounds[e]-r:t._outerBounds[i]+r,s=["top","left"].includes(t.schema.orient)?r:-r,c="band"===t.schema.scale?t._d3Scale.bandwidth()/2:0,l="x"===n;return(t._gridLineData??[]).map(e=>{const n=t._getPosition(e.id)+c;return{points:[l?[n,a]:[a,n],l?[n,a+s]:[a+s,n]]}})})(t).forEach((i,o)=>{const r=Fr(t,t.schema.gridConfig,n[o],o);e.push({type:"line",key:`grid-${o}`,points:i.points,paint:r})});const i=t._tickShape&&"function"==typeof t._tickShape.toScene?t._tickShape.toScene():null;if(i&&e.push(i),t._tickShape){const n=t._tickShape._labelClass;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){const i=n.toScene();if(i&&Array.isArray(i.children)){const n=i.children;zr(n,t.schema.tickTooltip,Ar(t)),e.push(...n)}}}const o=Nr(t);if(o&&e.push(...lo(t,o.points,e=>Fr(t,e))),t._titleClass&&"function"==typeof t._titleClass.toScene&&t._titleClass._data&&t._titleClass._data.length){const n=t._titleClass.toScene();Dr([n],t.schema.title,t.schema.titleTooltip),e.push(n)}let r;const a=t._select&&"function"==typeof t._select.node?t._select.node():null;if(a&&"function"==typeof a.getAttribute){const t=a.getAttribute("transform");if(t){const e=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);e&&(r={x:Number(e[1]),y:Number(e[2])})}}return{type:"group",key:`Axis-${t._uuid.slice(0,8)}`,...r?{transform:r}:{},children:e}}(this)}render(t){if(void 0===this._select&&"compute"!==this.schema.renderMode)if(this._managesOwnScenePaint){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width",`${this.schema.width}px`),t.setAttribute("height",`${this.schema.height}px`),document.body.appendChild(t),this.select(t)}else{const t=document.createElement("div");document.body.appendChild(t),this.select(t)}const e=br(this),{ticks:n,labels:i}=e,o=this._select,a="compute"===this.schema.renderMode&&(void 0===this._select||null===this._select||"function"==typeof this._select.node&&null===this._select.node())?null:r.elem(`g#d3plus-Axis-${this._uuid}`,{parent:o});this._group=a;const s=(0!==this.schema.gridSize?this.schema.grid||"log"===this.schema.scale&&!this.schema.gridLog?i:n:[]).map(t=>({id:t}));this._gridLineData=s;const c=function(t,e){const{ticks:n,labels:i,textData:o,tickFormat:r,hBuff:a,labelHeight:s}=e,{height:c,x:l,y:h,horizontal:u,opposite:d}=t._position,f=["top","left"].includes(t.schema.orient),m=t.schema.padding,p=t._margin,g=t._outerBounds,y=i.filter((t,e)=>o[e].lines.length&&!n.includes(t)),x=o.some(t=>t.rotate);let b=n.concat(y).map(e=>{const y=o.find(t=>t.d===e),b=t._getPosition(e),k=y?y.space:0,_=y?y.fP:0,v=y&&t.schema.labelOffset?y.offset??0:0,w=u?k:y?.room??g.width-p[t._position.opposite]-a-p[t.schema.orient]+m,M=!u&&y&&"number"==typeof t.schema.fixedSize?Math.max(w,Math.ceil(y.width)+m):w,S=p[d],C=(a+v)*(f?-1:1),$=f?g[h]+g[c]-S:g[h]+S;return{id:e,labelBounds:y?.slant?ja(t,y,Math.abs(C)+(u?_:m)):x&&y?Ha(t,y,C):{x:u?-k/2:"left"===t.schema.orient?-M-m+C:C+m,y:u?"bottom"===t.schema.orient?C+_:C-s-_:-k/2,width:u?k:M,height:u?s:k},rotate:!!y&&y.rotate,angle:y?y.angle:0,cut:!!y?.cut,lineHeight:y?.lineHeight,size:i.includes(e)||"log"===t.schema.scale&&Math.log10(Math.abs(e))%1==0?C:n.includes(e)?Math.ceil(C/2):t._scaleData.find(t=>+t===e)?Math.ceil(C/4):0,text:!(y?.truncated||!i.includes(e))&&r(e),tick:n.includes(e),[l]:b+("band"===t.schema.scale?t._d3Scale.bandwidth()/2:0),[h]:$}});return"Line"===t.schema.shape&&(b=b.concat(b.map(t=>{const e=Object.assign({},t);return e[h]=e[h]+t.size,e}))),b}(this,e);return function(t,e){t._tickShape=(new Ra[t.schema.shape]).renderMode("compute").select(null).data(e).duration(t.schema.duration).labelConfig({ellipsis:Di,truncateWord:t=>!!(void 0!==t.cut?t:t.data)?.cut,...t._labelRotation&&t._labelSlant?{split:xi}:{},rotate:t=>{const e=void 0!==t.rotate?t:t.data;return e?.rotate?Number(e.angle??-90):0}}),t._tickShape.config(te.bind(t)(t.schema.shapeConfig)).labelConfig({lineHeight:(e,n)=>{const i=void 0!==e.lineHeight?e:e.data;return"number"==typeof i?.lineHeight?i.lineHeight:Ln(t.schema.shapeConfig,i?.id,n)},padding:0}).render()}(this,c),function(t,e,n){const{range:i}=e,{horizontal:o}=t._position,a=t._margin,s=t._outerBounds;t._titleClass.renderMode("compute").duration(t.schema.duration).select(n?r.elem("g.d3plus-Axis-title",{parent:n}).node():null).x(o?i[0]:"left"===t.schema.orient?s.x+a.left/2-(i[i.length-1]-i[0])/2:s.x+s.width-a.right/2-(i[i.length-1]-i[0])/2).y(o?"bottom"===t.schema.orient?s.y+s.height-a.bottom:s.y:i[0]+(i[i.length-1]-i[0])/2-a[t.schema.orient]/2),ni(t._titleClass,t,i,a[t.schema.orient]).render()}(this,e,a),this._lastScale=this._getPosition.bind(this),"compute"===this.schema.renderMode||this._managesOwnScenePaint||ne(this),t&&setTimeout(t,this.schema.duration+100),this}barConfig(t){return arguments.length?(this.schema.barConfig=ht(this,"barConfig",t),this):this.schema.barConfig}breakConfig(t){return arguments.length?(this.schema.breakConfig=ht(this,"breakConfig",t),this):this.schema.breakConfig}baselineBreakConfig(t){return arguments.length?(this.schema.baselineBreakConfig=ht(this,"baselineBreakConfig",t),this):this.schema.baselineBreakConfig}data(t){return arguments.length?(this._data=t,this):this._data}gridConfig(t){return arguments.length?(this.schema.gridConfig=ht(this,"gridConfig",t),this):this.schema.gridConfig}labelRotation(t){return arguments.length?(this._labelRotationSetting=t,this):this._labelRotationSetting}orient(t){if(arguments.length){const e=["top","bottom"].includes(t),n={top:"bottom",right:"left",bottom:"top",left:"right"};return this._position={horizontal:e,width:e?"width":"height",height:e?"height":"width",x:e?"x":"y",y:e?"y":"x",opposite:n[t]},this.schema.orient=t,this}return this.schema.orient}outerBounds(){return this._outerBounds}measure(){return br(this),this}select(t){return arguments.length?(this._select=null==t?void 0:o.select(t),this):this._select}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ht(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ht(this,"titleConfig",t),this):this.schema.titleConfig}constructor(){super(),this._scaleData=[],this._labelAngle=0,this._labelSlant=!1,this._labelOverflow=[0,0],this._softMaxSize=!1,this._thinForLines=!1,this._dropTitle=!1,this._d3Scale=null,this._d3ScaleNegative=null,this._domainEndFirst=!1,this._baselineBreak=null,this._breaks=[],kt(this,Ia),this._data=[],this._labelRotation=!1,this._labelRotationSetting=void 0,this.schema.barConfig={stroke:Ai(this),"stroke-width":1},this.schema.baselineBreakConfig=zi(this),this.schema.breakConfig=zi(this),this.schema.gridConfig=function(t){return{stroke:()=>Mi(t),"stroke-width":1}}(this),this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig=function(t){return{fill:Ai(t),height:t=>t.tick?8:0,label:t=>t.text,labelBounds:t=>t.labelBounds,labelConfig:{fontColor:Ai(t),fontResize:!1,fontSize:W(12),padding:5,textAnchor:()=>{if(t._labelRotation&&t._labelSlant)return ui(t.schema.orient,t._labelAngle);const e=r.rtl();return"left"===t.schema.orient?e?"start":"end":"right"===t.schema.orient?e?"end":"start":t._labelRotation?ui(t.schema.orient,t._labelAngle):"middle"},verticalAlign:()=>"bottom"===t.schema.orient?"top":"top"===t.schema.orient?t._labelRotation?"top":"bottom":"middle"},r:t=>t.tick?4:0,stroke:Ai(t),strokeWidth:1,width:t=>t.tick?8:0}}(this),this._tickUnit=0,this._titleClass=new ei,this.schema.titleConfig=function(t){return{fontColor:Ai(t),fontSize:12,textAnchor:"middle"}}(this),this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}Ga._displayName="Axis",dt(Ga.prototype,"barConfig","breakConfig","baselineBreakConfig","gridConfig","shapeConfig","titleConfig");class qa extends Ga{constructor(){super(),this.orient("bottom")}}qa._displayName="AxisBottom";class Va extends Ga{constructor(){super(),this.orient("left")}}Va._displayName="AxisLeft";class Ka extends Ga{constructor(){super(),this.orient("right")}}Ka._displayName="AxisRight";class Ya extends Ga{constructor(){super(),this.orient("top")}}Ya._displayName="AxisTop";const Ua=new WeakMap;function Xa(t){const e=t._lineData,{align:n,direction:i,padding:o}=t.schema,r=t._outerBounds,a=[e,t._data,r.x,r.y,r.width,t._titleHeight,t._rtl,n,i,o],s=Ua.get(t);if(s&&s.deps.every((t,e)=>t===a[e]))return s;const c=new Map;e.forEach(t=>{const e=c.get(t.y);e?e.push(t):c.set(t.y,[t])});const l=new Map,h=new Map;c.forEach((e,n)=>{l.set(n,t._rowWidth(e)),h.set(n,d.max(e.map(t=>t.height)))});const u=d.max(t._data.map((e,n)=>t._fetchConfig("height",e,n))),f=new Map,m=[],p=[];e.forEach(e=>{const a=e.y,s=l.get(a),c="left"===n||"right"===n&&"column"===i?0:"center"===n?(r.width-s)/2:r.width-s,g=f.get(a)||{widths:0,pads:0,last:0,count:0},y=g.count?g.widths+o*(g.pads-g.last):0,x=t._rtl?e.width+o:0;m.push(y+o*(g.count?e.sentence?2:1:0)+r.x+e.shapeWidth/2+c+x),p.push(a+t._titleHeight+r.y+d.max([h.get(a),u])/2);const b=e.width?2:1;f.set(a,{widths:g.widths+e.shapeWidth+e.width,pads:g.pads+b,last:b,count:g.count+1})});const g={deps:a,x:m,y:p};return Ua.set(t,g),g}function Qa(t,e,n,i=1){const o=t._lineData,r=t.schema.padding,a=d.max(o,t=>t.shapeWidth)??0,s=o.length;if("column"===t.schema.direction)return{width:e-a-2*r-1,height:Math.floor((n-r)/s-r)};const c=Math.ceil(s/i);return{width:Math.floor((e-1)/c)-a-2*r,height:Math.floor((n-r)/i-r)}}function Za(t,e){const n=t.lh+1,i=Math.floor(e.height/n);if(e.width<24||i<1)return null;const o=s.textWrap().fontFamily(t.f).fontSize(t.s).lineHeight(t.lh).width(e.width).height(i*n)(t.sentence),r=o.truncated;return r&&!o.lines.length?null:{cut:r,shown:r?o.lines.join("").length:`${t.sentence}`.length,width:r?e.width:Math.min(e.width,Math.ceil(d.max(o.widths)??0)+10),height:(r?i:o.lines.length)*n}}function Ja(t,e,n){const i=t._lineData,o=i.filter(t=>t.sentence);if(!o.length)return!1;const r="column"===t.schema.direction?[1]:Array.from({length:i.length},(t,e)=>e+1),a=d.max(i,t=>t.shapeHeight)??0,c=t.schema.padding;let l;for(const i of r){const r=Qa(t,e,n,i),s=o.map(t=>Za(t,r));if(s.some(t=>!t))continue;const h=s,u=h.filter(t=>t.cut).length,d=h.reduce((t,e)=>t+e.shown,0),f=i*(Math.max(a,...h.map(t=>t.height))+c)+c;(!l||u<l.cut||u===l.cut&&(d>l.shown||d===l.shown&&f<l.height))&&(l={fits:h,cut:u,shown:d,height:f})}return!!l&&(o.forEach((e,n)=>{const i=l.fits[n];e.cut=i.cut,e.width=i.width,e.height=i.height,e.lines=function(t,e){const n=t.schema.shapeConfig.labelConfig??{},i=e.s,o="function"==typeof n.ellipsis?n.ellipsis:Jn;var r,a;const c=s.textWrap().fontFamily(e.f).fontSize(i).lineHeight((r=n.lineHeight,a=1.2*i,void 0===r?a:"function"==typeof r?r(e.data,e.i):r)).width(e.width).height(Math.max(e.height,e.shapeHeight)).ellipsis(o)(e.sentence).lines.filter(t=>""!==t);return c.length?c:[o("",0)]}(t,e)}),!0)}function ts(t){return t.width+t.shapeWidth}function es(t,e,n){const i={lines:1,newRows:[],maxLines:d.max(t._lineData.map(t=>t.words.length))};t._wrapLines=()=>function(t,e,n,i){if(e.lines++,e.lines>e.maxLines)return;const o=1===e.lines?t._lineData.slice():t._lineData.filter(t=>ts(t)>n&&t.words.length>=e.lines).sort((t,e)=>e.sentence.length-t.sentence.length);if(o.length&&i>o[0].height*e.lines){let n=!1;for(let t=0;t<o.length;t++){const i=o[t],a=i.og,c=a.height*e.lines,l=a.width*(1/e.lines*1.5),h=s.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(l).height(c)(i.sentence);if(h.truncated){n=!0;break}i.lines=h.lines,i.width=Math.ceil(d.max(h.lines.map(t=>r.textWidth(t,{"font-family":i.f,"font-size":i.s}))))+10,i.height=h.lines.length*(i.lh+1)}n||t._wrapRows()}else e.newRows=[]}(t,i,e,n),t._wrapRows=()=>function(t,e,n,i){e.newRows=[];let o=1,r=0;for(let a=0;a<t._lineData.length;a++){const s=t._lineData[a],c=ts(s)+t.schema.padding*(s.width?2:1);if(d.sum(e.newRows.map(t=>d.max(t,t=>d.max([t.height,t.shapeHeight]))))>i){e.newRows=[];break}if(ts(s)>n){e.newRows=[],t._wrapLines();break}r+ts(s)<=n?r+=c:"column"!==t.schema.direction&&(r=c,o++),e.newRows[o-1]||(e.newRows[o-1]=[]),e.newRows[o-1].push(s),"column"===t.schema.direction&&(r=0,o++)}}(t,i,e,n);const o=()=>!i.newRows.length||d.sum(i.newRows,t._rowHeight.bind(t))+t.schema.padding>n;if(t._wrapRows(),o()&&(!t._cutLabels||!Ja(t,e,n)||(t._wrapRows(),o()))){for(let e=0;e<t._lineData.length;e++)t._lineData[e].width=0,t._lineData[e].height=0,t._lineData[e].cut=!1;t._wrapRows()}return!o()&&(i.newRows.forEach((e,n)=>{e.forEach(e=>{n&&(e.y=d.sum(i.newRows.slice(0,n),t._rowHeight.bind(t)))})}),d.max(i.newRows,t._rowWidth.bind(t)))}const ns=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:H("id")},{key:"label",coerce:"const",default:H("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:W("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class is extends Xt{_fetchConfig(t,e,n){const i=this.schema.shapeConfig.labelConfig;if("lineHeight"===t)return Ln(this.schema.shapeConfig,e,n,this._fetchConfig("fontSize",e,n));const o=void 0!==this.schema.shapeConfig[t]?this.schema.shapeConfig[t]:i?.[t];return"function"==typeof o?o(e,n):o}_rowHeight(t){return d.max(t.map(t=>t.height).concat(t.map(t=>t.shapeHeight)))+this.schema.padding}_rowWidth(t){return d.sum(t.map((e,n)=>{const i=this.schema.padding*(n===t.length-1?0:e.width?2:1);return e.shapeWidth+e.width+i}))}toScene(){const t=[];let e;this._titleClass&&"function"==typeof this._titleClass.toScene&&this._titleClass._data&&this._titleClass._data.length&&t.push(this._titleClass.toScene()),(this._shapes||[]).forEach(e=>{const n=e;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){t.push(n.toScene());const e=n._labelClass;if(e&&"function"==typeof e.toScene&&e._data&&e._data.length){const n=e.toScene();n&&Array.isArray(n.children)&&t.push(...n.children)}}});const n=this._select&&"function"==typeof this._select.node?this._select.node():null;if(n&&"function"==typeof n.getAttribute){const t=n.getAttribute("transform");if(t){const n=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);n&&(e={x:Number(n[1]),y:Number(n[2])})}}return{type:"group",key:`Legend-${this._uuid.slice(0,8)}`,...e?{transform:e}:{},children:t}}render(t){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(o.select("body").append("div").node()),this._group=r.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=r.elem("g.d3plus-Legend-title",{parent:this._group}),this._shapeGroup=r.elem("g.d3plus-Legend-shape",{parent:this._group}),function(t){if(t._titleHeight=0,t._titleWidth=0,t.schema.title){const e=t.schema.titleConfig.fontFamily||t._titleClass.fontFamily()(),n=t.schema.titleConfig.fontSize||t._titleClass.fontSize()(),i=Ln(t.schema.titleConfig,{text:t.schema.title},0,n),o=s.textWrap().fontFamily(e).fontSize(n).lineHeight(i).width(t.schema.width-2*t.schema.padding).height(t.schema.height)(t.schema.title);if(o.truncated||!o.lines.length)return;t._titleHeight=o.lines.length*(i+1)+t.schema.padding,t._titleWidth=d.max(o.widths)}}(this);const e=this.schema.height-this._titleHeight;this._lineData=function(t,e){return t._data.map((n,i)=>{const o=t.schema.label(n,i),a=t.schema.shape(n,i),c=t._fetchConfig("r",n,i),l=t._fetchConfig("height",n,i);let h={data:n,i:i,id:t.schema.id(n,i),shape:a,shapeR:c,shapeWidth:"Circle"===a?2*c:"Line"===a?l:t._fetchConfig("width",n,i),shapeHeight:"Circle"===a?2*c:l,y:0};if(!o)return h.sentence=!1,h.words=[],h.height=0,h.width=0,h;const u=t._fetchConfig("fontFamily",n,i),f=t._fetchConfig("lineHeight",n,i),m=t._fetchConfig("fontSize",n,i),p=e-(t._data.length+1)*t.schema.padding,g=t.schema.width,y=s.textWrap().fontFamily(u).fontSize(m).lineHeight(f).width(g).height(p)(o);return h=Object.assign(h,y),h.width=h.lines.length?Math.ceil(d.max(h.lines.map(t=>r.textWidth(t,{"font-family":u,"font-size":m}))))+10:0,h.height=Math.ceil(h.lines.length*(f+1)),h.og={height:h.height,width:h.width},h.f=u,h.s=m,h.lh=f,h})}(this,e);let n=this._rowWidth(this._lineData);const i=this.schema.width-2*this.schema.padding,a=n<=i&&(!this._lineData.length||this._rowHeight(this._lineData)+this.schema.padding<=e);var c;return"column"!==this.schema.direction&&a||(n=es(this,i,e)),!1===n?((c=this)._titleClass.data([]),c._shapes=[],Object.assign(c._outerBounds,{width:0,height:0,x:0,y:0})):(function(t,e){const n=d.max(t._lineData,(e,n)=>d.max([e.height,t._fetchConfig("height",e.data,n)])+e.y)+t._titleHeight,i=d.max([e,t._titleWidth]);t._outerBounds.width=i,t._outerBounds.height=n;let o=t.schema.padding,r=t.schema.padding;"center"===t.schema.align?o=(t.schema.width-i)/2:"right"===t.schema.align&&(o=t.schema.width-t.schema.padding-i),"middle"===t.schema.verticalAlign?r=(t.schema.height-n)/2:"bottom"===t.schema.verticalAlign&&(r=t.schema.height-t.schema.padding-n),t._outerBounds.x=o,t._outerBounds.y=r}(this,n),function(t){t._titleClass.renderMode("compute").data(t._titleHeight?[{text:t.schema.title}]:[]).duration(t.schema.duration).select(t._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[t.schema.align]).width(t.schema.width-2*t.schema.padding).x(t.schema.padding).y(t._outerBounds.y).config(t.schema.titleConfig).render()}(this),function(t){t._shapes=[];const e=te.bind(t)(t.schema.shapeConfig,"legend"),n={id:t=>t.id,label:t=>t.label},i=t._data.map((e,n)=>({__d3plus__:!0,data:e,i:n,id:t.schema.id(e,n),label:!!t._lineData[n].width&&t.schema.label(e,n),shape:t.schema.shape(e,n)}));t._shapes=[],["Circle","Rect"].forEach(o=>{t._shapes.push((new Ra[o]).renderMode("compute").parent(t).data(i.filter(t=>t.shape===o||"Line"===t.shape)).duration(t.schema.duration).labelConfig({padding:0}).select(t._shapeGroup.node()).verticalAlign("top").config(e).config(n).config(function(t,e){const n=t=>"Line"===t.shape,i=(e,n)=>t._fetchConfig(e,n.data,n.i),o=e=>t._lineData[e.i];return"Rect"===e?{width:t=>n(t)?o(t).shapeWidth:i("width",t),height:t=>n(t)?2:i("height",t)}:{r:t=>n(t)?.3*o(t).shapeHeight:i("r",t),label:t=>!n(t)&&t.label,hitArea:t=>n(t)?null:i("hitArea",t)}}(t,o)).render())})}(this)),"compute"!==this.schema.renderMode&&ne(this),t&&setTimeout(t,this.schema.duration+100),this}active(t){return this._shapes.forEach(e=>e.active(t)),this}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return this._shapes.forEach(e=>e.hover(t)),this}outerBounds(){return this._outerBounds}select(t){return arguments.length?(this._select=o.select(t),this._rtl=r.rtl(),this):this._select}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ht(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ht(this,"titleConfig",t),this):this.schema.titleConfig}constructor(){var t;super(),this._cutLabels=!1,kt(this,ns),this._titleClass=new ei,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(t=this,{fill:H("color"),height:W(12),hitArea:(e,n)=>{const i=t._lineData[n],o=d.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:o,x:-i.shapeWidth/2,y:-o/2}},labelBounds:(e,n)=>{const i=t._lineData[n],o=i.shapeWidth/2,r=d.max([i.shapeHeight,i.height]),a=t._rtl?i.shapeWidth+i.width+2*t.schema.padding:0;return{width:i.width,height:r,x:o+5-a,y:-r/2}},labelConfig:{fontColor:()=>vi(t),fontFamily:t._titleClass.fontFamily(),fontResize:!1,fontSize:W(10),pointerEvents:W("none"),textAnchor:"start",verticalAlign:"middle"},opacity:1,r:W(6),width:W(12),x:(e,n)=>Xa(t).x[n],y:(e,n)=>Xa(t).y[n]}),this.schema.titleConfig={fontColor:()=>vi(this),fontSize:12},this._rtl=!1,this._titleHeight=0,this._titleWidth=0}}function os(t){const[e,n]=t.toExponential(14).split("e"),i=e.split(".")[1].replace(/0+$/,"");return Math.max(0,i.length-Number(n))}is._displayName="Legend",dt(is.prototype,"shapeConfig","titleConfig");const rs=(t,e)=>+(t*10**e).toPrecision(15),as=(t,e)=>+(t/10**e).toPrecision(15)||0;function ss(t){const e=t.filter(Number.isFinite);if(!e.length)return 0;const n=d.max(e)-Math.min(...e)||Math.abs(e[0]),i=e.map(t=>Math.abs(t)<1e-9*n?0:t),o=i.filter(t=>function(t){return t.toExponential(14).split("e")[0].replace(/[-.]/g,"").replace(/0+$/,"").length||1}(t)<12),r=d.max(o.map(os))??0;if(o.length===i.length)return r;const a=n?Math.max(0,2-Math.floor(Math.log10(n))):0;return Math.max(r,a)}const cs=["buckets","jenks","linear","log","quantile"],ls=t=>"buckets"===t||"jenks"===t||"quantile"===t;const hs=t=>t.schema.colorMin??J(t._theme,"min",t.schema.colorDefaults.off),us=t=>t.schema.colorMid??J(t._theme,"mid",t.schema.colorDefaults.light),ds=t=>t.schema.colorMax??J(t._theme,"max",t.schema.colorDefaults.sequential),fs=(t,e,n)=>tt(t._theme,e,n,Boolean(t.schema.ordinalRamp)&&!t._theme?.dark),ms=(t,n,i)=>t._theme?.dark?k.interpolateRgb.gamma(2.2)(n,us(t))(i):e.colorLighter(n,i);function ps(t,e){const{scale:n}=e;let i=t.schema.buckets instanceof Array?t.schema.buckets:void 0;const o=e.diverging&&!e.colors?function(t,e,n){const{domain:i,numBuckets:o}=e,r=Math.floor(o/2),a=k.interpolateRgb.gamma(2.2)(hs(t),us(t)),s=d.range(0,r,1).map(t=>a(t/r)),c=(o%2?[0]:[]).map(()=>us(t)),l=k.interpolateRgb.gamma(2.2)(ds(t),us(t)),h=d.range(0,r,1).map(t=>l(t/r)).reverse(),u=s.concat(c).concat(h);if(!n){const e=(u.length-1)/2;n=d.range(i[0],t.schema.midpoint,-(i[0]-t.schema.midpoint)/e).concat(d.range(t.schema.midpoint,i[1],(i[1]-t.schema.midpoint)/e)).concat([i[1]])}return{colors:u,buckets:n}}(t,e,i):function(t,e,n){const{allValues:i,domain:o,negative:r,positive:a,diverging:s,numBuckets:c,scale:l}=e;let{colors:h}=e;if(!h){const e=r?hs(t):ds(t);if("buckets"===l||"quantile"===l){const n=fs(t,e,c);h=a?n:n.slice().reverse()}else{const n=fs(t,e,2);h=r?n.slice().reverse():n}}if(!n)if("quantile"===l){const t=1/(h.length-1);n=d.range(0,1+t/2,t).map(t=>d.quantile(i,t))}else if(s&&t.schema.color&&t.schema.centered){const e=h.indexOf(us(t)),i=(t.schema.midpoint-o[0])/e,r=(o[1]-t.schema.midpoint)/(h.length-e),a=d.range(o[0],t.schema.midpoint,i),s=d.range(t.schema.midpoint,o[1]+r/2,r);n=a.concat(s)}else{const t=(o[1]-o[0])/(h.length-1);n=d.range(o[0],o[1]+t/2,t)}return{colors:h,buckets:n}}(t,e,i);let r,{colors:a}=o;if(i=o.buckets,"buckets"===n||"quantile"===n)r=i,a=[a[0]].concat(a);else if("log"===n){const t=i.filter(t=>t<0);if(t.length){const e=t[0],n=t.map(t=>-Math.pow(Math.abs(e),t/e));t.forEach((t,e)=>{i[i.indexOf(t)]=n[e]})}const e=i.filter(t=>t>0);if(e.length){const t=e[e.length-1],n=e.map(e=>Math.pow(t,e/t));e.forEach((t,e)=>{i[i.indexOf(t)]=n[e]})}i.includes(0)&&(i[i.indexOf(0)]=1)}const s="buckets"===n||"quantile"===n?c.scaleThreshold:c.scaleLinear;return t._colorScale=s().domain(i).range(a),{colors:a,ticks:r,labels:void 0}}function gs(t){const e=["bottom","top"].includes(t.schema.orient),i=e?"height":"width",o=e?"width":"height",r=e?"x":"y",a=e?"y":"x",s=t._data.map(t.schema.value).filter(t=>"number"==typeof t&&!Number.isNaN(t)).sort((t,e)=>t-e),l=function(t,e,n){const i=e.length?[e[0],e[e.length-1]]:[void 0,void 0],o="function"==typeof t?t.call(n,e.slice(),i):t;return cs.includes(o)?o:(Rt(`ColorScale received unknown scale ${JSON.stringify(o)??String(o)}; using "linear". Use one of ${cs.map(t=>`"${t}"`).join(", ")}, or a function returning one.`),"linear")}(t.schema.scale,s,t);t._scaleType=l;const h=t.schema.domain||d.extent(s),f=h[0]<t.schema.midpoint,m=h[1]>t.schema.midpoint,p=f&&m,g=d.min([t.schema.buckets instanceof Array?t.schema.buckets.length:t.schema.buckets,p&&"jenks"!==l?2*Math.floor(n.unique(s).length/2)-1:n.unique(s).length]);let y=p&&(!t.schema.color||t.schema.color instanceof Array&&!t.schema.color.includes(us(t)))?void 0:t.schema.color;!y||y instanceof Array||(y=fs(t,y,g));const x={scale:l,allValues:s,domain:h,negative:f,positive:m,diverging:p,numBuckets:g,colors:y},b="jenks"===l?function(t,e){const{allValues:n,diverging:i,numBuckets:o}=e;let r,a,{colors:s}=e;const l=d.min([s?s.length:o,o,n.length]);let h;if(t.schema.buckets instanceof Array)r=t.schema.buckets;else{if(i&&t.schema.centered){const e=Math.floor(l/2),i=l%2,o=n.filter(e=>e<t.schema.midpoint),r=d.deviation(o),a=n.concat(t.schema.midpoint).filter(e=>e>=t.schema.midpoint),s=d.deviation(a),c=r>s?1:0,f=s>r?1:0,m=u.ckmeans(o,d.min([e+i*c,o.length])),p=u.ckmeans(a,d.min([e+i*f,a.length]));h=m.concat(p)}else h=u.ckmeans(n,l);r=h.map(t=>t[0])}const f=new Set(r);if(r.length!==f.size&&(a=Array.from(f)),!s)if(i){const e=[hs(t),us(t),ds(t)],n=r.slice(0,l).filter((e,n)=>e<t.schema.midpoint&&r[n+1]<=t.schema.midpoint),i=r.slice(0,l).filter((e,n)=>e<=t.schema.midpoint&&r[n+1]>t.schema.midpoint),o=r.slice(0,l).filter(e=>e>t.schema.midpoint),a=n.map((i,o)=>o?ms(t,e[0],o/n.length):e[0]),c=i.map(()=>e[1]),h=o.map((n,i)=>i===o.length-1?e[2]:ms(t,e[2],1-(i+1)/o.length));s=a.concat(c).concat(h)}else s=fs(t,ds(t),o);return r.length<=l&&(s=s.slice(-r.length)),s=[s[0]].concat(s),t._colorScale=c.scaleThreshold().domain(r).range(s),{colors:s,ticks:r,labels:a}}(t,x):ps(t,x);return t._colorScale.clamp&&t._colorScale.clamp(!0),{scale:l,allValues:s,domain:h,ticks:b.ticks,labels:b.labels,colors:b.colors,horizontal:e,height:i,width:o,x:r,y:a}}const ys=["shapeConfig","titleConfig"],xs=new WeakMap;function bs(t,e,n){const i={x:0,y:0},{axisConfig:o,labelConfig:s,axisDomain:l,labelData:h}=function(t,e,n){const{horizontal:i,height:o,width:a,domain:s,labels:c,ticks:l}=e,h=s.slice();if(t.schema.bucketAxis){const t=h[h.length-1],e=h[h.length-2],n=t?t/10:e/10,i=n>=1||n<=-1?Math.round(n).toString().length-1:-1*n.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,o=Math.pow(10,i);h[h.length-1]=t+o}const u=r.assign({domain:i?h:h.slice().reverse(),duration:t.schema.duration,height:t.schema.height,labels:c||l,orient:t.schema.orient,padding:t.schema.padding,scale:"log"===e.scale?"log":"linear",ticks:l,width:t.schema.width},t.schema.axisConfig),d=r.assign({height:t.schema[o]/2,width:t.schema[a]/2},t.schema.labelConfig);t._labelClass.config(d);const f=[];if(i&&t._labelMin){const e={"font-family":t._labelClass.fontFamily()(t._labelMin),"font-size":t._labelClass.fontSize()(t._labelMin),"font-weight":t._labelClass.fontWeight()(t._labelMin)};e["font-family"]instanceof Array&&(e["font-family"]=e["font-family"][0]);let o=r.textWidth(t._labelMin,e);o&&o<t.schema[a]/2&&(f.push(t._labelMin),o+=t.schema.padding,i&&(n.x+=o),u[a]=u[a]-o)}if(i&&t._labelMax){const e={"font-family":t._labelClass.fontFamily()(t._labelMax),"font-size":t._labelClass.fontSize()(t._labelMax),"font-weight":t._labelClass.fontWeight()(t._labelMax)};e["font-family"]instanceof Array&&(e["font-family"]=e["font-family"][0]);let o=r.textWidth(t._labelMax,e);o&&o<t.schema[a]/2&&(f.push(t._labelMax),o+=t.schema.padding,i||(n.y+=o),u[a]=u[a]-o)}return{axisConfig:u,labelConfig:d,axisDomain:h,labelData:f}}(t,e,i),{axisBounds:u,axisScale:d,scaleRange:f}=function(t,e,n,i,o){const{horizontal:a,height:s,width:c,x:l,y:h}=e;t._axisTest._thinForLines=t._axisClass._thinForLines=!!t.schema.bucketAxis,t._axisTest.renderMode("compute").select(r.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:t._group}).node()).config(i).duration(0).render();const u=t._axisTest.outerBounds();t._outerBounds[c]=t.schema[c]-2*t.schema.padding,t._outerBounds[s]=u[s]+t.schema.size,t._outerBounds[l]=t.schema.padding,t._outerBounds[h]=t.schema.padding,"middle"===t.schema.align?t._outerBounds[h]=(t.schema[s]-t._outerBounds[s])/2:"end"===t.schema.align&&(t._outerBounds[h]=t.schema[s]-t.schema.padding-t._outerBounds[s]);const d=t._outerBounds[h]+(["bottom","right"].includes(t.schema.orient)?t.schema.size:0)-(i.padding||t._axisClass.padding()),f=`translate(${o.x+(a?0:d)}, ${o.y+(a?d:0)})`;return t._axisClass.renderMode("compute").select(r.elem("g.d3plus-ColorScale-axis",r.assign(n.groupParams,{condition:!0,enter:{transform:f},update:{transform:f}})).node()).config(i).align("start").render(),{axisBounds:u,axisScale:t._axisTest._getPosition.bind(t._axisTest),scaleRange:t._axisTest._getRange()}}(t,e,n,o,i);!function(t,e,n,i){const{horizontal:o,colors:r}=e,s=t._colorScale.domain(),l=c.scaleLinear().domain(i).range(o?[0,100]:[100,0]),h=r.map((t,e)=>({offset:(e<=s.length-1?l(n(s[e])):100)/100,color:String(t)})).sort((t,e)=>t.offset-e.offset),u={type:"linear",from:o?[0,0]:[0,1],to:o?[1,0]:[0,0],stops:h};t._gradientFill=a.gradientToken(u)}(t,e,d,f);const m=function(t,e,n,i){const{height:o,width:a,x:s,y:c,ticks:l}=e,{axisScale:h,scaleRange:u,axisDomain:d,axisBounds:f,offsets:m}=i,p=(t,e)=>{const n=l[e+1]||d[d.length-1];return Math.abs(h(n)-h(t))},g=r.assign({duration:t.schema.duration,fill:l?e=>t._colorScale(e):t._gradientFill,[s]:l?(e,n)=>h(e)+p(e,n)/2-(["left","right"].includes(t.schema.orient)?p(e,n):0):u[0]+(u[1]-u[0])/2+m[s],[c]:t._outerBounds[c]+(["top","left"].includes(t.schema.orient)?f[o]:0)+t.schema.size/2+m[c],[a]:l?p:u[1]-u[0],[o]:t.schema.size},t.schema.rectConfig),y=t._outerBounds[c]+(["top","left"].includes(t.schema.orient)?f[o]:0)+m[c];return t._barGeometry={orient:t.schema.orient,position:t=>h(t)+m[s],range:[u[0]+m[s],u[1]+m[s]],cross:[y,y+t.schema.size],domain:[d[0],d[d.length-1]],...l?{ticks:l}:{}},t._rectClass.renderMode("compute").data(l||[0]).id((t,e)=>e).select(n.rectGroup.node()).config(g).render(),g}(t,e,n,{axisScale:d,scaleRange:f,axisDomain:l,axisBounds:u,offsets:i});!function(t,e,n,i,o,r){const{horizontal:a,height:s,width:c}=e;i.height=t._outerBounds[s],i.width=t._outerBounds[c],t._labelClass.renderMode("compute"),t._labelClass.config(i).data(r).select(n.labelGroup.node()).x(e=>e===t._labelMax?o.x+o.width/2+t.schema.padding:t._outerBounds.x).y(e=>o.y-t._labelClass.fontSize()(e)/2).text(t=>t).rotate(a?0:"right"===t.schema.orient?90:-90).render()}(t,e,n,s,m,h)}const ks=t=>"bottom"===t||"top"===t;function _s(t,[e,n]){const i=Math.min(e,n),o=Math.max(e,n);return Math.min(o,Math.max(i,t))}function vs(t,e){if("number"!=typeof e||!Number.isFinite(e))return null;const n=t.position(_s(e,t.domain));return Number.isFinite(n)?_s(n,t.range):null}function ws(t,e,n,i){return"bottom"===t?[[e,n[1]],[e,n[1]+i]]:"top"===t?[[e,n[0]],[e,n[0]-i]]:"right"===t?[[n[1],e],[n[1]+i,e]]:[[n[0],e],[n[0]-i,e]]}function Ms(t,e){return"function"==typeof t?t(e):t}function Ss(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",t}function Cs(t){const e=Ms(t.config.tickConfig?.length,t.value),n=t.cs._axisClass.schema.tickSize;return"number"==typeof e?e:"number"==typeof n?n:8}function $s(t,e,n,i){const o=t.config.tickConfig||{};return Ss({type:"line",key:`${t.key}-tick`,points:ws(e,n,i,Cs(t)),paint:{fill:"none",stroke:Ms(o.stroke,t.value)??t.tickPaint.stroke??t.ink,strokeWidth:Ms(o.strokeWidth,t.value)??t.tickPaint.strokeWidth??1}})}function As(t,n,i,o){const{cs:a,value:s}=t,c=t.config.badgeConfig||{},l=Ms(c.fontSize,s)??11,h=Ms(c.fontFamily,s)||`${a._labelClass.fontFamily()(o)}`,u=Ms(c.fontWeight,s)??400,d=Ms(c.padding,s)??3,f=Ms(c.fill,s)??t.color,m=Ms(c.fontColor,s)??e.colorContrast(f,a.schema.colorDefaults),p=r.textWidth(o,{"font-family":h,"font-size":l,"font-weight":u}),g=ks(n.orient)?a.schema.width:a.schema.height,y=Cs(t),x=a._axisClass.schema,b=("number"==typeof x.tickSize?x.tickSize:8)+("number"==typeof x.padding?x.padding:0),k=Math.max(d,b-y),_=function(t,e,n,i,o,r){const{width:a,height:s}=i;if(ks(t))return{x:_s(e-a/2,[0,Math.max(0,o-a)]),y:"bottom"===t?n[1]+r:n[0]-r-s,width:a,height:s};const c=_s(e-s/2,[0,Math.max(0,o-s)]);return{x:"right"===t?n[1]+r:n[0]-r-a,y:c,width:a,height:s}}(n.orient,i,n.cross,ks(n.orient)?{width:p+2*d,height:l+2*k}:{width:p+2*k,height:l+2*d},g,y),v=`${t.key}-badge`;return Ss({type:"group",key:v,children:[Ss({type:"rect",key:`${v}-box`,..._,rx:Ms(c.rx,s)??0,paint:{fill:f,stroke:Ms(c.stroke,s)??t.ink,strokeWidth:Ms(c.strokeWidth,s)??1}}),Ss({type:"text",key:`${v}-text`,x:0,y:0,transform:{x:_.x+_.width/2,y:_.y+_.height/2},lines:[{text:o,x:0,y:0,width:p}],font:{family:h,size:l,weight:u,anchor:"middle",baseline:"middle"},paint:{fill:m}})]})}function zs(t,e){if(!e.ticks)return[];const n=function(t,e,n){let i=-1;return t.forEach((t,n)=>{e>=t&&(i=n)}),i<0?t.length?[t[0],t[1]??n]:null:[t[i],t[i+1]??n]}(e.ticks,t.value,e.domain[1]);if(!n)return[];const[i,o]=n.map(t=>vs(e,t));if(null===i||null===o)return[];const r=t.config.outlineConfig||{},a=Math.min(i,o),s=Math.abs(o-i),[c,l]=e.cross,h=ks(e.orient)?{x:a,y:c,width:s,height:l-c}:{x:c,y:a,width:l-c,height:s};return[Ss({type:"rect",key:`${t.key}-outline`,...h,paint:{fill:"none",stroke:Ms(r.stroke,t.value)??t.ink,strokeWidth:Ms(r.strokeWidth,t.value)??2}})]}function Ds(t){let e;const n=(t,i)=>{if(e)return;const o=i||String(t.key).startsWith("Axis-");"group"===t.type?t.children.forEach(t=>n(t,o)):o&&"path"===t.type&&!String(t.key).endsWith("::hit")&&(e={stroke:t.paint?.stroke,strokeWidth:t.paint?.strokeWidth})};return t.children.forEach(t=>n(t,!1)),e??{}}function Ls(t,e){const n=t._hoverValue,i=t._barGeometry;if(!1===t.schema.hoverMark||"number"!=typeof n||!Number.isFinite(n)||!t._colorScale||!i)return;const o=vi(t),r={cs:t,key:`${e.key}-hover`,value:n,color:String(t._colorScale(n)),ink:o,config:t.schema.hoverMarkConfig||{},tickPaint:Ds(e)};e.children.push(...function(t,e){const n=vs(e,t.value);if(null===n)return[];const i=function(t,e){const n=t._axisClass._labelFormat??t.schema.axisConfig.tickFormat;return`${(n?n(e):`${e}`)??""}`.replace(/<[^>]*>/g,"").trim()}(t.cs,t.value);return[...zs(t,e),$s(t,e.orient,n,e.cross),...i?[As(t,e,n,i)]:[]]}(r,i))}const Fs=t=>t.datum?.data?.data;const Ns=t=>"group"===t.type?{...t,children:t.children.map(Ns)}:{...t};function Bs(t,e){const n=Ns(t),i=new Set,o=[],r=t=>{if("group"===t.type)t.children.forEach(r);else{if("text"!==t.type)return;void 0!==e.titleDatum&&t.datum===e.titleDatum?i.add(t):e.buckets.has(Fs(t))&&o.push(t)}};r(n),Dr([...i],e.title,e.titleTooltip),function(t,e,n){if(!1!==e)for(const i of t){const t=n.get(Fs(i));if("text"!==i.type||!t)continue;const o=i.datum.data,r=`${o?.label??o?.id??""}`,a=vr(i,r);wr(e,a)&&(i.axisTooltip={part:"tick",value:t.value,index:t.index,text:r,truncated:a,option:e})}}(o,e.tickTooltip,e.buckets);const a=t=>"group"===t.type?{...t,children:t.children.map(a)}:i.has(t)?Lr(t):t.axisTooltip?{...t,interactive:!0,interactionGroup:"axis"}:t;return a(n)}const Es=["#e8e8e8","#e4acac","#c85a5a","#b0d5df","#ad9ea5","#985356","#64acbe","#627f8c","#574249"];function Rs(t){const e=Math.round(Math.sqrt(t));return e>=2&&e*e===t?e:0}function Ps(t,e){return function(t,e){const n=Rs(t.length);if(!n)return[];if(n===e)return t.slice();const o=(e,i)=>t[i*n+e],r=[],a=t=>{const i=e>1?t*(n-1)/(e-1):0,o=Math.min(n-2,Math.floor(i));return[o,i-o]};for(let t=0;t<e;t++){const[n,s]=a(t);for(let t=0;t<e;t++){const[e,c]=a(t),l=k.interpolateRgb(o(e,n),o(e+1,n))(c),h=k.interpolateRgb(o(e,n+1),o(e+1,n+1))(c);r.push(i.rgb(k.interpolateRgb(l,h)(s)).formatHex())}}return r}(Array.isArray(t)&&Rs(t.length)>0&&t.every(t=>"string"==typeof t&&i.rgb(t).displayable())?t:Es,e)}function Ts(t,e){const n=t.filter(Number.isFinite).sort(d.ascending),i=n.length,o=t=>{if(!i||!Number.isFinite(t))return 0;const o=d.bisectLeft(n,t)+d.bisectRight(n,t);return Math.min(e-1,Math.floor(o*e/(2*i)))},r=Array.from({length:e},()=>null);for(const t of n){const e=o(t),n=r[e];n?n[1]=t:r[e]=[t,t]}return{bin:o,ranges:r}}function Os(t){return Array.isArray(t)&&2===t.length&&Number.isFinite(t[0])&&Number.isFinite(t[1])}const Ws=4;function js(t,e){return[(t-e)*Math.SQRT1_2,-(t+e)*Math.SQRT1_2]}function Hs(t){const e=t.schema.bivariateLabels,n=t._bivariateFields??[],i=t=>{const i=(Array.isArray(e)?e[t]:void 0)??n[t];return null==i?"":`${i}`};return[i(0),i(1)]}function Is(t,e){const n=t.schema.axisConfig?.tickFormat;return n||(e.length&&Qo(e)?e=>Jo(e,t.schema.locale):e=>p.formatAbbreviate(e,t.schema.locale))}function Gs(t,e,n,i){const o=e.ranges[n];return o?t.schema.bucketJoiner(i(o[0]),i(o[1])):""}function qs(t,e,[n,i],o,r){return[[o[0],Gs(t,e.x,n,r[0])],[o[1],Gs(t,e.y,i,r[1])]].filter(([,t])=>t).map(([t,e])=>t?`${t}: ${e}`:e).join(", ")}function Vs(t,e,n,i){if(!e)return null;const o=function(t,e){const n=n=>{const i=t._labelClass[n]();return"function"==typeof i?i(e,0):i},i=n("fontFamily");return{family:s.fontFamilyStringify(i),size:Number(n("fontSize"))||12,weight:n("fontWeight")??400,color:`${n("fontColor")}`}}(t,e),a={"font-family":o.family,"font-size":o.size,"font-weight":o.weight},c=0===n?" →":"← ",l=r.textWidth(c,a),h=Math.max(...e.split(/\s+/).map(t=>r.textWidth(t,a))),u=s.textWrap().fontFamily(o.family).fontSize(o.size).fontWeight(o.weight).lineHeight(1.2*o.size).maxLines(2).split(t=>t.match(/\S+\s*/g)??[]).width(Math.max(i-l,h+1)).height(1.2*o.size*2+1)(e),d=u.lines.length?u.lines.slice():[e];0===n?d[d.length-1]+=c:d[0]=c+d[0];const f=1.2*o.size,m=d.map(t=>r.textWidth(t,a)),p=Math.max(...m),g=0===n?-45:45,y=0===n?[Math.SQRT1_2,-Math.SQRT1_2]:[Math.SQRT1_2,Math.SQRT1_2],x=(0===n?1:-1)*Math.max(0,p-i)/2,[b,k]=0===n?js(i/2,0):js(0,i/2),_=b+y[0]*x,v=k+y[1]*x,w=0===n?[Math.SQRT1_2,Math.SQRT1_2]:[-Math.SQRT1_2,Math.SQRT1_2],M=Ws+f*d.length,S=[[-p/2,Ws],[p/2,Ws],[-p/2,M],[p/2,M]].map(([t,e])=>[_+y[0]*t+w[0]*e,v+y[1]*t+w[1]*e]);return{node:{type:"text",key:`bivariate-label-${n}`,x:0,y:0,transform:{x:_,y:v,rotate:g},lines:d.map((t,e)=>({text:t,x:0,y:Ws+f*(e+.5),width:m[e]})),font:{family:o.family,size:o.size,weight:o.weight,anchor:"middle",baseline:"middle"},paint:{fill:o.color},interactive:!1,aria:{hidden:!0}},corners:S}}function Ks(t,e,n){const i=t.schema.legendConfig?.shapeConfig??{},o=t=>{const o=i[t];return"function"==typeof o?o(e,n):o},r=o("stroke"),a=Number(o("strokeWidth")),s=o("strokeOpacity");return"string"==typeof r&&r&&a>0?{stroke:r,strokeWidth:a,..."number"==typeof s?{strokeOpacity:s}:{}}:{}}function Ys(t,e,n){const i=function(t,e,n){const i=e.size,o=n/i,r=Hs(t),a=t=>e.domain().map(e=>e[t]),s=[Is(t,a(0)),Is(t,a(1))],c=[];for(let n=0;n<i;n++)for(let a=0;a<i;a++){const l=[js(a*o,n*o),js((a+1)*o,n*o),js((a+1)*o,(n+1)*o),js(a*o,(n+1)*o)],h={color:e.colors[n*i+a],id:qs(t,e,[a,n],r,s),_isColorScaleBucket:!0,_bivariateX:a,_bivariateY:n};c.push({type:"path",key:`bivariate-cell-${a}-${n}`,d:`M${l.map(t=>t.map(t=>+t.toFixed(3)).join(",")).join("L")}Z`,datum:h,index:n*i+a,paint:{fill:h.color,...Ks(t,h,n*i+a)},aria:{label:h.id}})}return{nodes:c,corners:[js(0,0),js(n,0),js(0,n),js(n,n)]}}(t,e,n),o=Hs(t),r=[Vs(t,o[0],0,n),Vs(t,o[1],1,n)].filter(Boolean),a=i.corners.concat(...r.map(t=>t.corners)),s=a.map(t=>t[0]),c=a.map(t=>t[1]),l=Math.min(...s),h=Math.min(...c);return{nodes:[...i.nodes,...r.map(t=>t.node)],bounds:{x:l,y:h,width:Math.max(...s)-l,height:Math.max(...c)-h}}}function Us(t){const e=function(t){return"number"==typeof t&&Number.isFinite(t)?Math.min(4,Math.max(2,Math.round(t))):3}(t.schema.bivariateBuckets),n=function(t,e,n){const i=Ts(t.map(t=>t[0]),e),o=Ts(t.map(t=>t[1]),e),r=t=>Os(t)?[i.bin(t[0]),o.bin(t[1])]:null,a=t=>{const i=r(t);return i?n[i[1]*e+i[0]]:void 0};return a.cell=r,a.size=e,a.x=i,a.y=o,a.colors=n,a.domain=()=>t,a.range=()=>n,a}(t._data.map((e,n)=>t.schema.value(e,n)).filter(Os),e,Ps(t.schema.bivariateColors,e));t._colorScale=n,t._barGeometry=void 0,t._labelClass.config(t.schema.labelConfig);const i=function(t,e){const n=Number(t.schema.width)||0,i=Number(t.schema.height)||0;let o=80,r=Ys(t,e,o);for(let a=0;a<4&&o>80/3;a++){const a=Math.max(r.bounds.width-n,r.bounds.height-i);if(a<=0||!n||!i)break;o=Math.max(80/3,o-a*Math.SQRT1_2-1),r=Ys(t,e,o)}const a=["bottom","top"].includes(t.schema.orient),s=(e,n)=>{const i=t.schema.align,o=Math.max(0,e-n);return"start"===i?0:"end"===i?o:o/2},c=a?Math.max(0,n-r.bounds.width)/2:s(n,r.bounds.width),l=a?s(i,r.bounds.height):Math.max(0,i-r.bounds.height)/2;return{nodes:[{type:"group",key:"bivariate-key",transform:{x:c-r.bounds.x,y:l-r.bounds.y},children:r.nodes}],bounds:{x:c,y:l,width:r.bounds.width,height:r.bounds.height}}}(t,n);return t._outerBounds=i.bounds,i}const Xs=[{key:"align",coerce:"identity",default:"middle"},{key:"bivariate",coerce:"identity",default:!1},{key:"bivariateBuckets",coerce:"identity",default:3},{key:"bivariateColors",coerce:"identity"},{key:"bivariateLabels",coerce:"identity"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(t,e)=>t!==e?`${t} - ${e}`:`${t}`},{key:"centered",coerce:"identity",default:!0},{key:"color",coerce:"identity"},{key:"colorMax",coerce:"identity"},{key:"colorMid",coerce:"identity"},{key:"colorMin",coerce:"identity"},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"hoverMark",coerce:"identity",default:!0},{key:"hoverMarkConfig",merge:!0,factory:function(){return{tickConfig:{},badgeConfig:{fontSize:11,fontWeight:400,padding:3,rx:2},outlineConfig:{strokeWidth:2}}}},{key:"midpoint",coerce:"identity",default:0},{key:"ordinalRamp",coerce:"identity",default:!1},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:H("value")},{key:"width",coerce:"identity",default:400}];class Qs extends Xt{render(t){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(o.select("body").append("div").node()),this._group=r.elem("g.d3plus-ColorScale",{parent:this._select});const e=Boolean(this.schema.bivariate);this._bivariateNodes=e?Us(this).nodes:void 0;const n=e?void 0:gs(this),i=!e&&(this.schema.bucketAxis||!ls(n.scale)),a=m.transition().duration(this.schema.duration),s={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:a,update:{opacity:1}},c={labelGroup:r.elem("g.d3plus-ColorScale-labels",Object.assign({condition:i},s)),rectGroup:r.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:i},s)),legendGroup:r.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!i&&!e},s)),groupParams:s,gradient:i};return n&&(i?bs(this,n,c):function(t,e,n){const{horizontal:i,allValues:o,ticks:a,colors:s}=e;t._barGeometry=void 0,r.elem("g.d3plus-ColorScale-axis",Object.assign({condition:n.gradient},n.groupParams)),t._swatchBuckets=new Map;let c=a.reduce((e,n,i)=>{const r=t.schema.bucketFormat.bind(t)(n,i,a,o),c={color:s[i+1],id:r,_isColorScaleBucket:!0};return t._swatchBuckets.set(c,{value:n,index:i}),e.push(c),e},[]);i||(c=c.reverse());const l=r.assign({align:i?"center":{start:"left",middle:"center",end:"right"}[t.schema.align],direction:i?"row":"column",duration:t.schema.duration,height:t.schema.height,padding:t.schema.padding,shapeConfig:r.assign({duration:t.schema.duration},t.schema.axisConfig.shapeConfig||{}),title:t.schema.axisConfig.title,titleConfig:t.schema.axisConfig.titleConfig||{},width:t.schema.width,verticalAlign:i?{start:"top",middle:"middle",end:"bottom"}[t.schema.align]:"middle"},t.schema.legendConfig),h=t._legendClass;h.config(ut(h,[...ys,...xs.get(h)??[]])),xs.set(h,Object.keys(l)),h.renderMode("compute").data(c).select(n.legendGroup.node()).config(l).render(),h.title()&&function(t){return!!t.data().length&&(!t.outerBounds().width||t._lineData.some(t=>t.sentence&&(!t.width||t.cut)))}(h)&&h.title(void 0).render(),t._outerBounds=t._legendClass.outerBounds()}(this,n,c)),"compute"!==this.schema.renderMode&&ne(this),t&&setTimeout(t,this.schema.duration+100),this}toScene(){const t=[],e=this.schema.bucketAxis||!ls(this._scaleType),n=(e,n=t=>t)=>{if(e&&"function"==typeof e.toScene){const i=e.toScene();i&&t.push(n(i))}};let i;this._bivariateNodes?t.push(...this._bivariateNodes):e?(n(this._rectClass,Lr),n(this._axisClass,Lr),n(this._labelClass,Lr)):n(this._legendClass,t=>Bs(t,{title:this._legendClass.schema.title,titleDatum:this._legendClass._titleClass.data()[0],titleTooltip:this.schema.axisConfig.titleTooltip,tickTooltip:this.schema.axisConfig.tickTooltip,buckets:this._swatchBuckets}));const o=this._select&&"function"==typeof this._select.node?this._select.node():null;if(o&&"function"==typeof o.getAttribute){const t=o.getAttribute("transform");if(t){const e=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);e&&(i={x:Number(e[1]),y:Number(e[2])})}}const r={type:"group",key:`ColorScale-${this._uuid.slice(0,8)}`,...i?{transform:i}:{},children:t};return this._bivariateNodes||Ls(this,r),r}axisConfig(t){return arguments.length?(this.schema.axisConfig=ht(this,"axisConfig",t),this):this.schema.axisConfig}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return arguments.length?(this._hoverValue=t,this):this._hoverValue}labelConfig(t){return arguments.length?(this.schema.labelConfig=ht(this,"labelConfig",t),this):this.schema.labelConfig}labelMin(t){return arguments.length?(this._labelMin=t,this):this._labelMin}labelMax(t){return arguments.length?(this._labelMax=t,this):this._labelMax}legendConfig(t){return arguments.length?(this.schema.legendConfig=ht(this,"legendConfig",t),this):this.schema.legendConfig}outerBounds(){return this._outerBounds}rectConfig(t){return arguments.length?(this.schema.rectConfig=ht(this,"rectConfig",t),this):this.schema.rectConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){super(),this._scaleType="linear",this._swatchBuckets=new Map,kt(this,Xs),this._axisClass=new Ga,this.schema.axisConfig={gridSize:0},this._axisTest=new Ga,this.schema.bucketFormat=(t,e,n,i)=>{const o=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:Qo(i)?t=>Jo(t,this.schema.locale):p.formatAbbreviate,r=e===n.length-1;if(t===n[e+1]||r){const e=r&&t<d.max(i)?"+":"";return`${o(function(t,e){const n=ss(e);return as(Math.round(rs(t,n)),n)}(t,i))}${e}`}const[a,s]=function(t,e,n,i,o){const r=n[e+1],a=ss(i),s=rs(t,a),c=as(1===e&&n[0]===t?Math.floor(s)+1:Math.ceil(s),a),l=t=>as(Math.ceil(rs(r,t))-1,t),h=o(as(Math.ceil(rs(r,a)),a));let u=a,d=l(u);for(;o(d)===h&&l(u-1)>=c;)d=l(--u);return[c,d]}(t,e,n,i,o);return this.schema.bucketJoiner(o(a),o(s))},this._data=[],this._labelClass=new ei,this.schema.labelConfig={fontColor:()=>vi(this),fontSize:12},this._legendClass=new is,this._legendClass._cutLabels=!0,this.schema.legendConfig={shapeConfig:{stroke:()=>this.schema.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new ta).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}function Zs(t,e,n){return n.width<=n.availableWidth/3&&n.height<=n.availableHeight/3}Qs._displayName="ColorScale",dt(Qs.prototype,"axisConfig","labelConfig","legendConfig","rectConfig");function Js(t){for(let e=1;e<15;e++)if(Number(t.toPrecision(e))===t)return e;return 15}function tc(t,e=3){const[n,i]=t;if(e<=1)return[i];if(2===e)return[n,i];const o=d.ticks(n,i,4*e).filter(t=>t>n&&t<i),r=.15*(i-n),a=[];for(let t=1;t<e-1;t++){const s=n+(i-n)*t/(e-1),c=o.filter(t=>!a.includes(t)&&Math.abs(t-s)<=r);c.sort((t,e)=>Js(t)-Js(e)||Math.abs(t-s)-Math.abs(e-s)),c.length&&a.push(c[0])}return[n,...a.sort((t,e)=>t-e),i]}function ec(t){const e=t.scale.domain();if(e.length<2||!Number.isFinite(e[0])||!Number.isFinite(e[1])||e[0]===e[1])return{circles:[],lines:[],labels:[],width:0,height:0};const n=t.maxRadius??1/0,i=function(t,e){const n="function"==typeof t?t(e):Array.isArray(t)?t:tc(e,t??3);return Array.from(new Set(n.filter(t=>Number.isFinite(t)))).sort((t,e)=>e-t)}(t.values,e).filter(e=>t.scale(e)<=n+.5),o=i.map(e=>Math.max(0,t.scale(e)||0)),a=Math.max(0,...o);if(!i.length||!a)return{circles:[],lines:[],labels:[],width:0,height:0};const{padding:s,fontSize:c}=t,l=1.2*c,h=i.map(e=>t.tickFormat(e)),u=h.map(e=>r.textWidth(e,{"font-family":t.fontFamily,"font-size":c})),d=t.title?String(t.title):"",f=d?r.textWidth(d,{"font-family":t.titleFontFamily,"font-size":t.titleFontSize,"font-weight":t.titleFontWeight}):0,m=d?1.2*t.titleFontSize+2:0,p=2*a+t.lineLength+t.labelPadding+Math.max(...u),g=Math.max(p,f),y=Math.min(s+g/2,s+g-p+a),x=s+m+l/2+2*a,b=i.map((t,e)=>({value:t,cx:y,cy:x-o[e],r:o[e]})),k=y+a+t.lineLength+t.labelPadding,_=[],v=[];let w,M=-1/0;if(b.forEach((e,n)=>{const i=e.cy-e.r,o=Math.max(i,M+l);M=o,_.push({value:e.value,text:h[n],x:k,y:o,width:u[n]});const r=[[e.cx,i],[e.cx+a,i]];o!==i&&r.push([e.cx+a+t.lineLength/2,o]),r.push([k-t.labelPadding,o]),v.push({value:e.value,points:r})}),d){w={text:d,x:Math.min(Math.max(y,s+f/2),s+g-f/2),y:s+t.titleFontSize,width:f}}const S=Math.max(x,M+l/2)+s;return{circles:b,lines:v,labels:_,title:w,width:Math.ceil(g+2*s),height:Math.ceil(S)}}function nc(t,e){if(1===e||!Number.isFinite(e)||e<=0)return t;const[n,i]=t.domain(),o=t.invert?Math.max(n,Math.min(i,t.invert(t(i)/e))):i,r=(o<i?d.ticks(n,o,4).filter(t=>t>n&&t<=o).pop():void 0)??o,a=n=>t(n)*e;return a.domain=()=>[n,r],a}const ic=[{key:"labelPadding",coerce:"identity",default:4},{key:"lineLength",coerce:"identity",default:6},{key:"padding",coerce:"identity",default:4},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity"},{key:"tickFormat",coerce:"identity"},{key:"title",coerce:"identity"},{key:"values",coerce:"identity"}],oc=t=>s.fontFamilyStringify(void 0===t?s.fontFamily:Array.isArray(t)?t:[t]);class rc extends Xt{labelConfig(t){return arguments.length?(this.schema.labelConfig=ht(this,"labelConfig",t),this):this.schema.labelConfig}lineConfig(t){return arguments.length?(this.schema.lineConfig=ht(this,"lineConfig",t),this):this.schema.lineConfig}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ht(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ht(this,"titleConfig",t),this):this.schema.titleConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}layout(){const t=this.schema.scale;if(!t||"function"!=typeof t.domain)return this._layout={circles:[],lines:[],labels:[],width:0,height:0};const e=this.schema.labelConfig,n=this.schema.titleConfig,i=this.schema.locale;return this._layout=ec({scale:t,values:this.schema.values,tickFormat:this.schema.tickFormat??(t=>p.formatAbbreviate(t,i)),fontFamily:oc(e.fontFamily),fontSize:e.fontSize??10,title:this.schema.title,titleFontFamily:oc(n.fontFamily),titleFontSize:n.fontSize??11,titleFontWeight:n.fontWeight??600,lineLength:this.schema.lineLength,labelPadding:this.schema.labelPadding,padding:this.schema.padding,maxRadius:this._maxRadius}),this._layout}outerBounds(){return{width:this._layout.width,height:this._layout.height}}toScene(t=0,e=0){const n=this._layout,i=this.schema.shapeConfig,o=this.schema.lineConfig,r=this.schema.labelConfig,a=this.schema.titleConfig,s=oc(r.fontFamily),c=[];return n.circles.forEach(t=>c.push({type:"circle",key:`circle-${t.value}`,interactive:!1,cx:t.cx,cy:t.cy,r:t.r,paint:{...i}})),n.lines.forEach(t=>c.push({type:"line",key:`line-${t.value}`,interactive:!1,points:t.points,paint:{fill:"none",...o}})),n.labels.forEach(t=>c.push({type:"text",key:`label-${t.value}`,interactive:!1,x:0,y:0,transform:{x:t.x,y:t.y},lines:[{text:t.text,x:0,y:0,width:t.width}],font:{family:s,size:r.fontSize??10,anchor:"start",baseline:"middle"},paint:{fill:r.fontColor}})),n.title&&c.push({type:"text",key:"title",interactive:!1,x:0,y:0,transform:{x:n.title.x,y:n.title.y},lines:[{text:n.title.text,x:0,y:0,width:n.title.width}],font:{family:oc(a.fontFamily),size:a.fontSize??11,weight:a.fontWeight??600,anchor:"middle",baseline:"alphabetic"},paint:{fill:a.fontColor}}),{type:"group",key:`SizeLegend-${this._uuid.slice(0,8)}`,transform:{x:t,y:e},children:c}}render(t){return this.layout(),"compute"!==this.schema.renderMode&&(void 0===this._select&&this.select(o.select("body").append("div").node()),this.schema.width=this._layout.width,this.schema.height=this._layout.height,ne(this)),t&&setTimeout(t,0),this}constructor(){super(),kt(this,ic),this._layout={circles:[],lines:[],labels:[],width:0,height:0},this.schema.labelConfig={fontColor:e.colorDefaults.dark,fontSize:10},this.schema.lineConfig={stroke:e.colorDefaults.dark,strokeOpacity:.5,strokeWidth:1},this.schema.shapeConfig={fill:e.colorDefaults.dark,fillOpacity:.05,stroke:e.colorDefaults.dark,strokeOpacity:.6,strokeWidth:1},this.schema.titleConfig={fontColor:e.colorDefaults.dark,fontSize:11,fontWeight:600}}}rc._displayName="SizeLegend",dt(rc.prototype,"labelConfig","lineConfig","shapeConfig","titleConfig");class ac{exit(t,e){t.transition().duration(e).style("opacity",0).transition().remove(),this._isVisible=!1}hide({duration:t=600,callback:e}={}){return this.mask.call(this.exit.bind(this),t),this.elem.call(this.exit.bind(this),t),e&&setTimeout(e,t+100),this._isVisible=!1,this}render({callback:t,container:e="body",duration:n=600,html:i="Please Wait",mask:a="rgba(0, 0, 0, 0.05)",style:s={}}={}){const c=o.select(e);return this.mask=c.selectAll("div.d3plus-Mask").data(a?[a]:[]),this.mask=this.mask.enter().append("div").attr("class","d3plus-Mask").style("opacity",1).merge(this.mask),this.mask.exit().call(this.exit.bind(this),n),r.stylize(this.mask,{"background-color":"transparent",bottom:"0px",left:"0px",position:"absolute",right:"0px",top:"0px"}),this.elem=c.selectAll("div.d3plus-Message").data([i]),this.elem=this.elem.enter().append("div").attr("class","d3plus-Message").style("opacity",1).merge(this.elem).html(String),r.stylize(this.elem,s),t&&setTimeout(t,100),this._isVisible=!0,this}constructor(){this._isVisible=!1}}const sc=t=>"function"==typeof t?t():t;function cc(t,e){const n=sc(t),i="number"==typeof n&&Number.isFinite(n)?n:1,o=sc(e);return{min:i,max:"number"==typeof o&&Number.isFinite(o)?Math.max(Math.floor(o),Math.ceil(i),1):1/0}}function lc(t,e,n,i,o="hi",r="lo"){const a=i.min-1;Math.abs(e-t)<a&&("lo"===r?(e=Math.min(n-1,t+a),t=Math.max(0,e-a)):(t=Math.max(0,e-a),e=Math.min(n-1,t+a)));const s=i.max-1;return e-t>s&&("lo"===o?e=t+s:t=e-s),[t,e]}function hc(t){const e=cc(t.brushMin,t.brushMax);return!1===t.brushing?{...e,min:1}:e}const uc="#bbb";const dc=t=>()=>Z(t._theme,t=>t.accent,"#228be6");function fc(t){return t.slice().sort((t,e)=>Number(t)-Number(e))}function mc(t){return{labelBounds:e=>"buttons"===t._buttonBehaviorCurrent?{x:e.labelBounds.x,y:-t.schema.buttonHeight/2+1,width:e.labelBounds.width,height:t.schema.buttonHeight}:e.labelBounds,labelConfig:{fontColor:()=>vi(t),fontSize:()=>12,verticalAlign:()=>"buttons"===t._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===t._buttonBehaviorCurrent?function(t){return t._theme?.painted||t._theme?.dark?ki(t):"#fff"}(t):uc,stroke:()=>"buttons"===t._buttonBehaviorCurrent?uc:"transparent",height:e=>"buttons"===t._buttonBehaviorCurrent?t.schema.buttonHeight:e.tick?t.schema.handleSize:0,width:e=>"buttons"===t._buttonBehaviorCurrent?t._ticksWidth/t._availableTicks.length:e.tick?t.schema.domain.map(Number).includes(e.id)?2:1:0,y:e=>"buttons"===t._buttonBehaviorCurrent?"middle"===t.schema.align?t.schema.height/2:"start"===t.schema.align?t._margin.top+t.schema.buttonHeight/2:t.schema.height-t.schema.buttonHeight/2-t._margin.bottom:e.y,rx:e=>"buttons"===t._buttonBehaviorCurrent?0:t.schema.domain.map(Number).includes(e.id)?1:0,ry:e=>"buttons"===t._buttonBehaviorCurrent?0:t.schema.domain.map(Number).includes(e.id)?1:0}}function pc(t){t.schema.brushFilter=t=>{const e=t;return!e.button&&e.detail<2},t.schema.domain=[2001,2010],t.schema.gridSize=0,t.schema.handleConfig={fill:()=>t.schema.colorDefaults.light,stroke:dc(t),"stroke-width":2,rx:2,ry:2},t.schema.height=100,t.schema.labelOffset=!1,t._labelRotationSetting=!1,t.schema.on={},t.orient("bottom"),t._playButtonClass=new ei,t.schema.playButtonConfig={fontColor:()=>vi(t),fontSize:15,text:()=>t._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},t.schema.selectionConfig={fill:dc(t),"fill-opacity":()=>"buttons"===t._buttonBehaviorCurrent?.3:1,"stroke-width":0},t.schema.shape="Rect",t.schema.barConfig=r.assign({},t.schema.barConfig,{stroke:()=>"buttons"===t._buttonBehaviorCurrent?"transparent":uc,"stroke-width":()=>"buttons"===t._buttonBehaviorCurrent?0:1}),t.schema.shapeConfig=r.assign({},t.schema.shapeConfig,mc(t)),t._buttonBehaviorCurrent="auto",t._hiddenHandles=!1,t._paddingLeft=0,t._ticksWidth=0}const gc=["ticks","buttons"];function yc(t,e){return gc.includes(e)?`${t}-${e}`:null}function xc(t,e,n){if(!t)return;const i=yc(e,n);for(const n of gc){const o=`${e}-${n}`;t.classList.toggle(o,o===i)}}function bc(t,e,n,i=n){const o=hc(t.schema);if(o.min<=1&&o.max===1/0||!n.length)return;const a=n.map(Number),s=[e[0],e[e.length-1]].map(t=>function(t,e){let n=-1;return t.forEach((i,o)=>{(n<0||Math.abs(i-e)<Math.abs(t[n]-e))&&(n=o)}),n}(a,Number(t))),c=Math.min(...s),l=Math.max(...s),[h,u]=lc(c,l,a.length,o,"hi","hi");h===c&&u===l||([e[0],e[e.length-1]]=fc([n[h],n[u]]),t.schema.selection=[i[h],i[u]].map(t=>r.date(t)))}const kc=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushCursor",coerce:"identity",default:"pointer"},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMax",coerce:"const"},{key:"brushMin",coerce:"const",default:W(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class _c extends Ga{_brushBrush(t){if(!t.sourceEvent||null===t.selection||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render()),this._updateDomain(t)),this._brushStyle(),t.sourceEvent&&!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const e=o.pointers(t,this._select.node());e.length&&this._brushGroup.selectAll(".handle").filter(t=>"e"===t.type).attr("x",e[0][0]-this.schema.handleSize/2)}this.schema.on.brush&&this.schema.on.brush(this.schema.selection)}_snapBrushVisual(t){const e=this._hiddenHandles?0:this.schema.handleSize;this._brushGroup.selectAll(".selection").attr("x",t[0]).attr("width",t[1]-t[0]),this._brushGroup.selectAll(".handle").attr("x",n=>("e"===n.type[n.type.length-1]?t[1]:t[0])-e/2)}_brushEnd(t){if(!t.sourceEvent)return;const e=this._updateDomain(t);this._brushStyle();const n=this._brushGroup.transition(this._transition);this.schema.brushing&&this.schema.duration||n.duration(0),n.call(this._brush.move,this._updateBrushLimit(e)),this.schema.on.end&&this.schema.on.end(this.schema.selection)}_brushStart(t){null===t.sourceEvent||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),null!==t.selection&&this._snapBrushVisual(this._updateBrushLimit(this._updateDomain(t)))),this._brushStyle(),this.schema.on.start&&this.schema.on.start(t)}_brushStyle(){const{height:t}=this._position,e="Circle"===this.schema.shape?"function"==typeof this.schema.shapeConfig.r?2*this.schema.shapeConfig.r({tick:!0}):this.schema.shapeConfig.r:"Rect"===this.schema.shape?"function"==typeof this.schema.shapeConfig[t]?this.schema.shapeConfig[t]({tick:!0}):this.schema.shapeConfig[t]:this.schema.tickSize,n=this._brushGroup.selectAll(".selection").call(r.attrize,this.schema.selectionConfig).attr("transform","translate(0,-1)").attr("height",e+2).style("display",()=>this.schema.brushing||this._hiddenHandles?null:"none"),i=this._brushGroup.selectAll(".handle").call(r.attrize,this.schema.handleConfig).style("display",t=>this._hiddenHandles||!this.schema.brushing&&"w"===t.type?"none":null).attr("transform",t=>"buttons"===this._buttonBehaviorCurrent?`translate(${"w"===t.type?-this.schema.handleSize/2:0},-1)`:"").attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight+2:e+this.schema.handleSize);if(!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const t=+n.attr("x")||0,e=+n.attr("width")||0;i.filter(t=>"e"===t.type).attr("x",t+e/2-this.schema.handleSize/2)}if(this._brushGroup.selectAll(".overlay").attr("x",this._paddingLeft).attr("cursor",function(t){const e=t.schema.brushCursor;return"function"==typeof e?e(t._buttonBehaviorCurrent):e??null}(this)).attr("transform",`translate(0,${"buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight/2:-this.schema.handleSize})`).attr("width","buttons"===this._buttonBehaviorCurrent?this._ticksWidth:this.schema.width).attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight:2*this.schema.handleSize),"buttons"===this._buttonBehaviorCurrent){const t="middle"===this.schema.align?this.schema.height/2-this.schema.buttonHeight/2:"start"===this.schema.align?this._margin.top:this.schema.height-this.schema.buttonHeight-this._margin.bottom;i.attr("y",t),n.attr("y",t)}}_updateDomain(t){const e=o.pointers(t,this._select.node()),n=(t.selection&&this.schema.brushing||!e.length?t.selection:[e[0][0],e[0][0]]).map(Number),i="ticks"===this._buttonBehaviorCurrent,a=fc(this._availableTicks).map(Number),s=this._d3Scale.range(),c=this._availableTicks.map(Number),l=t=>a.indexOf(i?u.closest(+this._d3Scale.invert(t),a):c[s.indexOf(u.closest(t,s))]),h=i?a:s,d=t.selection,f=e.length?e[0][0]:NaN,m=d&&Math.abs(f-d[0])<Math.abs(f-d[1])?"lo":"hi",[p,g]=function(t,e,n,i,o=!1){const r=Math.min(...t),a=Math.max(...t),s=t["lo"===i?0:1]===r?"lo":"hi",c=o?((t,e,n)=>t===e?"lo":n)(r,a,s):"lo";return lc(r,a,e,n,s,c)}([l(n[0]),l(n[1])],a.length,hc(this.schema),m,!i),y=t=>s[c.indexOf(a[t])],x=i?[r.date(a[p]),r.date(a[g])]:fc([y(p),y(g)]),b=+x[0]===+x[1];return"brush"!==t.type&&"end"!==t.type||(this.schema.selection="ticks"===this._buttonBehaviorCurrent?b?x[0]:x:b?r.date(this._availableTicks[h.indexOf(x[0])]):fc([r.date(this._availableTicks[h.indexOf(x[0])]),r.date(this._availableTicks[h.indexOf(x[1])])])),x}_updateBrushLimit(t){const e="ticks"===this._buttonBehaviorCurrent?fc(t.map(r.date).map(t=>this._d3Scale(t))):t;if(e[0]===e[1]&&(e[0]-=.1,e[1]+=.1),"buttons"===this._buttonBehaviorCurrent){const t=this._hiddenHandles?0:this.schema.handleSize,n=.5*(this._ticksWidth/this._availableTicks.length-t);e[0]-=n,e[1]+=n}return e}_togglePlay(){if(this._playTimer)return clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),void this._onPlayToggle?.();const t=t=>{this.selection(t).render(),this.schema.on.end&&this.schema.on.end(this.schema.selection)};let e=!0;const n=()=>{const n=fc(("ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks)||[]);if(!n.length)return;let i=this.schema.selection||[this.schema.domain[this.schema.domain.length-1]];i instanceof Array||(i=[i]),i=i.map(r.date).map(Number),1===i.length&&i.push(i[0]);const o=n.map(Number),a=o.indexOf(i[0]),s=o.indexOf(i[i.length-1]);s===o.length-1?e?t([n[0],n[s-a]]):(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),this._onPlayToggle?.()):(s+1===o.length-1&&(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1),t([n[a+1],n[s+1]])),e=!1},i=Number(this.schema.duration)||0,o=i>0?i:this.schema.playButtonInterval;this._playTimer=setInterval(n,o),n(),this._onPlayToggle?.()}_isFullRangeSelected(){const t="ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks;if(!t||t.length<2)return!1;if(null==this.schema.selection)return!1;const e=(this.schema.selection instanceof Array?this.schema.selection:[this.schema.selection]).map(r.date).map(Number),n=t.map(Number);return Math.min(...e)<=Math.min(...n)&&Math.max(...e)>=Math.max(...n)}toScene(){const t=super.toScene(),e=this._playButtonClass;return this.schema.playButton&&e&&"function"==typeof e.toScene&&e._data&&e._data.length&&t.children.push(e.toScene()),t}render(t){const{height:e,y:n}=this._position,{ticks:i,tickFormat:o}=function(t){t.schema.ticks&&(t.schema.ticks=Fo(t.schema.ticks)),t._data&&(t._data=Fo(t._data));let e=t.schema.ticks?t.schema.ticks:t.schema.domain.map(r.date);if(!t.schema.ticks){const n=c.scaleTime().domain(e).range([0,t.schema.width]);e=n.ticks()}const n=t.schema.timeLocale||l.locale[t.schema.locale]||l.locale["en-US"];let i;void 0===t._userFormat&&(t._userFormat=t.schema.tickFormat||!1);const o=t.schema.tickFormat=t._userFormat?t._userFormat:t=>(i&&i.format===y.timeFormat||(i={format:y.timeFormat,label:p.dateFormatter(e,y.timeFormat)}),i.label(t).replace(/^Q/g,n.quarter));return{ticks:e,tickFormat:o}}(this);!function(t,e,n){if(t._ticksWidth=t.schema.width,["auto","buttons"].includes(t.schema.buttonBehavior)){let i=0;e.forEach((e,o)=>{const{fontFamily:a,fontSize:c}=t.schema.shapeConfig.labelConfig,l="function"==typeof a?a(e,o):a,h="function"==typeof c?c(e,o):c,u=s.textWrap().fontFamily(l).fontSize(h).lineHeight(Ln(t.schema.shapeConfig,e,o,h))(n(e));let f=u.lines.length?Math.ceil(d.max(u.lines.map(t=>r.textWidth(t,{"font-family":l,"font-size":h}))))+h/4:0;f%2&&f++,i<f&&(i=f+2*t.schema.buttonPadding)}),t._ticksWidth=i*e.length}}(this,i,o);const h=this.schema.playButton?this.schema.playButtonConfig.width||this.schema.buttonHeight:0,u=function(t,e,n){const i=t.schema.width-n;t._buttonBehaviorCurrent="auto"===t.schema.buttonBehavior?t._ticksWidth<i?"buttons":"ticks":t.schema.buttonBehavior;const o=t._hiddenHandles="buttons"===t._buttonBehaviorCurrent&&!t.schema.brushing;if("buttons"===t._buttonBehaviorCurrent){t.schema.scale="ordinal",t.schema.domain=t.schema.ticks?t.schema.ticks:e,t.schema.ticks=t.schema.domain;const i=.5*t._ticksWidth/t.schema.ticks.length,o=t.schema.width-t._ticksWidth-n;t._paddingLeft="middle"===t.schema.buttonAlign?o/2+n:"end"===t.schema.buttonAlign?o+n:n,t.schema.range=[t._paddingLeft+i,t._paddingLeft+t._ticksWidth-i]}else t.schema.scale="time",t.schema.domain=d.extent(e),t.schema.range=[n?1.5*n:void 0,void 0],t._paddingLeft=n;return o}(this,i,h);if(super.render(t),function(t,e,n,i){const o=t._outerBounds[i],a=t._d3Scale.range(),[s,c]="buttons"===t._buttonBehaviorCurrent?[t._paddingLeft,t._paddingLeft+t._ticksWidth]:[a[0],a[a.length-1]],l=t._brush=f.brushX().extent([[s,o],[c,o+t._outerBounds[n]]]).filter(t.schema.brushFilter).handleSize(e?0:t.schema.handleSize).on("start",t._brushStart.bind(t)).on("brush",t._brushBrush.bind(t)).on("end",t._brushEnd.bind(t)),h=fc(("ticks"===t._buttonBehaviorCurrent?t._availableTicks:t.schema.ticks)||[]),u=e=>{const n=h[h.map(Number).indexOf(+e)];return void 0===n?void 0:t._d3Scale(n)},d="ticks"===t._buttonBehaviorCurrent?h:h.map(u),m=fc([t.schema.brushMin()>d.length?d[0]:d[d.length-t.schema.brushMin()],d[d.length-1]]),p=void 0===t.schema.selection?m:t.schema.selection instanceof Array?"buttons"===t._buttonBehaviorCurrent?fc(t.schema.selection.map(r.date).map(u)):t.schema.selection.map(r.date):"buttons"===t._buttonBehaviorCurrent?[u(r.date(t.schema.selection))]:[t.schema.selection];1===p.length&&p.push(p[0]),bc(t,p,d,h),t._updateBrushLimit(p),t._brushGroup=r.elem("g.brushGroup",{parent:t._group});const g=t._brushGroup.call(l).transition(t._transition);t.schema.duration||g.duration(0),g.call(l.move,"ticks"===t._buttonBehaviorCurrent?t._updateBrushLimit(p):p),t._outerBounds.y-=t.schema.handleSize/2,t._outerBounds.height+=t.schema.handleSize/2}(this,u,e,n),function(t,e){const n=r.elem("g.d3plus-Timeline-play",{parent:t._group}),i=t.schema.playButton?[{x:t._paddingLeft-e,y:"buttons"===t._buttonBehaviorCurrent?"middle"===t.schema.align?t.schema.height/2-t.schema.buttonHeight/2:"start"===t.schema.align?t._margin.top:t.schema.height-t.schema.buttonHeight-t._margin.bottom:t._outerBounds.y,width:e,height:t.schema.buttonHeight}]:[],o=t._isFullRangeSelected();t._playButtonClass.renderMode("compute").data(i).select(n.node()).config(te.bind(t)(t.schema.playButtonConfig)),o&&t._playButtonClass.config({fontColor:t.schema.colorDefaults.missing}),t._playButtonClass.render();const a=r.elem("rect.d3plus-Timeline-play-hit",{parent:n,condition:i.length>0});if(i.length){const e=i[0];a.attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height).attr("fill","transparent").attr("cursor",o?"default":"pointer").style("pointer-events",o?"none":"all").on("click",()=>{t._isFullRangeSelected()||t._togglePlay()})}}(this,h),xc(this._group?.node(),"d3plus-Timeline",this._buttonBehaviorCurrent),"compute"!==this.schema.renderMode&&this._select&&(function(t,e){const n=t._select,i=n&&"function"==typeof n.node?n.node():null;if(!(i instanceof Element))return;const o=i,r=t.schema.width??400,s=t.schema.height??100,c=t;c._sceneRenderer?c._sceneRenderer.resize(r,s):(c._sceneRenderer=new a.SvgRenderer,c._sceneRenderer.mount({container:o,width:r,height:s})),c._sceneRenderer.drawScene({root:{type:"group",key:"root",children:[e]},width:r,height:s},{duration:0}),It(t)}(this,this.toScene()),this._group)){const t=this._select.node(),e=this._group.node();t instanceof Element&&e instanceof Element&&e.parentNode===t&&t.appendChild(e)}return this}handleConfig(t){return arguments.length?(this.schema.handleConfig=ht(this,"handleConfig",t),this):this.schema.handleConfig}on(t,e){return 2===arguments.length?(this.schema.on[t]=e,this):arguments.length?"string"==typeof t?this.schema.on[t]:(this.schema.on=r.assign({},this.schema.on,t),this):this.schema.on}playButtonConfig(t){return arguments.length?(this.schema.playButtonConfig=ht(this,"playButtonConfig",t),this):this.schema.playButtonConfig}selectionConfig(t){return arguments.length?(this.schema.selectionConfig=ht(this,"selectionConfig",t),this):this.schema.selectionConfig}constructor(){super(),kt(this,kc),pc(this),this._managesOwnScenePaint=!0}}function vc(t=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:t[0],y:t[1],top:t[1],right:t[0],bottom:t[1],left:t[0]})}}async function wc(t,e,n,i,o,r){const{x:a,y:s,placement:c,middlewareData:l}=await g.computePosition(t,e,{strategy:"fixed",placement:"top",middleware:[g.offset(i+o),g.flip({fallbackPlacements:["bottom"],padding:5}),g.shift({padding:5}),g.arrow({element:n})]});Object.assign(e.style,{position:"fixed",left:`${a}px`,top:`${s}px`,visibility:"visible"});const h="bottom"===c,u=parseFloat(n.style.borderRightWidth)||0;h?(n.style.transform="rotate(225deg)",n.style.top=`-${r/2+u}px`,n.style.bottom=""):(n.style.transform="rotate(45deg)",n.style.bottom=`-${r/2+u}px`,n.style.top=""),n.style.left=null!=l.arrow?.x?`${l.arrow.x}px`:""}_c._displayName="Timeline",dt(_c.prototype,"handleConfig","playButtonConfig","selectionConfig");const Mc=['[id="d3plus-portal"]',".d3plus-tooltip-portal",".d3plus-tooltip",".d3plus-tooltip-title",".d3plus-tooltip-body",".d3plus-tooltip-footer",".d3plus-tooltip-arrow",".d3plus-tooltip-table",".d3plus-tooltip-thead",".d3plus-tooltip-tbody"];function Sc(t,e,n,i){return`${i?`d3plus-tooltip-${i}`:"d3plus-tooltip"}-${t._uuid}-${e?t.schema.id(e,n):""}`}function Cc(t,e,n,i){e.append("div").attr("class",`d3plus-tooltip-${i}`).attr("id",(e,n)=>Sc(t,e,n,i));const o=(e,n)=>t.schema[i](e,n),a=t=>!1!==t&&null!=t,s=n.select(`.d3plus-tooltip-${i}`).html((t,e)=>{const n=o(t,e);return a(n)?n:""}).style("display",(t,e)=>a(o(t,e))?"block":"none");r.stylize(s,t.schema[`${i}Style`])}function $c(t,e){e.style("background",t.schema.background).style("border-radius",t.schema.borderRadius).style("pointer-events",t.schema.pointerEvents).style("padding",t.schema.padding).style("max-width",t.schema.maxWidth).style("min-width",t.schema.minWidth).style("width",t.schema.width).style("height",t.schema.height).style("border",t.schema.border)}const Ac=t=>(t._theme??V).tooltip;const zc="d3plus-tooltip",Dc=[{key:"arrow",coerce:"const",default:H("arrow","")},{key:"background",coerce:"const",factory:t=>()=>Z(t._theme,t=>t.tooltip.background,t.schema.colorDefaults.light)},{key:"body",coerce:"const",default:H("body","")},{key:"border",coerce:"const",factory:t=>()=>`1px solid ${Ac(t).border}`},{key:"borderRadius",coerce:"const",default:W("4px")},{key:"footer",coerce:"const",default:H("footer","")},{key:"height",coerce:"const",default:W("auto")},{key:"id",coerce:"const",default:(t,e)=>`${e}`},{key:"offset",coerce:"const",default:W(5)},{key:"padding",coerce:"const",default:W("10px")},{key:"pointerEvents",coerce:"const",default:W("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:H("title","")},{key:"titleSwatch",coerce:"identity",default:!0},{key:"maxWidth",coerce:"const",default:W("300px")},{key:"minWidth",coerce:"const",default:W("200px")},{key:"width",coerce:"const",default:W("auto")}];class Lc extends Xt{render(t){const e=this,n=`d3plus-tooltip-${this._uuid}-`,i=function(t){if(!t._parentEl)return r.elem("div#d3plus-portal");let e=t._portalEl??null;return e&&e.isConnected||(e=document.createElement("div"),e.setAttribute("class","d3plus-tooltip-portal"),e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="0",e.style.height="0",e.style.pointerEvents="none",document.body.appendChild(e),t._portalEl=e),o.select(e)}(this);a.resetInjectedBoxes(i.node(),Mc);const s=i.selectAll(`.${zc}`).filter(function(){return this.id.startsWith(n)}).data(this._data,this.schema.id),c=s.enter().append("div").attr("class",zc),l=s.merge(c);return l.each(function(){this instanceof Element&&Ht(this,e.schema.className,[zc])}),r.stylize(l,this.schema.tooltipStyle),Cc(this,c,l,"title"),Cc(this,c,l,"body"),function(t,e,n,i){const o=e.append("table").attr("class","d3plus-tooltip-table"),a=n.select(".d3plus-tooltip-table");r.stylize(a,t.schema.tableStyle),o.append("thead").attr("class","d3plus-tooltip-thead");const s=n.select(".d3plus-tooltip-thead");r.stylize(s,t.schema.theadStyle);const c=s.selectAll("tr").data([0]),l=c.enter().append("tr");c.exit().remove();const h=c.merge(l);r.stylize(h,t.schema.trStyle);const u=h.selectAll("th").data(t.schema.thead),d=u.enter().append("th").merge(u).html(i);r.stylize(d,t.schema.thStyle),u.exit().remove(),o.append("tbody").attr("class","d3plus-tooltip-tbody");const f=n.select(".d3plus-tooltip-tbody");r.stylize(f,t.schema.tbodyStyle);const m=f.selectAll("tr").data(t.schema.tbody),p=m.enter().append("tr");m.exit().remove();const g=m.merge(p);r.stylize(g,t.schema.trStyle);const y=g.selectAll("td").data(t=>t),x=y.enter().append("td").merge(y).html(i);r.stylize(x,t.schema.tdStyle)}(this,c,l,function(t){if("function"==typeof t){const n=o.select(this.parentNode.parentNode).datum();return t(n,e._data.indexOf(n),n)}return t}),Cc(this,c,l,"footer"),Cc(this,c,l,"arrow"),function(t,e,n,i){e.attr("id",(e,n)=>Sc(t,e,n)).style("visibility","hidden").call(e=>$c(t,e)).each(function(e,n){const i=t.schema.id(e,n),o=this,r=o.querySelector(".d3plus-tooltip-arrow"),a=r.offsetHeight,s=r.getBoundingClientRect().height/2;r.style.bottom=`-${a/2}px`;const c=t.schema.position(e,n),l=Array.isArray(c)?vc(c):c;t._tooltipRefs[i]={reference:l,arrowEl:r,tooltip:o,arrowHeight:a,arrowDistance:s},wc(l,o,r,t.schema.offset(e,n),s,a)}),n.each(function(e,n){const i=t.schema.id(e,n),o=t.schema.position(e,n),r=t._tooltipRefs[i];r&&(r.reference=Array.isArray(o)?vc(o):o,wc(r.reference,r.tooltip,r.arrowEl,t.schema.offset(e,n),r.arrowDistance,r.arrowHeight))}).call(e=>$c(t,e)),i.exit().each(function(e,n){const i=t.schema.id(e,n);delete t._tooltipRefs[i]}).remove()}(this,c,l,s),t&&setTimeout(t,100),this}className(t){return arguments.length?super.className(t):super.className()}arrowStyle(t){return arguments.length?(this.schema.arrowStyle=ht(this,"arrowStyle",t),this):this.schema.arrowStyle}bodyStyle(t){return arguments.length?(this.schema.bodyStyle=ht(this,"bodyStyle",t),this):this.schema.bodyStyle}parent(t){if(!arguments.length)return this._parentEl;const e=this._parentEl,n=t||void 0;return e&&e!==n&&this._portalEl&&(this._portalEl.remove(),this._portalEl=void 0),this._parentEl=n,this}data(t){return arguments.length?(this._data=t,this):this._data}footerStyle(t){return arguments.length?(this.schema.footerStyle=ht(this,"footerStyle",t),this):this.schema.footerStyle}position(t){return arguments.length?(this.schema.position="string"==typeof t?W(o.select(t).node()||[0,0]):"function"==typeof t?t:W(t),this):this.schema.position}tableStyle(t){return arguments.length?(this.schema.tableStyle=ht(this,"tableStyle",t),this):this.schema.tableStyle}tbodyStyle(t){return arguments.length?(this.schema.tbodyStyle=ht(this,"tbodyStyle",t),this):this.schema.tbodyStyle}theadStyle(t){return arguments.length?(this.schema.theadStyle=ht(this,"theadStyle",t),this):this.schema.theadStyle}titleStyle(t){return arguments.length?(this.schema.titleStyle=ht(this,"titleStyle",t),this):this.schema.titleStyle}tooltipStyle(t){return arguments.length?(this.schema.tooltipStyle=ht(this,"tooltipStyle",t),this):this.schema.tooltipStyle}trStyle(t){return arguments.length?(this.schema.trStyle=ht(this,"trStyle",t),this):this.schema.trStyle}tdStyle(t){return arguments.length?(this.schema.tdStyle=ht(this,"tdStyle",t),this):this.schema.tdStyle}thStyle(t){return arguments.length?(this.schema.thStyle=ht(this,"thStyle",t),this):this.schema.thStyle}constructor(){super(),kt(this,Dc),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=t=>[t.x,t.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":()=>Ac(this).shadow,color:(t,n)=>function(t,n){const i=e.colorContrast(n,t.schema.colorDefaults);return t._theme&&n===t._theme.tooltip.background?Z(t._theme,t=>t.tooltip.text,i):i}(this,this.schema.background(t,n)),"font-family":s.fontFamilyStringify(s.fontFamily)},this.schema.trStyle={"border-top":(t,e)=>e?`1px solid ${Ac(this).divider}`:"none"};const t=(t,e)=>e?"right":"left";this.schema.tdStyle={"text-align":t},this.schema.thStyle={"text-align":t}}}Lc._displayName="Tooltip",dt(Lc.prototype,"arrowStyle","bodyStyle","footerStyle","tableStyle","tbodyStyle","theadStyle","titleStyle","tooltipStyle","trStyle","tdStyle","thStyle");const Fc=new WeakSet;function Nc(t){return Fc.add(t),t}function Bc(t){return"function"==typeof t&&Fc.has(t)}const Ec=new WeakMap;function Rc(t){if(null==t||""===t)return null;if("number"!=typeof t&&"string"!=typeof t)return null;const e=+t;return Number.isFinite(e)?e:null}function Pc(t){return"function"==typeof(e=t.schema.colorScale)&&Ec.get(e)||null;var e}function Tc(t){return ki(t)}function Oc(t){return vi(t)}function Wc(t){return Mi(t)}function jc(t){return k.interpolateRgb(Tc(t),Oc(t))(.7)}function Hc(t,e,n){const i={fill:"none",vectorEffect:"non-scaling-stroke"};return[{...t,key:`viz-focus-halo-${n}`,paint:{...i,stroke:e.halo,strokeWidth:e.strokeWidth+2}},{...t,key:`viz-focus-ring-${n}`,paint:{...i,stroke:e.stroke,strokeWidth:e.strokeWidth}}].map(t=>({...t,interactive:!1,aria:{hidden:!0}}))}function Ic(t,e){const{node:n,box:i,center:o,chain:r}=t,a=e.padding;if(void 0!==t.pointIndex)return Hc({type:"circle",cx:o[0],cy:o[1],r:5+a},e,"circle");if("circle"===n.type)return Hc({type:"circle",cx:o[0],cy:o[1],r:i.width/2+a},e,"circle");if("path"===n.type&&function(t){const e=t.paint?.fill;return!!e&&"none"!==e&&"transparent"!==e}(n)){return function(t,e){return t.reduceRight((t,e,n)=>[{type:"group",key:`viz-focus-t${n}`,transform:e,children:t,interactive:!1}],e)}(n.transform?[...r,n.transform]:r,Hc({type:"path",d:n.d},e,"path"))}return Hc({type:"rect",x:i.x-a,y:i.y-a,width:i.width+2*a,height:i.height+2*a},e,"rect")}function Gc(t,e){return{type:"group",key:"viz-focus",interactive:!1,aria:{hidden:!0},children:Ic(t,e)}}function qc([t,e],n){if(!n)return[t,e];let i=t,o=e;if(n.rotate){const[t,e]=n.rotateAnchor??[0,0],r=n.rotate*Math.PI/180,a=Math.cos(r),s=Math.sin(r),c=i-t,l=o-e;i=t+c*a-l*s,o=e+c*s+l*a}const r=n.scale??1;return[i*r+(n.x??0),o*r+(n.y??0)]}const Vc=([t,e])=>({x:t,y:e,width:0,height:0});function Kc(t){switch(t.type){case"rect":case"image":return[{x:t.x,y:t.y,width:t.width,height:t.height}];case"circle":return[{x:t.cx-t.r,y:t.cy-t.r,width:2*t.r,height:2*t.r}];case"path":{const e=u.path2polygon(t.d,10);return e.length?e.map(Vc):[u.pathBounds(t.d)]}case"line":return t.points.map(Vc);case"area":return[...t.topline,...t.baseline].map(Vc);case"text":return function(t){if(t.path)return a.pathTextBoxes(t).map(e=>{const n=a.rotatedBoxBounds(e);return{...n,x:t.x+n.x,y:t.y+n.y}});const e=t.font?.size??0,n=t.font?.baseline??"alphabetic",i="hanging"===n?0:"middle"===n?e/2:.8*e;return(t.lines||[]).filter(t=>t.text&&t.width).map(n=>({x:t.x+a.lineLeft(n,t.font),y:t.y+n.y-i,width:n.width,height:e}))}(t);default:return[]}}function Yc(t){return e=>t.reduceRight((t,e)=>qc(t,e),e)}function Uc(t,e){if(0===t.width&&0===t.height){const[n,i]=e([t.x,t.y]);return{x:n,y:i,width:n-n,height:i-i}}const n=[e([t.x,t.y]),e([t.x+t.width,t.y]),e([t.x,t.y+t.height]),e([t.x+t.width,t.y+t.height])],i=n.map(t=>t[0]),o=n.map(t=>t[1]),r=Math.min(...i),a=Math.min(...o);return{x:r,y:a,width:Math.max(...i)-r,height:Math.max(...o)-a}}function Xc(t,e,n,i=!1){const o=[],r=(t,e)=>{for(const a of t){if(String(a.key).endsWith("::hit")||n&&n(a))continue;const t=a.transform?[...e,a.transform]:e;if("group"===a.type){r(a.children,t);continue}if(!i&&void 0===a.datum)continue;const s=Yc(t);for(const t of Kc(a))[t.x,t.y,t.width,t.height].every(Number.isFinite)&&o.push(Uc(t,s))}};return r(t,e?[e]:[]),o}const Qc={"viz-chart-cells":"shape","viz-legend":"legend"},Zc=new Set(["axis","timeline","trend"]);function Jc(t){const e=t;return String(e.key).endsWith("::hit")||!1===e.interactive||!!e.aria?.hidden||void 0!==e.interactionGroup&&Zc.has(e.interactionGroup)}function tl(t){const e=t;return e&&e.data?e.data:e}const el=([t,e],n)=>t>=n.x-1&&t<=n.x+n.width+1&&e>=n.y-1&&e<=n.y+n.height+1,nl=t=>[t.x,t.y,t.width,t.height].every(Number.isFinite);function il(t,e,n,i){const o=Yc(e),r=[];return(t.interactionPoints||[]).forEach((a,s)=>{if(i.has(a.datum))return;i.add(a.datum);const c=o([a.x,a.y]),l={x:c[0],y:c[1],width:0,height:0};if(!nl(l))return;const h=`${t.key}@${s}`;r.push({id:h,node:t,pointIndex:s,center:c,box:l,group:n,chain:e})}),r}function ol(t,e,n){const i=Yc(t.transform?[...e,t.transform]:e),o=Kc(t).filter(nl).map(t=>Uc(t,i));if(!o.length)return null;const r=function(t){const e=Math.min(...t.map(t=>t.x)),n=Math.min(...t.map(t=>t.y));return{x:e,y:n,width:Math.max(...t.map(t=>t.x+t.width))-e,height:Math.max(...t.map(t=>t.y+t.height))-n}}(o),a="path"===t.type?[o.reduce((t,e)=>t+e.x,0)/o.length,o.reduce((t,e)=>t+e.y,0)/o.length]:[r.x+r.width/2,r.y+r.height/2];return{id:String(t.key),node:t,center:a,box:r,group:n,chain:e}}function rl(t){return[...t].sort((t,e)=>Math.round(t.box.x)-Math.round(e.box.x)||Math.round(t.box.y)-Math.round(e.box.y))}function al(t){const e={shape:[],legend:[]};for(const n of t){const t=Qc[String(n.key)];if(!t)continue;const i=new Set,o=(n,r,a)=>{if(Jc(n))return;if("group"===n.type){const t=n.transform?[...r,n.transform]:r,e=n.clip,i=e&&"rect"===e.type?[...a,Uc(e,Yc(t))]:a;for(const e of n.children)o(e,t,i);return}if(!ze.has(n.type)||void 0===n.datum)return;if(0===n.paint?.opacity)return;const s=t=>a.every(e=>el(t.center,e));if(n.interactionPoints?.length){const o=il(n,r,t,i);return void e[t].push(...o.filter(s))}const c=tl(n.datum);if(i.has(c))return;const l=ol(n,r,t);l&&s(l)&&(i.add(c),e[t].push(l))};o(n,[],[])}return[...rl(e.shape),...rl(e.legend)]}function sl(t,e,n){const i="x"===n?"width":"height";return Math.min(t[n]+t[i],e[n]+e[i])-Math.max(t[n],e[n])}function cl(t,e,n){if(!e)return t[0]??null;const i="left"===n||"right"===n,o="right"===n||"down"===n?1:-1,r=i?"y":"x",a=void 0!==e.pointIndex&&function(t){const e=t.interactionPoints||[],n=t=>Math.max(...e.map(e=>e[t]))-Math.min(...e.map(e=>e[t]));return n("x")>=n("y")?"x":"y"}(e.node)===(i?"x":"y");let s=null,c=1/0,l=null,h=1/0;for(const n of t){if(n.id===e.id)continue;const t=n.center[0]-e.center[0],u=n.center[1]-e.center[1],d=o*(i?t:u);if(d<=.5)continue;const f=a&&n.node===e.node||sl(n.box,e.box,r)>0?0:Math.abs(i?u:t);f<=d&&d+2*f<c&&(s=n,c=d+2*f);const m=Math.hypot(t,u);m<h&&(l=n,h=m)}return s??l??e}const ll="Use arrow keys to move between data points, Enter to select, and Escape to exit.",hl={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",border:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap"};function ul(t){return String(t??"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function dl(t){const{schema:e}=t,n=ul(e.svgTitle);if(n)return n;if("function"==typeof e.title)try{const n=ul(e.title(t._filteredData||[]));if(n)return n}catch{}return e.translate("Chart")}function fl(t,e){const n=t.ownerDocument,i=n.createElement("div");i.className="d3plus-keyboard-nav",i.setAttribute("tabindex","0"),i.setAttribute("role","application"),Object.assign(i.style,{position:"absolute",pointerEvents:"none",outline:"none"});const o=n.createElement("span");o.id=`${e}-keyboard-desc`;const r=n.createElement("span");r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true");for(const t of[o,r])Object.assign(t.style,hl),i.appendChild(t);return t.appendChild(i),{host:i,desc:o,live:r}}function ml(t,{host:e,desc:n}){const i=e=>t.schema.translate(e);e.setAttribute("aria-label",dl(t)),e.setAttribute("aria-roledescription",i("interactive chart"));const o=t.schema.svgDesc?`${t._uuid}-desc ${n.id}`:n.id;e.setAttribute("aria-describedby",o);const r=t._keyboardGesture?.keys()??null,a=i(ll);n.textContent=r?`${a} ${r.instructions}`:a,r?e.setAttribute("aria-keyshortcuts",r.shortcuts):e.removeAttribute("aria-keyshortcuts");const s=t._select?.node?.();Object.assign(e.style,{top:s?.style.top||"0px",left:s?.style.left||"0px",width:`${t.schema.width||0}px`,height:`${t.schema.height||0}px`})}function pl(t,e){const n=t;return{d:n&&n.data?n.data:n,i:n&&"number"==typeof n.i?n.i:e,x:t}}const gl={area:"Area",circle:"Circle",line:"Line",path:"Path",rect:"Rect"};function yl(t){return"string"==typeof t.shapeType?t.shapeType:gl[t.type]}const xl={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function bl(t){return al(t._paintedScene?.root.children??[])}function kl(t,e){return e.find(e=>e.id===t.current)??null}function _l(t){const{node:e,pointIndex:n}=t,i=void 0!==n?e.interactionPoints?.[n]:void 0;return i?pl(i.datum,i.index):pl(e.datum,e.index??0)}function vl(t,e){const{node:n,pointIndex:i}=e;if(void 0!==i?n.interactionPoints?.[i]:void 0){const i=t.schema.shapeConfig||{},o=n.shapeType&&i[n.shapeType]?.ariaLabel||i.ariaLabel;if("function"==typeof o)try{const{d:t,i:n}=_l(e),i=o(t,n);if(i)return String(i)}catch{}}else if(n.aria?.label)return n.aria.label;const{d:o,i:r}=_l(e);return void 0===o?"":String(t._drawLabel(o,r)??"")}function wl(t,e){const n=t.schema.keyboardNavConfig||{},{d:i,i:o}=_l(e),r=(t,e)=>{const n="function"==typeof t?t(i,o):t;return null==n?e:n};return{stroke:r(n.stroke,Oc(t)),strokeWidth:r(n.strokeWidth,2),padding:r(n.padding,2),halo:Tc(t)}}function Ml(t,e,n){if(e.queue.push(n),void 0!==e.timer)return;const i=()=>{e.timer=void 0;const n=(t._transitionEndsAt??0)-Date.now();if(n>0)return void(e.timer=setTimeout(i,n+5));const o=e.queue.splice(0);for(const t of o)t()};i()}function Sl(t,e,n,i={}){const o=n??i.at,r=o?[...o.center]:[0,0],a=t._select?.node?.(),s=a?.getBoundingClientRect?.()??{left:0,top:0},c=new MouseEvent(i.nativeType??e,{clientX:s.left+r[0],clientY:s.top+r[1],shiftKey:!!i.shiftKey}),l={type:e,point:r,pick:n?{node:n.node,datum:n.node.datum,index:n.node.index}:null,nativeEvent:c};t._routeSceneEvent?.(l)}function Cl(t,e,n){const i=e.hovered;i&&i.node.key===n.node.key||(i&&Sl(t,"mouseleave",null,{nativeType:"mousemove",at:n}),Sl(t,"mouseenter",n)),Sl(t,"mousemove",n),e.hovered=n}function $l(t,e){const n=e.hovered;n&&(e.hovered=null,Sl(t,"mouseleave",null,{at:n}))}function Al(t,e){const{host:n}=e;let i=n.ownerDocument.activeElement===n&&!e.current;if(i)try{i=n.matches(":focus-visible")}catch{}n.style.outline=i?`2px solid ${Oc(t)}`:"none",n.style.outlineOffset=i?"-2px":""}function zl(t,e,n,i=!0){e.current=n.id,e.chartScene=t._chartScene,e.zoom=t._zoomTransform;const o=vl(t,n);e.live.textContent!==o&&(e.live.textContent=o),Ml(t,e,()=>{Cl(t,e,n),i&&t._scheduleSceneRepaint()}),Al(t,e)}function Dl(t,e){const n=null!==e.current;e.current=null,Ml(t,e,()=>{$l(t,e),n&&t._scheduleSceneRepaint()}),Al(t,e)}function Ll(t,e,n){const i=n;if(i.altKey||i.ctrlKey||i.metaKey)return;if(t._keyboardGesture?.keydown(i))return void i.preventDefault();const{key:o}=i,r=bl(t),a=kl(e,r),s=function(t,e,n){return xl[t]?cl(e,n,xl[t]):"Home"===t?e[0]??null:"End"===t?e[e.length-1]??null:void 0}(o,r,a);if(void 0!==s)i.preventDefault(),s&&zl(t,e,s);else if(!a||"Enter"!==o&&" "!==o)a&&"Escape"===o&&(i.preventDefault(),Dl(t,e));else{i.preventDefault();const n=i.shiftKey;Ml(t,e,()=>{Cl(t,e,a),Sl(t,"click",a,{shiftKey:n})})}}function Fl(t){const e=t._keyboardNav;if(e){t._keyboardNav=void 0,void 0!==e.timer&&clearTimeout(e.timer),e.queue=[],$l(t,e);for(const[t,n]of e.listeners)e.host.removeEventListener(t,n);e.host.remove()}}function Nl(t,e){const n={...fl(e,t._uuid),current:null,hovered:null,stale:!1,queue:[],listeners:[]};n.listeners=[["keydown",e=>Ll(t,n,e)],["focus",()=>function(t,e){if(!e.current){const n=bl(t)[0];n&&zl(t,e,n)}Al(t,e)}(t,n)],["blur",()=>Dl(t,n)]];for(const[t,e]of n.listeners)n.host.addEventListener(t,e);return n}function Bl(t){const e=t.schema.keyboardNav?function(t){const e=t._select?.node?.(),n=e?.parentNode;return n&&1===n.nodeType&&"http://www.w3.org/1999/xhtml"===n.namespaceURI?n:null}(t):null;if(!e)return void Fl(t);let n=t._keyboardNav;n&&n.host.parentNode!==e&&(Fl(t),n=void 0),n||(n=t._keyboardNav=Nl(t,e)),ml(t,n);const i=t._chartScene!==n.chartScene||t._zoomTransform!==n.zoom;if(n.current&&i&&(n.stale=!0),n.stale){n.stale=!1;const e=n.current?kl(n,bl(t)):null;e?zl(t,n,e,!1):Dl(t,n)}}function El(t,e){const n=t._keyboardNav;if(!n||!n.current)return;const i=al(e);let o=kl(n,i);o||(o=i[0]??null,n.current=o?o.id:null,n.stale=!0),o&&e.push(Gc(o,wl(t,o)))}const Rl=t=>t&&"function"!=typeof t?G(t):t,Pl={aggs:{merge:!0},ariaHidden:{},attribution:{},attributionIcon:{},attributionStyle:{merge:!0},backControlClassName:{},backControlStyle:{},cache:{},color:{coerce:Rl},colorOrdinal:{default:!1},colorScale:{coerce:t=>function(t){return Array.isArray(t)&&2===t.length&&t.every(t=>"string"==typeof t||"function"==typeof t)}(t)?function(t){const e=t.map(t=>"function"==typeof t?t:G(t)),n=(t,n)=>{const i=Rc(e[0](t,n)),o=Rc(e[1](t,n));return null===i||null===o?void 0:[i,o]};return Ec.set(n,{accessors:e,fields:t.map(t=>"string"==typeof t?t:void 0)}),n}(t):Rl(t)},colorScaleConfig:{merge:!0},colorScaleMaxSize:{},colorScalePadding:{coerce:"const"},colorScalePosition:{coerce:"const"},dataCutoff:{},dataFormat:{},dataPollingInterval:{onSet:t=>function(t){(t._dataPollStop||t._sceneRenderer)&&(t._queue?.some(t=>"data"===t[3])||pn(t))}(t)},depth:{},detectResize:{},detectResizeDelay:{},detectVisible:{},detectVisibleInterval:{},detectVisibleUnload:{},discrete:{},duration:{},filter:{},height:{},hiddenColor:{coerce:"const"},hiddenOpacity:{coerce:"const"},hoverDistance:{default:20},keyboardNav:{default:!0,onSet:(t,e)=>{e||Fl(t)}},keyboardNavConfig:{merge:!0,default:{padding:2,strokeWidth:2}},label:{coerce:"const"},labelPosition:{coerce:"const",default:"auto"},legend:{coerce:"const"},legendConfig:{merge:!0},legendFilterInvert:{coerce:"const"},legendHistory:{default:!0},legendInset:{},legendInsetConfig:{merge:!0},legendPadding:{coerce:"const"},legendPosition:{coerce:"const"},legendSort:{},legendTooltip:{merge:!0},link:{onSet:t=>Re(t)},loadingHTML:{coerce:"const"},loadingMessage:{},messageMask:{},messageStyle:{merge:!0},minimap:{},minimapClassName:{},minimapLabelStyle:{},minimapStyle:{},minimapViewportStyle:{},minimapViewportStyleActive:{},noDataHTML:{coerce:"const"},noDataMessage:{},pointLabelConfig:{merge:!0,default:{fontMin:10,fontSize:11,padding:3}},reducedMotion:{},saveControl:{},saveControlClassName:{},saveControlConfig:{merge:!0},saveControlMenuClassName:{},saveControlMenuItemStyle:{},saveControlMenuItemStyleHover:{},saveControlMenuStyle:{},saveControlStyle:{},saveControlStyleActive:{},saveControlStyleHover:{},scrollContainer:{},search:{},searchAccessor:{},searchControlClassName:{},searchControlStyle:{},searchControlStyleActive:{},searchControlStyleHover:{},shape:{coerce:"const"},sizeLegend:{coerce:"const"},sizeLegendConfig:{merge:!0},sizeLegendPosition:{},subtitle:{coerce:"const"},subtitleConfig:{merge:!0},subtitlePadding:{coerce:"const"},svgDesc:{},svgTitle:{},tableView:{},tableViewClassName:{},tableViewControlClassName:{},tableViewControlStyle:{},tableViewControlStyleActive:{},tableViewControlStyleHover:{},tableViewDownload:{},tableViewPageSize:{},tableViewSort:{},theme:{},thresholdName:{coerce:"const"},timeFilter:{},timeline:{},timelineConfig:{merge:!0},timelinePadding:{coerce:"const"},title:{coerce:"const"},titleConfig:{merge:!0},titlePadding:{coerce:"const"},tooltip:{coerce:"const"},tooltipConfig:{merge:!0},totalConfig:{merge:!0},totalFormat:{},totalPadding:{coerce:"const"},width:{},zoom:{},zoomBrushHandleSize:{},zoomBrushHandleStyle:{},zoomBrushSelectionStyle:{},zoomControlClassName:{},zoomControlIcons:{},zoomControls:{},zoomControlStyle:{},zoomControlStyleActive:{},zoomControlStyleHover:{},zoomDoubleClick:{},zoomDrag:{},zoomFactor:{},zoomMax:{},zoomPadding:{},zoomPan:{},zoomScroll:{}},Tl=Object.entries(Pl).map(([t,e])=>({key:t,...e}));function Ol(t){if(!["string","number","boolean"].includes(typeof t))return;const e=`${t}`;return""===e||i.color(e)?void 0:e}function Wl(t,e){if(t._legendCategories&&e){for(;e.__d3plus__&&e.data;)e=e.data;return t._legendCategories.get(e)}}function jl(t,e){return Wl(this,t)??this._drawLabel(t,e,this._legendDepth)}function Hl(t){return a.isFlipEligible(t)?"rect"===t.type?{x:t.x,y:t.y,width:t.width,height:t.height}:"circle"===t.type?{x:t.cx-t.r,y:t.cy-t.r,width:2*t.r,height:2*t.r}:"area"===t.type?u.pathBounds(a.areaPath(t)):"path"===t.type?u.pathBounds(t.d):null:null}function Il(t,e){for(const n of t){if(a.isFlipEligible(n)&&e(n))return n;if("group"===n.type&&n.children.length){const t=Il(n.children,e);if(t)return t}}}function Gl(t){const e=t._pendingEnterOrigin;if(t._pendingEnterOrigin=void 0,e&&t._bodyRect){const n=t._bodyRect;t._resolvedEnterFrom={x:n.x+e.fx*n.width,y:n.y+e.fy*n.height,width:e.fw*n.width,height:e.fh*n.height},t._resolvedEnterFromBody=n,t._resolvedInstantExitKey=e.key}else t._resolvedEnterFrom=void 0,t._resolvedEnterFromBody=void 0,t._resolvedInstantExitKey=void 0;const n=t._pendingExitReunion;if(t._pendingExitReunion=void 0,n&&t._chartScene){const e=t.schema.groupBy?.[n.groupDepth],i=e?Il(t._chartScene,t=>{const i=function(t){const e=t;return e&&e.data?e.data:e}(t.datum);return void 0!==i&&e(i,function(t,e){const n=t;return n&&"number"==typeof n.i?n.i:e??0}(t.datum,t.index))===n.groupId}):void 0;t._resolvedExitTo=i?Hl(i)??void 0:void 0,t._resolvedExitToBody=n.body,t._resolvedReunionEnterKey=i?.key,t._resolvedReunionEnterFrom=i?n.body:void 0,t._resolvedInstantExitAll=Boolean(i)}else t._resolvedExitTo=void 0,t._resolvedExitToBody=void 0,t._resolvedReunionEnterKey=void 0,t._resolvedReunionEnterFrom=void 0,t._resolvedInstantExitAll=void 0}function ql(t){return(t._sceneRenderer?.elements?.()??[]).find(t=>"canvas"===t.localName)}function Vl(t,e){const n="canvas"===t._renderer?ql(t):void 0;n?n.style.cursor=e:t._select?.style("cursor",e)}function Kl(t,e,n=!1){const i=t.schema.groupBy,o=Math.max(0,(i?.length??1)-1),r=(n?t._legendDepth:ge(e)??(e?t._shapeDepth?.(e):void 0))??t._drawDepth??0;return{depth:Math.min(Math.max(r,0),o),maxDepth:o,legend:n}}function Yl(t,e,n,i=!1){const{schema:o}=t;return"function"!=typeof o.tooltip?Boolean(o.tooltip):Boolean(o.tooltip(e,n,Kl(t,e,i)))}function Ul(t,e,n,i){i.stopPropagation();const o=ge(t);if(void 0===o){if(this._drawDepth<this.schema.groupBy.length-1){Vl(this,"auto");const n=this.schema.groupBy[this._drawDepth],i=n(t,e);this.hover(!1),Yl(this,t,e)&&this._tooltipClass.data([]).render();const o=this.schema.filter,r=this._lastScenePick?.node,a=r&&Hl(r);if(a&&this._bodyRect&&this._bodyRect.width&&this._bodyRect.height){const t=this._bodyRect;this._pendingEnterOrigin={fx:(a.x-t.x)/t.width,fy:(a.y-t.y)/t.height,fw:a.width/t.width,fh:a.height/t.height,key:r.key,parentStartAngle:r.startAngle,parentEndAngle:r.endAngle}}const s=$e(this);this._history.push({depth:this.schema.depth,filter:o,groupId:i,groupDepth:this._drawDepth,...s&&{legend:s}});const c=Array.isArray(i)?t=>i.includes(t):t=>t===i;this.config({depth:this._drawDepth+1,filter:(t,e)=>(!o||o(t,e))&&c(n(t,e))}).render()}}else!function(t,e,n){const i=t.schema.groupBy,o=ye(i,e,n);if(!be(i,o,t._filteredData??[]))return;Vl(t,"auto"),t.hover(!1),t._tooltipClass.data([]).render();const r=t.schema.filter;t._history.push({depth:t.schema.depth,filter:r}),t.config({filter:(t,e)=>(!r||r(t,e))&&xe(i,o,t,e)}).render()}(this,t,o)}function Xl(t,e,n,i){Vl(this,"auto"),Yl(this,t,e,!0)&&this._tooltipClass.data([]).render();let o=this._id(t,e);o instanceof Array||(o=[o]);const r=this._hidden.indexOf(o[0]),a=this._solo.indexOf(o[0]),s=d.merge(this._legendClass.data().map((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),n})).length,c=this.schema.legendFilterInvert.bind(this)(this),l=this,h=Me(l),u=()=>{Se(l,h),Ke(l),this.render()};c?i.shiftKey?r<0&&!this._solo.length?(this._hidden=this._hidden.concat(o),a>=0&&(this._solo=[]),this._hidden.length===s&&(this._hidden=[]),u()):a>=0&&(this._solo=[],this._hidden=[],u()):(a<0&&this._hidden.length<s-1?(this._solo=o,this._hidden=[]):(this._solo=[],this._hidden=[]),u()):i.shiftKey&&a<0?(this._solo=o,this._hidden=[],u()):i.shiftKey||(r>=0?this._hidden=this._hidden.filter(t=>!o.includes(t)):a>=0?(this._solo=[],this._hidden=[]):this._solo.length&&a<0?(this._solo=this._solo.concat(o),this._solo.length===s&&(this._solo=[])):(this._hidden=this._hidden.concat(o),this._hidden.length===s&&(this._hidden=[])),u())}const Ql=new WeakMap;function Zl(t,e,n){let i=Ql.get(t);i||Ql.set(t,i=new Map),i.set(e,n)}function Jl(t,e){const n=t.schema.on?.[e];return Boolean(n)&&Ql.get(t)?.get(e)===n}function th(t,e){const n=t.schema.on??{};return Boolean(n.click)||Boolean(n[e])&&!Jl(t,e)}const eh=new WeakMap,nh=new WeakMap;function ih(t){let e=eh.get(t);return e||eh.set(t,e=new WeakMap),e}function oh(t){return"number"==typeof t&&Number.isFinite(t)}function rh(t,e,n){ih(t).set(e,n)}function ah(t){const e=t.schema.linkColor,n=t.schema.links;if("function"!=typeof e||!Array.isArray(n))return[];const i=t.schema.nodes,o=nh.get(t);if(o&&o.links===n&&o.nodes===i&&o.accessor===e)return o.rows;const r=Array.isArray(i)?i:[],a=new Map;for(const t of r)t&&"object"==typeof t&&void 0!==t.id&&!a.has(`${t.id}`)&&a.set(`${t.id}`,t);const s=ih(t),c=[];return n.forEach((t,n)=>{if(!t||"object"!=typeof t)return;const i=e(function(t,e,n){const i=t=>t&&"object"==typeof t?t:n.get(`${t}`)??("number"==typeof t?e[t]:void 0)??{id:t};return{...t,source:i(t.source),target:i(t.target)}}(t,r,a),n);oh(i)&&(s.set(t,i),c.push(t))}),nh.set(t,{links:n,nodes:i,accessor:e,rows:c}),c}function sh(t){const e="function"==typeof t.schema.colorScale?t.schema.colorScale:void 0;if(!ah(t).length)return e;const n=ih(t);return(t,i)=>t&&"object"==typeof t&&n.has(t)?n.get(t):e?e(t,i):void 0}function ch(t,e){const n=t._colorScaleClass;if(!n)return;const i=n._colorScale,o=n.color();return i?i.domain().length?i(e):i.range()[i.range().length-1]:Array.isArray(o)?o[o.length-1]:o}function lh(t){const e=t._colorScaleClass,n=sh(t);if(!e||"function"!=typeof e._colorScale||!n)return null;const i=e._colorScale;return{rows:Array.isArray(e._data)?e._data:[],colorOf:(t,e)=>{let o=t;for(;o&&o.__d3plus__&&o.data;)o=o.data;return o&&o._isColorScaleBucket?o.color:i(n(o,e))}}}function hh(t,e,n){const i=lh(t);if(!i)return null;let o=0,r=0;return i.rows.forEach((t,a)=>{const s=n(t,a);Number.isFinite(s)&&(o+=s,i.colorOf(t,a)===e&&(r+=s))}),o?r/o:null}function uh(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e&&e._isColorScaleBucket?e:null}function dh(t,e){const n=uh(e);if(!n)return!1;const i=function(t,e){const n=lh(t);return n?(t,i)=>n.colorOf(t,i)===e:null}(t,n.color);return i&&(t._hoverBucket=!0,t.hover?.(i)),!0}function fh(t,e){if((!this._sharedHoverActive||"shared"!==this._sharedHoverState?.mode)&&!dh(this,t)&&(this._hoverBucket=!1,(!this._sharedHoverActive||!this._plotColumnHighlight)&&Ye(this))){const n=ge(t);if(void 0!==n){const e=this.schema.groupBy,i=ye(e,t,n);return void this.hover((t,n)=>xe(e,i,t,n))}let i=this._id(t,e);i instanceof Array||(i=[i]),this.hover((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),i.some(t=>n.includes(t))})}}function mh(t,e){return"function"==typeof t?function(){return t.apply(this,e)}:Array.isArray(t)?t.map(t=>mh(t,e)):it(t)?Object.fromEntries(Object.entries(t).map(([t,n])=>[t,mh(n,e)])):t}function ph(t,e=!0,n){const{option:i,part:o,value:r,index:a}=t;if(!1===i)return null;const s=!(!t.truncated||!e)&&t.text,c="title"===o?[r]:[r,a];if(it(i))return{title:s,body:!1,config:mh(i,c)};const l="function"==typeof i?i.apply(n,c):"string"==typeof i?i:void 0;if(!1===l)return null;const h=!!(t=>null!=t&&!1!==t&&""!==t)(l)&&`${l}`;return!1===s&&!1===h?null:{title:s,body:h}}const gh=new WeakSet;function yh(t){return"object"==typeof t&&null!==t&&gh.has(t)}function xh(t,e){if(!t._tooltipClass)return!1;const n="mousemove"===e.type||"mouseenter"===e.type;if(!n&&"mouseleave"!==e.type)return!1;const i=!t._transitionEndsAt||Date.now()>=t._transitionEndsAt,o=n&&i?kr(e.pick?.node):void 0,r=!1!==j(t.schema.tooltip)?.value,a=o&&ph(o,r,t);return o&&a?(function(t,e,n,i){const o=t._tooltipClass,r=te.bind(t),{part:a,value:s,index:c,text:l}=e,h={part:a,value:s,index:c,text:l};gh.add(h);const u={...o.schema};o.data([h]).config(r(t.schema.tooltipConfig)).title(n.title).body(n.body).footer(!1).thead([]).tbody([]).position(function(t){const e=t.nativeEvent;return e&&e.touches&&e.touches.length?[e.touches[0].clientX,e.touches[0].clientY]:e?[e.clientX,e.clientY]:t.point}(i)),n.config||!1!==n.body||o.titleStyle({"margin-bottom":"0"}),n.config&&o.config(r(n.config)),o.render();for(const t of Object.keys(o.schema))t in u||delete o.schema[t];Object.assign(o.schema,u)}(t,o,a,e),!0):(function(t){return yh(t._tooltipClass?.data()[0])}(t)&&t._tooltipClass.data([]).render(),!1)}function bh(t,e){if(!Array.isArray(t)&&!Array.isArray(e))return t===e;const n=new Set([].concat(t)),i=new Set([].concat(e));return n.size===i.size&&[...n].every(t=>i.has(t))}function kh(t,e){const n=Boolean(this._lastScenePick?.isLegend);setTimeout(()=>{let i=t;for(;i&&i.__d3plus__&&i.data;)i=i.data;if(!i)return;let o=this._hoverDatum;for(;o&&o.__d3plus__&&o.data;)o=o.data;if(o&&bh(this._id(o),this._id(i)))return;if(this._sharedHoverActive)return;Ye(this)&&this._hover&&!this._hover(t,e)||this.hover(!1);const r=this._tooltipClass.data();if(r.length&&!yh(r[0])&&Yl(this,t,e,n)){let t=r[0];for(;t.__d3plus__&&t.data;)t=t.data;bh(this._id(t),this._id(i))&&this._tooltipClass.data([]).render()}},0),Vl(this,"auto")}const _h="__d3plusShare",vh="__d3plus",wh=new WeakSet;function Mh(t,e){t[_h]=e,(void 0===t.share||wh.has(t))&&(t.share=e,wh.add(t))}function Sh(t){return t?t[_h]:void 0}function Ch(t){const e=Sh(t);return Array.isArray(e)?e.reduce((t,e)=>t+e,0):"number"==typeof e?e:NaN}function $h(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function Ah(t,e,n){let i=0;for(const t of e)i+=Math.abs(+n(t))||0;return i>0?Math.abs(+n(t))/i:NaN}function zh(t){return t.startsWith(vh)}const Dh=`${vh}Members`;function Lh(t,e,n,i){const o=new Map;return t.forEach((t,r)=>{const a=`${e(t,r)}`,s=+i(t,r)||0,c=o.get(a);c?c.value+=s:o.set(a,{label:`${n(t,r)}`,value:s})}),Array.from(o.values()).sort((t,e)=>e.value-t.value)}const Fh=t=>`<span class="d3plus-tooltip-member" style="padding-left: 12px">${t}</span>`;function Nh(t,e,n=10){const i=function(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;const n=e?e[Dh]:void 0;return n?Array.isArray(n)?n:[n]:[]}(e);if(!i.length)return[];const o=t._thresholdMemberFormat??(e=>p.formatAbbreviate(e,t.schema.locale)),r=i.slice(0,n).map(t=>[Fh(t.label),o(t.value)]),a=i.slice(n);return a.length&&r.push([Fh(`+${p.formatAbbreviate(a.length,t.schema.locale)} ${t.schema.translate("more")}`),o(a.reduce((t,e)=>t+e.value,0))]),r}function Bh(t,e,n){const i=Nh(e,n);if(!i.length)return t;const o=t.tbody();return t.tbody((t,e)=>{const n="function"==typeof o?o(t,e):o;return[...Array.isArray(n)?n:[],...i]}),t}const Eh=10,Rh="display: inline-block; flex: none; margin-right: 6px; width: 10px; height: 10px;";function Ph(t,e){if(!t)return"";if("Line"===e){const e=6;return`<span class="d3plus-tooltip-swatch d3plus-tooltip-swatch-line" style="${Rh} position: relative"><span style="position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: ${t}"></span><span style="position: absolute; left: ${(Eh-e)/2}px; top: ${(Eh-e)/2}px; width: ${e}px; height: ${e}px; border-radius: 50%; background: ${t}"></span></span>`}return`<span class="d3plus-tooltip-swatch" style="${Rh} border-radius: ${"Circle"===e?"50%":"1px"}; background: ${t}"></span>`}function Th(t,e){return t?null==e||!1===e||""===e?"":`<span style="display: inline-flex; align-items: center">${t}<span>${e}</span></span>`:`${e}`}const Oh=t=>"string"==typeof t&&"none"!==t&&"transparent"!==t?t:void 0;function Wh(t,e){for(const n of t){if(n.key===e)return n;const t=n.children&&Wh(n.children,e);if(t)return t}}const jh=["::hit","::confidence","::stem"];function Hh(t,e){const n=e&&e.key;if("string"!=typeof n)return e;let i=n;for(const t of jh)for(;i.endsWith(t);)i=i.slice(0,-t.length);return i===n?e:Wh(t._chartScene||[],i)||e}function Ih(t,e){const n=Hh(t,e);return n&&Gh(n)}function Gh(t){const e=t.paint;if(e)return"Line"===t.shapeType?Oh(e.stroke)??Oh(e.fill):Oh(e.fill)??Oh(e.stroke)}const qh=t=>!!t.paint&&"Label"!==t.shapeType&&"text"!==t.type,Vh=t=>t.shapeType??("circle"===t.type?"Circle":void 0);function Kh(t){let e=t;for(;e&&"object"==typeof e&&e.data&&"object"==typeof e.data&&!Array.isArray(e.data);)e=e.data;return e}function Yh(t,e,n){for(const i of t){if(qh(i)&&!`${i.key}`.endsWith("::hit")&&"legend"===i.interactionGroup===n&&Kh(i.datum)===e&&Gh(i))return i;const t=i.children&&Yh(i.children,e,n);if(t)return t}}function Uh(t,e){if(!e||!e.node)return"";const n=e.node,i=qh(n)?Ih(t,n):void 0;if(i&&!e.isLegend)return Ph(i,Vh(n));const o=t._paintedScene?.root,r=i?n:o&&Yh([o],Kh(e.d),!!e.isLegend);if(!r)return"";const a=r.datum?.shape;return Ph(Ih(t,r),e.isLegend&&"string"==typeof a?a:Vh(r))}function Xh(t,e){if(!e||!1===t.schema.titleSwatch)return t;const n=t.schema.title;return t.title((t,i)=>Th(e,n(t,i)))}function Qh(t,e,n,i){const o=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY],r=d.merge(this._legendClass.data().map((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),n})).length;if(!t)return;let a=this._id(t,e);a instanceof Array&&(a=a[0]);const s=this.schema.translate,c=th(this,"click.legend"),l=Jl(this,"click.legend"),h=this._drawDepth<this.schema.groupBy.length-1;if(Vl(this,c||l&&h?"pointer":"auto"),!Yl(this,t,e,!0))return;const u=this.schema.legendFilterInvert.bind(this)(this),f=this._solo.includes(a),m=this._hidden.includes(a);this._tooltipClass.data([n||t]).footer(!!l&&(u?this._solo.length&&!f||m?s("Click to Highlight"):1===this._solo.length&&f||this._hidden.length===r-1?s("Click to Show All"):`${s("Click to Highlight")}<br />${s("Shift+Click to Hide")}`:this._solo.length&&!f||m?`${s("Click to Show")}<br />${s("Shift+Click to Highlight")}`:1===this._solo.length&&f||this._hidden.length===r-1?s("Click to Show All"):`${s("Click to Hide")}<br />${s("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():jl.bind(this)).titleSwatch(!0).position(o).config(te.bind(this)(this.schema.tooltipConfig)).config(te.bind(this)(this.schema.legendTooltip)),Bh(this._tooltipClass,this,t),Xh(this._tooltipClass,Uh(this,this._lastScenePick)).render()}function Zh(t){const e=t._colorScaleClass?.schema.axisConfig?.title;return"string"==typeof e&&e?e:q(t.schema.colorScale)??t.schema.translate("Value")}function Jh(t,e,n){const i=t._colorScaleClass,o=t.schema.colorScale;if(!1===t._colorScaleTooltip||!i)return[];if(r=t,a="tooltipConfig",s="tbody",Boolean(mt.get(r)?.get(a)?.has(s)))return[];var r,a,s;if("function"!=typeof o||!e||"object"!=typeof e)return[];if(e._isColorScaleBucket)return[];if(Pc(t))return function(t,e,n){const i=Pc(t),o=t._colorScaleClass;if(!i||!o||!e||"object"!=typeof e)return[];if(e._isColorScaleBucket)return[];const r=Hs(o),a=o._colorScale,s="function"==typeof a?.domain?a.domain():[],c=[];return i.accessors.forEach((t,i)=>{const a=Rc(t(e,n));if(null===a)return;const l=s.map(t=>Array.isArray(t)?t[i]:NaN);c.push([r[i],Is(o,l)(a)])}),c}(t,e,n);const c=Rc(o(e,n));if(null===c)return[];const l=i.schema.value,h=(i._data??[]).map((t,e)=>l(t,e)).filter(t=>"number"==typeof t);return[[Zh(t),Is(i,h)(c)]]}const tu=new WeakMap;function eu(t){if(!t)return null;const{touches:e,changedTouches:n}=t,i=e?.[0]??n?.[0]??t;return"number"==typeof i.clientX&&"number"==typeof i.clientY?[i.clientX,i.clientY]:null}function nu(t,e){if(!e)return!1;if("wheel"===e.type||"touchmove"===e.type)return!0;if("mousemove"!==e.type)return!1;const n=eu(e);return!t||!n||n[0]!==t[0]||n[1]!==t[1]}function iu(t){return!!t._gestureHover?.moving}function ou(t,e){t._gestureHover={press:eu(e.sourceEvent),moving:!1}}function ru(t,e){const n=t._gestureHover;n&&!n.moving&&nu(n.press,e.sourceEvent)&&(n.moving=!0,function(t,e){t._nearestHover&&(t._nearestHover.key=null);const n=(t._zoomEventTarget||t._container)?.node(),i=eu(e),o=n?.getBoundingClientRect(),r=i&&o?[i[0]-o.left,i[1]-o.top]:[0,0];t._routeSceneEvent?.({type:"mouseleave",point:r,pick:null,nativeEvent:e});const a=t._tooltipClass;a&&a.data().length&&a.data([]).render()}(t,e.sourceEvent))}function au(t){t._gestureHover=void 0}function su(t,e){const n=t._facetPanels;if(!n||!n.length||!e)return;const i=t._zoomTransform,o=i&&i.scale?i.scale:1,r=(e[0]-(i?.x??0))/o,a=(e[1]-(i?.y??0))/o;return n.find(t=>{const e=t.cell;return r>=e.x&&r<=e.x+e.width&&a>=e.y&&a<=e.y+e.height})}function cu(t,e,n){if(!e)return n();const i=t,o=function(t){return{_chartScene:t.scene,_chartTransform:t.chartTransform,...t.state}}(e),r={};for(const t of Object.keys(o))r[t]=i[t],i[t]=o[t];try{return n()}finally{for(const t of Object.keys(o))i[t]===o[t]&&(i[t]=r[t])}}function lu(t,e){const n=t;for(const t of e)for(const e of Object.keys(t.state))n[e]=void 0}function hu(t,e,[n,i],[o,r]){const a=o-n,s=r-i,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((t-n)*a+(e-i)*s)/c)):0;return Math.hypot(t-(n+l*a),e-(i+l*s))}function uu(t,e,n){let i=!1,o=1/0;for(let r=0,a=n.length-1;r<n.length;a=r++){const[s,c]=n[r],[l,h]=n[a];c>e!=h>e&&t<(l-s)*(e-c)/(h-c)+s&&(i=!i),o=Math.min(o,hu(t,e,n[a],n[r]))}return i?0:o}function du(t,e){const n=t.map((t,e)=>e).filter(e=>Number.isFinite(t[e].x)&&Number.isFinite(t[e].y)),i=function(t,e){let n=e.x,i=e.y,o=e.x+e.width,r=e.y+e.height;for(const e of t)n=Math.min(n,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y);return{x:n,y:i,width:o-n,height:r-i}}(n.map(e=>t[e]),e),o=_.Delaunay.from(n,e=>t[e].x,e=>t[e].y),r=new Map(n.map((t,e)=>[t,e])),a=t=>Number.isFinite(t.r)?Math.max(0,t.r):0,s=n.reduce((e,n)=>Math.max(e,a(t[n])),0);let c;const l=t=>{const e=(c??(c=o.voronoi([i.x,i.y,i.x+i.width,i.y+i.height]))).cellPolygon(t);return e?e.slice(0,-1):null},h=t=>[...o.neighbors(t)].filter(t=>t>=0);return{points:t,bounds:i,nearest:(e,i,r=1/0)=>{if(!n.length||!Number.isFinite(e)||!Number.isFinite(i))return null;const c=o.find(e,i),u=o=>Math.hypot(t[n[o]].x-e,t[n[o]].y-i),d=r+s;if(u(c)>d)return null;let f=null,m=1/0;const p=new Set([c]),g=[c];for(;g.length;){const o=g.shift(),s=n[o],c=t[s],y=u(o),x=Math.max(0,y-a(c));x<=r&&(!f||x<f.distance||x===f.distance&&(y<m||y===m&&s<f.index))&&(f={index:s,point:c,distance:x},m=y);for(const t of h(o)){if(p.has(t))continue;p.add(t);const n=l(t);n&&uu(e,i,n)<=d&&g.push(t)}}return f},cell:t=>{const e=r.get(t);return void 0===e?null:l(e)},neighbors:t=>{const e=r.get(t);return void 0===e?[]:h(e).map(t=>n[t]).sort((t,e)=>t-e)}}}const fu=["Circle","Rect"];function mu(t,e=fu){const n=yl(t);return!!n&&e.includes(n)&&!t.owners?.length}function pu(t,e){return al(t).filter(t=>"shape"===t.group&&void 0===t.pointIndex&&e(t.node)).map(t=>({x:t.center[0],y:t.center[1],r:Math.min(t.box.width,t.box.height)/2,item:t}))}function gu(t){const e=Number(t.schema.hoverDistance);if(!(e>0&&t._pointMark))return 0;const n="x"===t.schema.discrete||"y"===t.schema.discrete;return t.schema.tooltipShared&&n?0:e}function yu(t,e){const n=t._paintedScene;if(e.index&&e.index.scene===n)return e.index;const i=pu(n?.root.children??[],e=>!!t._pointMark?.(e)),o=new Map;for(const e of i){const n=su(t,[e.x,e.y])?.key??"";o.has(n)||o.set(n,[]),o.get(n).push(e)}const r={x:0,y:0,width:Number(t.schema.width)||0,height:Number(t.schema.height)||0},a=new Map([...o].map(([t,e])=>[t,du(e,r)])),s=new Map(i.map(t=>[String(t.item.node.key),t.item]));return e.index={scene:n,panels:a,byKey:s},e.index}function xu(t,e){var n;if(!e||!gu(t)||!t._pointMark(e))return;const i=(n=t)._nearestHover??(n._nearestHover={key:null}),o=String(e.key).replace(/::hit$/,"");return yu(t,i).byKey.get(o)}function bu(t,e,n){var i;const o=gu(t);if(!o||!n)return e;if(e){const n=e.node;if(t._pointMark(n))return e;if(n.interactionGroup&&"axis"!==n.interactionGroup)return e;if("text"===n.type&&void 0!==n.datum)return e}const r=yu(t,(i=t)._nearestHover??(i._nearestHover={key:null})),a=t._facetPanels?.length?su(t,n):null;if(void 0===a)return e;const s=r.panels.get(a?.key??""),c=s?.nearest(n[0],n[1],o);if(!c)return e;const l=c.point.item.node;return{node:l,datum:l.datum,index:l.index}}function ku(t,e){var n;if(iu(t))return;const i=e=>t._routeSceneEvent?.(e),o=(n=t)._nearestHover??(n._nearestHover={key:null}),r=e.nativeEvent?.type,a="mousemove"===r;if("mouseenter"===e.type||"mouseleave"===e.type){if(a)return;const n=e.nativeEvent?.relatedTarget;if("mouseleave"===e.type&&o.surface?.aroundScene(n??null)&&gu(t))return;return o.key="mouseenter"===e.type&&e.pick?String(e.pick.node.key):null,void i(e)}const s=bu(t,e.pick,e.point),c=s===e.pick?e:{...e,pick:s};if("click"===e.type&&!s&&e.point&&t._backgroundClick?.(e.point),"mousemove"===e.type&&a){const t=s?String(s.node.key):null;if(t!==o.key){const{point:n,nativeEvent:r}=e;null!==o.key&&i({type:"mouseleave",point:n,pick:null,nativeEvent:r}),o.key=t,s&&i({type:"mouseenter",point:n,pick:s,nativeEvent:r})}}i(c)}function _u(t){const e=(t._sceneRenderer?.elements?.()??[]).find(t=>"svg"===t.localName||"canvas"===t.localName)??t._select?.node?.();if(!e)return{left:0,top:0};const n="svg"===e.localName&&"function"==typeof e.getScreenCTM?e.getScreenCTM():null;if(n)return{left:n.e,top:n.f};const i=e.getBoundingClientRect();return{left:i.left,top:i.top}}function vu(t,e){const n=e.left+t.x,i=e.top+t.y,o={x:n,y:i,left:n,top:i,right:n+t.width,bottom:i+t.height,width:t.width,height:t.height};return{getBoundingClientRect:()=>o}}function wu(t,e){const n=xu(t,e);return n?vu(n.box,_u(t)):void 0}function Mu(t,e,n,i){if(!t)return;const o=th(this,"click.shape"),r=Jl(this,"click.shape"),a=ge(t),s=void 0===a?this._drawDepth<this.schema.groupBy.length-1:be(this.schema.groupBy,ye(this.schema.groupBy,t,a),this._filteredData??[]);if(Vl(this,o||r&&s?"pointer":"auto"),!Yl(this,t,e))return;if(this._sharedHoverActive)return;const c=wu(this,this._lastScenePick?.node)??(i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY]);let l=n||t;for(;l&&l.__d3plus__&&l.data;)l=l.data;this._tooltipClass.data([l]).footer(!(!r||!s)&&this.schema.translate("Click to Expand")).title((t,e)=>this._drawLabel(t,e)).titleSwatch(!0).position(c).config(te.bind(this)(this.schema.tooltipConfig)),function(t,e,n,i){let o=t.tbody();"function"==typeof o&&tu.has(o)&&(o=tu.get(o),t.tbody(o));const r=Jh(e,n,i);if(!r.length)return t;const a=(t,e)=>{const n="function"==typeof o?o(t,e):o;return[...r,...Array.isArray(n)?n:[]]};tu.set(a,o),t.tbody(a)}(this._tooltipClass,this,l,e),Bh(this._tooltipClass,this,l),Xh(this._tooltipClass,Uh(this,this._lastScenePick)).render()}function Su(t){const e=i.color(t);return e?e.darker(.25).toString():t}function Cu(){return"undefined"==typeof window||window.innerWidth>600}const $u={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`400 12px/1 ${s.fontFamilyStringify(s.fontFamily)}`,gap:"4px",height:"20px","justify-content":"center",margin:0,padding:"0 6px",width:"auto"};function Au(t){const e={"click.shape":Ul.bind(t),"click.legend":Xl.bind(t)};for(const[n,i]of Object.entries(e))Zl(t,n,i);t.schema.on={...e,mouseenter:fh.bind(t),mouseleave:kh.bind(t),"mousemove.shape":Mu.bind(t),"mousemove.legend":Qh.bind(t)},t._queue=[];const n=e=>{const{width:n,height:i}=e[0].contentRect;(n!==t.schema.width&&t._autoWidth||i!==t.schema.height&&t._autoHeight)&&n&&i&&(t._setSVGSize(n,i),t._callback||t.render())},i=function(t,e){let n;return function(...i){const o=this;clearTimeout(n),n=setTimeout(()=>t.apply(o,i),e)}}(n,t.schema.detectResizeDelay);t._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(e=>{const{width:o,height:r}=e[0].contentRect;if(t._resizeSettled)i(e);else{if(!o||!r)return;t._resizeSettled=!0,n(e)}}),t.schema.scrollContainer="undefined"==typeof window?"":window}const zu="rgba(255, 255, 255, 0.7)",Du={"border-radius":"3px 0 0 0",display:"flex","align-items":"center",gap:"4px",font:`400 10px/1.4 ${s.fontFamilyStringify(s.fontFamily)}`,background:zu,color:e.colorContrast(zu)},Lu={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Fu={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Nu=!1,Bu={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Eu={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Ru=!1;const Pu={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)","border-radius":"2px","box-sizing":"border-box"},Tu={background:"rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.5)","border-radius":"2px",cursor:"grab"},Ou={background:"rgba(0, 0, 0, 0.25)",cursor:"grabbing"},Wu={bottom:"2px",right:"3px",color:"rgba(0, 0, 0, 0.75)",font:`400 9px/1 ${s.fontFamilyStringify(s.fontFamily)}`,"pointer-events":"none"};const ju={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Hu={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Iu=!1;const Gu={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},qu={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Vu=!1,Ku={background:"Canvas",border:"1px solid rgba(128, 128, 128, 0.5)","border-radius":"3px","box-shadow":"0 2px 6px rgba(0, 0, 0, 0.2)",color:"CanvasText","margin-top":"4px",padding:"2px 0"},Yu={background:"none",border:"none",color:"inherit",font:`12px/1.2 ${s.fontFamilyStringify(s.fontFamily)}`,margin:0,padding:"4px 10px"},Uu={background:"rgba(128, 128, 128, 0.2)"};function Xu(t){t.schema.aggs={},kt(t,Tl),function(t){t._renderer="svg",t.schema.ariaHidden=!0,t.schema.attribution=!1,t.schema.attributionIcon=void 0,t.schema.attributionStyle=Du,t.schema.cache=!0,t.schema.theme="auto"}(t),function(t){t.schema.color=(e,n)=>t.schema.groupBy[0](e,n);const n=c.scaleOrdinal().range(e.colorDefaults.scale.range());t.schema.colorDefaults={...e.colorDefaults,scale:n},t._autoColorScale=n,t._colorScaleClass=new Qs,t.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},t.schema.colorScalePadding=Cu,t.schema.colorScalePosition=W("auto"),t.schema.colorScaleMaxSize=600}(t),function(t){t._data=[],t.schema.dataCutoff=100,t.schema.dataPollingInterval=!1,t.schema.detectResize=!0,t.schema.detectResizeDelay=400,t.schema.detectVisible=!0,t.schema.detectVisibleInterval=1e3,t.schema.detectVisibleUnload=!0,t.schema.duration=600,t.schema.reducedMotion="auto",t.schema.fontFamily=s.fontFamily,t._hidden=[],t.schema.hiddenColor=()=>Z(t._theme,t=>t.hidden,"#aaa"),t.schema.hiddenOpacity=W(.5),t._history=[],t.schema.groupBy=[H("id")],t.schema.facetConfig={}}(t),function(t){t.schema.legend=(e,n)=>{if(t._alongLegendHide)return!1;if(t._legendCategories)return n.length>1;const i=d.max(n,(e,n)=>{if(e._isAggregation)return 1;const i=t.schema.groupBy[t._legendDepth].bind(t)(e,n);return i instanceof Array?i.length:1});return n.length>1&&(i??0)<=2},t._defaultLegend=t.schema.legend,t._legendClass=new is,t.schema.legendConfig={label:jl.bind(t),shapeConfig:{ariaLabel:jl.bind(t),labelConfig:{fontColor:()=>Oc(t),fontResize:!1,padding:0}}},t.schema.legendFilterInvert=W(!1),t.schema.legendPadding=Cu,t.schema.legendPosition=W("auto");const e=e=>Wl(t,e)??t._drawLabel(e);t.schema.legendSort=(t,n)=>e(t).localeCompare(e(n)),t.schema.legendTooltip={},t._sizeLegendClass=new rc,Object.assign(t.schema,{sizeLegend:Zs,sizeLegendConfig:{},sizeLegendPosition:"right"})}(t),function(t){t.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${t.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${t.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,t.schema.loadingMessage=!0,t._messageClass=new ac,t.schema.messageMask="rgba(0, 0, 0, 0.05)",t.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},t.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${t.schema.translate("No Data Available")}</strong>\n </div>`,t.schema.noDataMessage=!0}(t),Au(t),function(t){t.schema.shape=W("Rect"),t.schema.shapeConfig={ariaLabel:(e,n)=>t._drawLabel(e,n),fill:(n,o)=>{for(;n.__d3plus__&&n.data;)o=(n=n.data).i;if(t.schema.colorScale){const e=t.schema.colorScale(n,o);if(null!=e)return ch(t,e)}const r=t.schema.color(n,o);if(i.color(r))return r;const a="string"==typeof r?r:JSON.stringify(r);return t.schema.colorOrdinal&&t._ordinalColorScale?t._ordinalColorScale(a):e.colorAssign(a,Te(t))},labelConfig:{fontColor:Nc((n,i)=>{const o="function"==typeof t.schema.shapeConfig.fill?t.schema.shapeConfig.fill(n,i):t.schema.shapeConfig.fill;return e.colorContrast(o,t.schema.colorDefaults)})},opacity:W(1),stroke:Nc((e,n)=>Su("function"==typeof t.schema.shapeConfig.fill?t.schema.shapeConfig.fill(e,n):t.schema.shapeConfig.fill)),role:"presentation",strokeWidth:W(0)},t._solo=[]}(t),function(t){t._subtitleClass=new ei,t.schema.subtitleConfig={ariaHidden:!0,fontColor:()=>Oc(t),fontSize:12,padding:5,textAnchor:"middle"},t.schema.subtitlePadding=Cu,t.schema.svgDesc="",t.schema.svgTitle="",t.schema.timeline=!0,t._timelineClass=(new _c).align("end"),t.schema.timelineConfig={padding:5},t.schema.timelinePadding=Cu,t.schema.threshold=W(1e-4),t.schema.thresholdKey=void 0,t.schema.thresholdName=()=>t.schema.translate("Values"),t._titleClass=new ei,t.schema.titleConfig={ariaHidden:!0,fontColor:()=>Oc(t),fontSize:16,padding:5,textAnchor:"middle"},t.schema.titlePadding=Cu,t.schema.tooltip=W(!0),t._tooltipClass=new Lc,t.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},t._totalClass=new ei,t.schema.totalConfig={fontColor:()=>Oc(t),fontSize:10,padding:5,textAnchor:"middle"},t.schema.totalFormat=e=>`${t.schema.translate("Total")}: ${p.formatAbbreviate(e,t.schema.locale)}`,t.schema.totalPadding=Cu}(t),function(t){t.schema.zoom=!0,t._zoomBehavior=h.zoom(),t._zoomBrush=f.brush(),t.schema.zoomBrushHandleSize=1,t.schema.zoomBrushHandleStyle={fill:"#444"},t.schema.zoomBrushSelectionStyle={fill:"#777","stroke-width":0},t.schema.zoomControlClassName=void 0,t.schema.zoomControlIcons=void 0,t.schema.zoomControls=!0,t.schema.zoomControlStyle=Lu,t.schema.zoomControlStyleActive=Fu,t.schema.zoomControlStyleHover=Nu,t.schema.zoomDoubleClick="in",t.schema.zoomDrag="pan",t.schema.zoomFactor=2,t.schema.zoomMax=void 0,t.schema.zoomPadding=20,t.schema.zoomPan=!0,t.schema.zoomScroll="modifier"}(t),function(t){t.schema.tableView=!0,t.schema.tableViewClassName=void 0,t.schema.tableViewControlClassName=void 0,t.schema.tableViewControlStyle=Bu,t.schema.tableViewControlStyleActive=Eu,t.schema.tableViewControlStyleHover=Ru,t.schema.tableViewDownload=!0,t.schema.tableViewPageSize=50,t.schema.tableViewSort=!0}(t),function(t){t.schema.minimap=!0,t.schema.minimapClassName=void 0,t.schema.minimapStyle=Pu,t.schema.minimapViewportStyle=Tu,t.schema.minimapViewportStyleActive=Ou,t.schema.minimapLabelStyle=Wu}(t),function(t){t.schema.backControlClassName=void 0,t.schema.backControlStyle=$u}(t),function(t){t.schema.search=!0,t.schema.searchAccessor=(e,n)=>t._drawLabel(e,n),t.schema.searchControlClassName=void 0,t.schema.searchControlStyle=ju,t.schema.searchControlStyleActive=Hu,t.schema.searchControlStyleHover=Iu}(t),function(t){t.schema.saveControl=!0,t.schema.saveControlClassName=void 0,t.schema.saveControlConfig={},t.schema.saveControlMenuClassName=void 0,t.schema.saveControlMenuItemStyle=Yu,t.schema.saveControlMenuItemStyleHover=Uu,t.schema.saveControlMenuStyle=Ku,t.schema.saveControlStyle=Gu,t.schema.saveControlStyleActive=qu,t.schema.saveControlStyleHover=Vu}(t)}const Qu=t=>t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Zu={AccentColor:"Highlight",AccentColorText:"HighlightText"};function Ju(t,e,n){const i=Qu(e);t.style.setProperty(i,n);const o=Zu[n];o&&!t.style.getPropertyValue(i)&&t.style.setProperty(i,o)}function td(t,e,n){return n&&t===e?{}:t||{}}function ed(t,e,n,i){const{base:o,active:r={},hover:a={}}=e;for(const e of new Set([...Object.keys(o),...Object.keys(r),...Object.keys(a)]))t.style.removeProperty(Qu(e));for(const e of[o,n?a:{},i?r:{}])for(const n in e){const i=e[n];null!=i&&!1!==i&&Ju(t,n,String(i))}}function nd(t,e,n){const i=Boolean(t[`${e}ClassName`]),o=(n,o)=>td(t[`${e}Style${n}`],o,i);return{base:o("",n.base),active:o("Active",n.active),hover:o("Hover",n.hover)}}function id(t){return String(t??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[t]))}function od(t){return Boolean(t._brushing)}function rd(t){return nd(t.schema,"zoomControl",{base:Lu,active:Fu,hover:Nu})}function ad(t,e,n=!1){ed(e,rd(t),n,e.classList.contains("active"))}const sd='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',cd=`<svg ${sd}><line x1="12" y1="4" x2="12" y2="20"/><line x1="4" y1="12" x2="20" y2="12"/></svg>`,ld=`<svg ${sd}><line x1="4" y1="12" x2="20" y2="12"/></svg>`,hd=`<svg ${sd}><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>`,ud=`<svg ${sd} stroke-dasharray="4 3"><rect x="4" y="4" width="16" height="16" rx="1"/></svg>`;function dd(t,e,n){const i=t.schema.zoomControlIcons?.[e];return"string"==typeof i?i:"function"==typeof i?(t=>`<span class="zoom-control-icon" data-icon="${t}" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>`)(e):n}const fd={zoomIn:"zoom-in",zoomOut:"zoom-out",zoomReset:"zoom-reset",zoomBrush:"zoom-brush"},md={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"4px",boxSizing:"border-box",paddingTop:"4px",paddingRight:"4px",pointerEvents:"none"};function pd(t){const e=t.schema.zoomControlClassName?` ${t.schema.zoomControlClassName}`:"",n=(n,i,o,r)=>`<button type="button" style="pointer-events:auto" class="zoom-control ${n}${r?" active":""}${e}" aria-label="${t.schema.translate(i)}"${void 0===r?"":` aria-pressed="${r}"`}>${o}</button>`;return n("zoom-in","Zoom In",dd(t,"zoomIn",cd))+n("zoom-out","Zoom Out",dd(t,"zoomOut",ld))+n("zoom-reset","Reset Zoom",dd(t,"zoomReset",hd))+n("zoom-brush","Brush Zoom",dd(t,"zoomBrush",ud),od(t))}function gd(t){let e=t._select&&t._select.node()?t._select.node().parentNode:null;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e instanceof HTMLElement?e:null}function yd(t){const e=gd(t)?.querySelector(".d3plus-zoom-control .zoom-brush");if(!e)return;const n=od(t);e.classList.toggle("active",n),e.setAttribute("aria-pressed",String(n)),ad(t,e,e.matches(":hover"))}function xd(t){return Boolean(t.schema.zoom)&&!1!==t.schema.zoomControls&&!t._ssr}const bd={width:96,height:24};function kd(t){if(!xd(t))return null;const e=pd(t),{base:n}=rd(t),i=`${e}|${JSON.stringify(n)}`,o=t._zoomControlsBox;if(o&&o.signature===i)return o;let r=bd;const a=gd(t);if(a){const n=document.createElement("div");n.className="d3plus-zoom-control";for(const t in md)n.style.setProperty(Qu(t),md[t]);n.style.setProperty("display","inline-flex"),n.style.setProperty("position","absolute"),n.style.setProperty("visibility","hidden"),n.style.setProperty("pointer-events","none"),n.innerHTML=e,n.querySelectorAll(".zoom-control").forEach(e=>ad(t,e)),a.appendChild(n);const i=n.getBoundingClientRect();a.removeChild(n),i.width&&i.height&&(r={width:Math.ceil(i.width),height:Math.ceil(i.height)})}return t._zoomControlsBox={...r,signature:i},t._zoomControlsBox}function _d(t){const e=kd(t);return e||(t.schema.zoom&&!t._ssr?{width:bd.width,height:t._margin?.top??0}:null)}function vd(t){const e=kd(t);return e&&e.height?e.height+4:0}const wd=["sizeLegend","legend","colorScale"];function Md(t){return{padding:10,margin:6,fillOpacity:.85,strokeWidth:1,rx:4,...t.schema.legendInsetConfig||{}}}function Sd(t,e){return Boolean(t._insetPending&&t._insetPending.has(e))}function Cd(t,e){const n=t._insetPlacement;return n&&n.key===e?n:null}function $d(t,e){return Cd(t,e)?.orient??"column"}function Ad(t,e){return"column"===t?{width:.4*e.width,height:.6*e.height}:{width:.6*e.width,height:.4*e.height}}function zd(t,n){const i=Md(t),o=i.fill??Tc(t);return{type:"rect",key:"viz-inset-background",x:n.x,y:n.y,width:n.width,height:n.height,rx:i.rx,ry:i.rx,paint:{fill:o,fillOpacity:i.fillOpacity,stroke:i.stroke??e.colorContrast(o,t.schema.colorDefaults),strokeOpacity:i.stroke?1:.15,strokeWidth:i.strokeWidth}}}function Dd(t,e,n,i){const o=Ld(t,e,i);return o?[zd(t,Cd(t,e)),{...n,transform:o}]:[n]}function Ld(t,e,n){const i=Cd(t,e);if(!i)return null;const{margin:o}=Md(t);return{x:i.x+o-(n.x??0),y:i.y+o-(n.y??0)}}function Fd(t){return{width:t.reduce((t,e,n)=>t+e.width+(n?6:0),0),height:Math.max(0,...t.map(t=>t.height))}}function Nd(t){const e=t._bottomRightBox;return e&&e.width&&e.height?e:null}function Bd(t){const e=Nd(t);return e&&!e.inset?e:null}function Ed(t,e,n){const i=Bd(t);if(!i||"right"===i.side||e>=i.bottom+i.height)return 0;const o=i.width-n;return o>0?o+6:0}function Rd(t,e){const n=Bd(t);return n?Math.max(0,n.bottom+n.height-e):0}function Pd(t,e,n,i){return{inset:"bottom"===e?Ed(t,n,i):0,drop:"left"===e||"right"===e?Rd(t,n):0}}function Td(t,e){const n=Bd(t);return n&&"bottom"===n.side?Math.max(0,n.bottom+n.height-e):0}function Od(t,e){const n=Bd(t);return n&&"right"===n.side?Math.max(0,n.width+6-e):0}function Wd(t,e){const n=t._zoomTransform?.scale??1;if(e.inset)return function(t,e,n){const i=Cd(t,"sizeLegend");if(!i)return null;const{margin:o}=Md(t),r=e.items.map(t=>({item:t,paint:t.paint(n)})).filter(t=>Boolean(t.paint));if(!r.length)return null;const a=r.reduce((t,e,n)=>t+e.paint.width+(n?6:0),0)+2*o,s=Math.max(...r.map(t=>t.paint.height))+2*o,c="left"===i.alignX?i.x:"center"===i.alignX?i.x+(i.width-a)/2:i.x+i.width-a,l="top"===i.alignY?i.y:"middle"===i.alignY?i.y+(i.height-s)/2:i.y+i.height-s,h=[zd(t,{...i,x:c,y:l,width:a,height:s})];let u=c+a-o;const d=l+s-o;for(const{item:t,paint:e}of r)h.push({type:"group",key:t.key,transform:{x:u-e.width,y:d-e.height},children:[e.node]}),u-=e.width+6;return{type:"group",key:"viz-bottomRight",children:h}}(t,e,n);const i=[];let o=t.schema.width;const r=t.schema.height-e.bottom;return e.items.forEach(t=>{const e=t.paint(n);e&&i.push({type:"group",key:t.key,transform:{x:o-e.width,y:r-e.height},children:[e.node]}),o-=t.width+6}),i.length?{type:"group",key:"viz-bottomRight",children:i}:null}function jd(t){const e=t.target;return Boolean(e&&"function"==typeof e.closest&&e.closest("g.d3plus-viz-timeline, g.d3plus-zoom-brush"))}function Hd(t){const e=t._plotZoomBase?.scales;return e?{x:Boolean(e.x||e.x2),y:Boolean(e.y||e.y2)}:{x:!0,y:!0}}const Id="zoombox",Gd=["mousemove","mouseup","keydown","selectstart","dragstart"].map(t=>`${t}.${Id}`).join(" ");function qd([t,e],[[n,i],[o,r]]){return[Math.max(n,Math.min(o,t)),Math.max(i,Math.min(r,e))]}function Vd(t,e){const n=e.currentTarget,i=function(t){return t._zoomBehavior.extent().bind(document)()}(t),r=o.pointer(e,n);if(!function(t,e,n){return!t.button&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&t.detail<2&&!jd(t)&&function([t,e],[[n,i],[o,r]]){return t>=n&&t<=o&&e>=i&&e<=r}(e,n)}(e,r,i))return;const a=e.view??window,s=o.select(a),c=[e.clientX,e.clientY];let l=null;const u=e=>{s.on(Gd,null),l&&(Vl(t,"auto"),function(t){t._brushGroup.call(t._zoomBrush.move,null).style("display","none").style("pointer-events",null)}(t),au(t),function(t){const e=o.select(t);e.on(`click.${Id}`,t=>{t.preventDefault(),t.stopImmediatePropagation()},!0),setTimeout(()=>e.on(`click.${Id}`,null),0)}(a),e&&t._zoomToBounds?.(l),l=null)};s.on(`mousemove.${Id}`,a=>{if(!l){if(s=c,u=[a.clientX,a.clientY],!(Math.hypot(u[0]-s[0],u[1]-s[1])>3))return;h.zoomTransform(n),ou(t,{sourceEvent:e}),ru(t,{sourceEvent:a}),Vl(t,"crosshair")}var s,u;a.preventDefault();const d=qd(o.pointer(a,n),i);var f,m;f=qd(r,i),m=d,l=[[Math.min(f[0],m[0]),Math.min(f[1],m[1])],[Math.max(f[0],m[0]),Math.max(f[1],m[1])]],function(t,e){const{left:n,top:i}=t._margin;t._brushGroup.style("display","inline").style("pointer-events","none").call(t._zoomBrush.move,e.map(([t,e])=>[t-n,e-i]))}(t,l)},!0).on(`mouseup.${Id}`,()=>u(!0),!0).on(`keydown.${Id}`,t=>{"Escape"===t.key&&l&&u(!1)},!0).on(`selectstart.${Id} dragstart.${Id}`,t=>t.preventDefault(),!0)}function Kd(t,e,n){const i="brush"===t.schema.zoomDrag;e.on(`mousedown.${Id}`,i?e=>Vd(t,e):null),function(t,e,n){const i=t.schema.zoomDoubleClick;!1===i?e.on("dblclick.zoom",null):"reset"===i&&e.on("dblclick.zoom",t=>{t.button||t.ctrlKey||jd(t)||(t.preventDefault(),t.stopImmediatePropagation(),n())})}(t,e,n)}function Yd(t){t.on(`.${Id}`,null)}const Ud=new WeakMap;function Xd(t){Ud.delete(t)}function Qd(t){return{type:"htmlOverlay",key:"viz-zoom-controls",x:0,y:0,width:t.schema.width,style:md,className:"d3plus-zoom-control",html:pd(t),events:{".zoom-in":{click:()=>lf.bind(t)(t.schema.zoomFactor)},".zoom-out":{click:()=>lf.bind(t)(1/t.schema.zoomFactor)},".zoom-reset":{click:()=>lf.bind(t)(0)},".zoom-brush":{click:e=>{const n=e.target.closest(".zoom-brush");if(!n)return;const i=!od(t);n.classList.toggle("active",i),n.setAttribute("aria-pressed",String(i)),ad(t,n,n.matches(":hover")),of.bind(t)(i)}}},onUpdate:e=>{e.querySelectorAll(".zoom-control").forEach(e=>{e.dataset.zoomBound||(e.dataset.zoomBound="1",ad(t,e),e.addEventListener("mouseenter",()=>ad(t,e,!0)),e.addEventListener("mouseleave",()=>ad(t,e)),function(t,e){var n;const i=t.schema.zoomControlIcons;if(!i)return;const o=Object.keys(fd).find(t=>e.classList.contains(fd[t])),r=o&&i[o];if(!o||"function"!=typeof r)return;const a=e.querySelector(".zoom-control-icon");if(!a)return;const s=(n=t)._zoomIconCleanup||(n._zoomIconCleanup={});s[o]?.(),s[o]=r(a)||void 0}(t,e))})}}}const Zd={name:"zoom",layout:({viz:t})=>{if(t.schema.zoom?function(t){if(!t._select)return;if(!t._ssr&&(!t._container||t._container.classed("d3plus-zoom"))){const{width:e,height:n}=wt(t);An(t,{kind:"generic",width:e,height:n,duration:Jt(t)})}"canvas"!==t._renderer&&tf(t,t._select)}(t):function(t){t._zoomTransform=void 0,Xd(t);const e=t._zoomEventTarget||t._container;e&&e.node()&&e.property("__zoom",h.zoomIdentity)}(t),!t._container||!t._zoomGroup)return{panel:null,margin:{}};const e=wt(t),n=t._zoomHeight||e.height,i=t._zoomWidth||e.width,{left:o,top:r}=t._margin,a=[[o,r],[o+i,r+n]];t._zoomBehavior.filter(e=>function(t,e){const n="modifier"===t.schema.zoomScroll;return"wheel"===e.type?!n||e.ctrlKey||e.metaKey:!jd(e)&&(!("mousedown"===e.type&&"brush"===t.schema.zoomDrag&&!e.shiftKey)&&("touchstart"===e.type&&n?(e.touches?.length??0)>1||rf(t):!e.ctrlKey&&!e.button))}(t,e)).wheelDelta(af).extent(a).scaleExtent([1,Jd(t,i,n)]).translateExtent(a).on("start",e=>{ou(t,e),t._zoomGesture?.start(e)}).on("zoom",e=>{ru(t,e),t._zoomGesture?.zoom(e)||function(t,e){const n=e;if(!n||"object"!=typeof n||"number"!=typeof n.k)return!1;const i=Ud.get(t)??{k:1,x:0,y:0};return n.k===i.k&&(n.x??0)===i.x&&(n.y??0)===i.y}(t,e.transform)||cf.bind(t)(e.transform)}).on("end",e=>{t._zoomGesture?.end(e),au(t)}),t._zoomToBounds=uf.bind(t);const s=xd(t)?Qd(t):null;t._zoomBrush.extent([[0,0],[i,n]]).filter(t=>!t.button&&t.detail<2).handleSize(t.schema.zoomBrushHandleSize).on("start",mf.bind(t)).on("brush",df.bind(t)).on("end",ff.bind(t));const c=t._select.selectAll(":scope > g.d3plus-zoom-brush").data([0]);return t._brushGroup=c.enter().append("g").attr("class","d3plus-zoom-brush").merge(c).attr("transform",`translate(${o}, ${r})`).call(t._zoomBrush),of.bind(t)(od(t)),t._renderTiles&&t._renderTiles(nf(t),0),{panel:s,margin:{}}}};function Jd(t,e,n){return"number"==typeof t.schema.zoomMax?t.schema.zoomMax:function(t,e,n,i,o=1){const r=Math.max(1,e-2*i),a=Math.max(1,n-2*i);let s=1;for(const e of t){if(void 0===e.datum||"group"===e.type||"text"===e.type)continue;if(String(e.key).endsWith("::hit"))continue;const t=o*(e.transform?.scale??1);for(const[n,i]of zn(e)){const e=Math.min(n>0?r/(n*t):1/0,i>0?a/(i*t):1/0);Number.isFinite(e)&&e>s&&(s=e)}}return s}(t._zoomShapes||t._chartScene||[],e,n,t.schema.zoomPadding,t._chartTransform?.scale??1)}function tf(t,e){const n=t._zoomEventTarget;n&&n.node()===e.node()||(n&&Yd(n.on(".zoom",null)),t._container&&Yd(t._container.on(".zoom",null)),t._zoomEventTarget=e)}function ef(t){const e="canvas"===t._renderer,n=od(t);t._select&&t._select.style("pointer-events",e||n?"none":null),t._container&&t._container.style("pointer-events",e?"none":null),t._brushGroup&&t._brushGroup.style("pointer-events",n?"all":null)}function nf(t){const e=h.zoomTransform((t._zoomEventTarget||t._container).node()),{left:n,top:i}=t._margin;return h.zoomIdentity.translate(e.x+(e.k-1)*n,e.y+(e.k-1)*i).scale(e.k)}function of(t=!1){!function(t,e){t._brushing=e}(this,t),t?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none"),ef(this);const e=this._zoomEventTarget||this._container;!t&&this.schema.zoom?(e.call(this._zoomBehavior),this.schema.zoomScroll||e.on("wheel.zoom",null),sf(this),this.schema.zoomPan||e.on("mousedown.zoom mousemove.zoom",null).on("touchstart.zoom touchmove.zoom touchend.zoom touchcancel.zoom",null),Kd(this,e,()=>lf.bind(this)(0))):Yd(e.on(".zoom",null))}function rf(t){const e=t._zoomEventTarget||t._container;return Boolean(e&&e.node()&&h.zoomTransform(e.node()).k>1)}function af(t){const e=t.ctrlKey&&0===t.deltaMode&&Math.abs(t.deltaY)<50;return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(e?10:1)}function sf(t){const e=t._zoomEventTarget||t._container;if(!e)return;const n="modifier"===t.schema.zoomScroll&&t.schema.zoomPan;e.style("touch-action",n?rf(t)?"none":"pan-x pan-y":null)}function cf(t=!1,e=0){Zt(this)&&(e=0),this._zoomGroup&&(e?this._zoomGroup.transition().duration(e).attr("transform",t):this._zoomGroup.attr("transform",t));const n=t;if(n&&"object"==typeof n&&"k"in n){const t={k:n.k??1,x:n.x??0,y:n.y??0};!function(t,e){Ud.set(t,{k:e.k,x:e.x,y:e.y})}(this,t),this._zoomRescale&&this._zoomRescale(t,e)?this._zoomTransform=void 0:this._zoomTransform={x:t.x,y:t.y,scale:t.k}}else!1===n&&(this._zoomTransform=void 0,Xd(this));!function(t){const e=Nd(t);if(!e||!t._featurePanels)return;const n=t._featurePanels.filter(t=>"viz-bottomRight"!==t.key),i=Wd(t,e);t._featurePanels=i?[...n,i]:n}(this),this._drawSceneToTarget&&this._sceneRenderer&&this._drawSceneToTarget(e),sf(this),this._renderTiles&&this._renderTiles(nf(this),e)}function lf(t=0){if(!this._container)return;const[[e,n],[i,o]]=this._zoomBehavior.extent().bind(document)(),r=(e+i)/2,a=(n+o)/2,s=h.zoomTransform((this._zoomEventTarget||this._container).node());if(!t)return this._zoomGesture?.reset(),hf(this,1,0,0);const c=s.k*t;hf(this,c,r-(r-s.x)/s.k*c,a-(a-s.y)/s.k*c)}function hf(t,e,n,i,o=Jt(t)){const[r,a]=t._zoomBehavior.scaleExtent(),[[s,c],[l,u]]=t._zoomBehavior.translateExtent(),d=Math.max(r,Math.min(a,e)),f=Math.max(l*(1-d),Math.min(s*(1-d),n)),m=Math.max(u*(1-d),Math.min(c*(1-d),i)),p=h.zoomIdentity.translate(f,m).scale(d);(t._zoomEventTarget||t._container).property("__zoom",p),cf.bind(t)(p,o)}function uf(t,e=Jt(this)){if(!t)return hf(this,1,0,0,e);const n=h.zoomTransform((this._zoomEventTarget||this._container).node()),i=function(t,e){const[[n,i],[o,r]]=function(t){const e=t._plotZoomBase;if(e){const{layout:t,chartTransform:n,pCtx:i}=e,o=n.y-i.x2Height;return[[t.xRange[0]+n.x,t.yRange[0]+o],[t.xRange[1]+n.x,t.yRange[1]+o]]}const[[n,i],[o,r]]=t._zoomBehavior.translateExtent(),a=t.schema.zoomPadding;return[[n+a,i+a],[o-a,r-a]]}(t),[[a,s],[c,l]]=e,h=Hd(t),u=(o-n)/(c-a),d=(r-i)/(l-s),f=h.x&&h.y?Math.min(u,d):h.x?u:d;return{k:f,x:(n+o)/2-f*(a+c)/2,y:(i+r)/2-f*(s+l)/2}}(this,t.map(([t,e])=>[(t-n.x)/n.k,(e-n.y)/n.k]));hf(this,i.k,i.x,i.y,e)}function df(){pf.bind(this)()}function ff(t){if(!t.selection||!t.sourceEvent)return;this._brushGroup.call(this._zoomBrush.move,null),of.bind(this)(!1),yd(this);const{left:e,top:n}=this._margin;uf.bind(this)(t.selection.map(([t,i])=>[t+e,i+n]))}function mf(){pf.bind(this)()}function pf(){this._brushGroup.selectAll(".selection").call(r.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(r.attrize,this.schema.zoomBrushHandleStyle||{})}function gf(t){const e=t._zoomEventTarget||t._container;return Boolean(t.schema.zoom&&t._zoomBehavior&&t._brushGroup&&e?.node())}function yf(t,e){gf(t)&&lf.call(t,e)}const xf=Ra;let bf;function kf(t,e,n={}){const i=`${t}.${n.method??"shapeConfig"}()`,o=function(){if(!bf){bf={};for(const[t,e]of Object.entries(xf))bf[t]=new e}return bf}(),a=n.shapes??Object.fromEntries(Object.keys(o).map(t=>[t,t])),s=n.extra??{},c=Object.values(a).map(t=>o[t]);for(const t of Object.keys(e)){const n=a[t]&&o[a[t]];if(n){if(!r.isObject(e[t]))continue;for(const o of Object.keys(e[t]))o in n||s[t]?.includes(o)||Et(i,`${t}.${o}`)}else s[""]?.includes(t)||c.some(e=>t in e)||Et(i,t)}}class _f extends Xt{active(t){return arguments.length?(this._active=t,1!==this.schema.shapeConfig.activeOpacity&&(this.schema.legend&&this._legendClass.active(t),this._sceneRenderer&&this._scheduleSceneRepaint()),Ge(this,"active",t),this):this._active}data(t,e){return arguments.length?(_n(this,"data",arguments.length>1?[t,e]:[t]),this._hidden=[],this._solo=[],Ae(this),this._userData&&JSON.stringify(t)!==JSON.stringify(this._userData)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userData=t,this._dataSignature=void 0,un(this),this):this._data}facet(t){return arguments.length?(this.schema.facet=re(t),this):this.schema.facet}facetConfig(t){return arguments.length?(this.schema.facetConfig=ht(this,"facetConfig",t),this):this.schema.facetConfig}fontFamily(t){if(arguments.length){const e={fontFamily:t},n={titleConfig:e,shapeConfig:{labelConfig:e}};return this.shapeConfig({labelConfig:e}),this.colorScaleConfig({axisConfig:n}),["axis","column","row","timeline","x","y","x2","y2"].forEach(t=>{const e=`${t}Config`;this[e]&&this[e](n)}),["back","title","total","subtitle"].forEach(t=>{const n=`${t}Config`;this[n]&&this[n](e)}),this.tooltipConfig({tooltipStyle:{"font-family":s.fontFamilyStringify(t)}}),this.schema.fontFamily=t,this}return this.schema.fontFamily}groupBy(t){if(!arguments.length)return this.schema.groupBy;this._groupByRaw=t;const e=t instanceof Array?t:[t];return this.schema.groupBy=e.map(t=>"function"==typeof t?t:(this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const i=n.unique(t.map(e));return 1===i.length?i[0]:i}),G(t))),this}hover(t){if(!arguments.length)return this._hover;const e="function"==typeof this._hover;let n=this._hover=t;if(1!==this.schema.shapeConfig.hoverOpacity&&void 0!==t){if("function"==typeof t){const e=[...this._filteredData??[],...this._legendClass.data()??[]].filter(t),i=new Set;e.map(this._ids).forEach(t=>{for(let e=1;e<=t.length;e++)i.add(JSON.stringify(t.slice(0,e)))}),i.size&&(n=(t,e)=>{const n=this._ids(t,e),o=ge(t);return i.has(JSON.stringify(void 0===o?n:n.slice(0,o+1)))})}this.schema.legend&&this._legendClass.hover(n)}return this._sceneRenderer&&void 0!==t&&(Ye(this)||this._hoverBucket||e)&&this._scheduleSceneRepaint(),Ge(this,"hover",t),this}highlight(t){return arguments.length?(this._highlight=t,this._sceneRenderer&&this._scheduleSceneRepaint(),Ge(this,"highlight",t),this):this._highlight}select(t){return arguments.length?(this._select=o.select(t),this):this._select}shapeConfig(t){return arguments.length?(it(t)&&kf(qt(this),t),this.schema.shapeConfig=ht(this,"shapeConfig",t),this):this.schema.shapeConfig}threshold(t){return arguments.length?("function"==typeof t?this.schema.threshold=t:isFinite(t)&&!isNaN(t)&&(this.schema.threshold=W(1*t)),this):this.schema.threshold}thresholdKey(t){return arguments.length?(this.schema.thresholdKey="function"==typeof t?t:G(t),this):this.schema.thresholdKey}time(t){return arguments.length?("function"==typeof t?this.schema.time=t:t?(this.schema.time=G(t),this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const i=n.unique(t.map(e));return 1===i.length?i[0]:i}),this._userTime&&JSON.stringify(t)!==JSON.stringify(this._userTime)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userTime=t):(this.schema.time=void 0,this._userTime=void 0,this.schema.timeFilter=!1,this._timelineSelection=!1),this):this.schema.time}timelineDefault(t){return arguments.length?(t instanceof Array||(t=[t,t]),this.schema.timelineDefault=t.map(t=>r.date(t)).filter(t=>!1!==t),this):this.schema.timelineDefault}total(t){return arguments.length?(this.schema.total="function"==typeof t?t:!!t&&G(t),this):this.schema.total}zoomIn(){return yf(this,this.schema.zoomFactor),this}zoomOut(){return yf(this,1/this.schema.zoomFactor),this}zoomReset(){return yf(this,0),this}zoomBrush(t){return arguments.length?(e=this,n=Boolean(t),gf(e)&&n!==od(e)&&(of.call(e,n),yd(e)),this):od(this);var e,n}}function vf(t,e){const n=t._colorScaleClass;if(!n||!sh(t))return;let i=!1;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;if(!1===n.hoverMark())return;i=function(t,e){const n=sh(t);if(!e||"function"!=typeof n)return null;if(e.interactionGroup)return null;if(uh(e.datum))return null;let i=e.datum,o="number"==typeof e.index?e.index:0;for(;i&&i.__d3plus__&&i.data;)i=i.data,"number"==typeof i.i&&(o=i.i);if(!i||"object"!=typeof i)return null;const r=n(i,o);if(Os(r))return r;if(null==r||""===r)return null;if("number"!=typeof r&&"string"!=typeof r)return null;const a=+r;return Number.isFinite(a)?a:null}(t,e.pick?.node)??!1}else if("mouseleave"!==e.type)return;var o,r;(o=n.hover()??!1,r=i,Array.isArray(o)&&Array.isArray(r)?o[0]!==r[0]||o[1]!==r[1]:o!==r)&&(n.hover(i),t._scheduleSceneRepaint())}_f._displayName="VizBase",dt(_f.prototype,"facetConfig","shapeConfig");function wf(t,e){const n=t.datum?.data;"text"===t.type&&n&&"tick"in n&&"id"in n&&(t.hoverMatch={field:e,value:n.id});const i=t.children;if(i)for(const t of i)wf(t,e)}function Mf(t,e){let n=t;for(;n&&"object"==typeof n;){if(Object.prototype.hasOwnProperty.call(n,e)){const t=n[e];return(Array.isArray(t)?t:[t]).map(String)}n=n.data}return[]}const Sf={hover:{darken:.5,width:2},active:{darken:1,width:3}};function Cf(t){const e="function"==typeof t._hover?t._hover:null,n="function"==typeof t._active?t._active:null,i="function"==typeof t._highlight?t._highlight:null;if(!e&&!n&&!i)return null;const o=t.schema.shapeConfig??{};let r="number"==typeof o.hoverOpacity?o.hoverOpacity:.5;const a="number"==typeof o.activeOpacity?o.activeOpacity:.25,s=!e&&!n;return e&&t._hoverBucket&&r>=1&&(r=.5),{predicate:e??n??i,dimOpacity:e?r:n?a:1,isHover:!!e,gray:s,kind:e?"hover":n?"active":"highlight",activePredicate:n}}function $f(t,e){const n=function(t){const e=t._colorScaleClass;if(!e||"function"==typeof t._hover)return null;const n=e.hover();if(!("number"==typeof n&&Number.isFinite(n)||Os(n))||!1===e.hoverMark()||e._barGeometry||"function"!=typeof e._colorScale)return null;const i=t.schema.shapeConfig,o=i?.hoverOpacity;return{color:e._colorScale(n),dimOpacity:"number"==typeof o&&o<1?o:.5}}(e);let i,o;if(n)i=new Set([n.color]),o=n.dimOpacity;else{const n=Cf(e);if(!n)return t;i=function(t,e){const n=lh(t);if(!n)return null;const i=new Set;return n.rows.forEach((t,o)=>{e(t,o)&&i.add(n.colorOf(t,o))}),i}(e,n.predicate),o=n.dimOpacity}if(!i)return t;const r=t=>{let e=t,n=t.datum;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(n&&n._isColorScaleBucket&&!i.has(n.color)){const n=t.paint&&"number"==typeof t.paint.opacity?t.paint.opacity:1;e={...t,paint:{...t.paint??{},opacity:n*o}}}const a=e.children;return a&&a.length&&(e={...e,children:a.map(r)}),e};return t.map(r)}function Af(t,e,n){let i=e;if(t(i,n))return!0;for(;i&&i.__d3plus__&&i.data;)if(i=i.data,t(i,n))return!0;return!1}function zf(t,e){const n=t.datum;if(n){const i=n.data??n,o="number"==typeof t.index?t.index:"number"==typeof i.i?i.i:0;return Af(e,i,o)}const i=t.interactionPoints;return i&&i.length?i.some((t,n)=>{const i=t.datum;return Af(e,i,"number"==typeof i.i?i.i:n)}):null}function Df(t,e=new Set){for(const n of t){n.hoverMatch&&e.add(n.hoverMatch.field);const t=n.children;t&&Df(t,e)}return e}function Lf(t,n){const o=Cf(n);if(!o)return t;const{predicate:r,dimOpacity:a,isHover:s,gray:c,kind:l,activePredicate:h}=o,u=Df(t),d=n._hoverFocus,f=u.size?d&&"hover"===l&&d.hover===n._hover?function(t,e){return new Map([...e].map(e=>[e,new Set(t.flatMap(t=>Mf(t,e)))]))}(d.rows,u):function(t,e,n){const i=new Map([...n].map(t=>[t,new Set])),o=t=>{for(const[e,n]of i)for(const i of Mf(t,e))n.add(i)},r=t=>{const n=t.interactionGroup;if("axis"===n||"timeline"===n||t.hoverMatch)return;if(zf(t,e))if(t.hoverKeys&&o(t.hoverKeys),t.datum)o(t.datum);else for(const n of t.interactionPoints??[])Af(e,n.datum,0)&&o(n.datum);const i=t.children;i&&i.forEach(r)};return t.forEach(r),i}(t,r,u):null,m=t=>{const n=t.paint??{};if(c){const i={...n};return"string"==typeof n.fill&&(i.fill=e.colorGrayscale(n.fill)),"string"==typeof n.stroke&&(i.stroke=e.colorGrayscale(n.stroke)),{...t,paint:i}}const i="number"==typeof n.opacity?n.opacity:1;return{...t,paint:{...n,opacity:i*a}}},p=t=>{const{field:e,value:n}=t.hoverMatch;return f?.get(e)?.has(String(n))?t:m(t)},g=t=>{if(t.hoverMatch)return p(t);const e=t.children;return f&&e&&e.length?{...t,children:e.map(g)}:t},y=t=>{const e=t.interactionGroup;if("axis"===e||"timeline"===e)return g(t);if(t.hoverMatch)return p(t);let n=t;const o=zf(t,r);if(null!==o)if(o){if("highlight"!==l&&ze.has(t.type)){n=function(t,e){const{darken:n,width:o}=Sf[e],r={...t.paint??{}},a="path"===t.type?t.emphasis:void 0,s=a?.d?.[e],c=s?{...t,d:s}:t;if(a?.fill){const t="string"==typeof r.fill?i.color(r.fill):null;return t&&(r.fill=t.darker(n).formatHex()),{...c,paint:r}}let l="string"==typeof r.fill?r.fill:void 0;if(l&&"transparent"!==l&&"none"!==l||(l="string"==typeof r.stroke?r.stroke:void 0),!l||"transparent"===l||"none"===l)return t;const h=i.color(l);h&&(r.stroke=h.darker(n).formatHex());const u="number"==typeof r.strokeWidth&&r.strokeWidth?r.strokeWidth:1;return r.strokeWidth=u*o,{...c,paint:r}}(t,"active"===l||!!h&&!0===zf(t,h)?"active":"hover")}s&&(n={...n,z:1e6})}else n=m(t);const a=n.children;return a&&a.length&&(n={...n,children:a.map(y)}),n};return t.map(y)}function Ff(t){const e=Boolean(t.schema.backControlClassName);return td(t.schema.backControlStyle,$u,e)}const Nf=`<svg ${sd}><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>`;function Bf(t){const e=t._history.pop();e&&ke(e)?(Ce(t,e),Ke(t),t.render()):e?(void 0!==e.groupId&&void 0!==e.groupDepth&&(t._pendingExitReunion={groupId:e.groupId,groupDepth:e.groupDepth,body:t._bodyRect}),e.legend&&Ce(t,e.legend),t.config({depth:e.depth,filter:e.filter}).render()):t.depth(t._drawDepth-1).filter(!1).render()}function Ef(t){const e=t.schema.backControlClassName?` ${t.schema.backControlClassName}`:"",n=t.schema.translate("Back");return`<button type="button" class="back-control${e}">${Nf}${n}</button>`}function Rf(t){return function(t){return Boolean(t._history&&t._history.length)&&!t._ssr}(t)?{key:"back",html:Ef(t),styleSignature:JSON.stringify(Ff(t)),events:{".back-control":{click:()=>Bf(t)}},onUpdate:e=>{const n=e.querySelector(".back-control");n&&!n.dataset.backBound&&(n.dataset.backBound="1",function(t,e){ed(e,{base:Ff(t)},!1,!1)}(t,n))}}:null}function Pf(t){return Boolean(t._tableView)}function Tf(t){return t._tableViewPage||0}function Of(t,e){t._tableViewPage=e}function Wf(t){return t._tableViewSort}function jf(t){return"raw"===t._tableViewDataSource?"raw":"aggregate"}function Hf(t){if(t._tableData?.())return!1;const e=t._data,n=t._filteredData||e;return!(!e||!n||e===n)&&e.length!==n.length}function If(t){return nd(t.schema,"tableViewControl",{base:Bu,active:Eu,hover:Ru})}function Gf(t,e,n=!1){ed(e,If(t),n,e.classList.contains("active"))}function qf(t){return JSON.stringify(If(t))}const Vf='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Kf=`<svg ${Vf}><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="12" y1="3" x2="12" y2="21"/></svg>`,Yf=`<svg ${Vf}><path d="M12 3v12"/><polyline points="7 11 12 16 17 11"/><path d="M4 18v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"/></svg>`,Uf=`<svg ${Vf}><polyline points="14 4 19 9 14 14"/><line x1="4" y1="9" x2="19" y2="9"/><polyline points="10 20 5 15 10 10"/><line x1="20" y1="15" x2="5" y2="15"/></svg>`,Xf='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;vertical-align:middle;margin-left:4px;flex-shrink:0"',Qf=`<svg ${Xf}><polyline points="6 15 12 9 18 15"/></svg>`,Zf=`<svg ${Xf}><polyline points="6 9 12 15 18 9"/></svg>`;function Jf(t){const e=Pf(t);return`<button type="button" class="table-view-control table-view-toggle${e?" active":""}${t.schema.tableViewControlClassName?` ${t.schema.tableViewControlClassName}`:""}" aria-label="${t.schema.translate(e?"Show Chart":"Show Data Table")}" aria-pressed="${e}">${Kf}</button>`}function tm(t){const e=function(t){return null==t?"":t instanceof Date?t.toISOString():String(t)}(t);return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function em(t,e,n){const i=t.schema.groupBy;return i&&i.length?i.map(t=>String(t(e,n))).join("\0"):""}function nm(t,e){const n=t._data;if(!n||!n.length)return e;const{exact:i,group:o}=function(t){const e=t._data||[],n=t._tableViewGroupOrder;if(n&&n.data===e)return n;const i=new Map,o=new Map;e.forEach((e,n)=>{const r=JSON.stringify(e);i.has(r)||i.set(r,n);const a=em(t,e,n);o.has(a)||o.set(a,n)});const r={data:e,exact:i,group:o};return t._tableViewGroupOrder=r,r}(t);return e.map((e,n)=>({row:e,order:i.get(JSON.stringify(e))??o.get(em(t,e,n))??Number.MAX_SAFE_INTEGER})).sort((t,e)=>t.order-e.order).map(t=>t.row)}function im(t){const e=t._tableData?.(),n=!e&&"raw"===jf(t)&&Hf(t);let i=((e??(n?t._data:t._filteredData||t._data))||[]).slice();const o=function(t){const e=[],n=new Set;for(const i of t)for(const t of Object.keys(i))n.has(t)||zh(t)||(n.add(t),e.push(t));return e}(i),r=Wf(t);if(r&&o.includes(r.column)){const e="desc"===r.direction?-1:1,{column:n}=r;i.sort((i,o)=>e*function(t,e,n){const i=null==t,o=null==e;return i||o?i&&o?0:i?1:-1:"number"==typeof t&&"number"==typeof e?t-e:t instanceof Date&&e instanceof Date?t.getTime()-e.getTime():String(t).localeCompare(String(e),n,{numeric:!0})}(i[n],o[n],t.schema.locale))}else n||e||(i=nm(t,i));return{rows:i,columns:o}}function om(t,e){const n=e.length,i=t.schema.tableViewPageSize,o="number"==typeof i&&i>0?i:n||1,r=Math.max(1,Math.ceil(n/o)),a=Math.min(Math.max(0,Tf(t)),r-1);Of(t,a);const s=a*o,c=Math.min(s+o,n);return{slice:e.slice(s,c),page:a,totalPages:r,start:s,end:c,total:n}}const rm=t=>(t._theme??V).table,am=t=>`position:sticky;top:0;background:${rm(t).header};text-align:left;padding:6px 10px;border-bottom:2px solid ${rm(t).border};white-space:nowrap;`;function sm(t,e,n){return e.map(e=>`<td style="padding:6px 10px;border-bottom:1px solid ${rm(t).rule};"><div class="d3plus-table-view-cell" style="max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${id(function(t,e){return null==t?"":t instanceof Date?t.toLocaleDateString(e):"number"==typeof t?t.toLocaleString(e):String(t)}(n[e],t.schema.locale))}</div></td>`).join("")}function cm(t,e){return t?`<tr aria-hidden="true" style="height:${t}px;padding:0;border:0;"><td style="padding:0;border:0;" colspan="${e}"></td></tr>`:""}function lm(t,e,n,i,o,r){const a=Math.max(e.length,1);return cm(30*i,a)+n.slice(i,o).map(n=>function(t,e,n){return`<tr style="height:30px;">${sm(t,e,n)}</tr>`}(t,e,n)).join("")+cm(30*(r-o),a)}function hm(t){const e=Wf(t),{rows:n,columns:i}=im(t),{slice:o,page:r,totalPages:a,start:c,end:l,total:h}=om(t,n),u=o.length,d=u>300,f=h?lm(t,i,o,0,d?Math.min(u,60):u,u):`<tr><td style="padding:12px;color:${(t._theme??V).textMuted};" colspan="${Math.max(i.length,1)}">${t.schema.translate("No Data Available")}</td></tr>`,m=i.map(n=>function(t,e,n){const i=id(e);if(!function(t){return!1!==t.schema.tableViewSort}(t))return`<th style="${am(t)}">${i}</th>`;const o=n?.column===e,r=o?"desc"===n.direction?"descending":"ascending":"none",a=o?"desc"===n.direction?Zf:Qf:"";return`<th class="tableview-sort-header" data-column="${id(e)}" role="button" tabindex="0" aria-sort="${r}" style="${am(t)}cursor:pointer;user-select:none;">${i}${a}</th>`}(t,n,e)).join(""),p=a>1?`<div class="d3plus-table-view-pagination" style="display:flex;align-items:center;gap:8px;padding:6px 10px;border-top:1px solid ${rm(t).rule};font-size:12px;flex:0 0 auto;">\n <button type="button" class="tableview-page-prev"${r<=0?" disabled":""}>‹ ${t.schema.translate("Previous")}</button>\n <span>${h?c+1:0}–${l} / ${h}</span>\n <button type="button" class="tableview-page-next"${r>=a-1?" disabled":""}>${t.schema.translate("Next")} ›</button>\n </div>`:"",g=t.schema.tableViewClassName?` ${t.schema.tableViewClassName}`:"",y=Jf(t)+(function(t){return!1!==t.schema.tableViewDownload}(t)?function(t){const e=t.schema.translate("Download");return`<button type="button" class="table-view-control tableview-download-csv" aria-label="${e}" title="${e} CSV">${Yf}</button>`}(t):"")+(Hf(t)?function(t){const e="raw"===jf(t),n=t.schema.tableViewControlClassName?` ${t.schema.tableViewControlClassName}`:"",i=t.schema.translate(e?"Show Aggregate Data":"Show Raw Data");return`<button type="button" class="table-view-control tableview-source-toggle${e?" active":""}${n}" aria-label="${i}" title="${i}" aria-pressed="${e}">${Uf}</button>`}(t):""),x=d?"table-layout:fixed;":"";return`\n <div class="d3plus-table-view-frame" style="display:flex;flex-direction:column;width:100%;height:100%;box-sizing:border-box;background:${rm(t).background};color:${rm(t).text};font:12px/1.4 ${s.fontFamilyStringify(t.schema.fontFamily||"sans-serif")};">\n <div class="d3plus-table-view-toolbar" style="flex:0 0 auto;display:flex;gap:4px;padding:4px;">${y}</div>\n <div class="d3plus-table-view-scroll"${d?' data-tableview-virtual="1"':""} style="flex:1 1 auto;min-height:0;overflow:auto;">\n <table class="d3plus-table-view-table${g}" style="border-collapse:collapse;width:100%;${x}">\n <thead><tr>${m}</tr></thead>\n <tbody>${f}</tbody>\n </table>\n </div>\n ${p}\n </div>`}function um(t){const{rows:e,columns:n}=im(t),i=function(t,e){const n=[t.map(tm).join(",")];for(const i of e)n.push(t.map(t=>tm(i[t])).join(","));return n.join("\r\n")}(n,e),o=new Blob([i],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download="table-view.csv",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}function dm(t,e){t.querySelectorAll(".table-view-control").forEach(t=>{t.dataset.tableViewBound||(t.dataset.tableViewBound="1",Gf(e,t),t.addEventListener("mouseenter",()=>Gf(e,t,!0)),t.addEventListener("mouseleave",()=>Gf(e,t)))})}function fm(t,e){const n=t.querySelector(".d3plus-table-view-scroll[data-tableview-virtual]");if(!n||n.dataset.tableviewVirtualBound)return;const i=n.querySelector("tbody");if(!i)return;n.dataset.tableviewVirtualBound="1";const{rows:o,columns:r}=im(e),{slice:a}=om(e,o);let s=0;const c=()=>{s=0,function(t,e,n,i,o){const r=i.length,a=Math.max(1,Math.ceil(e.clientHeight/30)),s=Math.max(0,Math.floor(e.scrollTop/30)-10),c=Math.min(r,s+a+20);n.innerHTML=lm(t,o,i,s,c,r)}(e,n,i,a,r)};n.addEventListener("scroll",()=>{s||(s=requestAnimationFrame(c))},{passive:!0}),c()}const mm="viz-table-view-overlay";function pm(t){const e=t.target.closest(".tableview-sort-header");return e?.dataset.column}function gm(t){return{type:"htmlOverlay",key:mm,x:0,y:0,width:t.schema.width,height:t.schema.height,className:"d3plus-table-view",html:hm(t),events:{".table-view-toggle":{click:()=>xm(t)},".tableview-page-prev":{click:()=>bm(t,-1)},".tableview-page-next":{click:()=>bm(t,1)},".tableview-download-csv":{click:()=>um(t)},".tableview-source-toggle":{click:()=>function(t){(function(t,e){t._tableViewDataSource=e})(t,"raw"===jf(t)?"aggregate":"raw"),Of(t,0),ym(t)}(t)},".tableview-sort-header":{click:e=>{const n=pm(e);n&&km(t,n)},keydown:e=>{const n=e.key;if("Enter"!==n&&" "!==n)return;const i=pm(e);i&&(e.preventDefault(),km(t,i))}}},onUpdate:e=>function(t,e){dm(t,e),fm(t,e)}(e,t)}}function ym(t){const e=(t._featurePanels||[]).slice(),n=e.findIndex(t=>t.key===mm);if(Pf(t)){const i=gm(t);n>=0?e[n]=i:e.push(i)}else n>=0&&e.splice(n,1);t._featurePanels=e,function(t){const e=gd(t)?.querySelector(".d3plus-top-left-controls-item .table-view-toggle");if(!e)return;const n=Pf(t);e.classList.toggle("active",n),e.setAttribute("aria-pressed",String(n)),Gf(t,e,e.matches(":hover"))}(t),t._drawSceneToTarget&&t._sceneRenderer&&t._drawSceneToTarget(0)}function xm(t){!function(t,e){t._tableView=e}(t,!Pf(t)),Of(t,0),ym(t)}function bm(t,e){Of(t,Math.max(0,Tf(t)+e)),ym(t)}function km(t,e){const n=Wf(t);!function(t,e){t._tableViewSort=e}(t,{column:e,direction:n?.column===e&&"asc"===n.direction?"desc":"asc"}),Of(t,0),ym(t)}const _m={name:"tableView",layout:({viz:t})=>Pf(t)?{panel:gm(t),margin:{}}:{panel:null,margin:{}}};function vm(t){return function(t){return Boolean(t.schema.tableView)&&!t._ssr}(t)?{key:"table-view",html:Jf(t),styleSignature:qf(t),events:{".table-view-toggle":{click:()=>xm(t)}},onUpdate:e=>dm(e,t)}:null}const wm=["png","svg","jpg"];function Mm(t){if(!Array.isArray(t))return wm.slice();const e=[];for(const n of t){const t=String(n).toLowerCase().replace("jpeg","jpg");wm.includes(t)&&!e.includes(t)&&e.push(t)}return e}function Sm(t){return("string"==typeof t||"number"==typeof t?String(t).replace(/<[^>]*>/g,"").replace(/[\\/:*?"<>|\p{Cc}]/gu,"").replace(/\s+/g," ").trim().slice(0,100).trim():"")||"download"}function Cm(t){return Tc({_select:t._select})}function $m(t){const e=t.schema.title;return"function"==typeof e?e(t._filteredData||[]):void 0}function Am(t){const{filename:e,formats:n,background:i,callback:o,...r}=t.schema.saveControlConfig||{};return{filename:"string"==typeof e&&e.trim()?Sm(e):Sm($m(t)),formats:Mm(n),background:!1!==i&&("string"==typeof i&&i?i:Cm(t)),callback:"function"==typeof o?o:void 0,renderOptions:r}}function zm(t){const e="canvas"===t._renderer?t.toCanvas():t._select?.node?.(),n="canvas"===t._renderer?"canvas":"svg";return e?.localName===n?e:null}const Dm=["position","top","left","content-visibility","touch-action"];function Lm(t,e){let n=null;if("canvas"===t._renderer){const e=t.toSVGString();if(e){const t=(new DOMParser).parseFromString(e,"image/svg+xml");n=t.querySelector("parsererror")?null:t.documentElement}}else{const e=zm(t);n=e?e.cloneNode(!0):null,n&&function(t){t.removeAttribute("aria-hidden");for(const e of Dm)t.style?.removeProperty(e)}(n)}if(!n||"svg"!==n.localName)return null;if(e){const t=n.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("class","d3plus-save-background"),t.setAttribute("width","100%"),t.setAttribute("height","100%"),t.setAttribute("fill",e),n.insertBefore(t,n.firstChild)}return n}function Fm(t){const e=t.pixelRatio;return"number"==typeof e&&e>0?e:"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1}function Nm(t,e){const n=t.getBoundingClientRect().width;return n>0&&t.width/n<e-.01}function Bm(t,e){const{filename:n,background:i,callback:o,renderOptions:r}=Am(t),a=t=>{o?o(t):t&&console.error(t)},s=()=>a(new Error("The chart has not been rendered, so it cannot be saved."));if("svg"===e){const e=Lm(t,i);return e?void v.saveElement(e,{filename:n,type:"svg",callback:a}):s()}const c=zm(t);if(!c)return s();const l={...r,backgroundColor:i||("jpg"===e?Cm(t):void 0)},h={filename:n,type:e};"canvas"===t._renderer&&Nm(c,Fm(l))&&function(t,e,n,i,o){const r=i.backgroundColor,a=Lm(t,"string"==typeof r&&r),s=e.ownerDocument;if(!a||!s.body)return!1;const c=s.createElement("div");c.setAttribute("aria-hidden","true"),c.style.cssText="position:fixed;left:-100000px;top:0;";const l=s.importNode(a,!0);return c.appendChild(l),s.body.appendChild(c),v.saveElement(l,{...n,callback:t=>{c.remove(),o(t)}},i),!0}(t,c,h,l,a)||v.saveElement(c,{...h,callback:a},l)}const Em={png:"PNG image",svg:"SVG vector",jpg:"JPG image"};function Rm(t){return Mm(t.schema.saveControlConfig?.formats)}function Pm(t){return nd(t.schema,"saveControl",{base:Gu,active:qu,hover:Vu})}function Tm(t,e,n=!1){ed(e,Pm(t),n,e.classList.contains("active"))}const Om={position:"relative",display:"inline-flex","align-items":"center"},Wm={position:"absolute",top:"100%",left:"0","z-index":"1",display:"none","flex-direction":"column","min-width":"max-content"},jm={display:"flex"},Hm={display:"block",width:"100%","text-align":"start","white-space":"nowrap",cursor:"pointer"};function Im(t){const e=Boolean(t.schema.saveControlMenuClassName),n=(n,i)=>td(t.schema[n],i,e);return{menu:n("saveControlMenuStyle",Ku),item:n("saveControlMenuItemStyle",Yu),itemHover:n("saveControlMenuItemStyleHover",Uu)}}function Gm(...t){return t.flatMap(t=>Object.entries(t)).filter(([,t])=>null!=t&&!1!==t).map(([t,e])=>`${Qu(t)}:${id(e)}`).join(";")}function qm(t){const e=Rm(t),n=e=>t.schema.translate(e),i=n("Download"),o=t.schema.saveControlClassName?` ${id(t.schema.saveControlClassName)}`:"",r=(t,e)=>`<button type="button" class="save-control save-toggle${o}" aria-label="${id(t)}" title="${id(t)}"${e}>${Yf}</button>`;if(1===e.length){const t=`${i} (${n(Em[e[0]])})`;return`<span class="save-root" style="${Gm(Om)}">${r(t,` data-format="${e[0]}"`)}</span>`}const a=Im(t),s=Gm(a.item,Hm),c=t.schema.saveControlMenuClassName?` ${id(t.schema.saveControlMenuClassName)}`:"",l=e.map(t=>`<button type="button" role="menuitem" tabindex="-1" class="save-menu-item" data-format="${t}" style="${s}">${id(n(Em[t]))}</button>`).join("");return`<span class="save-root" style="${Gm(Om)}">`+r(i,' aria-haspopup="menu" aria-expanded="false"')+`<span class="d3plus-save-menu${c}" role="menu" aria-label="${id(i)}" style="${Gm(a.menu,Wm)}">${l}</span></span>`}const Vm=new WeakMap;function Km(t){return t instanceof Element?t.closest(".save-root"):null}function Ym(t){return t.querySelector(".save-toggle")}function Um(t){return Array.from(t.querySelectorAll(".save-menu-item"))}function Xm(t){return"true"===Ym(t)?.getAttribute("aria-expanded")}function Qm(t,e,n){const i=Ym(e),o=e.querySelector(".d3plus-save-menu");if(!i||!o)return;i.setAttribute("aria-expanded",String(n)),i.classList.toggle("active",n),Tm(t,i,i.matches(":hover"));const r=n?jm:Wm;o.style.setProperty("display",String(r.display))}function Zm(t,e,n=!1){Vm.get(e)?.(),Vm.delete(e),Qm(t,e,!1),n&&Ym(e)?.focus()}function Jm(t,e,n="first"){Qm(t,e,!0);const i=e.ownerDocument,o=n=>{e.isConnected&&e.contains(n.target)||Zm(t,e)};Vm.get(e)?.(),i.addEventListener("pointerdown",o,!0),Vm.set(e,()=>i.removeEventListener("pointerdown",o,!0));const r=Um(e);r["last"===n?r.length-1:0]?.focus()}function tp(t,e,n){const i=e.target.closest(".save-menu-item");i&&function(t,e,n){const{item:i,itemHover:o}=Im(t);ed(e,{base:{...i,...Hm},hover:o},n,!1)}(t,i,n)}function ep(t){return function(t){return Boolean(t.schema.saveControl)&&!t._ssr&&Rm(t).length>0}(t)?{key:"save",html:qm(t),styleSignature:JSON.stringify(Pm(t)),events:{".save-toggle":{click:e=>function(t,e){const n=Km(e.target),i=n&&Ym(n);if(!n||!i)return;const o=i.dataset.format;o?Bm(t,o):Xm(n)?Zm(t,n,!0):Jm(t,n)}(t,e),keydown:e=>function(t,e){const n=e.key,i=Km(e.target);i&&i.querySelector(".d3plus-save-menu")&&("ArrowDown"===n||"ArrowUp"===n?(e.preventDefault(),Jm(t,i,"ArrowUp"===n?"last":"first")):"Escape"===n&&Xm(i)&&(e.stopPropagation(),Zm(t,i,!0)))}(t,e)},".d3plus-save-menu":{keydown:e=>function(t,e){const n=e.key,i=Km(e.target);if(!i)return;const o=Um(i),r=o.indexOf(e.target),a=t=>{e.preventDefault(),o[(t+o.length)%o.length]?.focus()};"ArrowDown"===n?a(r+1):"ArrowUp"===n?a(r-1):"Home"===n?a(0):"End"===n?a(o.length-1):"Escape"===n?(e.preventDefault(),e.stopPropagation(),Zm(t,i,!0)):"Tab"===n&&Zm(t,i)}(t,e)},".save-menu-item":{click:e=>function(t,e){const n=Km(e.target),i=e.target.closest(".save-menu-item");n&&i&&(Zm(t,n,!0),Bm(t,i.dataset.format))}(t,e),mouseover:t=>function(t){t.target.closest(".save-menu-item")?.focus()}(t),focusin:e=>tp(t,e,!0),focusout:e=>tp(t,e,!1)},".save-root":{focusout:e=>function(t,e){const n=Km(e.target),i=e.relatedTarget;n&&i&&!n.contains(i)&&Xm(n)&&Zm(t,n)}(t,e)}},onUpdate:e=>{const n=e.querySelector(".save-toggle");n&&!n.dataset.saveBound&&(n.dataset.saveBound="1",Tm(t,n),n.addEventListener("mouseenter",()=>Tm(t,n,!0)),n.addEventListener("mouseleave",()=>Tm(t,n)))}}:null}const np="rgb(255, 255, 255)",ip=t=>Boolean(t)&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t;function op(t){if(t._ssr||"undefined"==typeof window||"function"!=typeof getComputedStyle)return{dark:!1,background:np};let e=t._select?.node?.()??null;for(;e;){const t=getComputedStyle(e).backgroundColor;if(ip(t))return{dark:Y(t),background:t};e=e.parentElement}const n=getComputedStyle(document.documentElement).colorScheme||"",i=n.includes("dark")&&(!n.includes("light")||"function"==typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches);return i?{dark:i}:{dark:i,background:np}}function rp(t){return op(t).dark}function ap(t){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};const e="function"==typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):null;e?.addEventListener?.("change",t);const n="function"==typeof MutationObserver?new MutationObserver(t):null;for(const t of[document.documentElement,document.body])t&&n?.observe(t,{attributes:!0});const i=e=>{/background/.test(e.propertyName||"")&&t()};return document.addEventListener("transitionend",i),()=>{e?.removeEventListener?.("change",t),n?.disconnect(),document.removeEventListener("transitionend",i)}}function sp(t){t._themeWatch||t._ssr||"undefined"==typeof window||(t._themeWatch=ap(()=>{const e=t._select?.node?.();e&&e.isConnected&&t._theme&&!t._theme.painted&&rp(t)!==t._theme.dark&&t.render?.()}))}function cp(t){t._themeWatch?.(),t._themeWatch=void 0}function lp(t){const e=Q(t.schema.theme,op(t),t.schema.colorDefaults);return t._theme=e,$i(t,e),e.painted?cp(t):sp(t),e}function hp(t){const e=t._theme;if(!e?.painted)return;const{width:n,height:i}=t.schema,o={key:"viz-background",interactive:!1,paint:{fill:e.background}},r=function(t){if(t._ssr||!t._tileGroup||!t._margin)return;const{top:e,right:n,bottom:i,left:o}=t._margin,{width:r,height:a}=t.schema;return{x:o,y:e,width:r-o-n,height:a-e-i}}(t);if(!r)return{...o,type:"rect",x:0,y:0,width:n,height:i};const{x:a,y:s}=r;return{...o,type:"path",d:`M0,0H${n}V${i}H0ZM${a},${s}V${s+r.height}H${a+r.width}V${s}Z`}}function up(t){const e=hp(t);return e?[e]:[]}function dp(t){return t&&(t.painted||t.dark)?t.dark?"dark":"light":""}function fp(t){const e=dp(t._theme),n=t._sceneRenderer?.elements?.()??[];for(const t of n)"div"===t.localName&&"style"in t&&(t.style.colorScheme=e)}function mp(t,e,n,i){const o={};for(const[e,n]of Object.entries(i))o[e]=Z(t._theme,t=>n(t.overlay),void 0);return et(e,n,o)}function pp(t){return Boolean(t._searchOpen)}function gp(t){return nd(t.schema,"searchControl",{base:ju,active:Hu,hover:Iu})}function yp(t,e,n=!1){ed(e,gp(t),n,e.classList.contains("active"))}const xp=`<svg ${sd}><circle cx="10" cy="9" r="7"/><line x1="21" y1="20" x2="15" y2="14"/></svg>`,bp=`<svg ${sd}><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>`,kp={width:"0",padding:"0",border:"none",opacity:"0","pointer-events":"none"},_p={width:"120px",padding:"0 22px 0 6px",border:"1px solid #ccc","border-radius":"3px",opacity:"1","pointer-events":"auto"},vp={height:"20px","box-sizing":"border-box",margin:"0",font:`12px/1 ${s.fontFamilyStringify(s.fontFamily)}`,transition:"width 0.15s ease, opacity 0.15s ease"},wp={position:"relative",display:"inline-block"},Mp={display:"inline-flex","align-items":"center"},Sp={position:"absolute",top:"50%",right:"2px",transform:"translateY(-50%)",display:"inline-flex","align-items":"center","justify-content":"center",visibility:"visible",width:"16px",height:"16px",margin:"0",padding:"0",border:"none",background:"none",cursor:"pointer"},Cp={...Sp,visibility:"hidden",cursor:"default"},$p={position:"absolute",top:"100%",left:"0","margin-top":"4px",width:"100%","box-sizing":"border-box",display:"block",visibility:"visible",background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)","font-size":"11px","text-align":"center",padding:"2px 4px","white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis","pointer-events":"none"},Ap={...$p,visibility:"hidden"};function zp(t){return Object.entries(t).map(([t,e])=>`${Qu(t)}:${e}`).join(";")}function Dp(t,e){const n=e?_p:kp;for(const e in n)t.style.setProperty(Qu(e),n[e])}function Lp(t){const e=t.schema.searchControlClassName?` ${t.schema.searchControlClassName}`:"",n=t.schema.translate("Search"),i=pp(t),o=t._searchTerm||"",r=o.trim().length>0,a=zp({...vp,...i?_p:kp,...Zt(t)?{transition:"none"}:{}}),s=zp(r?Sp:Cp),c=zp(wp);return`<span class="search-root" style="${zp(Mp)}"><button type="button" class="search-control search-toggle${i?" active":""}${e}" aria-label="${n}" aria-pressed="${i}">${xp}</button><span class="search-input-wrap" style="${c}"><input type="text" class="search-control search-input" placeholder="${n}" aria-label="${n}" value="${id(o)}" style="${a}"${i?"":' tabindex="-1"'}/><button type="button" class="search-control search-clear" aria-label="${t.schema.translate("Clear")}" style="${s}"${r?"":' tabindex="-1"'}>${bp}</button><span class="search-count" aria-live="polite"></span></span></span>`}function Fp(t,e,n,i){const o=t.schema.searchAccessor(e,n);if("string"==typeof o&&o.toLowerCase().includes(i))return!0;return t._ids(e,n).some(t=>"string"==typeof t&&t.toLowerCase().includes(i))}function Np(t,e){const n=e.trim().toLowerCase();if(!n)return[];const i=[];return De(t._chartScene||[],(e,o,r)=>{Fp(t,e,o,n)&&i.push({node:r,row:e,index:o})}),i}function Bp(t,e){const n=Lp(t),i=function(t){const e=t._featurePanels??[];for(const t of e){if("viz-top-left-controls"!==t?.key||!t.children)continue;const e=t.children.find(t=>"viz-top-left-controls-search"===t.key);if(e)return e}return null}(t);i&&(i.html=n),a.markOverlayHtmlSynced(e,n)}function Ep(t,e){const n=e.querySelector(".search-count");if(!n)return;const i=t._searchTerm||"",o=i.trim().length>0,r=o?Np(t,i).length:0;"number"==typeof t._searchMatchIndex&&t._searchMatchIndex>=r&&(t._searchMatchIndex=void 0),function(t,e,n,i,o){const r=mp(t,n?$p:Ap,$p,{background:t=>t.background,border:t=>`1px solid ${t.border}`,color:t=>t.text});for(const t in r)e.style.setProperty(Qu(t),r[t]);const{text:a,label:s}=function(t,e,n){let i;return i=0===n?t.schema.translate("No Matches"):"number"!=typeof e?`${n} ${t.schema.translate(1===n?"Match":"Matches")}`:`${t.schema.translate("Match")} ${e+1}/${n}`,{text:i,label:i}}(t,i,o);e.textContent=n?a:"",e.setAttribute("aria-label",s)}(t,n,o,t._searchMatchIndex,r)}function Rp(t,e,n){const i=n.trim().length>0;t._searchMatchIndex=void 0;const o=e.querySelector(".search-clear");o&&function(t,e){const n=e?Sp:Cp;for(const e in n)t.style.setProperty(Qu(e),n[e]);t.tabIndex=e?0:-1}(o,i),Ep(t,e)}function Pp(t,e){t._searchOpen=!1,t._searchTerm="",t.highlight(t._searchPrevHighlight??!1),t._searchPrevHighlight=void 0,Bp(t,e),Rp(t,e,"");const n=e.querySelector(".search-toggle");n&&(n.classList.remove("active"),n.setAttribute("aria-pressed","false"),yp(t,n,n.matches(":hover")));const i=e.querySelector(".search-input");i&&(i.value="",i.setAttribute("tabindex","-1"),Dp(i,!1))}function Tp(t,e){const n=e.currentTarget;pp(t)?Pp(t,n):function(t,e){t._searchOpen=!0,t._searchPrevHighlight=t._highlight,Bp(t,e);const n=e.querySelector(".search-toggle");n&&(n.classList.add("active"),n.setAttribute("aria-pressed","true"),yp(t,n,n.matches(":hover")));const i=e.querySelector(".search-input");i&&(i.removeAttribute("tabindex"),Dp(i,!0),i.focus())}(t,n)}function Op(t,e,n){t._searchTerm=n,t.highlight(function(t,e){const n=e.trim().toLowerCase();return n?(e,i)=>Fp(t,e,i,n):t._searchPrevHighlight??!1}(t,n)),Bp(t,e),Rp(t,e,n)}function Wp(t,e,n){if("canvas"===t._renderer||"function"!=typeof t._zoomToBounds)return;const i=e.parentElement?.parentElement,o=i?.querySelector("svg");if(!i||!o)return;const r=function(t,e){const n=t.querySelectorAll("[data-key]");for(const t of n)if(t.getAttribute("data-key")===String(e))return t;return null}(i,n);if(!r)return;const a=r.getBoundingClientRect(),s=o.getBoundingClientRect();(a.width||a.height)&&t._zoomToBounds([[a.left-s.left,a.top-s.top],[a.right-s.left,a.bottom-s.top]],Jt(t))}function jp(t,e){const n=e,i=e.currentTarget;"Escape"===n.key?Pp(t,i):"Enter"===n.key&&(n.preventDefault(),function(t,e,n){const i=t._searchTerm||"";if(!i.trim())return;const o=Np(t,i);if(!o.length)return;const r=o.length,a=t._searchMatchIndex,s=(("number"==typeof a?a:1===n?-1:0)+n+r)%r;t._searchMatchIndex=s,Ep(t,e),Wp(t,e,o[s].node.key)}(t,i,n.shiftKey?-1:1))}function Hp(t){return function(t){return Boolean(t.schema.search)&&!t._ssr}(t)?{key:"search",html:Lp(t),styleSignature:JSON.stringify(gp(t)),events:{".search-toggle":{click:e=>Tp(t,e)},".search-clear":{click:e=>function(t,e){const n=e.currentTarget,i=n.querySelector(".search-input");i&&(i.value=""),Op(t,n,""),i?.focus()}(t,e)},".search-input":{input:e=>function(t,e){const n=e.target;Op(t,e.currentTarget,n.value)}(t,e),keydown:e=>jp(t,e)}},onUpdate:e=>{Ep(t,e);const n=e.querySelector(".search-toggle");n&&!n.dataset.searchBound&&(n.dataset.searchBound="1",yp(t,n),n.addEventListener("mouseenter",()=>yp(t,n,!0)),n.addEventListener("mouseleave",()=>yp(t,n)));const i=e.querySelector(".search-input");i&&!i.dataset.searchBlurBound&&(i.dataset.searchBlurBound="1",i.addEventListener("blur",n=>function(t,e,n){if((t._searchTerm||"").trim().length>0)return;const i=n.relatedTarget;i&&e.contains(i)||Pp(t,e)}(t,e,n)))}}:null}function Ip(t,e){if(!e.length)return null;const n=e.map(t=>`${t.key}:${t.html}|${t.styleSignature??""}`).join("||"),i=t._topLeftControlsBox;if(i&&i.signature===n)return i.measurement;const o=function(t,e){const n=gd(t);if(!n){let t=0;return{items:e.map(e=>{const n={...e,x:t};return t+=32,n}),width:Math.max(0,t-4),height:20}}const i=document.createElement("div");i.className="d3plus-top-left-controls",i.style.setProperty("display","inline-flex"),i.style.setProperty("align-items","center"),i.style.setProperty("gap","4px"),i.style.setProperty("position","absolute"),i.style.setProperty("visibility","hidden"),i.style.setProperty("pointer-events","none"),i.innerHTML=e.map(t=>`<span class="tlc-item" data-tlc-key="${t.key}" style="display:inline-flex;align-items:center;">${t.html}</span>`).join("");for(const t of e)t.onUpdate?.(i);n.appendChild(i);const o=i.getBoundingClientRect(),r=Array.from(i.querySelectorAll(":scope > .tlc-item")),a=e.map((t,e)=>{const n=r[e]?.getBoundingClientRect();return{...t,x:n?Math.round(n.left-o.left):0}});return n.removeChild(i),{items:a,width:o.width?Math.ceil(o.width):0,height:o.height?Math.ceil(o.height):0}}(t,e);return t._topLeftControlsBox={width:o.width,height:o.height,signature:n,measurement:o},o}function Gp(t,e){const n=Ip(t,e);return n?{type:"group",key:"viz-top-left-controls",children:n.items.map(t=>({type:"htmlOverlay",key:`viz-top-left-controls-${t.key}`,x:4+t.x,y:4,className:"d3plus-top-left-controls-item",html:t.html,events:t.events,onUpdate:t.onUpdate}))}:null}function qp(t,e){const n=Ip(t,e);return n?{width:n.width?n.width+4:0,height:n.height?n.height+4:0}:null}function Vp(t,e){const n=qp(t,e);return n&&n.height?n.height+4:0}const Kp=[Rf,vm,ep,Hp];function Yp(t){const e=[];for(const n of Kp){const i=n(t);i&&e.push(i)}return e}const Up={name:"topLeftControls",layout:({viz:t})=>{const e=Yp(t);return e.length?{panel:Gp(t,e),margin:{}}:{panel:null,margin:{}}}},Xp=["x","x2","y","y2"];function Qp(t,e){const n=t[`_${e}Config`];return t[`_${e}Time`]||"time"===n?.scale?po(n?.rangeBreaks):[]}function Zp(t,e,n){const i=t[`_${e}Config`];return!!po(i?.rangeBreaks).length&&(n instanceof Date?!isNaN(+n):!("number"==typeof n&&String(Math.abs(n)).length<=5)&&(("string"==typeof n||"number"==typeof n)&&Number.isFinite(fo(n))))}function Jp(t){const e=t._data?.[0],n=t.schema.time;if(!e||"function"!=typeof n)return[];const i=n(e,0);for(const n of Xp){const o=t[`_${n}`];if("function"!=typeof o||o(e,0)!==i)continue;const r=t[`_${n}Config`],a=po(r?.rangeBreaks);if(a.length)return a}return[]}const tg=t=>t instanceof Date||"number"==typeof t?+t:NaN;function eg(t,e){let n=e;return Xp.forEach(e=>{const i=Qp(t,e);if(!i.length||!n.length)return;const o=n.map(t=>tg(t[e])).filter(Number.isFinite);if(!o.length)return;const[r,a]=d.extent(o),s=_o(i,r,a),c=n.filter(t=>!s(tg(t[e])));c.length<n.length&&Pt(t,`rangeBreaks-${e}`,`Some data falls inside ${e}Config.rangeBreaks and is not drawn.`),n=c}),n}function ng(t,e,n){const i=Qp(t,e);if(!i.length)return n;const o=t[`_${e}Config`],{space:r}=no(o?.breakConfig),a=Do(i,{space:r});return a.domain(n.domain()),a.range(n.range()),a}function ig(t){const e=t.schema.filter,n=t._filterApplied;return e&&n?(t,i)=>n(t)||e(t,i):e}function og(t){if(!t.schema.timeline)return{min:1,max:1/0};const e=t.schema.timelineConfig||{},n=cc(e.brushMin,e.brushMax);return!1===e.brushing?{...n,min:1}:n}function rg(t,e,n){const i=[...new Set(e.map(Number))].sort((t,e)=>t-e);if(i.length<=n)return()=>!0;const o=i[i.length-n],a=t.schema.time;return(t,e)=>+r.date(a(t,e))>=o}function ag(t){const e=t.schema.timelineConfig||{},n=t.schema.timelineDefault&&t.schema.timelineDefault.length?t.schema.timelineDefault:e.selection;if(null==n||!1===n)return;const i=[].concat(n).map(t=>r.date(t)).filter(t=>t instanceof Date&&!isNaN(+t)).sort((t,e)=>+t-+e);return i.length?[i[0],i[i.length-1]]:void 0}function sg(t){let e;const n=t.schema.time,i=n&&!t.schema.timeFilter&&ag(t);if(n&&i&&t._data.length){const[t,e]=i.map(Number);return(i,o)=>{const a=Number(r.date(n(i,o)));return a>=t&&a<=e}}if(t.schema.time&&!t.schema.timeFilter&&t._data.length){const n=t._data.map(t.schema.time).map(t=>r.date(t)),i=t._data[0],o=0;e=t.schema.discrete&&`_${t.schema.discrete}`in t&&t[`_${t.schema.discrete}`](i,o)===t.schema.time(i,o)?rg(t,n,og(t).max):rg(t,n,Math.max(1,Math.ceil(og(t).min)))}return e}function cg(t,e,i,o,r,a=t._data){const s=[],c=[];if(a.length){const l=t.schema.timeFilter||r;let h=l?a.filter(l):a;const u=ig(t);u&&(h=h.filter(u));const f=[];for(let e=0;e<=i;e++)f.push(t.schema.groupBy[e]);f.push(...function(t){const e=t.schema.discrete;if(!e)return[];const n=[],i=t;for(const o of[e,`${e}2`])`_${o}`in t?n.push(i[`_${o}`]):"function"==typeof t.schema[o]&&n.push(t.schema[o]);return n}(t));const m=function(t){let e,n=0;return i=>{if(e)return e.get(i)??-1;const o=t.indexOf(i);if(n+=o<0?t.length:o+1,n>=t.length){e=new Map;for(let n=t.length-1;n>=0;n--)e.set(t[n],n)}return o}}(t._data),p=d.rollup(h,e=>{const i=m(e[0]),r=t.schema.shape(e[0],i),a=o(e[0],i),l=t._mergeRows?t._mergeRows(e):n.merge(e,t.schema.aggs);t._hidden.includes(a)||t._solo.length&&!t._solo.includes(a)||(!t.schema.discrete&&"Line"===r||t._unmergedShapes?.includes(r)?s.push(...e):s.push(l)),c.push(l)},...f);e.filteredData=s,e._thresholdTree=p}else e.filteredData=s;e.legendData=c}function lg(t){const e="function"==typeof t.config?t.config():{};return Object.freeze(e)}function hg(t){const e=(e,n,i)=>{const o=t.schema.shape(e,n);"fill"===i&&"Line"===o&&(i="stroke");const r=t.schema.shapeConfig[o]&&t.schema.shapeConfig[o][i]?t.schema.shapeConfig[o][i]:t.schema.shapeConfig[i];return"function"==typeof r?r.bind(t)(e,n):r};return{getAttr:e,colorOf:(e,n)=>"function"==typeof t.schema.color?t.schema.color(e,n):void 0,keyOf:(t,n,i)=>[null==i?e(t,n,"fill"):"string"==typeof i?i:JSON.stringify(i),e(t,n,"opacity"),e(t,n,"texture")].join("_")}}function ug(t){const{getAttr:e,colorOf:i,keyOf:o}=hg(t),r=(t,e)=>o(t,e,i(t,e)),a=j(t.schema.legend);if(a&&!a.value)return{legendData:[],legendKey:r,getAttr:e};const s=function(t){const e=t._legendData||[];return t.schema.colorScale?e.filter((e,n)=>void 0===t.schema.colorScale(e,n)):e}(t),c=new Map;s.forEach((t,e)=>{const n=i(t,e),r=o(t,e,n),a=c.get(r);a?a.leaves.push(t):c.set(r,{leaves:[t],color:n})});const l=Array.from(c.values(),({leaves:e,color:i})=>({datum:n.merge(e,t.schema.aggs),color:i})),h=l.map(t=>t.datum),u=h.map((e,n)=>t._ids(e,n).slice(0,t._drawDepth+1));t._legendDepth=0;for(let e=0;e<=t._drawDepth;e++){const n=u.map(t=>t[e]);if(!n.some(t=>Array.isArray(t))&&Array.from(new Set(n)).length===h.length){t._legendDepth=e;break}}t._legendCategories=function(t,e){const n=t.schema.groupBy?.[t._legendDepth??0];return"function"==typeof n&&e.some((e,i)=>{const o=n.bind(t)(e,i);return Array.isArray(o)&&o.length>1})}(t,h)?function(t){const e=new WeakMap,n=new Set;for(const{datum:i,color:o}of t){const t=Ol(o);if(void 0===t||n.has(t))return;n.add(t),e.set(i,t)}return e}(l):void 0;const d=t=>t._isAggregation?1:0;return h.sort((e,n)=>d(e)-d(n)||t.schema.legendSort(e,n)),{legendData:h,legendKey:r,getAttr:e}}function dg(t,e,n){const{legendData:i,legendKey:o,getAttr:a}=e,s=(e,n)=>{let i=t._id(e,n);return Array.isArray(i)&&(i=i[0]),t._hidden.includes(i)||t._solo.length>0&&!t._solo.includes(i)},c={transform:`translate(${n.x}, ${n.y})`},l=r.elem("g.d3plus-viz-legend",{condition:n.visible&&!t.schema.legendConfig.select,enter:c,parent:t._select,duration:0,update:c}).node();t._legendClass.renderMode("compute").id(o).align(n.align).direction(n.direction).duration(Jt(t)).data(n.visible?i:[]).height(n.height).locale(t.schema.locale).parent(t).select(l).shape((e,n)=>{const i=t.schema.shape(e,n);return"Circle"===i||"Line"===i?i:"Rect"}).verticalAlign(n.verticalAlign).width(n.width).shapeConfig(te.bind(t)(t.schema.shapeConfig,"legend")).shapeConfig({fill:(e,n)=>s(e,n)?t.schema.hiddenColor(e,n):a(e,n,"fill"),labelConfig:{fontOpacity:(e,n)=>s(e,n)?t.schema.hiddenOpacity(e,n):1}}).config(t.schema.legendConfig).render()}function fg(t){const{width:e,height:n}=t.outerBounds();return!(!e||!n)&&(t._lineData||[]).every(t=>{if(!t.sentence)return!0;const e=t.lines.length;return t.width>0&&!t.truncated&&e<=`${t.sentence}`.split("\n").length&&t.height<=t.og.height})}function mg(t,e){const n=lg(t);return!1!==iy(t.schema.legendPosition.bind(t)(n),t)&&Boolean(t.schema.legend.bind(t)(n,e.legendData))}function pg(t,e,n,i=ug(t)){const o=mg(t,i)&&!t.schema.legendConfig.select;if(dg(t,i,{x:0,y:0,...Ad(e,n),align:"left",direction:e,verticalAlign:"top",visible:o}),!o)return null;const r=t._legendClass,a=(r._lineData||[]).every(t=>t.width>0),{width:s,height:c}=r.outerBounds();return a&&s&&c?{width:s,height:c}:null}function gg(t,e,n){if(Sd(t,"legend"))return pg(t,$d(t,"legend"),{width:t.schema.width-n.left-n.right,height:t.schema.height-n.top-n.bottom},e),{panel:null,margin:{}};const i=lg(t),o=iy(t.schema.legendPosition.bind(t)(i),t),r=["top","bottom"].includes(o),a=t.schema.legendPadding(t)?t._padding:{top:0,right:0,bottom:0,left:0},{drop:s,insetRight:c,shorten:l}=function(t,e,n,i){const o=cy(t,e,n.top,"left"===e?n.left:n.right),r=Pd(t,e,n.bottom+i.bottom,n.right+i.right);return{drop:o,insetRight:r.inset,shorten:r.drop}}(t,o,n,a),h={x:r?n.left+a.left:n.left,y:(r?n.top:n.top+a.top)+s,width:(r?t.schema.width-(n.left+n.right+a.left+a.right):t.schema.width-(n.left+n.right))-c,height:(r?t.schema.height-(n.bottom+n.top):t.schema.height-(n.bottom+n.top+a.bottom+a.top))-s-l,align:r?"center":o,direction:r?"row":"column",verticalAlign:r?o:"middle",visible:mg(t,e)};let u=0;"top"===o?u=function(t,e,n,i,o){const r=n.visible&&!t.schema.legendConfig.select?hy(t,i,n.x,o,!0):[{left:0,right:0,drop:0}];for(const[i,{left:o,right:a,drop:s}]of r.entries())if(dg(t,e,{...n,x:n.x+o,y:n.y+s,width:n.width-o-a,height:n.height-s}),i===r.length-1||fg(t._legendClass))return s;return 0}(t,e,h,n.top,n.right+a.right):dg(t,e,h);const d=t._legendClass.outerBounds(),f={};return!t.schema.legendConfig.select&&d.height&&(f[o]=r?u+d.height+2*t._legendClass.padding():d.width+2*t._legendClass.padding()),{panel:null,margin:f}}const yg={name:"legend",configFields:["legend","legendConfig","legendPadding","legendPosition","legendSort"],layout:({viz:t,layoutMargin:e})=>gg(t,ug(t),e)};function xg(t){return t instanceof Date?""+ +t:`${t}`}function bg(t){if(null!=t&&""!==t)return t instanceof Date||"string"==typeof t||"number"==typeof t||"boolean"==typeof t?t:`${t}`}function kg(t,e){const n=t instanceof Date?+t:t,i=e instanceof Date?+e:e;return"number"==typeof n&&"number"==typeof i?n-i:`${t}`.localeCompare(`${e}`,void 0,{numeric:!0})}function _g(t,e){const n=t.slice();if(Array.isArray(e)){const t=new Map(e.map((t,e)=>[xg(t),e])),i=e=>t.get(xg(e))??1/0;return n.sort((t,e)=>i(t)-i(e))}return"function"==typeof e?n.sort(e):"data"===e?n:(n.sort(kg),"descending"===e?n.reverse():n)}function vg(t,e,n){const i=new Map;t.forEach((t,n)=>{const o=bg(e(t,n));if(void 0===o)return;const r=xg(o);let a=i.get(r);a||i.set(r,a={key:r,value:o,rows:[]}),a.rows.push(t)});const o=new Map(Array.from(i.values()).map(t=>[t.key,t]));return _g(Array.from(i.values()).map(t=>t.value),n).map(t=>o.get(xg(t)))}function wg(t,e){const n=t.schema.facet;if(!n)return[];const i=t._data||[],o=ig(t);return vg(o?i.filter(o):i,n,e)}function Mg(t,e,n){const i={};cg(t,i,t._drawDepth,t._id,n,e);let o=i.filteredData??[];return e.length&&i._thresholdTree&&t._thresholdFunction&&(o=t._thresholdFunction(o,i._thresholdTree,t._thresholdRows??i.legendData)),o}function Sg(t){return sg(t)}function Cg(t,e){if(t instanceof Date){const n=e.filter(t=>t instanceof Date).sort((t,e)=>+t-+e);return p.formatDate(t,n)}return`${t}`}const $g=1/3;function Ag(t){return"top"===t||"bottom"===t}function zg(t){return!t.schema.bivariate&&!t.schema.bucketAxis&&ls(t._scaleType)}function Dg(t,e){const n="end"===t.align;return Ag(t.orient)?{...t,y:n?t.y+t.height-e:t.y,height:e}:{...t,x:n?t.x+t.width-e:t.x,width:e}}function Lg(t,e){const n=t[e];return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Fg(t,e=[]){return"text"===t.type?e.push(t.lines.map(t=>t.text).join(" ")):"group"===t.type&&t.children.forEach(t=>Fg(t,e)),e}function Ng(t){const e=t._colorScaleClass,{height:n}=e.outerBounds();return{claim:n?n+2*e.padding():0,labels:n?Fg(e.toScene()):[]}}const Bg=t=>t.filter(t=>t.endsWith("...")).length;function Eg(t,e,n){return!(!e.claim||e.claim>n.claim)&&(t?e.labels.join("\n")===n.labels.join("\n"):e.labels.length>=Math.ceil(n.labels.length/2)&&Bg(e.labels)<=Bg(n.labels))}const Rg=Ra,Pg=t=>new Rg[t];function Tg(t,e,n){return"function"==typeof t?t(e,n):t}function Og(t,e,n,i){const o=Pr(Tg(t.texture,e,n),()=>i,()=>Tg(t.stroke,e,n),t.textureDefault);return o?`pattern:${o}`:"string"==typeof i?i:void 0}function Wg(t,e,n){const i=Tg(t.fill,e,n),o=Tg(t.stroke,e,n),r=Tg(t.strokeWidth,e,n),a=Tg(t.opacity,e,n),s=Tg(t.vectorEffect,e,n);return{fill:Og(t,e,n,i),stroke:o,strokeWidth:r,opacity:a,vectorEffect:"none"===s||"non-scaling-stroke"===s?s:void 0}}function jg(t,e,n){return t._drawLabel(e.data??e,e.i??n)}function Hg(t,e,n,i="shape"){return te.bind(t)(n??t.schema.shapeConfig,i,e)}function Ig(t,e){const n=t.schema.shapeConfig??{},i=t=>t&&"object"==typeof t?t.labelConfig:void 0,o={...i(n),...i(n[e])};for(const t in o)Bc(o[t])&&delete o[t];const{labelConfig:r}=Hg(t,e,{labelConfig:o});return r??{}}function Gg(t,e={}){if(!t)return[];const n=!1!==e.shape,i=!1!==e.labels;try{t.render();const e=[];if(n&&"function"==typeof t.toScene){const n=t.toScene();n&&Array.isArray(n.children)&&e.push(...n.children)}if(i){const n=t._labelClass;if(n&&"function"==typeof n.toScene){const t=n.toScene();t&&Array.isArray(t.children)&&e.push(...t.children)}}return e}catch{return[]}}function qg(t){const e=ah(t);if("function"!=typeof t.schema.colorScale)return e;const i=t._colorScaleRows?t._colorScaleRows():function(t){const e=t.schema.facet,i=Array.from(d.rollup(t._data,e=>n.merge(e,t.schema.aggs),(n,i)=>`${t.schema.time?t.schema.time(n,i):"all"}-${e?xg(e(n,i)):"all"}-${t._ids(n,i).join("_")}`).values());return i.filter((e,n)=>{const i=t.schema.colorScale(e,n);return null!=i})}(t);return e.length?[...i,...e]:i}const Vg=["axisConfig","labelConfig","legendConfig","rectConfig"],Kg=new WeakMap,Yg=["fillOpacity","opacity","stroke","strokeDasharray","strokeLinecap","strokeOpacity","strokeWidth"];function Ug(t){let e;const n=new Map,i=(i,o)=>{void 0===e&&(e=function(t){const e=lh(t);if(!e)return null;const n=new Map;return e.rows.forEach((t,i)=>{const o=e.colorOf(t,i);n.has(o)||n.set(o,{row:t,i:i})}),n}(t));const r=e?.get(i.color)??e?.values().next().value;if(!r)return;const{row:a,i:s}=r,c=t._colorScaleShape(a,s),l="Line"===c?"":c;return n.has(l)||n.set(l,Hg(t,l)),Tg(n.get(l)[o],a,s)};return Object.fromEntries(Yg.map(t=>[t,e=>i(e,t)]))}function Xg(t,e,n){const i={opacity:e.orient?1:0,transform:`translate(${e.x}, ${e.y})`},o=r.elem("g.d3plus-viz-colorScale",{condition:n&&!t.schema.colorScaleConfig.select,enter:i,parent:t._select,duration:0,update:i}).node(),a=sh(t);if(!a)return;const s=t._colorScaleClass,c=t.schema.colorScaleConfig;s.config(ut(s,[...Vg,...Kg.get(s)??[]])),Kg.set(s,Object.keys(c));const{limit:l}=e,h=Pc(t);s._bivariateFields=h?function(t,e){return e.fields.map((e,n)=>e??`${t.schema.translate("Value")} ${n+1}`)}(t,h):void 0,s.renderMode("compute").bivariate(Boolean(h)).align(e.align).duration(Jt(t)).data(qg(t)).locale(t.schema.locale).orient(e.orient).select(o).value(a).legendConfig({shapeConfig:Ug(t)}).ordinalRamp(ah(t).length>0).axisConfig({maxSize:void 0===l?void 0:()=>function(t,e,n){return Math.max(0,Math.floor(t-e-2*n))}(l,s.size(),s.padding())}).config(c).width(e.width).height(e.height).hover(!1).render()}function Qg(t){return iy(t.schema.colorScalePosition.bind(t)(lg(t)),t)}function Zg(t,e,n){const i=Boolean(sh(t))&&!1!==Qg(t)&&!t.schema.colorScaleConfig.select,o=Ad(e,n),r=t.schema.colorScaleMaxSize,a=t.schema.colorScaleConfig;if(Xg(t,{x:0,y:0,width:Lg(a,"width")??("row"===e?d.min([r,o.width]):o.width),height:Lg(a,"height")??("column"===e?d.min([r,o.height]):o.height),orient:"column"===e?"right":"bottom",align:"start"},i),!i)return null;const{width:s,height:c}=t._colorScaleClass.outerBounds();return s&&c?{width:s,height:c}:null}const Jg={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:t,layoutMargin:e})=>{if(Sd(t,"colorScale"))return Zg(t,$d(t,"colorScale"),{width:t.schema.width-e.left-e.right,height:t.schema.height-e.top-e.bottom}),{panel:null,margin:{}};const n=Qg(t),i=Ag(n),o=sh(t)&&n,r=t.schema.colorScalePadding(t)?t._padding:{top:0,right:0,bottom:0,left:0},a=cy(t,n,e.top,"left"===n?e.left:e.right),s=Pd(t,n,e.bottom+r.bottom,e.right+r.right),c=t.schema.colorScaleConfig,l=Lg(c,"width"),h=Lg(c,"height"),u=t.schema.width-(e.left+e.right+r.left+r.right)-s.inset,f=i?d.min([l??t.schema.colorScaleMaxSize,u]):t.schema.width-(e.left+e.right),m=t.schema.height-(e.bottom+e.top+r.bottom+r.top)-a-s.drop,p=i?t.schema.height-(e.bottom+e.top):d.min([h??t.schema.colorScaleMaxSize,m]),g=function(t,e){const n=t[Ag(t.orient)?"height":"width"];if(void 0===e)return{...t,limit:n*$g};const i=Math.max(0,Math.min(e,n));return{...Dg(t,i),limit:i}}({x:i?e.left+r.left+(u-f)/2:e.left,y:i?e.top:e.top+r.top+a+(m-p)/2,width:f,height:p,orient:n,align:{bottom:"end",left:"start",right:"end",top:"start"}[n]||"bottom"},i?h:l),y=o&&!t.schema.colorScaleConfig.select,x=e=>{Xg(t,e,Boolean(o));const n=y?function(t,e){if(void 0===e.limit||!zg(t))return;const n=Ag(e.orient)?"height":"width",i=t.legendConfig()[n];return"number"==typeof i?i===e[n]?void 0:Dg(e,i):t.outerBounds()[n]+2*t.padding()>e.limit&&e[n]!==e.limit?Dg(e,e.limit):void 0}(t._colorScaleClass,e):void 0;n&&Xg(t,n,!0)},b=y&&"top"===n?function(t,e,n,i){const o=t.schema.width-e.x-e.width,r=hy(t,e.y,e.x,o,!0);if(1===r.length&&!r[0].drop)return i(e),0;i(e);const a=Ng(t),s=zg(t._colorScaleClass);for(const[o,{left:c,right:l,drop:h}]of r.entries()){const u=o===r.length-1;if(i({...e,x:e.x+c,y:e.y+h,width:e.width-c-l,height:Math.max(0,Math.min(e.height,n-h))}),u||Eg(s,Ng(t),a))return h}return 0}(t,g,p,x):(x(g),0),k={};if(o){const e=t._colorScaleClass.outerBounds();if(!t.schema.colorScaleConfig.select&&e.height){const o="function"==typeof t._colorScaleClass.padding?t._colorScaleClass.padding():t._legendClass.padding();k[n]=i?b+e.height+2*o:e.width+2*o}}return{panel:null,margin:k}}};function ty(t,e){const n=t.querySelector(".d3plus-attribution-text"),i=t.querySelector(".d3plus-attribution-toggle");n&&(n.style.display=e?"":"none"),i&&i.setAttribute("aria-expanded",String(e)),t.style.borderRadius="3px 0 0 0",t.style.padding=e?"4px 6px":"2px"}const ey={name:"attribution",configFields:["attribution","attributionIcon","attributionStyle"],layout:({viz:t})=>{let e=o.select(t._select.node().parentNode).selectAll("div.d3plus-attribution").data(t.schema.attribution?[0]:[]);const n=e.enter().append("div").attr("class","d3plus-attribution");e.exit().remove();const i=mp(t,t.schema.attributionStyle,Du,{background:t=>t.background,color:t=>t.text});e=e.merge(n).style("position","absolute").style("right",`${t._margin.right}px`).style("bottom",`${t._margin.bottom}px`).call(r.stylize,i);const a=`<span class="d3plus-attribution-text">${t.schema.attribution}</span><button type="button" class="d3plus-attribution-toggle" aria-label="${t.schema.translate("Attribution")}" aria-expanded="true">${function(t){const e=t.schema.attributionIcon;return"string"==typeof e?e:"function"==typeof e?'<span class="d3plus-attribution-icon" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="width:12px;height:12px;display:block"><circle cx="12" cy="12" r="10"/><line x1="12" y1="11" x2="12" y2="17"/><line x1="12" y1="7" x2="12" y2="7.01"/></svg>'}(t)}</button>`,s=e.node();if(s&&s.__d3plusHTML!==a){s.innerHTML=a,s.__d3plusHTML=a,s.querySelectorAll("a").forEach(t=>{t.style.color="inherit",t.style.textDecoration="none"});const e=s.querySelector(".d3plus-attribution-toggle");e&&(e.style.border="0",e.style.background="transparent",e.style.color="inherit",e.style.margin="0",e.style.padding="0",e.style.flexShrink="0"),function(t,e){const n=t.schema.attributionIcon;if("function"!=typeof n)return;const i=e.querySelector(".d3plus-attribution-icon");i&&(t._attributionIconCleanup?.(),t._attributionIconCleanup=n(i)||void 0)}(t,s)}const c=e.node();if(!c)return{panel:null,margin:{}};const{width:l}=wt(t);c.style.maxWidth=`${Math.min(280,l)}px`;const h=c.querySelector(".d3plus-attribution-text");h.style.whiteSpace="nowrap";const u=h.getBoundingClientRect().width>.5*l;h.style.whiteSpace="";const d=o.select(c).select(".d3plus-attribution-toggle").style("display",u?"":"none");if(!u)return o.select(c).on(".compact",null),ty(c,!0),{panel:null,margin:{}};const f=()=>ty(c,Boolean(t._attributionPinned||c.matches(":hover, :focus-within")));return o.select(c).on("mouseenter.compact focusin.compact",()=>ty(c,!0)).on("mouseleave.compact focusout.compact",()=>window.setTimeout(f,0)),d.on("click.compact",()=>{t._attributionPinned=!t._attributionPinned,ty(c,t._attributionPinned)}),ty(c,Boolean(t._attributionPinned)),{panel:null,margin:{}}}},ny=new Set([!1,"top","right","bottom","left"]);function iy(t,e){return"auto"===t?function(t){return t.schema.width>1.5*t.schema.height?"right":"bottom"}(e):ny.has(t)?t:"bottom"}function oy(t,e,n={top:0,right:0,bottom:0,left:0}){const i={top:0,right:0,bottom:0,left:0},o=[];for(const r of e){if(!r.layout)continue;const e={top:n.top+i.top,right:n.right+i.right,bottom:n.bottom+i.bottom,left:n.left+i.left},a=r.layout({...t,layoutMargin:e}),{panel:s,margin:c,vizUpdate:l}=a;if(s&&o.push(s),i.top+=c.top??0,i.right+=c.right??0,i.bottom+=c.bottom??0,i.left+=c.left??0,l&&t.viz){const e=t.viz;for(const t of Object.keys(l)){e[t.startsWith("_")?t:`_${t}`]=l[t]}}}return{panels:o,margin:i}}const ry=6;function ay(t,e,n){const i=kd(t);if(!i||e>=vd(t))return 0;const o=i.width-n;return o>0?o+ry:0}function sy(t,e,n){const i=function(t,e,n,i){const o=qp(t,i);return!o||e>=Vp(t,i)?0:Math.max(0,o.width-n)}(t,e,n,Yp(t));return i>0?i+ry:0}function cy(t,e,n,i){return"right"===e&&ay(t,n,i)?vd(t)-n:"left"===e&&sy(t,n,i)?Vp(t,Yp(t))-n:0}function ly(t){return Math.max(vd(t),Vp(t,Yp(t)))}function hy(t,e,n,i,o){const r=function(t,e,n,i){const o=sy(t,e,n),r=ay(t,e,i);return{left:o,right:r,symmetric:Math.max(o,r)}}(t,e,n,i);if(!r.left&&!r.right)return[{left:0,right:0,drop:0}];const a=[];return o&&r.left!==r.right&&a.push({left:r.symmetric,right:r.symmetric,drop:0}),a.push({left:r.left,right:r.right,drop:0}),a.push({left:0,right:0,drop:Math.max(0,ly(t)-e)}),a}function uy(t,e){const{viz:n,layoutMargin:i}=t,o=e.getText(n);if(!o)return{panel:null,margin:{}};const a=n.schema[e.paddingMethod](n)?n._padding:{right:0,left:0},s=n[e.textClassKey];s.data([{text:o}]).locale(n.schema.locale).config(n.schema[e.configKey]);const{x:c,width:l,drop:h,boxes:u}=function(t,e,n,i,o,r){const a=e.split(),s=(t,n,i)=>{e.width(n);const o=()=>{const o=e._textData();return{x:t,width:n,drop:i,boxes:o,lines:o[0]?.lines??[],truncated:!o.length||o[0].truncated}};return bi(o(),()=>{e.split(yi(a));const t=o();return e.split(a),t})},c=s(i,r,0).result;if(!c.boxes.length)return c;const l=hy(t,n,i,o,"middle"===c.boxes[0].tA);if(1===l.length)return c;for(const[t,{left:e,right:n,drop:o}]of l.entries()){const{fits:a,result:c}=s(i+e,r-e-n,o);if(a||t===l.length-1)return c}return c}(n,s,i.top,i.left+a.left,i.right+a.right,n.schema.width-(i.left+i.right+a.left+a.right));if(!u.length)return{panel:null,margin:{}};const d=u[0],f=d.lH,m=n.schema[e.configKey]?.padding??0,p=d.lines.length*f+2*m,g=i.top+h+m,y=r.rtl(),x=Gn(d,l,y),b=x.lines.map((t,e)=>({...t,y:(e+1)*f-(f-d.fS)}));return{panel:{type:"text",key:e.panelKey,x:0,y:0,lines:b,font:{family:d.fF,size:d.fS,anchor:x.anchor,baseline:"alphabetic",...y?{dir:"rtl"}:{}},paint:{fill:d.fC,opacity:d.fO},transform:{x:c,y:g}},margin:{top:h+p}}}const dy={name:"title",configFields:["title","titleConfig","titlePadding"],layout:t=>uy(t,{panelKey:"viz-title",getText:t=>!!t.schema.title&&t.schema.title(t._filteredData||[]),textClassKey:"_titleClass",configKey:"titleConfig",paddingMethod:"titlePadding"})},fy={name:"subtitle",configFields:["subtitle","subtitleConfig","subtitlePadding"],layout:t=>uy(t,{panelKey:"viz-subtitle",getText:t=>!!t.schema.subtitle&&t.schema.subtitle(t._filteredData||[]),textClassKey:"_subtitleClass",configKey:"subtitleConfig",paddingMethod:"subtitlePadding"})};const my={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:t,layoutMargin:e})=>{let i=t.schema.time&&t.schema.timeline;const o=i?n.unique(t._data.map(t.schema.time)).map(t=>r.date(t)):[];i=i&&o.length>1;const a=t.schema.timelinePadding(t)?t._padding:{right:0,left:0},s={transform:`translate(${e.left+a.left}, 0)`},c=r.elem("g.d3plus-viz-timeline",{condition:i,enter:s,parent:t._select,duration:Jt(t),update:s}).node();if(!i)return{panel:null,margin:{}};const l=t._timelineClass.renderMode("compute").domain(d.extent(o)).duration(Jt(t)).height(t.schema.height-e.bottom).locale(t.schema.locale).select(c).ticks(o.sort((t,e)=>+t-+e)).width(t.schema.width-(e.left+e.right+a.left+a.right)),h=d.extent(o);if(t._timelineSelection)t._timelineSelection[0]<h[0]&&(t._timelineSelection[0]=h[0]),t._timelineSelection[1]>h[1]&&(t._timelineSelection[1]=h[1]);else{const e=d.extent((t._filteredData||[]).flatMap((e,n)=>t.schema.time(e,n)).map(t=>r.date(t)));t._timelineSelection=ag(t)||(e[0]?e:h)}l.selection(t._timelineSelection),l._onPlayToggle=()=>t._scheduleSceneRepaint();const u=Jp(t);l.rangeBreaks(!!u.length&&u);const f={...t.schema.timelineConfig};return delete f.selection,l.config(f).on("brush",t=>{f.on&&f.on.brush&&f.on.brush(t)}).on("end",e=>{!function(t,e){if(Array.isArray(e)||(e=[e,e]),JSON.stringify(e)!==JSON.stringify(t._timelineSelection)){t._timelineSelection=e;const n=e.map(Number);t.timeFilter(e=>{const i=r.date(t.schema.time(e)).getTime();return i>=n[0]&&i<=n[1]}).render()}}(t,e),f.on&&f.on.end&&f.on.end(e)}).render(),xc(c,"d3plus-viz-timeline",l._buttonBehaviorCurrent),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},py={name:"total",configFields:["total","totalConfig","totalFormat","totalPadding"],layout:t=>uy(t,{panelKey:"viz-total",getText:t=>{const e=t._filteredData||[],n="function"==typeof t.schema.total?d.sum(e.map(t.schema.total)):!(!0!==t.schema.total||!t._size)&&d.sum(e.map(t._size));return!!n&&t.schema.totalFormat(n)},textClassKey:"_totalClass",configKey:"totalConfig",paddingMethod:"totalPadding"})};function gy(t,e,n){return t.schema.minimapClassName&&e===n?{}:e||{}}function yy(t,...e){const n=new Set;for(const t of e)for(const e of Object.keys(t))n.add(e);for(const e of n)t.style.removeProperty(Qu(e));for(const n of e)for(const e in n){const i=n[e];null!=i&&!1!==i&&t.style.setProperty(Qu(e),String(i))}}function xy(t){const e=t.schema.minimapClassName?` ${t.schema.minimapClassName}`:"";return`<div class="d3plus-minimap-viewport${e}" tabindex="0" role="application" aria-label="${t.schema.translate("Pan viewport — drag or use arrow keys")}"></div><div class="d3plus-minimap-label${e}"></div>`}function by(t){const e=function(t){return t._zoomEventTarget||t._container}(t)?.node();return e?h.zoomTransform(e):h.zoomIdentity}const ky={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function _y(t,e,n,i,o){const[[r,a],[s,c]]=t._zoomBehavior.translateExtent(),l=Hd(t),h=by(t);hf(t,i,l.x?(r+s)/2-e*i:h.x,l.y?(a+c)/2-n*i:h.y,o)}function vy(t,e,n,i,o){const[[r,a],[s,c]]=t._zoomBehavior.translateExtent();return[r+i/e*(s-r),a+o/n*(c-a)]}function wy(t,e,n,i,o,r){const a=r.parentElement,s=a?.querySelector(".d3plus-minimap-label");if(!a||!s)return;const c=by(t),l=c.k>1;if(yy(a,i.outer),yy(a,{position:"absolute","box-sizing":"border-box",overflow:"hidden",opacity:l?"1":"0","pointer-events":l?"auto":"none",transition:`opacity ${Jt(t)}ms`}),!l)return;const[[h,u],[d,f]]=t._zoomBehavior.translateExtent(),m=d-h,p=f-u,g=Math.min(1,1/c.k),y=Hd(t),x=y.x?g:1,b=y.y?g:1,k=(h-c.x)/c.k,_=(u-c.y)/c.k,v=Math.max(0,Math.min(1-x,m?(k-h)/m:0)),w=Math.max(0,Math.min(1-b,p?(_-u)/p:0));yy(r,i.viewport,o.dragging?i.viewportActive:{}),yy(r,{position:"absolute","box-sizing":"border-box","touch-action":"none",left:v*e+"px",top:w*n+"px",width:`${Math.max(1,x*e)}px`,height:`${Math.max(1,b*n)}px`}),yy(s,i.label),yy(s,{position:"absolute"}),s.textContent=function(t){const e=Math.round(10*t)/10;return`${e%1==0?e.toFixed(0):e.toFixed(1)}x`}(c.k)}function My(t,e,n,i,o){const r=t=>t.target?.closest(".d3plus-minimap-viewport"),a=t=>{if(t.pointerId!==i.dragPointerId)return;i.dragging=!1;const e=r(t);e&&o(e)};return{pointerdown:e=>{const n=e,a=r(e);if(!a)return;try{a.setPointerCapture(n.pointerId)}catch{}i.dragging=!0,i.dragPointerId=n.pointerId;const s=by(t);i.dragStart={x:n.clientX,y:n.clientY,tx:s.x,ty:s.y,k:s.k},o(a),e.preventDefault()},pointermove:n=>{const o=n;if(!i.dragging||o.pointerId!==i.dragPointerId)return;const[[r],[a]]=t._zoomBehavior.translateExtent(),s=(a-r)/e,c=Hd(t),l=c.x?(o.clientX-i.dragStart.x)*s*i.dragStart.k:0,h=c.y?(o.clientY-i.dragStart.y)*s*i.dragStart.k:0;hf(t,i.dragStart.k,i.dragStart.tx-l,i.dragStart.ty-h,0)},pointerup:a,pointercancel:a,keydown:n=>{const i=n,o=ky[i.key];if(!o)return;i.preventDefault();const[[r],[a]]=t._zoomBehavior.translateExtent(),s=(a-r)/e,c=i.shiftKey?40:10,l=by(t),h=Hd(t),u=h.x?o[0]*c*s*l.k:0,d=h.y?o[1]*c*s*l.k:0;hf(t,l.k,l.x-u,l.y-d,Jt(t))}}}function Sy(t,e,n){return{click:i=>{const o=i.target;if(o?.closest(".d3plus-minimap-viewport"))return;const r=o?.closest(".d3plus-minimap");if(!r)return;const a=i,s=r.getBoundingClientRect(),[c,l]=vy(t,e,n,a.clientX-s.left,a.clientY-s.top);_y(t,c,l,by(t).k,Jt(t))},dblclick:e=>{e.preventDefault(),hf(t,1,0,0)},wheel:i=>{const o=i;if(!o.ctrlKey&&!o.metaKey)return;o.preventDefault();const r=i.target?.closest(".d3plus-minimap");if(!r)return;const a=r.getBoundingClientRect(),[s,c]=vy(t,e,n,o.clientX-a.left,o.clientY-a.top),l=o.deltaY<0?t.schema.zoomFactor:1/t.schema.zoomFactor;_y(t,s,c,by(t).k*l,0)}}}function Cy(t,e,n,i){const o=function(t){const e=t,n=(t,e)=>U(t.text,e);return{outer:mp(e,gy(t,t.schema.minimapStyle,Pu),Pu,{background:t=>t.background,border:t=>`1px solid ${t.border}`}),viewport:mp(e,gy(t,t.schema.minimapViewportStyle,Tu),Tu,{background:t=>n(t,.15),border:t=>`1px solid ${n(t,.5)}`}),viewportActive:mp(e,gy(t,t.schema.minimapViewportStyleActive,Ou),Ou,{background:t=>n(t,.25)}),label:mp(e,gy(t,t.schema.minimapLabelStyle,Wu),Wu,{color:t=>t.text})}}(t),r={dragging:!1,dragPointerId:null,dragStart:{x:0,y:0,tx:0,ty:0,k:1}},a=i=>wy(t,e,n,o,r,i),s=t.schema.minimapClassName?` ${t.schema.minimapClassName}`:"";return{type:"htmlOverlay",key:"viz-minimap",x:t.schema.width-4-e,y:i+4,width:e,height:n,className:`d3plus-minimap${s}`,html:xy(t),events:{".d3plus-minimap-viewport":My(t,e,0,r,a),".d3plus-minimap":Sy(t,e,n)},onUpdate:t=>{const e=t.querySelector(".d3plus-minimap-viewport");e&&a(e)}}}const $y={name:"minimap",layout:({viz:t})=>{if(!(t.schema.zoom&&t.schema.minimap&&t._container&&t._zoomBehavior))return{panel:null,margin:{}};const e=_d(t);if(!e)return{panel:null,margin:{}};const n=wt(t),i=t._zoomHeight||n.height,o=t._zoomWidth||n.width;if(!o||!i)return{panel:null,margin:{}};const r=e.width-4;return{panel:Cy(t,r,r*(i/o),e.height),margin:{}}}};function Ay(t,e,n){const{width:i,height:o}=wt(t);return{bounds:e??{x:t._margin.left,y:t._margin.top,width:i,height:o},obstacles:Xc(t._chartScene||[],t._chartTransform,n)}}const zy=Math.ceil(Ln(void 0,null,0,12)+1)+5;function Dy(t){const e=Ad("column",{width:t.schema.width||0,height:t.schema.height||0}),n=e.width*e.height,i=function(t,e=1/0){const n=j(t.schema.legend);if(n&&!n.value)return 0;const{colorOf:i,keyOf:o}=hg(t),r=new Set,a=t._legendData||[],s=Boolean(t.schema.colorScale);let c=0;for(let n=0;n<a.length&&r.size<=e;n++){const e=a[n];s&&void 0!==t.schema.colorScale(e,n)||(r.add(o(e,c,i(e,c))),c++)}return r.size}(t,Math.floor(n/(zy*zy))+1);return i*zy*zy<=n}function Ly(t,e){return"auto"===e.bind(t)(lg(t))}const Fy={sizeLegend:["column"],legend:["column","row"],colorScale:["column","row"]};function Ny(t,e,n,i,o){if("sizeLegend"===e){const e=Nd(t);return e?{width:e.width,height:e.height}:null}return"legend"===e?pg(t,n,i,o()):Zg(t,n,i)}const By=[{alignX:"right",alignY:"bottom"},{alignX:"right",alignY:"top"},{alignX:"left",alignY:"bottom"},{alignX:"left",alignY:"top"}];function Ey(t,e,n,i){const o=.5,r=t.filter(t=>t.width>=n&&t.height>=i);if(!r.length)return null;const a=t=>({right:Math.abs(t.x+t.width-(e.x+e.width))<o,left:Math.abs(t.x-e.x)<o,bottom:Math.abs(t.y+t.height-(e.y+e.height))<o,top:Math.abs(t.y-e.y)<o}),s=(t,e,o)=>({x:"right"===e?t.x+t.width-n:"left"===e?t.x:t.x+(t.width-n)/2,y:"bottom"===o?t.y+t.height-i:"top"===o?t.y:t.y+(t.height-i)/2,width:n,height:i,alignX:e,alignY:o});for(const{alignX:t,alignY:e}of By){const n=r.find(n=>{const i=a(n);return i[t]&&i[e]});if(n)return s(n,t,e)}const c=r[0],l=a(c);return s(c,l.right?"right":l.left?"left":"center",l.bottom?"bottom":l.top?"top":"middle")}function Ry(t){const e=t._insetRegion?.();if(!e)return null;const{padding:n}=Md(t),i=e.bounds,o={x:i.x+n,y:i.y+n,width:i.width-2*n,height:i.height-2*n};if(o.width<=0||o.height<=0)return null;const r=function(t){const e=[],{width:n,height:i}=wt(t),o=t.schema.minimap?_d(t):kd(t);if(o){const r=t.schema.minimap?(o.width-4)*(i/Math.max(1,n)):0;e.push({x:t.schema.width-o.width,y:0,width:o.width,height:o.height+r})}const r=qp(t,Yp(t));if(r&&e.push({x:0,y:0,width:r.width,height:r.height}),t.schema.attribution){const i=t._select?.node?.()?.parentNode,o=i?.querySelector?.("div.d3plus-attribution"),r=String(t.schema.attribution).replace(/<[^>]*>/g,""),a=Math.min(o?.offsetWidth||6*r.length+30,n/2),s=o?.offsetHeight||22,c=t.schema.width-t._margin.right,l=t.schema.height-t._margin.bottom;e.push({x:c-a,y:l-s,width:a,height:s})}return e}(t);return{rects:u.negativeSpace(o,e.obstacles,{padding:n,exclude:r}),bounds:o,area:i}}function Py(t,e){const n=e.filter(e=>function(t,e){return"sizeLegend"===e?Boolean(Nd(t)?.inset):"legend"===e?Boolean(t._legendClass?._data?.length):Boolean(sh(t))&&!1!==iy(t.schema.colorScalePosition.bind(t)(lg(t)),t)&&!t.schema.colorScaleConfig.select}(t,e)),i=n.length?Ry(t):null;if(!i||!i.rects.length)return{placement:null,showing:n};const{margin:o}=Md(t);let r;const a=()=>r??(r=ug(t));for(const e of n)for(const r of Fy[e]){const s=Ny(t,e,r,i.area,a),c=s&&Ey(i.rects,i.bounds,s.width+2*o,s.height+2*o);if(c)return{placement:{key:e,orient:r,...c},showing:n}}return{placement:null,showing:n}}function Ty(t,e){t._margin={...e.margin},t._padding={...e.padding},t._draw()}function Oy(t){t._insetPlacement=null;const e="function"==typeof t._insetRegion&&function(t){const e=t.schema.legendInset;return"function"==typeof e?Boolean(e.bind(t)(lg(t))):Boolean(e)}(t)?function(t){return wd.filter(e=>"legend"===e?Ly(t,t.schema.legendPosition)&&Dy(t):"colorScale"!==e||Ly(t,t.schema.colorScalePosition))}(t):[];if(!e.length)return t._insetPending=null,void t._draw();const n={margin:{...t._margin},padding:{...t._padding}};t._insetPending=new Set(e),t._draw();const i=Py(t,e),{showing:o}=i;let{placement:r}=i;if(o.length){if(r&&o.some(t=>t!==r.key)&&(t._insetPending=new Set([r.key]),Ty(t,n),r=Py(t,[r.key]).placement),!r)return t._insetPending=new Set,void Ty(t,n);t._insetPlacement=r}}function Wy(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n][0]-t[n-1][0],t[n][1]-t[n-1][1]);return e}function jy(t,e=.02){if(t.length<2)return t;const[n,i]=t[0],[o,r]=t[t.length-1],a=o-n,s=r-i;return(Math.abs(a)<Math.abs(s)*e?s>0:a<0)?[...t].reverse():t}function Hy(t,e){if(t.length<2||!e)return t;const n=t.slice(1).map((e,n)=>((t,e)=>{const n=Math.hypot(e[0]-t[0],e[1]-t[1])||1;return[(e[1]-t[1])/n,-(e[0]-t[0])/n]})(t[n],e));return t.map((i,o)=>{const r=o>0?n[o-1]:null,a=o<t.length-1?n[o]:null,s=r&&a?[r[0]+a[0],r[1]+a[1]]:r??a,c=Math.hypot(s[0],s[1])||1;return[i[0]+s[0]/c*e,i[1]+s[1]/c*e]})}function Iy(t,e,n){const i=[];let o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=Math.hypot(c-a,l-s),u=o+h,d=t=>{const e=h?(t-o)/h:0;return[a+(c-a)*e,s+(l-s)*e]};if(u>=e&&o<=n){if(i.length||i.push(d(Math.max(e,o))),!(u<=n)){i.push(d(n));break}i.push([c,l])}o=u}return i}class Gy{seek(t){const{cum:e}=this,n=this.points.length;let i=this.i;if(i>1&&e[i-1]>=t){let n=1,o=i-1;for(;n<o;){const i=n+o>>1;e[i]>=t?o=i:n=i+1}i=n}for(;i<n&&e[i]<t;)i++;return this.i=i,i}trim(t,e){const{points:n,cum:i}=this,o=[];for(let r=this.seek(t);r<n.length;r++){const[a,s]=n[r-1],[c,l]=n[r],h=Math.hypot(c-a,l-s),u=i[r-1],d=i[r],f=t=>{const e=h?(t-u)/h:0;return[a+(c-a)*e,s+(l-s)*e]};if(d>=t&&u<=e){if(o.length||o.push(f(Math.max(t,u))),!(d<=e)){o.push(f(e));break}o.push([c,l])}}return o}at(t){const e=this.seek(t);if(e>=this.points.length||!(this.cum[e-1]<=t))return;const[n,i]=this.points[e-1],[o,r]=this.points[e],a=Math.hypot(o-n,r-i),s=this.cum[e-1],c=a?(Math.max(t,s)-s)/a:0;return[n+(o-n)*c,i+(r-i)*c]}constructor(t){this.points=t,this.i=1;const e=[0];let n=0;for(let i=1;i<t.length;i++)n+=Math.hypot(t[i][0]-t[i-1][0],t[i][1]-t[i-1][1]),e.push(n);this.cum=e,this.length=n}}function qy(t){const e=t=>Math.round(100*t)/100;return t.map(([t,n],i)=>`${i?"L":"M"}${e(t)},${e(n)}`).join("")}function Vy(t,e,n){return t.map(t=>"group"===t.type?{...t,children:Vy(t.children,e,n)}:"text"!==t.type?t:{...t,halo:!0,paint:{...t.paint,stroke:e,strokeWidth:"function"==typeof n?n(t):n,strokeOpacity:1}})}function Ky(t,e,n={},i={}){if(!e.length)return[];const o=Boolean(t._theme?.dark),r=(new ei).renderMode("compute").locale(t.schema.locale).data(e.map(t=>({...t,id:t.key}))).config({fontSize:11,fontWeight:600,fontColor:t=>Si(t.color,o),text:t=>t.text,textAnchor:t=>t.anchor,textPath:t=>t.d,truncateWord:!0,x:0,y:0,...n}).toScene().children;return(!1===i.halo?r:Vy(r,Tc(t),3)).map(t=>{const e=t.datum;return{...t,interactive:!1,datum:e?.datum,index:e?.index??t.index,aria:{hidden:!0}}})}const Yy=new WeakMap,Uy=new WeakSet,Xy=t=>t instanceof Date?String(t.getTime()):String(t);function Qy(t){if("function"==typeof t)return t;if("string"==typeof t&&t){const e=G(t);return Yy.set(e,{key:t}),e}}function Zy(t,e){return Yy.set(t,{text:e}),t}function Jy(t,e,i,o={}){const r=new Map;for(const n of t){if(!n.data)continue;const t=Xy(n[e]),i=r.get(t);i?i.data.push(n.data):r.set(t,{value:n[e],data:[n.data]})}return Array.from(r.values(),({value:t,data:e})=>{const r=1===e.length?e[0]:n.merge(e,o);return{value:t,size:Number(i(r,0)),data:r}})}function tx(t){let e=0;return t.filter(t=>Number.isFinite(t.size)&&t.size>0).map(t=>{const n=e+t.size,i={...t,start:e,end:n,mid:(e+n)/2};return e=n,i})}function ex(t,e,n){const i=t.schema.barWidth,o=t.schema.discrete,r=t._discreteExtent&&!Uy.has(t._discreteExtent);if("function"!=typeof i||"x"!==o&&"y"!==o||r)return function(t){t._barSpans=void 0,t._discreteExtent&&Uy.has(t._discreteExtent)&&(t._discreteExtent=void 0)}(t),[e,n];const a=Jy(n,o,i,t.schema.aggs),s=t.schema[`${o}Sort`];s&&a.sort((t,e)=>s(t.data,e.data));const c=tx(a),l=new Map(c.map(t=>[Xy(t.value),t])),h=new WeakMap,u=t=>t.filter(t=>{const e=l.get(Xy(t[o]));return!!e&&(t.data&&h.set(t.data,e),t[o]=e.mid,!0)}),d=u(e),f=n===e?d:u(n),m=c.length?c[c.length-1].end:0,p={axis:o,spans:c,total:m,byDatum:h};t._barSpans=p,"x"===o?t._xTime=!1:t._yTime=!1;const g=t=>{const e=p.byDatum.get(t);return e?[e.start,e.end]:[0,0]};return Uy.add(g),t._discreteExtent=g,[d,f]}function nx(t){return t instanceof Date?p.formatDate(t,[t]):String(t)}function ix(t,e,n){return t.total?`${p.formatAbbreviate(e.size/t.total*100,n)}%`:""}function ox(t,e,n){const i=ix(e,n,t.schema.locale),o=t.schema.barWidthShareFormat;if("function"!=typeof o||!n.data)return i;const r=e.total?n.size/e.total:0,a=o(n.data,{share:r,size:n.size,total:e.total,text:i});return null==a?"":String(a)}function rx(t,e,n){return e?"x"===n?`${t}\n${e}`:`${t} (${e})`:t}function ax(t){const e=t._barSpans;if(e&&"opposite"===t.schema.barWidthShare)return"x"===e.axis?"x2":"y2"}function sx(t,e){const n=t._barSpans;if(!n||ax(t)!==e)return{};const i=n.spans.map(t=>t.mid),o=new Map(n.spans.map(e=>[e.mid,ox(t,n,e)]));return{barConfig:{"stroke-width":0},gridSize:0,labels:i,tickFormat:t=>o.get(t)??"",tickSize:0,ticks:i,title:!1}}function cx(t,e){const n=t._barSpans;if(!n||n.axis!==e)return{};const i=n.spans.map(t=>t.mid),o=new Map(n.spans.map(t=>[t.mid,nx(t.value)])),r=t=>o.get(t)??"";if(!0!==t.schema.barWidthShare)return{labels:i,ticks:i,tickFormat:r};const a=new Map(n.spans.map(i=>[i.mid,rx(nx(i.value),ox(t,n,i),e)]));return{labels:i,ticks:i,tickFormat:t=>a.get(t)??"",rotatedTickFormat:r}}function lx(t){const e=t.schema.barWidth,n=e?Yy.get(e):void 0;return n?.key?n.key:t.schema.translate(n?.text??"Width")}function hx(t,e){const n=t._barSpans,i=n&&e&&"object"==typeof e?n.byDatum.get(e):void 0;if(!n||!i)return[];const o=t.schema.locale,r=ix(n,i,o);return[[lx(t),`${p.formatAbbreviate(i.size,o)}${r?` (${r})`:""}`]]}const ux=t=>t._swarm?t._swarm.axis:"y"===t.schema.discrete?"x":"y";function dx(t){return!(!Array.isArray(t)||t.length>2)&&(void 0===t[0]||null===t[0])!=(void 0===t[1]||null===t[1])}function fx(t,e){if("x"!==e&&"y"!==e)return;const n=t[`_${e}Config`]?.domain;if(!dx(n)||!((t,e)=>t.schema.discrete!==e&&!t.schema[`${e}Sort`]&&t._swarm?.cross!==e)(t,e))return;const i=n.slice();return"y"===e&&2===i.length?i.reverse():i}const mx=(t,e)=>fx(t,e)??t.schema[`${e}Domain`];function px(t){const e=t._userBaseline;if("number"!=typeof e||!Number.isFinite(e))return;const n=ux(t);if(t[`_${n}Time`]||t.schema[`${n}Sort`])return;const i=t[`_${n}Config`];return"log"===i?.scale&&e<=0?void 0:n}function gx(t,e){return Boolean(mx(t,e))||px(t)===e}function yx(t,e){const n=t[`_${e}Config`]?.domain;return Array.isArray(n)&&n.some(t=>null!=t)&&!dx(n)}function xx(t,e,n){return yx(t,e)?"none":n}function bx(t,e,n){const i=t[`_${e}Config`]?.rounding;return i??xx(t,e,n)}function kx(t,e){const n=t[`_${e}Config`]?.domain;if(void 0!==n&&!fx(t,e))return!1;const i=mx(t,e);return i?dx(i):px(t)===e}function _x(t,e){const n=t[`_${e}Config`]??{};if(!kx(t,e))return n;const i={...n};return delete i.rounding,fx(t,e)&&delete i.domain,i}function vx(t,e,n){const i=mx(t,e),o=i?i.slice():void 0;if(px(t)!==e)return o;const r=t._userBaseline,a=n?.[1],s="number"==typeof a&&a<=r?1:0,c=o??[];return void 0===c[s]&&(c[s]=r),c}function wx(t,e){const n=t.schema[`${e}Break`],i={break:void 0!==n&&n},o=_x(t,e),r={...cx(t,e),...t._plotAxisDefaults?.[e]};if(!Object.keys(r).length)return{...i,...o};const a=Object.fromEntries(Object.entries(o).filter(([,t])=>void 0!==t));return st({...i,...r},a)}function Mx(t,e){const n=Boolean(t.schema.baselineBreak)&&ux(t)===e,{baseline:i}=t.schema;return"number"==typeof i?{baseline:i,baselineBreak:n}:{baselineBreak:n}}function Sx(t,e,n,i=t.schema[`${e}Domain`]){if(!t.schema.baselineBreak||e!==ux(t)||"linear"!==n)return!1;const{baseline:o}=t.schema;if("number"!=typeof o||!Array.isArray(i))return!1;const[r,a]=i;return"number"==typeof r&&r>o||"number"==typeof a&&a<o}function Cx(t,e){const n="y"===ux(t),i=(n?t._yAxis:t._xAxis)?._baselineBreak,o=n?t._yFunc:t._xFunc;if(!i||!o)return e;const r=o(i.edge),a=o(i.value);if(!Number.isFinite(r)||!Number.isFinite(a))return e;const s=n?1:0;return e.map(t=>(t[s]-r)*(a-r)<=0?t:n?[t[0],r]:[r,t[1]])}function $x(t,e){const n="y"===ux(t),i=n?t._yAxis:t._xAxis;if(!i||"function"!=typeof i._getRange)return;const o=i._getRange().map(Number);if(o.length<2||o.some(t=>!Number.isFinite(t)))return;const r=n?e.x2Height:0,a=n?e.yOffset:0;return[Math.min(o[0],o[o.length-1])-r-a,Math.max(o[0],o[o.length-1])-r]}function Ax(t,e,n){if(!n)return t;const[i,o]=n,r=t=>"number"==typeof t&&Number.isFinite(t)?Math.min(o,Math.max(i,t)):t,a=Object.assign({},t);for(const t of[e,`${e}0`,`${e}1`]){const e=a[t];if("function"==typeof e){const n=e;a[t]=function(...t){return r(n.apply(this,t))}}else"number"==typeof e&&(a[t]=r(e))}return a}function zx(t){return"along"===t?[]:"both"===t?["start","end"]:"start"===t?["start"]:t?["end"]:[]}function Dx(t,e,n){return zx("function"==typeof t?t(e,n):t)}function Lx(t,e,n,i,o){if(!t?.value||null==e)return;const r=t.valueFormat?t.valueFormat(e,n,i):o(e);return null==r||""===r?void 0:`${r}`}function Fx(t,e){return void 0===e?`${t}`:`${t} ${e}`}function Nx(t,e){return"start"===t?`start:${e}`:`${e}`}class Bx{static key(t,e){return 1048576*t+e}add(t,e=-1){for(const[n,i]of t){const t=Bx.key(Math.floor(n/this.cell),Math.floor(i/this.cell)),o=this.cells.get(t);o?o.push([n,i,e]):this.cells.set(t,[[n,i,e]])}}nearest(t,e){const n=Math.floor(t[0]/this.cell),i=Math.floor(t[1]/this.cell);let o=1/0;for(let r=-1;r<=1;r++)for(let a=-1;a<=1;a++){const s=this.cells.get(Bx.key(n+r,i+a));if(s)for(const[n,i,r]of s){if(-1!==r&&r===e)continue;const a=t[0]-n,s=t[1]-i,c=a*a+s*s;c<o&&(o=c)}}return Math.sqrt(o)}constructor(t){this.cell=t,this.cells=new Map}}function Ex(t,e){const n=new Gy(t),i=[];for(let t=0;t<=n.length;t+=e){const e=n.at(t);e&&i.push(e)}return i}function Rx(t){let e=0,n=null;for(let i=1;i<t.length;i++){const o=t[i][0]-t[i-1][0],r=t[i][1]-t[i-1][1];if(!o&&!r)continue;const a=Math.atan2(r,o);if(null!==n){let t=Math.abs(a-n);t>Math.PI&&(t=2*Math.PI-t),e+=t}n=a}return e}function Px(t,e){return Tx.flatMap(n=>Ox(t,e,n))}const Tx=[0,.35,.7];function Ox(t,e,n){const i=Math.max(2,e.fontSize/2);return Ex(Hy(t,e.lift+n*e.fontSize),i)}function Wx(t,e){const{rect:n,minClearance:i=2}=e;let o=1/0;for(const r of Tx)for(const a of Ox(t,e,r)){if(a[0]<n.x0||a[0]>n.x1||a[1]<n.y0||a[1]>n.y1)return null;if(o=Math.min(o,e.grid.nearest(a,e.ignore)),o<i)return null}const[r,a]=t[0],[s,c]=t[t.length-1],l=Math.abs(Math.atan2(c-a,s-r)),{roomReach:h=e.fontSize,roomWeight:u=.5}=e,d=Math.min(o,h)/h;return 2*Rx(t)+.5*l-d*u}function jx(t,e,n,i){let o=null,r=1/0;const a=Math.max(4,n.fontSize/2),s=n.maxTurn??Math.PI/2;for(let c=0;c<t.length;c++){const l=new Gy(t[c]);for(let t=0;t+e<=l.length;t+=a){if(i&&!i(t,c))continue;const a=jy(l.trim(t,t+e),n.steep);if(Rx(a)>s)continue;const h=Wx(a,n);null!==h&&h<r&&(r=h,o={points:a,piece:c,from:t})}}return o}function Hx(t,e,n){return jx(t,e,n)?.points??null}function Ix(t,e="Line"){const n=Hg(t,e).labelConfig??{},i={};for(const t of["fontFamily","fontSize","fontWeight"])void 0!==n[t]&&"function"!=typeof n[t]&&(i[t]=n[t]);return i}function Gx(t,e,n){const i=t.schema.lineLabels;if(!i)return[];const o=function(t){const e=[],n=(t,i,o)=>{const r=t.transform??{},s=i+(r.x??0),c=o+(r.y??0);"group"===t.type&&t.children.forEach(t=>n(t,s,c));const l=t.datum;if("path"!==t.type||"Line"!==t.shapeType||`${t.key}`.endsWith("::hit")||"Line"!==l?.shape)return;const h=(t.d.match(/M[^M]*/g)??[]).map(t=>a.samplePath(t).points.map(([t,e])=>[t+s,e+c])).filter(t=>t.length>1),u=t.paint?.stroke;e.push({row:l,key:`${t.key}`,color:`${u??"#444"}`,pieces:h})};return t.forEach(t=>n(t,0,0)),e}(e),c=o.filter(t=>function(t,e,n){return"along"===("function"==typeof t?t(e,n):t)}(i,t.row.data??t.row,t.row.i??0)),l=t._alongStats;if(l&&(l.series+=o.length,l.requested+=c.length),!c.length||o.length<2)return[];const h=Ix(t),u=h.fontSize??11,d={"font-family":r.fontExists(h.fontFamily??s.fontFamily),"font-size":u,"font-weight":h.fontWeight??600},f=new Bx(u);for(const t of o)for(const e of t.pieces)f.add(Ex(e,2));const m={grid:f,rect:n,fontSize:u,lift:3.5},p=new Set,g=c.flatMap(e=>{const n=`${t._drawLabel(e.row,e.row.i??0)}`;if(p.has(n))return l&&l.placed++,[];const i=r.textWidth(n,d)+u,o=Hx(e.pieces,i,m);return o?(f.add(Px(o,m)),p.add(n),l&&l.placed++,[{key:`line-label-along-${e.key}`,text:n,d:qy(Hy(o,m.lift)),color:e.color,anchor:"middle"}]):[]});return Ky(t,g,h)}function qx(t){return"inside"!==t&&"outside"!==t}function Vx(t,e=0,n=3){if(t.length<3)return[];const i=e?0:1;let o=1/0,r=-1/0;for(const n of t)o=Math.min(o,n[e]),r=Math.max(r,n[e]);if(!(r>o))return[];const a=Math.ceil((r-o)/n),s=(r-o)/a,c=new Array(a+1).fill(1/0),l=new Array(a+1).fill(-1/0),h=(t,e)=>{c[t]=Math.min(c[t],e),l[t]=Math.max(l[t],e)};for(let n=1;n<t.length;n++){const r=t[n-1],a=t[n],c=a[e]-r[e],l=Math.ceil((Math.min(r[e],a[e])-o)/s-1e-9),u=Math.floor((Math.max(r[e],a[e])-o)/s+1e-9);for(let t=l;t<=u;t++)if(c){const n=(o+t*s-r[e])/c;h(t,r[i]+n*(a[i]-r[i]))}else h(t,r[i]),h(t,a[i])}const u=[];return c.forEach((t,n)=>{if(t>l[n])return;const i=(t+l[n])/2,r=o+n*s;u.push({point:e?[i,r]:[r,i],thickness:l[n]-t})}),u}function Kx(t,e){const n=[];let i=[];for(const o of t)o.thickness>=e?i.push(o.point):(i.length>1&&n.push(i),i=[]);return i.length>1&&n.push(i),n}function Yx(t,e){const n=t.slice(0,1);for(let i=1;i<t.length;i++){const[o,r]=t[i-1],[a,s]=t[i],c=Math.ceil(Math.hypot(a-o,s-r)/e);for(let t=1;t<=c;t++)n.push([o+(a-o)*t/c,r+(s-r)*t/c])}return n}function Ux(t={}){const e=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0,n=e(t.fontSize)??e(t.fontMax)??16,i=Math.max(e(t.fontMin)??0,8),o=Math.min(n,i),r=[];for(let t=n;t>=o;t--)r.push(t);return r[r.length-1]!==o&&r.push(o),r}function Xx(t,n,i,o,r){const a="function"==typeof t?t(n,i):t;return"string"==typeof a&&a?a:e.colorContrast(o,r)}function Qx(t,e,n){const i="function"==typeof t?t(e,n):t;return"number"==typeof i||"string"==typeof i&&i?i:400}function Zx(t,e,n,i,o=0){const r=t.map(t=>Vx(t,o)),a=Math.max(0,...r.flat().map(t=>t.thickness));if(!n.length)return null;const s=new Bx(1.5*Math.max(...n));for(const e of t)s.add(Yx(e,2));for(const t of n){const n=t+4;if(n>a)continue;const c=r.flatMap(t=>Kx(t,n)),l={grid:s,rect:i,fontSize:t,lift:-.3*t,minClearance:.2*t+2,roomReach:1.5*t,roomWeight:1.5,steep:o?Math.tan(25*Math.PI/180):void 0},h=Hx(c,e(t)+t,l);if(h)return{points:Hy(h,l.lift),fontSize:t}}return null}function Jx(t,e,n){if(e>=1)return t;const o=i.rgb(t),r=i.rgb(n);if(Number.isNaN(o.r)||Number.isNaN(r.r))return t;const a=(t,n)=>t*e+n*(1-e);return i.rgb(a(o.r,r.r),a(o.g,r.g),a(o.b,r.b)).formatHex()}function tb(t,e,n){if(!t.schema.stacked)return[];const i=function(t,e){const n=[],i=(t,o,r)=>{const s=t.transform??{},c=o+(s.x??0),l=r+(s.y??0);if("group"===t.type&&t.children.forEach(t=>i(t,c,l)),"path"!==t.type||"Area"!==t.shapeType||!t.datum||`${t.key}`.endsWith("::hit"))return;const h=(t.d.match(/M[^M]*/g)??[]).map(t=>a.samplePath(t).points.map(([t,e])=>[t+c,e+l])).filter(t=>t.length>2),u=t.paint??{},d=("number"==typeof u.fillOpacity?u.fillOpacity:1)*("number"==typeof u.opacity?u.opacity:1);n.push({datum:t.datum,index:t.index??0,key:`${t.key}`,outlines:h,fill:Jx(`${u.fill??"#444"}`,d,e)})};return t.forEach(t=>i(t,0,0)),n}(e,Tc(t));if(!i.length)return[];const o=Hg(t,"Area"),{fontColor:c}=Ig(t,"Area"),l=Ix(t,"Area"),h=o.labelConfig??{},u=Ux(h),d=r.fontExists(l.fontFamily??s.fontFamily),f="y"===t.schema.discrete?1:0,m=t.schema.labelPosition,p=t._alongStats;p&&(p.series+=i.length);const g=i.flatMap(e=>{const i=e.datum.data??e.datum;if(!qx("function"==typeof m?m(i,e.index):m))return[];const a=function(t,e,n){let i="function"==typeof t?t(e,n):t;return Array.isArray(i)&&(i=i[0]),!1===i||null==i||""===i?null:`${i}`}(o.label,e.datum,e.index);if(!a)return[];p&&p.requested++;const s=Qx(h.fontWeight,e.datum,e.index),l={"font-family":d,"font-weight":s},g=Zx(e.outlines.map(e=>Cx(t,e)),t=>r.textWidth(a,{...l,"font-size":t}),u,n,f);return g?(p&&p.placed++,[{key:`area-label-along-${e.key}`,text:a,d:qy(g.points),color:Xx(c,e.datum,e.index,e.fill,t.schema.colorDefaults),anchor:"middle",datum:e.datum,index:e.index,fontSize:g.fontSize,fontWeight:s}]):[]});return Ky(t,g,{...l,fontColor:t=>t.color,fontSize:t=>t.fontSize,fontWeight:t=>t.fontWeight},{halo:!1})}function eb(t,e){return(n,i)=>{const o=n,r=o.__d3plus__&&o.data?o.data:n,a="number"==typeof o.i?o.i:i,s=t.schema.labelPosition;return!qx("function"==typeof s?s(r,a):s)&&("function"==typeof e?e(n,i):e)}}function nb(t){if(t.schema.legend!==t._defaultLegend)return!1;if(t._hidden?.length||t._solo?.length)return!1;const e=t.schema.lineLabels;return"along"===e||"function"==typeof e||function(t){if(!t.schema.stacked)return!1;const e=t.schema.shape,n=t._filteredData?.[0]??{};if("Area"!==("function"==typeof e?e(n,0):e))return!1;const i=t.schema.labelPosition;return"function"==typeof i||qx(i)}(t)||Boolean(t._alongLabelsPossible?.(t))}function ib(t,e,n){if(t<=0||e<=0)return 0;const i=Math.min(t,e*n);return i*(i/n)}function ob(t,e,n){if(t<=0)return{columns:0,rows:0};const{columns:i,rows:o}=n;if(i)return{columns:Math.min(i,t),rows:Math.max(o??0,Math.ceil(t/i))};if(o){const e=Math.ceil(t/o);return{columns:e,rows:Math.ceil(t/e)}}const r=n.gutter??{left:0,right:0,bottom:0};let a={columns:1,rows:t},s=-1,c=1/0,l=1/0;for(let i=1;i<=t;i++){const o=Math.ceil(t/i),h=(e.width-r.left-r.right-(i-1)*(n.columnPadding??n.padding))/i,u=(e.height-r.bottom-(o-1)*n.padding)/o-n.titleHeight,d=ib(h,u,n.aspect),f=i*o-t,m=u>0?Math.abs(Math.log(h/u/n.aspect)):1/0;(d>1.01*s||d>=.99*s&&(f<c||f===c&&m<l))&&(a={columns:i,rows:o},s=Math.max(d,s),c=f,l=m)}return a}function rb(t,e,n){const{columns:i,rows:o}=ob(t,e,n);if(!i)return[];const r=n.gutter??{left:0,right:0,bottom:0},a=n.padding,s=n.columnPadding??a,c=Math.max(0,(e.width-r.left-r.right-(i-1)*s)/i),l=Math.max(0,(e.height-r.bottom-(o-1)*a)/o),h=[];for(let n=0;n<t;n++){const o=Math.floor(n/i),u=n%i,d=n+i<t,f=e.x+u*(c+s)+(u?r.left:0),m=e.y+o*(l+a);h.push({index:n,row:o,column:u,x:f,y:m,width:c+(u?0:r.left)+(u===i-1?r.right:0),height:l+(d?0:r.bottom),edges:{top:0===o,right:u===i-1||n===t-1,bottom:!d,left:0===u}})}return h}const ab={top:0,right:0,bottom:0,left:0},sb=[{x:!0,y:!0},{x:!0,y:!1},{x:!1,y:!0},{x:!1,y:!1}];function cb(t){return`${t.x?"x":""}${t.y?"y":""}`}function lb(t,e={x:!1,y:!1}){const n=t[cb(e)]??ab,i={};for(const[e,o]of Object.entries(t))i[e]={top:Math.max(0,o.top-n.top),right:Math.max(0,o.right-n.right),bottom:Math.max(0,o.bottom-n.bottom),left:Math.max(0,o.left-n.left)};return i}function hb(t){const e=Object.values(t),n=(e,n)=>Math.max(0,...sb.filter(n).map(n=>t[cb(n)]?.[e]??0));return{top:Math.max(0,...e.map(t=>t.top)),right:Math.max(0,...e.map(t=>t.right)),bottom:n("bottom",t=>t.x),left:n("left",t=>t.y)}}function ub(t,e,n,i){const o=0===t.column?n.left:0,r=t.column===i-1?n.right:0,a=e+n.top,s=t.edges.bottom?n.bottom:0;return{x:t.x+o,y:t.y+a,width:Math.max(0,t.width-o-r),height:Math.max(0,t.height-a-s)}}function db(t){const e=Object.fromEntries(["top","right","bottom","left"].map(e=>[e,Math.max(...t.map(t=>t[e]))]));return t.map(t=>({top:t.top-e.top,right:t.right-e.right,bottom:t.bottom-e.bottom,left:t.left-e.left}))}function fb(t,e){return{x:t.x-e.left,y:t.y-e.top,width:t.width+e.left+e.right,height:t.height+e.top+e.bottom}}function mb(t){const e=(e,n)=>Math.max(0,...sb.filter(n).map(n=>t[cb(n)]?.[e]??0));return e("left",t=>t.x&&!t.y)+e("right",t=>t.x)}function pb(t,e){const n="function"==typeof e?e:t=>`${e}/${t}`;return t.map(t=>{const e=t.children,i={...t,key:n(`${t.key}`)};return e&&(i.children=pb(e,n)),i})}function gb(t,e,n){const i=(new ei).data(t.map((t,e)=>({id:`facet-title-${e}`,text:t.text}))).x((e,n)=>t[n].x).y((e,n)=>t[n].y).width((e,n)=>t[n].width).height(()=>1e4).verticalAlign("top").config(e);return n&&i.locale(n),i}function yb(t,e,n){if(!t.length)return 0;const i="number"==typeof e.padding?e.padding:0,o=gb(t,{...e,padding:0},n)._textData(),r=Math.max(0,...o.map(t=>t.lines.length*t.lH));return r?r+2*i:0}function xb(t,e,n){if(!t.length)return[];const i="number"==typeof e.padding?e.padding:0;return gb(t.map(t=>({...t,x:t.x+i,y:t.y+i,width:t.width-2*i})),{...e,padding:0},n).toScene().children.map(t=>{const e={...t,interactive:!1,interactionGroup:"facet"};return delete e.datum,delete e.index,e})}function bb(t,e,n,i){return{type:"group",key:`${t}/cells`,...i?{clip:i}:{},children:[{type:"group",key:`${t}/body`,...n?{transform:n}:{},children:e}]}}function kb(t,e,n,i){const o=[];return n&&o.push(n),e&&o.push(e),{type:"group",key:t,children:o,...i?{aria:{role:"group",label:i}}:{}}}function _b(t,e){return{top:e.y,left:e.x,right:t.schema.width-e.x-e.width,bottom:t.schema.height-e.y-e.height}}function vb(t,e){const{x:n,y:i}="boolean"==typeof e?{x:e,y:e}:e;return{x:!n||t.edges.bottom,y:!i||t.edges.left}}function wb(t,e,n,i,o){if(t._filteredData=n,t._margin=_b(t,i),t._padding={...e.padding},t._chartScene=[],t._chartTransform=void 0,t._chartClip=void 0,t._zoomShapes=void 0,!n.length||i.width<=0||i.height<=0)return{scene:[],zoomShapes:[],state:{}};const r=e.hooks.panel?e.hooks.panel(t,o):void 0;let a,s;t._facetStep="panel";try{t._draw(),a=t._chartScene||[],s=e.hooks.scene?e.hooks.scene(t,a):a}finally{t._facetStep=void 0,r&&r()}return{scene:s,zoomShapes:t._zoomShapes||a,chartTransform:t._chartTransform,chartClip:t._chartClip,state:e.hooks.capture?e.hooks.capture(t):{}}}function Mb(t,e){return void 0!==e.titleConfig.fontColor?e.titleConfig:{...e.titleConfig,fontColor:Oc(t)}}function Sb(t,e){const{title:n}=t,i=e.map(t=>t.value);return e.map(t=>!1===n?"":n?`${n(t.value,t.data)}`:Cg(t.value,i))}function Cb(t,e,n,i){const o=e.map((t,e)=>({text:t,x:0,y:0,width:n[e]?n[e].width:0})).filter(t=>t.text&&t.width>0);return yb(o,i,t.schema.locale)}function $b(t,e,n,i){const{config:o,hooks:r,panels:a,area:s}=e,c={columns:o.columns,rows:o.rows,padding:o.padding,titleHeight:0,aspect:("function"==typeof r.aspect?r.aspect(t):r.aspect)??oe},l=Cb(t,n,rb(a.length,s,c),i);c.titleHeight=l;const h=rb(a.length,s,c)[0],u=ub(h,l,ab,1);e.shared&&r.share&&(t._margin=_b(t,u),e.scales=r.share(t,a.map(t=>t.data)));const d=he(t,o,r,e.shared),f=d.x||d.y?function(t,e,n,i,o){const r=e.panels.find(t=>t.data.length)?.data,a=e.hooks.insets;if(!r||!a)return{};const s={};for(const c of sb.filter(t=>(o.x||t.x)&&(o.y||t.y)))wb(t,e,r,i,{cell:n,shared:e.shared,labels:c,scales:e.scales}),s[cb(c)]=a(t);return lb(s,function(t){return{x:!t.x,y:!t.y}}(o))}(t,e,h,u,d):{},m=hb(f);c.gutter=m,c.columnPadding=o.padding+mb(f),c.titleHeight=l+m.top;const p=rb(a.length,s,c),g=Math.max(1,...p.map(t=>t.column+1));return{cells:p,columns:g,titleHeight:l,outer:d,gutter:m,expansions:f}}function Ab(t,e,n){return{text:t,x:n.x,y:e.y,width:n.width}}function zb(t,e){const n=Mb(t,e.config),i=Sb(e.config,e.panels),o=$b(t,e,i,n),{cells:r,expansions:a}=o,s=r.map(t=>ub(t,o.titleHeight,o.gutter,o.columns)),c=xb(r.map((t,e)=>Ab(i[e],t,s[e])).filter(t=>t.text),n,t.schema.locale),l=r.map(t=>vb(t,o.outer)),h=r.map((t,e)=>fb(s[e],a[cb(l[e])]??ab)),u=function(t,e,n,i,o,r){const a=e.hooks.insets,{outer:s,expansions:c}=r;if(!a||s.x===s.y)return[];const l=e.panels.map((r,s)=>{if(!r.data.length)return;wb(t,e,r.data,i[s],{cell:n[s],shared:e.shared,labels:o[s],scales:e.scales});const l=c[cb(o[s])]??ab,h=a(t);return{top:h.top-l.top,right:h.right-l.right,bottom:h.bottom-l.bottom,left:h.left-l.left}}),h=db(l.filter(t=>!!t));let u=0;return l.map(t=>t?h[u++]:ab)}(t,e,r,h,l,o);let d=0;const f=[],m=[],p=[];return e.panels.forEach((n,o)=>{const a=r[o],s=u[o]?fb(h[o],u[o]):h[o],g=wb(t,e,n.data,s,{cell:a,shared:e.shared,labels:l[o],scales:e.scales}),y=`facet-${n.key}`,x=i[o]?c[d++]:void 0,b=g.scene.length?bb(y,pb(g.scene,y),g.chartTransform,g.chartClip):void 0;m.push(kb(y,x?{...x,key:`${y}/title`}:void 0,b,i[o])),p.push(...g.zoomShapes),f.push({key:y,value:n.value,cell:a,area:s,chartTransform:g.chartTransform,scene:g.scene,state:g.state})}),t._chartScene=m,{states:f,zoomShapes:p}}function Db(t){const e=ae(t.schema.facetConfig),n=wg(t,e.sort);if(!n.length||!(t._filteredData||[]).length)return!1;const i=Sg(t),o=n.map(e=>({...e,data:Mg(t,e.rows,i)})),r=o.flatMap(t=>t.data);if(!r.length)return!1;t._filteredData=r,t._insetPending=null,t._insetPlacement=null;const a=t._facetHooks?t._facetHooks():{};a.chrome&&(a.chrome(t,o.map(t=>t.data)),t._filteredData=r),t._facetStep="chrome";try{t._draw()}finally{t._facetStep=void 0}const s={...t._margin},c={...t._padding},l={x:s.left,y:s.top,width:t.schema.width-s.left-s.right,height:t.schema.height-s.top-s.bottom},h=ue(e,a),{states:u,zoomShapes:d}=zb(t,{config:e,hooks:a,panels:o,area:l,shared:h,scales:void 0,padding:c});return t._filteredData=r,t._margin=s,t._padding=c,t._chartTransform=void 0,t._chartClip=void 0,t._bodyRect={...l},t._zoomShapes=d,t._facetPanels=u,t._pendingEnterOrigin=void 0,t._pendingExitReunion=void 0,lu(t,u),!0}function Lb(t){!function(t,e){const n=nb(t);if(t._alongLegendHide=n,t._alongStats={series:0,requested:0,placed:0},!n)return e();const i={...t._margin},o={...t._padding};var r;e(),(r=t._alongStats)&&r.series>1&&r.requested===r.series&&r.placed===r.requested||(t._alongLegendHide=!1,t._alongStats={series:0,requested:0,placed:0},t._margin=i,t._padding=o,e())}(t,()=>{t._facetPanels=void 0,de(t)&&Db(t)||Oy(t)})}function Fb(t,e){const n=Oc(t),i=t._sizeLegendClass;i.renderMode("compute").locale(t.schema.locale).title(t._sizeKey).labelConfig({fontColor:n,fontFamily:t.schema.fontFamily}).titleConfig({fontColor:n,fontFamily:t.schema.fontFamily}).lineConfig({stroke:n}).shapeConfig({fill:n,stroke:n}).config(t.schema.sizeLegendConfig).scale(e);const{width:o,height:r}=i.layout();return{width:o,height:r}}function Nb(t,e){if(!t._sizeLegendClass||"function"!=typeof t._sizeLegendScale)return null;const n=t._sizeLegendScale(e);if(!n)return null;t._sizeLegendClass._maxRadius=void 0;const{width:i,height:o}=Fb(t,n);if(!i||!o)return null;const r={width:i,height:o,availableWidth:e.width,availableHeight:e.height};return t.schema.sizeLegend.bind(t)(lg(t),n,r)?{key:"sizeLegend",width:i,height:o,paint:e=>{const n=t._sizeLegendFinal;if(!n)return null;t._sizeLegendClass._maxRadius=1===e?void 0:n(n.domain()[1]);const i=Fb(t,nc(n,e));return i.width&&i.height?{node:t._sizeLegendClass.toScene(),...i}:null}}:null}const Bb=[Nb];function Eb(t,e,n){const i=[];for(const e of Bb){const o=e(t,n);o&&i.push(o)}const o="bottom"===t.schema.sizeLegendPosition?"bottom":"right",r=Sd(t,"sizeLegend");t._bottomRightBox=i.length?{...Fd(i),bottom:e,side:o,inset:r,items:i}:null}const Rb={name:"bottomRightControls",configFields:["sizeLegend","sizeLegendConfig","sizeLegendPosition"],layout:({viz:t})=>{const e=Nd(t);return{panel:e?Wd(t,e):null,margin:{}}}};function Pb(t){lp(t),t._preDraw(),Lb(t),Tb(t),Gl(t),t._drawSceneToTarget(),fp(t)}function Tb(t){const e=oy({viz:t},[Zd,$y,Up,Rb,ey,_m]);e.panels.length&&(t._featurePanels=[...t._featurePanels||[],...e.panels])}function Ob(){this._tooltipClass.data([]).render()}const Wb="d3plus-viz-spacer";function jb(t,e){return void 0===t||e?void 0:t}function Hb(t){const e=t._select?.node(),n=e?.parentNode;if(!e||!n||"http://www.w3.org/1999/xhtml"!==n.namespaceURI)return;let i=Array.from(n.children).find(t=>t.classList.contains(Wb));const o=jb(t.schema.width,t._autoWidth),r=jb(t.schema.height,t._autoHeight);if("canvas"===t._renderer||void 0===o&&void 0===r)i?.remove();else{if(!i){i=n.ownerDocument.createElement("div"),i.className=Wb,i.setAttribute("aria-hidden","true");const t=i.style;t.display="block",t.flex="none",t.boxSizing="content-box",t.margin="0",t.padding="0",t.border="0",t.visibility="hidden",t.pointerEvents="none",n.insertBefore(i,e.nextSibling)}i.style.width=`${o??0}px`,i.style.height=`${r??0}px`}}const Ib="d3plus-viz";const Gb=":where(.d3plus-render-overlays, .d3plus-zoom-control, .d3plus-top-left-controls)",qb=[".d3plus-zoom-control",".d3plus-top-left-controls",".d3plus-top-left-controls-item",`${Gb} .tlc-item`,`${Gb} .zoom-control-icon`,`${Gb} .search-root`,`${Gb} .search-input-wrap`,`${Gb} .search-count`,".d3plus-minimap",".d3plus-minimap-viewport",".d3plus-minimap-label",".d3plus-table-view",".d3plus-table-view-frame",".d3plus-table-view-toolbar",".d3plus-table-view-scroll",".d3plus-table-view-table",".d3plus-table-view-cell",".d3plus-table-view-pagination",".d3plus-attribution",".d3plus-attribution-text",".d3plus-attribution-icon",".d3plus-Mask",".d3plus-Message"];function Vb(t,e){!function(t){const e=void 0!==t.schema.width?`${t.schema.width}px`:void 0,n=void 0!==t.schema.height?`${t.schema.height}px`:void 0;t._select.classed("d3plus-viz")||t._select.style("width",e).style("height",n).attr("width",e).attr("height",n),t._select.transition().duration(Jt(t)).style("width",e).style("height",n).attr("width",e).attr("height",n)}(t),t._select.attr("class",Ib).attr("aria-hidden",t.schema.ariaHidden).attr("aria-labelledby",`${t._uuid}-title ${t._uuid}-desc`).attr("role","img").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").style("position","absolute").style("top",e.style("padding-top")).style("left",e.style("padding-left")).style("content-visibility",t.schema.detectVisible?"auto":null),It(t);"static"===e.style("position")&&e.style("position","relative"),e.style("font-family",s.fontFamilyStringify(t.schema.fontFamily)),null===t._select.attr("opacity")&&t._select.attr("opacity",1);const n=t._select.selectAll("title").data([0]),i=n.enter().append("title").attr("id",`${t._uuid}-title`);n.merge(i).text(t.schema.svgTitle);const o=t._select.selectAll("desc").data([0]),r=o.enter().append("desc").attr("id",`${t._uuid}-desc`);o.merge(r).text(t.schema.svgDesc)}function Kb(t){const e=[];return t._queue.forEach(n=>{const i=wn(t,n[3],n[2]);let o=!1;const r=new Promise(e=>{const r=(i,r)=>{o=!0,i?console.error(i):"data"===n[3]&&function(t,e){t._dataSignature=t.schema.dataPollingInterval?ln(e):void 0}(t,r),e()};try{n[0](n[1],i,n[3],r)}catch(t){r(t)}});o||e.push(r)}),t._queue=[],e}function Yb(t,e){var n;if(t._unloaded)return;let i;!function(t){const e=t._data instanceof Array&&t._data.length>0?Object.keys(t._data[0]):[],n=t._select.selectAll("g.data-table").data(!t.schema.ariaHidden&&t._data instanceof Array&&t._data.length?[0]:[]),i=n.enter().append("g").attr("class","data-table").attr("role","table");n.exit().remove();const o=n.merge(i).selectAll("text").data(t._data instanceof Array?d.range(0,t._data.length+1):[]);o.exit().remove();const r=o.merge(o.enter().append("text").attr("role","row")).selectAll("tspan").data((n,i)=>e.map(e=>({role:i?"cell":"columnheader",text:i?t._data[i-1][e]:e})));r.exit().remove(),r.merge(r.enter().append("tspan")).attr("role",t=>t.role).attr("dy","-1000px").html(t=>t.text)}(t),Pb(t),t._instantNextDraw=!1,sn(t),pn(t),!t._messageClass._isVisible||t.schema.noDataMessage&&!t._filteredData.length||(t._messageClass.hide({duration:Jt(t)}),"0"===t._select.attr("opacity")&&t._select.transition().duration(Jt(t)).attr("opacity",1));const o=()=>{if(i=void 0,!t._fontsUnsubscribe)return;const e=t._callback?Jt(t):(t._transitionEndsAt??0)-Date.now();e>0?i=setTimeout(o,e):t.render()};(n=t)._fontsUnsubscribe??(n._fontsUnsubscribe=r.onFontsLoaded(()=>{void 0===i&&o()})),t.schema.detectResize&&(t._autoWidth||t._autoHeight)?t._resizeObserver?.observe(t._select.node().parentNode):t._resizeObserver?.unobserve(t._select.node().parentNode),Ub(t,e)}function Ub(t,e){e&&setTimeout(()=>{e(),t._callback=void 0},Jt(t)+100)}function Xb(t,e,n,i){!function(t,e){console.error(`d3plus: ${function(t){const e=t.constructor;return e?._displayName||e?.name||"chart"}(t)} could not draw.`,e)}(t,e),n&&t._messageClass._isVisible&&t._messageClass.hide({duration:Jt(t)}),Ub(t,i)}function Qb(t,e){t._callback=e,e?t._renderCallback=e:e=t._renderCallback,t.schema.detectVisible&&t.schema.detectVisibleUnload||(t._unloadUnobserve?.(),t._unloadUnobserve=void 0,t._unloaded=!1),t._margin={bottom:0,left:0,right:0,top:0},t._padding={bottom:0,left:0,right:0,top:0},function(t){if(void 0===t._select||"svg"!==t._select.node().tagName.toLowerCase()){const e=void 0===t._select?o.select("body").insert("div","#d3plus-portal").style("height","100dvh").style("width","100%").style("min-height","150px"):t._select,n=e.select(".d3plus-viz").size()?e.select(".d3plus-viz"):e.append("svg");t.select(n.node())}}(t),function(t){if(t._tooltipClass&&t._select?.node){const e=t._select.node()?.parentNode;e&&t._tooltipClass.parent(e)}}(t),function(t){a.resetInjectedBoxes(t._select?.node(),qb)}(t),Hb(t);const n=function(t){return!!t._forceVisible||r.inViewport(t._select.node())}(t);!function(t,e){t.schema.width&&t.schema.height||t.schema.detectVisible&&!e||(t._autoWidth=void 0===t.schema.width||!!t._autoWidth&&t.schema.width===t._measuredWidth,t._autoHeight=void 0===t.schema.height||!!t._autoHeight&&t.schema.height===t._measuredHeight,t._setSVGSize())}(t,n),Hb(t);const i=o.select(t._select.node().parentNode);return Vb(t,i),function(t){t._visiblePoll=clearInterval(t._visiblePoll),t._resizePoll=clearTimeout(t._resizePoll),t._scrollPoll=clearTimeout(t._scrollPoll),t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t.schema.scrollContainer&&o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null)}(t),function(t,e,n){return t.schema.detectVisible&&"hidden"===t._select.style("visibility")?(t._visiblePoll=setInterval(()=>{"hidden"!==t._select.style("visibility")&&(t._visiblePoll=clearInterval(t._visiblePoll),t.render(n))},t.schema.detectVisibleInterval),!0):t.schema.detectVisible&&"none"===t._select.style("display")?(t._visiblePoll=setInterval(()=>{"none"!==t._select.style("display")&&(t._visiblePoll=clearInterval(t._visiblePoll),t.render(n))},t.schema.detectVisibleInterval),!0):!(!t.schema.detectVisible||e||(on()?(t._visibleUnobserve=rn(t._select.node(),t.schema.scrollContainer,()=>{t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t._forceVisible=!0,t.render(n)},t.schema.detectVisibleInterval),0):(o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,()=>{t._scrollPoll||(t._scrollPoll=setTimeout(()=>{r.inViewport(t._select.node())&&(o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null),t.render(n)),t._scrollPoll=clearTimeout(t._scrollPoll)},t.schema.detectVisibleInterval))}),0)))}(t,n,e)||function(t,e){vn(t);const n=Kb(t),i=Boolean(t.schema.loadingMessage&&n.length);i&&t._messageClass.render({container:t._select.node().parentNode,duration:Jt(t),html:t.schema.loadingHTML(t),mask:!!t._filteredData&&t.schema.messageMask,style:t.schema.messageStyle}),Promise.all(n).then(()=>Yb(t,e)).catch(n=>Xb(t,n,i,e))}(t,e),t._forceVisible=!1,o.select("body").on(`touchstart.${t._uuid}`,Ob.bind(t)),t}function Zb(t,e,n,i,o){const r=oy({viz:t},[e],n);for(const t of o)i[t]+=r.margin[t],n[t]+=r.margin[t]}function Jb(t){if(t._chartScene=[],t._chartTransform=void 0,"panel"===t._facetStep)return{marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:(t._featurePanels??[]).slice()};t._featurePanels=[];const e={marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]},n=lg(t),i=iy(t.schema.legendPosition.bind(t)(n),t),o=iy(t.schema.colorScalePosition.bind(t)(n),t);e.legendPosition=i,e.colorScalePosition=o;const r={top:t._margin.top,right:t._margin.right,bottom:t._margin.bottom,left:t._margin.left},a=oy({viz:t},[dy,fy,py],r);t._featurePanels.push(...a.panels),e.marginDelta.top+=a.margin.top,r.top+=a.margin.top;const s=oy({viz:t},[my],r);e.marginDelta.bottom+=s.margin.bottom,r.bottom+=s.margin.bottom,Eb(t,r.bottom,{width:t.schema.width-r.left-r.right,height:t.schema.height-r.top-r.bottom});const c=Od(t,r.right);r.right+=c,"top"!==i&&"bottom"!==i||Zb(t,yg,r,e.marginDelta,["top","bottom"]),"top"!==o&&"bottom"!==o||Zb(t,Jg,r,e.marginDelta,["top","bottom"]),r.right-=c;const l=Td(t,r.bottom);e.marginDelta.bottom+=l,r.bottom+=l,"left"!==i&&"right"!==i&&!1!==i||Zb(t,yg,r,e.marginDelta,["left","right"]),"left"!==o&&"right"!==o&&!1!==o||Zb(t,Jg,r,e.marginDelta,["left","right"]);const h=Od(t,r.right);e.marginDelta.right+=h,r.right+=h;const u=Math.max(0,ly(t)-e.marginDelta.top);e.marginDelta.top+=u,r.top+=u;const d=e.marginDelta;return t._margin={top:t._margin.top+d.top,right:t._margin.right+d.right,bottom:t._margin.bottom+d.bottom,left:t._margin.left+d.left},e.featurePanels=t._featurePanels.slice(),e}const tk={x:"_x",x2:"_x2",y:"_y",y2:"_y2",size:"_size",stackOrder:"_stackOrder"},ek=["dimensions"];const nk=t=>null!==t&&"object"==typeof t;function ik(t,e){return t.some(t=>t.some(t=>nk(t)&&e in t))}function ok(t){const e=new Set;for(const n of t)for(const t of n)if(nk(t))for(const n in t)e.add(n);return Array.from(e)}function rk(t,{key:e,field:n},i){const o=i.slice(0,10);return i.length>10&&o.push("…"),`${t} ${e}: no rows have '${n}'; fields are: ${o.join(", ")}`}function ak(t){const e=({key:t,field:e})=>`missing-field:${t}:${e}`,n=function(t){const e=new Map,n=(t,n)=>{const i=q(n);void 0===i||e.has(n)||e.set(n,{key:t,field:i})};for(const[e,i]of Object.entries(tk))n(e,t[i]);for(const e of t._confidenceBands??[])n("confidence",e.lower),n("confidence",e.upper);const i=Object.keys(t.schema).filter(t=>"thresholdKey"!==t);for(const e of[...i,"thresholdKey"]){const i=t.schema[e];Array.isArray(i)&&"function"==typeof i[0]?i.forEach(t=>n(e,t)):n(e,i)}const o=Array.from(e.values());for(const e of ek){const n=t.schema[e],i=Array.isArray(n)?n:[n];for(const t of i)"string"==typeof t&&o.push({key:e,field:t})}return o}(t).filter(n=>function(t,e){return Ft&&!Lt.get(t)?.has(e)}(t,e(n)));if(!n.length)return;const i=function(t){return[t._sourceData??t._data,t.schema.nodes,t.schema.links].filter(t=>Array.isArray(t))}(t);if(!i.some(t=>t.some(nk)))return;let o;for(const r of n)ik(i,r.field)||(o??(o=ok(i)),Pt(t,e(r),rk(qt(t),r,o)))}function sk(t,e,n){for(;e.__d3plus__&&e.data;)n=(e=e.data).i;return t(e,n)}function ck(t,e,n){const i={noDataMessage:!1};return new d.InternSet(e.map(n)).size>t.schema.dataCutoff?i.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==t._userHover&&(i.hoverOverride={hoverOpacity:t._userHover,duration:t._userDuration,restoreOriginals:!0}),i.noDataMessage=!(!t.schema.noDataMessage||e.length),i}function lk(t){ak(t);const n=void 0!==t.schema.depth?d.min([t.schema.depth>=0?t.schema.depth:0,t.schema.groupBy.length-1]):t.schema.groupBy.length-1,{id:i,ids:o,drawLabel:r}=function(t,e){const n=t.schema.groupBy,i=t.schema.label,o=t.schema.thresholdName,r=t.schema.locale,a=t=>"number"==typeof t?`${t}`:t,s=(t,e)=>n.map(n=>`${sk(n,t,e)}`).filter(Boolean);return{id:(t,i)=>{const o=sk(n[e],t,i);return Array.isArray(o)?o.map(a):a(o)},ids:s,drawLabel:(n,a,c)=>{const l=t._drawDepth??e;if(!n)return"";const h=ge(n),u=c??h??l;for(;n.__d3plus__&&n.data;)a=(n=n.data).i;if(u===h&&"string"==typeof n[me])return n[me];if(n._isColorScaleBucket)return`${n.id}`;if(n._isAggregation)return`${o(n,a)} < ${p.formatAbbreviate(100*n._threshold,r)}%`;if(i&&u===l)return`${i(n,a)}`;const d=s(n,a).slice(0,u+1),f=d.reverse().find(t=>!(t instanceof Array))||d[d.length-1];return f instanceof Array?function(t){return t.reduce((e,n,i)=>(i?i===t.length-1&&1===i?e+=` and ${n}`:i===t.length-1?e+=`, and ${n}`:e+=`, ${n}`:e+=n,e),"")}(f):`${f}`}}}(t,n);(function(t){const e=t=>!0===t||"number"==typeof t&&t>0,n=e=>t?.[e]?.trailPersist;return!!t&&(e(t.trailPersist)||e(n("Circle"))||e(n("Rect")))})(t.schema.shapeConfig)&&(t._axisPersist=!0,t.schema.timelineConfig={...t.schema.timelineConfig||{},brushing:!1});const a={};cg(t,a,n,i,sg(t)),t._drawDepth=n,t._id=i,t._ids=o,t._drawLabel=r,void 0!==a.legendData&&(t._legendData=a.legendData),t._thresholdRows=a.legendData;let s=a.filteredData||[];t._data.length&&a._thresholdTree&&(s=t._thresholdFunction(s,a._thresholdTree,t._thresholdRows),t._thresholdLegend&&a.legendData&&(t._legendData=t._thresholdLegend(a.legendData))),t._filteredData=s,function(t){if(!t.schema.colorOrdinal||t.schema.colorScale)return void(t._ordinalColorScale=void 0);const n=t._filteredData??[],i=t.schema.color,o=new Set,r=[];n.forEach((t,e)=>{const n=i(t,e),a="string"==typeof n?n:JSON.stringify(n);o.has(a)||(o.add(a),r.push(n))});const a=(r.every(t=>"number"==typeof t)?[...r].sort((t,e)=>t-e):r).map(t=>"string"==typeof t?t:JSON.stringify(t)),s=J(t._theme,"max",(t.schema.colorDefaults??e.colorDefaults).sequential),l=tt(t._theme,s,a.length||1,!0);t._ordinalColorScale=c.scaleOrdinal().domain(a).range(l)}(t);const l=ck(t,s,t._id);l.hoverOverride?.stashOriginals?(void 0===t._userHover&&(t._userHover=t.schema.shapeConfig.hoverOpacity||.5),void 0===t._userDuration&&(t._userDuration=t.schema.shapeConfig.duration||600),t.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,t.schema.shapeConfig.duration=l.hoverOverride.duration):l.hoverOverride?.restoreOriginals&&(t.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,t.schema.shapeConfig.duration=l.hoverOverride.duration),l.noDataMessage&&(t._messageClass.render({container:t._select.node().parentNode,duration:Jt(t),html:t.schema.noDataHTML(t),mask:!1,style:t.schema.messageStyle}),t._select.transition().duration(Jt(t)).attr("opacity",0))}function hk(t,e=!1){var n;const i=(n=t)._nearestHover??(n._nearestHover={key:null}),o=t._select?.node?.(),r="canvas"===t._renderer||e?void 0:o;if(i.surface&&i.surface.el===r)return;if(i.surface?.unbind(),i.surface=void 0,!r||"function"!=typeof r.addEventListener)return;const a=e=>{const n=e,i=function(t){return(t._sceneRenderer?.elements?.()??[]).find(t=>"svg"===t.localName)}(t);return!!n&&"function"==typeof n.closest&&r.contains(n)&&!(i&&i.contains(n))&&!n.closest("g.d3plus-viz-timeline, g.d3plus-viz-brush, g.d3plus-zoom-brush")},s=e=>{const n=_u(t);return[e.clientX-n.left,e.clientY-n.top]},c=e=>a(e.target)&&gu(t)>0,l=e=>{if(!c(e))return;const n=s(e);ku(t,{type:"mousemove",point:n,pick:null,nativeEvent:e})},h=e=>{if(!c(e))return;const n=s(e);bu(t,null,n)&&(e.stopPropagation(),ku(t,{type:"click",point:n,pick:null,nativeEvent:e}))},u=e=>{if(null===i.key)return;const n=s(e);ku(t,{type:"mouseleave",point:n,pick:null,nativeEvent:e})};r.addEventListener("mousemove",l),r.addEventListener("click",h,!0),r.addEventListener("mouseleave",u),i.surface={el:r,aroundScene:a,unbind:()=>{r.removeEventListener("mousemove",l),r.removeEventListener("click",h,!0),r.removeEventListener("mouseleave",u)}}}function uk(t,e){t.interactionGroup=e;const n=t.children;if(n)for(const t of n)uk(t,e)}class dk extends _f{_preDraw(){lk(this)}toScene(){const t=up(this);if(this._chartScene&&this._chartScene.length){const e=Lf(this._chartScene,this),n=[{type:"group",key:"viz-zoom",transform:this._zoomTransform??{x:0,y:0,scale:1},children:[{type:"group",key:"viz-chart-body",...this._chartTransform?{transform:this._chartTransform}:{},children:e}]}],i=this._chartClip??(this.schema.zoom&&this._margin?St(this):void 0);t.push({type:"group",key:"viz-chart-cells",...i?{clip:i}:{},children:n})}const e=[["legend",this._legendClass],["colorScale",this._colorScaleClass],["timeline",this._timelineClass]];for(const[n,i]of e)if(i&&"function"==typeof i.toScene&&i._select&&"function"==typeof i._select.node&&i._select.node()){let e=i.toScene();"legend"===n?(uk(e,"legend"),e=Lf([e],this)[0]):"colorScale"===n?e=$f([e],this)[0]:"timeline"===n&&uk(e,"timeline"),t.push({type:"group",key:`viz-${n}`,children:"timeline"===n?[e]:Dd(this,n,e,i.outerBounds())})}return this._featurePanels&&this._featurePanels.length&&t.push({type:"group",key:"viz-features",children:this._featurePanels}),El(this,t),{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:t}}}_draw(){Jb(this)}_sizeLegendScale(t){return null}_insetRegion(){return null}_tableData(){return null}_colorScaleShape(t,e){return this.schema.shape(t,e)}_thresholdFunction(t,e,n){return t}_thresholdLegend(t){return t}_setSVGSize(t,e){let[n,i]=t&&e?[t,e]:r.getSize(this._select.node().parentNode);n-=parseFloat(this._select.style("border-left-width")),n-=parseFloat(this._select.style("border-right-width")),i-=parseFloat(this._select.style("border-top-width")),i-=parseFloat(this._select.style("border-bottom-width")),this._autoWidth&&(this._measuredWidth=n),this._autoHeight&&(this._measuredHeight=i),this._autoWidth&&this.schema.width!==n&&(this.width(n),this._select.style("width",`${this.schema.width}px`).attr("width",`${this.schema.width}px`)),this._autoHeight&&this.schema.height!==i&&(this.height(i),this._select.style("height",`${this.schema.height}px`).attr("height",`${this.schema.height}px`))}render(t){return Qb(this,t)}toSVGString(){return function(t,e){const n=jt(e),i=/^\s*<[a-zA-Z][^\s>/]*/.exec(t);if(!n.length||!i)return t;const o=t.indexOf(">",i[0].length),r=t.slice(0,o<0?t.length:o),a=/\sclass="([^"]*)"/.exec(r);if(!a)return`${i[0]} class="${Gt(n.join(" "))}"${t.slice(i[0].length)}`;const s=a[1].split(/\s+/).filter(Boolean),c=[...s,...n.filter(t=>!s.includes(t))],l=a.index;return`${t.slice(0,l)} class="${Gt(c.join(" "))}"${t.slice(l+a[0].length)}`}(this._sceneRenderer?.toSVGString?.()??"",this.schema.className)}toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(t){return arguments.length?(this._renderer="canvas"===t?"canvas":"svg",this):this._renderer}_drawSceneToTarget(t){const e="canvas"===this._renderer?"canvas":"svg",n=this._select&&this._select.node?this._select.node():null;if(!n)return;const i=function(t,e){return"canvas"===t&&"undefined"!=typeof Element&&e instanceof Element&&"svg"===e.tagName.toLowerCase()?e.parentNode??e:e}(e,n),a=this.toScene();this._paintedScene=a;const s=this.schema.width||400,c=this.schema.height||300;this._ensureSceneRenderer(e,i,s,c),It(this);const l=Zt(this)?0:void 0!==t?t:this._instantNextDraw?0:this.schema.duration;l>0&&null!=this._sceneRepaintRAF&&(cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),l>0&&(this._transitionEndsAt=Date.now()+l+30);const h=this._timelineSelection,u=!(!this._timelineClass||!1!==this._timelineClass.schema.brushing)&&Array.isArray(h)&&h.length?Math.max(...h.map(t=>Number(r.date(Number(t))))):void 0,d=void 0!==u&&void 0!==this._trailSeq&&u>this._trailSeq?At(this,a,this._trailSeq,u):void 0;if(void 0!==u&&(this._trailSeq=u),this._sceneRenderer.drawScene(a,{duration:l,sequence:u,trailCatchup:d,enterFrom:this._resolvedEnterFrom,enterFromBody:this._resolvedEnterFromBody,exitTo:this._resolvedExitTo,exitToBody:this._resolvedExitToBody,instantExitKey:this._resolvedInstantExitKey,reunionEnterKey:this._resolvedReunionEnterKey,reunionEnterFrom:this._resolvedReunionEnterFrom,instantExitAll:this._resolvedInstantExitAll}),this._resolvedEnterFrom=void 0,this._resolvedEnterFromBody=void 0,this._resolvedExitTo=void 0,this._resolvedExitToBody=void 0,this._resolvedInstantExitKey=void 0,this._resolvedReunionEnterKey=void 0,this._resolvedReunionEnterFrom=void 0,this._resolvedInstantExitAll=void 0,this._lastSceneRendered=a,ef(this),this._select&&"canvas"===e&&this._select.selectAll("g.d3plus-viz-timeline, g.d3plus-viz-brush").style("pointer-events","auto"),"canvas"===e&&function(t){if(!t.schema.zoom||t._ssr||!t._zoomBehavior||!t._brushGroup)return;const e=t._sceneRenderer,n=e&&"function"==typeof e.toCanvas?e.toCanvas():null;!n||t._zoomEventTarget&&t._zoomEventTarget.node()===n||(tf(t,o.select(n)),of.bind(t)(od(t)))}(this),hk(this),Bl(this),"svg"===e){const t="function"==typeof n.querySelector?n:null,e=t?t.querySelector(":scope > g.d3plus-viz-timeline"):null;e&&t.appendChild(e),t?.querySelectorAll(":scope > g.d3plus-zoom-brush, :scope > g.d3plus-viz-brush").forEach(e=>{e!==t.lastElementChild&&t.appendChild(e)})}}_interactionDatum(t,e){return pl(t.datum,t.index??0)}_shapeDepth(t){}_pointMark(t){return!1}_sharedHover(t){}_classNameTargets(){return function(t,e,n){if("canvas"===n)return Ot(e).filter(t=>"canvas"===t.localName).map(t=>({el:t,keep:Tt}));const i="undefined"!=typeof Element&&t instanceof Element&&t.classList.contains(Ib)?t:void 0;return i?[{el:i,keep:[Ib]}]:[]}(this._select?.node?.(),this._sceneRenderer,"canvas"===this._renderer?"canvas":"svg")}_facetHooks(){return{}}_ensureSceneRenderer(t,e,n,i){const o=this._sceneRenderer?.target?this._sceneRenderer.target()?.container:void 0,r=!!this._sceneRenderer?.target&&o!==e;if(!this._sceneRenderer||this._sceneRenderer.kind!==t||r){this._sceneRenderer&&function(t){const e=ql(t);e&&(e.style.cursor="auto"),t._select?.style("cursor","auto")}(this),this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const o="canvas"===t?a.CanvasRenderer:a.SvgRenderer;this._sceneRenderer=new o,this._sceneRenderer.mount({container:e,width:n,height:i,pixelRatio:this._scenePixelRatio}),this._lastScenePick=null,this._sceneRenderer.on(t=>ku(this,t))}else this._sceneRenderer.resize(n,i)}_routeSceneEvent(t){cu(this,su(this,t.point),()=>this._dispatchSceneEvent(t))}_dispatchSceneEvent(t){this._sharedHover(t),vf(this,t);const e=xh(this,t);if(function(t,e,n){const i="mousemove"===e.type||"mouseenter"===e.type,o=n&&i?uh(e.pick?.node?.datum):null;o!==(t._swatchLabelBucket??null)&&(t._swatchLabelBucket&&(t._swatchLabelBucket=void 0,t.hover?.(!1)),o&&dh(t,o)&&(t._swatchLabelBucket=o))}(this,t,e),e)return;if(this._transitionEndsAt&&Date.now()<this._transitionEndsAt)return;const n=t.pick,i=(e,n,i,o)=>{const r=this.schema.on&&this.schema.on[e];if("function"==typeof r)try{r.call(this,n,i,o,t.nativeEvent)}catch(t){!function(t){const e=globalThis.reportError;"function"==typeof e?e(t):console.error(t)}(t)}};if("mouseleave"===t.type){const t=this._lastScenePick;if(t){i("mouseleave."+(t.isLegend?"legend":"shape"),t.d,t.i,t.x);for(const e of t.shapeTargets)i(`mouseleave.${e.shapeType}`,e.d,e.i,e.x);i("mouseleave",t.d,t.i,t.x)}return this._lastScenePick=null,void(this._hoverDatum=null)}if(!n||!n.node)return;const o=n.node;if("axis"===o.interactionGroup||"timeline"===o.interactionGroup||"trend"===o.interactionGroup)return;const r=t.nativeEvent&&t.nativeEvent.target,a="legend"===o.interactionGroup||!(!r||"function"!=typeof r.closest)&&!!r.closest('[data-key="viz-legend"]'),s=a?"legend":"shape",c=`${t.type}.${s}`,{d:l,i:h,x:u}=this._interactionDatum(n,t);if(void 0===l)return;const d=a?[]:function(t,e){const n=[],i=yl(t);i&&n.push({shapeType:i,...e});for(const e of t.owners??[])n.some(t=>t.shapeType===e.shapeType)||n.push({shapeType:e.shapeType,...pl(e.datum,e.index)});return n}(n.node,{d:l,i:h,x:u});this._lastScenePick={d:l,i:h,x:u,isLegend:a,shapeTargets:d,node:n.node},this._hoverDatum=u,i(c,l,h,u);for(const e of d)i(`${t.type}.${e.shapeType}`,e.d,e.i,e.x);i(t.type,l,h,u)}_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}destroy(){var t;return Pe(this),Fl(this),hk(this,!0),cp(this),un(this),this._resizeObserver?.disconnect(),this._fontsUnsubscribe?.(),this._fontsUnsubscribe=void 0,this._tooltipClass.data([]).render(),o.select("body").on(`touchstart.${this._uuid}`,null),(t=this)._visiblePoll&&(t._visiblePoll=clearInterval(t._visiblePoll)),t._resizePoll&&(t._resizePoll=clearTimeout(t._resizePoll)),t._scrollPoll&&(t._scrollPoll=clearTimeout(t._scrollPoll)),t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t._unloadUnobserve?.(),t._unloadUnobserve=void 0,t.schema.scrollContainer&&o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null),an(this),this}constructor(){var t;super(),Xu(this),(t=this).schema.legendInset=!0,t.schema.legendInsetConfig={}}}function fk(t,e=dk){class n extends e{_draw(e){return super._draw(e),t.layoutStage&&"chrome"!==this._facetStep&&Ct(this,t,t.layoutStage,t.chartTransform),this}toScene(){const e=super.toScene();return t.decorateScene?t.decorateScene(this,e):e}_sizeLegendScale(e){return t.sizeLegendScale?t.sizeLegendScale(this,e):super._sizeLegendScale(e)}_insetRegion(){return t.insetRegion?t.insetRegion(this):super._insetRegion()}_tableData(){return t.tableData?t.tableData(this):super._tableData()}_colorScaleShape(e,n){return t.colorScaleShape?t.colorScaleShape(this,e,n):super._colorScaleShape(e,n)}_pointMark(e){return t.pointMark?t.pointMark(this,e):super._pointMark(e)}_shapeDepth(e){return t.shapeDepth?t.shapeDepth(this,e):super._shapeDepth(e)}_facetHooks(){return t.facet?{...super._facetHooks(),...t.facet}:super._facetHooks()}_thresholdLegend(e){return t.thresholdFunction?t.thresholdFunction(this,e,e):super._thresholdLegend(e)}_thresholdFunction(e,n,i){return t.thresholdFunction?t.thresholdFunction(this,e,i):super._thresholdFunction(e,n,i)}constructor(){super(),function(t,e){if(e.ctx)for(const[n,i]of Object.entries(e.ctx))t.ctx[n]=i;if(e.defaults){const n=t;for(const[t,i]of Object.entries(e.defaults))n[`_${t}`]=i}e.fields&&kt(t,e.fields),e.setup&&e.setup(t)}(this,t),!1===t.colorScaleTooltip&&(this._colorScaleTooltip=!1)}}return n._displayName=t.name,Object.defineProperty(n,"name",{value:t.name}),n}function mk(t){return arguments.length?(this._hover=t,this.schema.legend&&this._legendClass&&this._legendClass.hover(t),this._sceneRenderer&&this._scheduleSceneRepaint(),Ge(this,"hover",t),this):this._hover}function pk(t){if("string"==typeof t)return{accessor:G(t),title:t,key:t};if("function"==typeof t)return{accessor:t,title:""};if(t&&"object"==typeof t&&"value"in t){const{value:e,title:n}=t,i=pk(e);return i?"string"==typeof n?{...i,title:n}:i:null}return null}function gk(t){return Array.isArray(t)?t.map(pk).filter(t=>null!==t):[]}function yk(t){return null==t||""===t||"number"==typeof t&&isNaN(t)}function xk(t,e){if(!e.length)return 0;if("number"==typeof t&&Number.isInteger(t))return t>=0&&t<e.length?t:0;if("string"==typeof t){const n=e.findIndex(e=>e.key===t);if(n>=0)return n;const i=e.findIndex(e=>e.title===t);if(i>=0)return i}return 0}function bk(t,e,n,i){const o={id:`${e.id}→${n.id}@${i.id}`,column:t,source:e,target:n,origin:i,value:0,rows:[],paths:new Set,sy0:0,sy1:0,ty0:0,ty1:0};return e.sourceBands.push(o),n.targetBands.push(o),o}function kk(t,e,n,i=0){const o=e.map(()=>new Map),r=e.map(()=>[]),a=new Map,s=[],c=new Map,l=[],h=[],u=Math.max(0,Math.min(e.length-1,i));let d=0;return t.forEach((t,i)=>{const f=e.map(e=>e.accessor(t,i));if(!e.length||f.some(yk))return;const m=Number(n(t,i));if(!Number.isFinite(m)||m<=0)return;const p=h.length;h.push(t),d+=m;const g=f.map((t,e)=>{const n=String(t);let i=o[e].get(n);return i||(i=function(t,e,n){const i=String(e);return{id:`${t}|${i}`,column:t,category:e,label:i,value:0,first:n,rank:n,rows:[],paths:new Set,sourceBands:[],targetBands:[],x0:0,x1:0,y0:0,y1:0}}(e,t,r[e].length),o[e].set(n,i),r[e].push(i)),i.value+=m,i.rows.push(p),i}),y=g.map(t=>t.id).join("\0");let x=c.get(y);void 0===x&&(x=l.length,c.set(y,x),l.push({nodes:g,value:0,rows:[]})),l[x].value+=m,l[x].rows.push(p);const b=g[u];for(const t of g)t.paths.add(x);for(let t=0;t<g.length-1;t++){const e=`${g[t].id}\0${g[t+1].id}\0${b.id}`;let n=a.get(e);n||(n=bk(t,g[t],g[t+1],b),a.set(e,n),s.push(n)),n.value+=m,n.rows.push(p),n.paths.add(x)}}),{columns:r,bands:s,paths:l,rows:h,colorBy:u,total:d}}function _k(t,e){const n=new Array(e).fill(void 0);n[t.origin.column]=t.origin.label,n[t.source.column]=t.source.label,n[t.target.column]=t.target.label;const i=n.findIndex(t=>void 0!==t);let o=n.length-1;for(;o>i&&void 0===n[o];)o--;const r=[];for(let t=i;t<=o;t++){const e=n[t];void 0!==e?r.push(e):"…"!==r[r.length-1]&&r.push("…")}return r.join(" → ")}dk._displayName="Viz";const vk=(t,e)=>t.first-e.first,wk=(t,e)=>e.value-t.value||vk(t,e);function Mk(t,e){const n=new Map;let i=0;for(const t of e)n.set(t,i+t.value/2),i+=t.value;const o=new Map;for(const e of t){let t=0,i=0;for(const o of e.targetBands){const e=n.get(o.source);void 0!==e&&(t+=e*o.value,i+=o.value)}o.set(e,i?t/i:1/0)}return o}function Sk(t,e="crossings"){t.columns.forEach((n,i)=>{if("function"==typeof e)n.sort((t,n)=>e(t,n)||vk(t,n));else if("data"===e)n.sort(vk);else if("crossings"===e&&i>0){const e=Mk(n,t.columns[i-1]);n.sort((t,n)=>(e.get(t)??0)-(e.get(n)??0)||wk(t,n))}else n.sort(wk);n.forEach((t,e)=>t.rank=e)})}function Ck(t,e,n){const i=Math.max(0,e),o=Math.max(1,Math.min(n,t>1?i/(2*t-1):i)),r=t>1?(i-o)/(t-1):0;return{x:Array.from({length:t},(e,n)=>t>1?n*r:(i-o)/2),nodeWidth:o}}function $k(t,e){const{columns:n}=t,i=n.length;if(!i)return;const{x:o,nodeWidth:r}=Ck(i,e.width,e.nodeWidth),a=Math.max(0,e.top),s=Math.max(0,e.height-a),c=Math.max(...n.map(t=>t.length)),l=c>1?Math.max(0,Math.min(e.nodePadding,s/2/(c-1))):0,h=n.filter(t=>t.length).map(t=>{const e=t.reduce((t,e)=>t+e.value,0);return e>0?(s-(t.length-1)*l)/e:1/0}),u=Math.max(0,Math.min(...h,1/0)),d=Number.isFinite(u)?u:0;n.forEach((t,e)=>{const n=o[e],i=t.reduce((t,e)=>t+e.value,0)*d+Math.max(0,t.length-1)*l;let c=a+(s-i)/2;for(const e of t)e.x0=n,e.x1=n+r,e.y0=c,e.y1=c+e.value*d,c=e.y1+l});const f=(t,e)=>t.target.rank-e.target.rank||t.origin.rank-e.origin.rank,m=(t,e)=>t.source.rank-e.source.rank||t.origin.rank-e.origin.rank;for(const t of n)for(const e of t){let t=e.y0;for(const n of e.sourceBands.sort(f))n.sy0=t,t+=n.value*d,n.sy1=t;t=e.y0;for(const n of e.targetBands.sort(m))n.ty0=t,t+=n.value*d,n.ty1=t}}function Ak(t){const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return`M${e},${t.sy0}C${i},${t.sy0},${i},${t.ty0},${n},${t.ty0}L${n},${t.ty1}C${i},${t.ty1},${i},${t.sy1},${e},${t.sy1}Z`}const zk=new WeakMap;function Dk(t){return t&&"object"==typeof t?zk.get(t):void 0}function Lk(t,e){return zk.set(t,e),t}function Fk(t){const e=Dk(t);return!e||"group"!==e.kind&&"path"!==e.kind?[t]:e.rows}const Nk=new WeakMap;function Bk(t){const e=t.schema.dimensions,n=t.schema.colorBy,i=Nk.get(t);if(i&&i.input===e&&i.colorBy===n)return i;const o=gk(e),r={input:e,colorBy:n,dims:o,k:xk(n,o)};return Nk.set(t,r),r}function Ek(t){return(e,n)=>{const i=Dk(e),{dims:o,k:r}=Bk(t);return i?i.id:o[r]?.accessor(e,n)}}function Rk(t){return delete t.datum,delete t.index,"group"===t.type&&t.children.forEach(Rk),t}function Pk(t){return Rk(Lr(t))}const Tk=1e4;function Ok(t,e,n){const i=(new ei).data(t.map(t=>({id:`pc-title-${t.key}`,text:t.text}))).x((e,n)=>t[n].x).y((e,n)=>t[n].y).width((e,n)=>t[n].width).height((e,n)=>t[n].height).config(e);return n&&i.locale(n),i}function Wk(t,e,n){if(!t.length)return[];const i=t.map((t,e)=>({key:`${e}`,text:t,x:0,y:0,width:Tk,height:Tk}));return Ok(i,{...e,padding:0},n)._textData().map(t=>Math.ceil(Math.max(0,...t.widths)))}function jk(t,e,n){if(!t.length)return 0;const i=Ok(t.map(t=>({...t,height:Tk})),{...e,padding:0},n)._textData();return Math.ceil(Math.max(0,...i.map(t=>t.lines.length*t.lH)))}function Hk(t,e,n,i){if(!t.length)return[];const o=new Map(t.map(t=>[`pc-title-${t.key}`,t]));return Ok(t,{...e,padding:0},n).toScene().children.map(t=>{const e=o.get(`${t.datum?.id}`);return i&&e&&Dr([t],e.text,i.get(e.key)),Pk(t)})}function Ik(t,e,n,i){const o=t.length,r=o>1?e[1]-e[0]:i,a=Math.max(1,r/2-4),s=[];return t.forEach((t,r)=>{if(!t)return;const c=e[r]+n/2,l={key:`${r}`,text:t,y:0,height:0};1===o?s.push({...l,x:0,width:Math.max(1,i),anchor:"middle"}):0===r?s.push({...l,x:e[r],width:a+n/2,anchor:"start"}):r===o-1?s.push({...l,x:c-a,width:a+n/2,anchor:"end"}):s.push({...l,x:c-a,width:2*a,anchor:"middle"})}),s}function Gk(t){return t.schema.dimensionTitleConfig?.titleTooltip}function qk(t,e){const n={fontColor:Oc(t),fontSize:12,fontWeight:600,textAnchor:(t,n)=>e[n]?.anchor??"middle",verticalAlign:"bottom",...t.schema.dimensionTitleConfig??{}};return delete n.titleTooltip,n}function Vk(t,e,n){const i=jk(t,e,n);for(const e of t)e.height=i;return i}function Kk(t,e,n,i){const o=new Map(t.map(t=>[t.key,i]));return Hk(t,e,n,o).map(t=>({...t,key:`alluvial-${String(t.key)}`}))}const Yk=()=>1;function Uk(t){const e=q(t.schema.value);if(e)return e;return(0,t.schema.translate)(t.schema.value===Yk?"Count":"Value")}function Xk(t,e,n){if(t.column===n)return t.category;return`${e[t.column]?.title||`${t.column+1}`}: ${t.label}`}function Qk(t,e,n){return t.paths.slice().sort((t,e)=>{for(let n=0;n<t.nodes.length;n++){const i=t.nodes[n].rank-e.nodes[n].rank;if(i)return i}return 0}).map(i=>{const o={};i.nodes.forEach((t,n)=>{o[e[n].title||`${n+1}`]=t.category}),o[n]=i.value;const r=i.nodes[t.colorBy];return Lk(o,{kind:"path",id:r.category,rows:i.rows.map(e=>t.rows[e])})})}function Zk(t,e,i){return n.merge(i.map(t=>e.rows[t]),t.schema.aggs)}const Jk=({viz:t})=>{const e=t,{width:n,height:i}=wt(e),o=(e._filteredData??[]).flatMap(Fk),{dims:r,k:a}=Bk(e),s=kk(o,r,e.schema.value,a);Sk(s,e.schema.nodeSort);const c=Ck(r.length,n,e.schema.nodeWidth),l=Ik(r.map(t=>t.title),c.x,c.nodeWidth,n),h=qk(e,l),u=Vk(l,h,e.schema.locale);$k(s,{width:n,height:i,top:u?u+8:0,nodeWidth:e.schema.nodeWidth,nodePadding:e.schema.nodePadding});const d=s.columns.flat().map((t,n)=>({__d3plus__:!0,data:Lk(Zk(e,s,t.rows),{kind:"node",id:Xk(t,r,s.colorBy),node:t}),i:n,id:t.id,shape:"Rect",node:t,x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1})),f=s.bands.map(t=>({band:t,datum:Lk(Zk(e,s,t.rows),{kind:"band",id:t.origin.category,band:t}),text:_k(t,r.length)})),m={graph:s,dims:r,nodes:d,bands:f,titles:l,titleStyle:h,width:n,height:i};return e.ctx.alluvial=m,"panel"!==e._facetStep&&(e._filteredData=Qk(s,r,Uk(e))),{shapeData:d}},t_={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",rotate(t){const e=t.r??t.data?.r;return"number"==typeof e?e:0},rotateAnchor(t){const e=t.rotateAnchor??t.data?.rotateAnchor;return Array.isArray(e)?e:[(t.w??0)/2,(t.h??0)/2]},fontColor(t,n){const i="function"==typeof this._fill?this._fill(t,n):this._fill;return"string"==typeof i?e.colorContrast(i):"black"}};function e_(t){const e=Br(t);if(!e.length)return[];const n=(new ei).config({...t_,...t.labelConfig??{}}).data(e).renderMode("compute");try{const t=n.toScene();return Array.isArray(t?.children)?t.children:[]}catch{return[]}}function n_(t,e,n,i,o){if(!e.length||!1===n.label)return[];const r=Array.from(new Set(e.map(t=>t.x0))).sort((t,e)=>t-e),a=r.length>1?r[r.length-1]:void 0,s=t=>t.data??t,c=new Set(e.filter(t=>t.x0===a).map(s)),l=new Map;for(const t of r){const n=e.filter(e=>e.x0===t).sort((t,e)=>t.y0-e.y0);n.forEach((t,e)=>{const i=e?(t.y0+n[e-1].y1)/2:0,r=e<n.length-1?(t.y1+n[e+1].y0)/2:o,a=(t.y0+t.y1)/2;l.set(t,Math.min(a-i,r-a))})}return e_({data:e,datum:t=>s(t),label:(e,i)=>{const o=e,r=Tg(n.label,s(o),o.i??i);return!1!==r&&(void 0===r?jg(t,o,i):r)},x:t=>t.x0,y:t=>t.y0,aes:()=>({}),rotate:W(0),id:t=>`sankey-label-${t.id}`,labelBounds:t=>(t=>{const e=r.indexOf(t.x0),n=t.x1-t.x0,o=l.get(t)??(t.y1-t.y0)/2,s=(t.y1-t.y0)/2-o;if(t.x0===a){const i=t.x0-(r[e-1]+n)-10;return{x:-5-i,y:s,width:i,height:2*o}}return{x:n+5,y:s,width:(e<r.length-1?r[e+1]:i)-t.x1-10,height:2*o}})(t),labelConfig:{fontColor:()=>Oc(t),fontResize:!1,fontSize:12,padding:0,textAnchor:t=>c.has(t.data)?"end":"start",verticalAlign:"middle",...Ig(t,"Rect")}})}function i_(t,e){return p.formatAbbreviate(e,t.schema.locale)}const o_=({viz:t})=>{const e=t.ctx.alluvial;if(!e)return[];const n=t,i=[],o=Hg(n,"Path"),r=Number(n.schema.bandOpacity??.5);e.bands.forEach(({band:t,datum:e,text:a},s)=>{const c=Wg(o,e,s);i.push({type:"path",shapeType:"Path",key:`alluvial-band-${t.id}`,d:Ak(t),datum:e,index:s,paint:{...c,fillOpacity:r,opacity:c.opacity??1},aria:{label:`${a}, ${i_(n,t.value)}.`}})});const a=Hg(n,"Rect");for(const t of e.nodes){const o=e.dims[t.node.column]?.title,r=o?`${o}: ${t.node.label}`:t.node.label;i.push({type:"rect",shapeType:"Rect",key:`alluvial-node-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,index:t.i,paint:Wg(a,t.data,t.i),aria:{label:`${r}, ${i_(n,t.node.value)}.`}})}var s;return i.push(...n_(n,e.nodes,{...a,label:(s=a,(t,e)=>{const n=Tg(s.label,t,e);if(void 0!==n)return n;const i=Dk(t);return"node"===i?.kind?i.node.label:void 0})},e.width,e.height)),i.push(...Kk(e.titles,e.titleStyle,n.schema.locale,Gk(n))),i};function r_(t,e){const[n,i]=t.size<=e.size?[t,e]:[e,t];for(const t of n)if(i.has(t))return!0;return!1}function a_(t,e){const n=Dk(e),i="band"===n?.kind?n.band.paths:"node"===n?.kind?n.node.paths:null;if(!i)return null;const o=new Set;for(const e of t.bands)r_(e.paths,i)&&o.add(e.id);for(const e of t.columns.flat())r_(e.paths,i)&&o.add(e.id);return o}function s_(t){const e=t.schema.on.mouseenter;t.schema.on.mouseenter=function(n,i,...o){const r=t.ctx.alluvial,a=r?a_(r.graph,n):null;if(!a)return e(n,i,...o);Ye(t)&&(t._hoverBucket=!1,t.hover(t=>{const e=function(t){const e=Dk(t);return"band"===e?.kind?e.band.id:"node"===e?.kind?e.node.id:void 0}(t);return void 0!==e&&a.has(e)}))}}function c_(t,e,n){const i=Dk(e),o=t.ctx.alluvial;return"band"===i?.kind?_k(i.band,o?o.dims.length:0):"node"===i?.kind?i.node.label:t._drawLabel(e,n)}function l_(t,e){const n=Dk(e);if("band"!==n?.kind&&"node"!==n?.kind)return[];const i=t.ctx.alluvial,o="band"===n.kind?n.band.value:n.node.value,r=t.schema.translate,a=[];if("node"===n.kind){const e=function(t,e){const n=t.ctx.alluvial;return n?.dims[e.column]?.title??""}(t,n.node);e&&a.push([e,n.node.label])}a.push([Uk(t),i_(t,o)]);const s=i?.graph.total??0;return s>0&&a.push([r("Share"),`${p.formatAbbreviate(o/s*100,t.schema.locale)}%`]),a}function h_(t){return"function"==typeof t?t:"string"==typeof t?G(t):W(t)}const u_={name:"Alluvial",layoutStage:Jk,emit:o_,thresholdFunction:function(t,e){const n=t.schema.groupBy[0];return e.filter((t,e)=>!yk(n(t,e)))},setup:t=>{t.schema.groupBy=[Ek(t)],function(t){const e=Ek(t);t._mergeRows=i=>{const o=n.merge(i,t.schema.aggs),r=t._data.indexOf(i[0]);return Lk(o,{kind:"group",id:e(i[0],r),rows:i})}}(t),s_(t),t.hover=mk},facet:{aspect:1.5},ctx:{},fields:[{key:"bandOpacity",default:.5},{key:"colorBy",default:0},{key:"dimensions",default:[]},{key:"dimensionTitleConfig",merge:!0,default:{}},{key:"nodePadding",default:10},{key:"nodeSort",default:"crossings"},{key:"nodeWidth",default:16},{key:"value",default:Yk,coerce:h_},{key:"shapeConfig",merge:!0,factory:t=>({Rect:{fill:(n,i)=>{const o=Dk(n),r=t.ctx.alluvial;if("node"===o?.kind&&o.node.column!==r?.graph.colorBy)return Z(t._theme,t=>t.link,e.colorGray[500]);const a=t.schema.shapeConfig.fill;return"function"==typeof a?a(n,i):a}}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>c_(t,e,n),tbody:e=>l_(t,e)})}]};var d_=fk(u_);function f_(t,e){const n=t.length-1;if(n<2||e>=1)return t.slice();const[i,o]=t[0],[r,a]=t[n];return t.map(([t,s],c)=>{const l=c/n,h=i+(r-i)*l,u=o+(a-o)*l;return[h+(t-h)*e,u+(s-u)*e]})}function m_(t,e=3){if(t.length<3)return t.slice();const n=t[0],i=t[t.length-1],o=[n,n,...t,i,i],r=[n];for(let t=0;t+3<o.length;t++){const[n,i,a,s]=[o[t],o[t+1],o[t+2],o[t+3]],c=Math.hypot(a[0]-i[0],a[1]-i[1]),l=Math.min(8,Math.max(1,Math.ceil(c/e)));for(let t=1;t<=l;t++){const e=t/l,o=1-e,c=o*o*o/6,h=(3*e*e*e-6*e*e+4)/6,u=(-3*e*e*e+3*e*e+3*e+1)/6,d=e*e*e/6;r.push([c*n[0]+h*i[0]+u*a[0]+d*s[0],c*n[1]+h*i[1]+u*a[1]+d*s[1]])}}return r[r.length-1]=i,r}function p_(t,e){if(t.length<3)return t.slice();const n=new Uint8Array(t.length);n[0]=n[t.length-1]=1;const i=[[0,t.length-1]];for(;i.length;){const[o,r]=i.pop(),[a,s]=t[o],c=t[r][0]-a,l=t[r][1]-s,h=Math.hypot(c,l);let u=-1,d=0;for(let e=o+1;e<r;e++){const[n,i]=t[e],o=h?Math.abs(c*(s-i)-(a-n)*l)/h:Math.hypot(n-a,i-s);o>d&&(d=o,u=e)}u>=0&&d>e&&(n[u]=1,i.push([o,u],[u,r]))}return t.filter((t,e)=>n[e])}function g_(t,e,n){const i=f_(t,e);return p_(n?m_(i):i,.25)}const y_={strength:.85,cycles:6,iterations:50,compatibility:.4,smoothing:!0},x_=t=>Math.hypot(t[1][0]-t[0][0],t[1][1]-t[0][1]),b_=t=>[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2];function k_(t,e){const n=x_(t),i=x_(e);if(!n||!i)return 0;const o=(t[1][0]-t[0][0])*(e[1][0]-e[0][0])+(t[1][1]-t[0][1])*(e[1][1]-e[0][1]);return Math.abs(o/(n*i))}function __(t,e){const n=x_(t),i=x_(e);if(!n||!i)return 0;const o=(n+i)/2;return 2/(o/Math.min(n,i)+Math.max(n,i)/o)}function v_(t,e){const n=(x_(t)+x_(e))/2,[i,o]=b_(t),[r,a]=b_(e),s=Math.hypot(i-r,o-a);return n+s?n/(n+s):0}function w_(t,e){const[[n,i],[o,r]]=t,a=o-n,s=r-i,c=a*a+s*s;if(!c)return 0;const l=([t,e])=>{const o=((t-n)*a+(e-i)*s)/c;return[n+o*a,i+o*s]},h=l(e[0]),u=l(e[1]),d=Math.hypot(u[0]-h[0],u[1]-h[1]);if(!d)return 0;const[f,m]=b_(t),p=Math.hypot((h[0]+u[0])/2-f,(h[1]+u[1])/2-m);return Math.max(0,1-2*p/d)}function M_(t,e){return Math.min(w_(t,e),w_(e,t))}function S_(t){if(t<=0)return 1/0;if(t>=1)return 1;const e=t=>2/((1+t)/2+2*t/(1+t));let n=1,i=2;for(;e(i)>=t;)i*=2;for(let o=0;o<50;o++){const o=(n+i)/2;e(o)>=t?n=o:i=o}return n}function C_(t){let e=1/0,n=-1/0;for(const i of t)i<e&&(e=i),i>n&&(n=i);return e<=n?[e,n]:[0,0]}function $_(t,e,n,i){const o=t.len[e],r=t.len[n],a=t.dx[e]*t.dx[n]+t.dy[e]*t.dy[n];let s=Math.abs(a)/(o*r);if(s<i)return 0;const c=(o+r)/2;if(s*=2/(c/Math.min(o,r)+Math.max(o,r)/c),s<i)return 0;if(s*=c/(c+Math.hypot(t.mx[e]-t.mx[n],t.my[e]-t.my[n])),s<i)return 0;const l=e=>[[t.x0[e],t.y0[e]],[t.x0[e]+t.dx[e],t.y0[e]+t.dy[e]]];return s*=M_(l(e),l(n)),s<i||s<=0?0:a<0?-s:s}function A_(t,e){const n=t.length,i=function(t){const e=t.length,n={x0:new Float64Array(e),y0:new Float64Array(e),dx:new Float64Array(e),dy:new Float64Array(e),len:new Float64Array(e),mx:new Float64Array(e),my:new Float64Array(e)};return t.forEach(([[t,e],[i,o]],r)=>{n.x0[r]=t,n.y0[r]=e,n.dx[r]=i-t,n.dy[r]=o-e,n.len[r]=Math.hypot(i-t,o-e),n.mx[r]=(t+i)/2,n.my[r]=(e+o)/2}),n}(t),o=Math.min(S_(e),1e6),r=e>0?(1-e)/e:1/0,a=Array.from({length:n},()=>[]),s=Array.from({length:n},()=>[]),c=t.map(b_),l=Math.max(1,C_(c.flatMap(t=>[Math.abs(t[0]),Math.abs(t[1])]))[1]),h=t=>Math.min(r*(i.len[t]*(1+o)/2),4*l),u=Array.from(i.len,(t,e)=>h(e)).sort((t,e)=>t-e),d=Math.max(u[n>>1]||l,2*l/256),{cells:f,nx:m,cx:p,cy:g}=function(t,e){const[n,i]=C_(t.map(t=>t[0])),[o,r]=C_(t.map(t=>t[1])),a=Math.max(1,Math.ceil((i-n)/e)+1),s=Math.max(1,Math.ceil((r-o)/e)+1),c=Array.from({length:a*s},()=>[]),l=t=>Math.min(a-1,0|Math.max(0,(t-n)/e)),h=t=>Math.min(s-1,0|Math.max(0,(t-o)/e));return t.forEach((t,e)=>c[h(t[1])*a+l(t[0])].push(e)),{cells:c,nx:a,cx:l,cy:h}}(c,d),y=f.length/m;for(let t=0;t<n&&n>1;t++){if(!i.len[t])continue;const n=h(t);for(let o=g(i.my[t]-n);o<=g(i.my[t]+n)&&o<y;o++)for(let r=p(i.mx[t]-n);r<=p(i.mx[t]+n);r++)for(const n of f[o*m+r]){if(n<=t||!i.len[n])continue;const o=$_(i,t,n,e);o&&(a[t].push(n),s[t].push(o),a[n].push(t),s[n].push(o))}}const x=new Int32Array(n+1);for(let t=0;t<n;t++)x[t+1]=x[t]+a[t].length;return{offsets:x,neighbors:Int32Array.from(a.flat()),weights:Float32Array.from(s.flat())}}function z_(t,e){const n=Math.max(1,Math.round(e)),i=[0];for(let e=1;e<t.length;e++)i.push(i[e-1]+Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]));const o=i[i.length-1],r=[t[0]];let a=1;for(let e=1;e<n;e++){const s=o*e/n;for(;a<t.length-1&&i[a]<s;)a++;const c=i[a]-i[a-1],l=c?(s-i[a-1])/c:0;r.push([t[a-1][0]+(t[a][0]-t[a-1][0])*l,t[a-1][1]+(t[a][1]-t[a-1][1])*l])}return r.push(t[t.length-1]),r}function D_(t,e,n,i){const o=new Float64Array(t.length*i*2);return t.forEach((t,r)=>{const a=[t[0]];for(let t=0;t<n;t++){const i=2*(r*n+t);a.push([e[i],e[i+1]])}a.push(t[1]);const s=z_(a,i+1);for(let t=0;t<i;t++)o[2*(r*i+t)]=s[t+1][0],o[2*(r*i+t)+1]=s[t+1][1]}),o}function L_(t,e,n,i,o,r,a){const{offsets:s,neighbors:c,weights:l}=n;for(let n=0;n<t.length;n++){const h=n*r,u=e[n]?.1*(r+1)/e[n]:0;for(let e=0;e<r;e++){const d=2*(h+e),f=i[d],m=i[d+1],p=e?i[d-2]:t[n][0][0],g=e?i[d-1]:t[n][0][1];let y=u*(p+(e<r-1?i[d+2]:t[n][1][0])-2*f),x=u*(g+(e<r-1?i[d+3]:t[n][1][1])-2*m);for(let t=s[n];t<s[n+1];t++){const n=l[t],o=n<0?r-1-e:e,a=2*(c[t]*r+o),s=i[a]-f,h=i[a+1]-m,u=Math.sqrt(s*s+h*h);if(u<1e-6)continue;const d=Math.abs(n)/u;y+=s*d,x+=h*d}o[d]=f+a*y,o[d+1]=m+a*x}}}function F_(){return{entries:new Map,runs:0}}function N_(t={}){const e=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,n=y_;return{strength:Math.min(1,Math.max(0,e(t.strength,n.strength))),cycles:Math.max(0,e(t.cycles,n.cycles)),iterations:Math.max(0,e(t.iterations,n.iterations)),compatibility:e(t.compatibility,n.compatibility),smoothing:t.smoothing??n.smoothing}}function B_(t,e){const n=t=>Math.round(10*t),i=t.map(([t,e])=>`${n(t[0])},${n(t[1])},${n(e[0])},${n(e[1])}`).join(";");return`${e.cycles}|${e.iterations}|${e.compatibility}|${i}`}function E_(t,e,n){const i=n?B_(t,e):"",o=n?.entries.get(i);if(o)return n.entries.delete(i),n.entries.set(i,o),o;const r=function(t){const[e,n]=C_(t.flatMap(t=>[t[0][0],t[1][0]])),[i,o]=C_(t.flatMap(t=>[t[0][1],t[1][1]])),r=1e3/(Math.max(n-e,o-i)||1);return{to:([t,n])=>[(t-e)*r,(n-i)*r],from:([t,n])=>[t/r+e,n/r+i]}}(t),a=function(t,e){const n=A_(t,e.compatibility),i=Float64Array.from(t.map(x_));let o=1,r=new Float64Array(2*t.length);t.forEach((t,e)=>{const[n,i]=b_(t);r[2*e]=n,r[2*e+1]=i});let a=3,s=Math.max(0,Math.round(e.iterations));const c=Math.max(0,Math.round(e.cycles));for(let e=0;e<c;e++){e&&(r=D_(t,r,o,2*o),o*=2);let c=new Float64Array(r.length);for(let e=0;e<s;e++)L_(t,i,n,r,c,o,a),[r,c]=[c,r];a/=2,s=Math.max(1,Math.round(2*s/3))}return t.map((t,e)=>{const n=[t[0]];for(let t=0;t<o;t++)n.push([r[2*(e*o+t)],r[2*(e*o+t)+1]]);return n.push(t[1]),n})}(t.map(([t,e])=>[r.to(t),r.to(e)]),e).map((e,n)=>{const i=e.map(r.from);return i[0]=t[n][0],i[i.length-1]=t[n][1],i});if(n)for(n.runs++,n.entries.set(i,a);n.entries.size>4;)n.entries.delete(n.entries.keys().next().value);return a}function R_(t,e={},n){if(!t.length)return[];const i=N_(e);return E_(t,i,n).map((e,n)=>x_(t[n])?g_(e,i.strength,i.smoothing):[t[n][0],t[n][1]])}const P_=[["right",1,0],["left",-1,0],["top",0,-1],["bottom",0,1],["top-right",Math.SQRT1_2,-Math.SQRT1_2],["top-left",-Math.SQRT1_2,-Math.SQRT1_2],["bottom-right",Math.SQRT1_2,Math.SQRT1_2],["bottom-left",-Math.SQRT1_2,Math.SQRT1_2]],T_=1e-6;function O_(t,e,n,i,o=0){const r=t.r+o,{x:a,y:s}=t;switch(e){case"right":return{x:a+r,y:s-i/2,width:n,height:i};case"left":return{x:a-r-n,y:s-i/2,width:n,height:i};case"top":return{x:a-n/2,y:s-r-i,width:n,height:i};case"bottom":return{x:a-n/2,y:s+r,width:n,height:i}}const c=r*Math.SQRT1_2;return{x:e.endsWith("right")?a+c:a-c-n,y:e.startsWith("top")?s-c-i:s+c,width:n,height:i}}function W_(t){let e=0;for(let n=0,i=t.length-1;n<t.length;i=n++)e+=t[i][0]*t[n][1]-t[n][0]*t[i][1];return e/2}function j_(t){const e=W_(t);if(Math.abs(e)<T_)return null;let n=0,i=0;for(let e=0,o=t.length-1;e<t.length;o=e++){const r=t[o][0]*t[e][1]-t[e][0]*t[o][1];n+=(t[o][0]+t[e][0])*r,i+=(t[o][1]+t[e][1])*r}return[n/(6*e),i/(6*e)]}function H_(t,e){const n=P_.map(t=>t[0]),i=e?j_(e):null;if(!i||!e)return n;const o=i[0]-t.x,r=i[1]-t.y,a=Math.sqrt(Math.abs(W_(e)));if(Math.hypot(o,r)<.1*a)return n;const s=Math.atan2(r,o),c=([,t,e])=>{let n=Math.abs(Math.atan2(e,t)-s);n>Math.PI&&(n=2*Math.PI-n);return 180*n/Math.PI+(t&&e?20:0)};return P_.map((t,e)=>({side:t[0],score:c(t),i:e})).sort((t,e)=>t.score-e.score||t.i-e.i).map(t=>t.side)}function I_(t,e,n){const i=[];for(let o=0;o<t.length;o++){const r=t[o],a=t[(o+t.length-1)%t.length];e(r)?(e(a)||i.push(n(a,r)),i.push(r)):e(a)&&i.push(n(a,r))}return i}const G_=(t,e,n)=>[n,t[1]+(e[1]-t[1])*(n-t[0])/(e[0]-t[0])],q_=(t,e,n)=>[t[0]+(e[0]-t[0])*(n-t[1])/(e[1]-t[1]),n];function V_(t,e){const n=t.width*t.height;if(!(n>0)||e.length<3)return 0;const i=t.x+t.width,o=t.y+t.height;let r=I_(e,e=>e[0]>=t.x,(e,n)=>G_(e,n,t.x));return r=I_(r,t=>t[0]<=i,(t,e)=>G_(t,e,i)),r=I_(r,e=>e[1]>=t.y,(e,n)=>q_(e,n,t.y)),r=I_(r,t=>t[1]<=o,(t,e)=>q_(t,e,o)),r.length<3?0:Math.min(1,Math.abs(W_(r))/n)}function K_(t,e){const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),i=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return n*n+i*i<e.r*e.r-T_}function Y_(t,e){return t.x<e.x+e.width-T_&&e.x<t.x+t.width-T_&&t.y<e.y+e.height-T_&&e.y<t.y+t.height-T_}function U_(t,e){return t.x>=e.x-T_&&t.y>=e.y-T_&&t.x+t.width<=e.x+e.width+T_&&t.y+t.height<=e.y+e.height+T_}class X_{keys(t){const e=this.size,n=[];for(let i=Math.floor(t.x/e);i<=Math.floor((t.x+t.width)/e);i++)for(let o=Math.floor(t.y/e);o<=Math.floor((t.y+t.height)/e);o++)n.push(`${i},${o}`);return n}add(t,e){for(const n of this.keys(t)){const t=this.cells.get(n);t?t.push(e):this.cells.set(n,[e])}}near(t){const e=new Set;for(const n of this.keys(t))for(const t of this.cells.get(n)??[])e.add(t);return e}constructor(t){this.size=t,this.cells=new Map}}function Q_(t,e,n,i={}){const o=i.gap??3,r=i.cellCoverage??.5,a=e.map(()=>({position:"hidden"})),s=t=>!!t&&[t.x,t.y,t.r].every(Number.isFinite),c=[];if(e.forEach((e,n)=>{s(t[e.circle])&&("inside"===e.position||"outside"!==e.position&&e.fitsInside?a[n]={position:"inside"}:e.width>0&&e.height>0&&c.push(n))}),!c.length)return a;const l=du(t.map((t,e)=>({x:t.x,y:t.y,r:t.r,item:e})),n),h=c.map(t=>Math.max(e[t].width,e[t].height)),u=new X_(Math.max(16,h.reduce((t,e)=>t+e,0)/h.length));t.forEach((t,e)=>{s(t)&&u.add((t=>({x:t.x-t.r,y:t.y-t.r,width:2*t.r,height:2*t.r}))(t),e)});const d=new X_(u.size);c.sort((n,i)=>t[e[i].circle].r-t[e[n].circle].r||n-i);for(const i of c){const s=e[i],c=t[s.circle],h=l.cell(s.circle);if(h&&U_({...c,width:0,height:0},n))for(const e of H_(c,h)){const l=O_(c,e,s.width,s.height,o);if(U_(l,n)&&(![...u.near(l)].some(e=>K_(l,t[e]))&&!([...d.near(l)].some(t=>Y_(l,t))||V_(l,h)<r-T_))){a[i]={position:"outside",side:e,box:l},d.add(l,l);break}}}return a}function Z_(t,e,n=0,i=0){const o=e[0]-t[0],r=e[1]-t[1],a=Math.hypot(o,r),s=Math.atan2(r,o);if(!a)return{x:t[0],y:t[1],angle:s};const c=(n+Math.max(0,a-n-i)/2)/a;return{x:t[0]+o*c,y:t[1]+r*c,angle:s}}function J_(t,e,n,i,o){const r=1-o,a=r*r*r,s=3*r*r*o,c=3*r*o*o,l=o*o*o;return[a*t[0]+s*e[0]+c*n[0]+l*i[0],a*t[1]+s*e[1]+c*n[1]+l*i[1]]}function tv(t,e,n,i,o){const r=1-o,a=3*r*r*(e[0]-t[0])+6*r*o*(n[0]-e[0])+3*o*o*(i[0]-n[0]),s=3*r*r*(e[1]-t[1])+6*r*o*(n[1]-e[1])+3*o*o*(i[1]-n[1]);return a||s?Math.atan2(s,a):Math.atan2(i[1]-t[1],i[0]-t[0])}function ev(t,e,n,i,o=64){const r=[0];let a=t;for(let s=1;s<=o;s++){const c=J_(t,e,n,i,s/o);r.push(r[s-1]+Math.hypot(c[0]-a[0],c[1]-a[1])),a=c}const s=r[o]/2;let c=1;for(;c<o&&r[c]<s;)c++;const l=r[c]-r[c-1],h=(c-1+(l?(s-r[c-1])/l:0))/o,[u,d]=J_(t,e,n,i,h);return{x:u,y:d,angle:tv(t,e,n,i,h)}}function nv(t){let e=180*t/Math.PI;return e=((e+90)%180+180)%180-90,0===e?0:Math.round(1e6*e)/1e6}function iv(t){const e=t.angle*Math.PI/180,n=Math.cos(e),i=Math.sin(e),o=t.width/2,r=t.height/2;return[[-o,-r],[o,-r],[o,r],[-o,r]].map(([e,o])=>[t.x+e*n-o*i,t.y+e*i+o*n])}function ov(t,e){for(const n of[t,e])for(let i=0;i<n.length;i++){const o=n[i],r=n[(i+1)%n.length],a=r[1]-o[1],s=o[0]-r[0],c=t=>{let e=1/0,n=-1/0;for(const[i,o]of t){const t=i*a+o*s;t<e&&(e=t),t>n&&(n=t)}return[e,n]},[l,h]=c(t),[u,d]=c(e),f=1e-9*Math.hypot(a,s);if(h<=u+f||d<=l+f)return!1}return!0}const rv=t=>({x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height});function av(t,e){return t.angle||e.angle?ov(iv(t),iv(e)):Y_(rv(t),rv(e))}function sv(t,e){const n=-t.angle*Math.PI/180,i=e.x-t.x,o=e.y-t.y,r={x:i*Math.cos(n)-o*Math.sin(n),y:i*Math.sin(n)+o*Math.cos(n),r:e.r};return K_(rv({...t,x:0,y:0}),r)}function cv(t,e){return t.angle?ov(iv(t),[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]]):Y_(rv(t),e)}function lv(t,e){const n=e.circles??[],i=e.boxes??[],o=e.labels??[],r=[],a=[];for(const e of t){const t=e.boxes??[e.box];if(!t.length||!t.every(t=>t.width>0&&t.height>0))continue;const s=t=>n.some(e=>sv(t,e))||i.some(e=>cv(t,e))||o.some(e=>av(t,e))||a.some(e=>av(t,e));t.some(s)||(r.push(e),a.push(...t))}return r}function hv(t,e,n){const i="function"==typeof t?t(e,n):t;return!0===i||"target"===i?{source:!1,target:!0}:"source"===i?{source:!0,target:!1}:"both"===i?{source:!0,target:!0}:{source:!1,target:!1}}const uv=t=>Math.round(100*t)/100;function dv(t,e,n,i){const o=.6*i,r=t-Math.cos(n)*i,a=e-Math.sin(n)*i,s=Math.cos(n+Math.PI/2),c=Math.sin(n+Math.PI/2);return`M${uv(t)},${uv(e)}L${uv(r+s*o)},${uv(a+c*o)}L${uv(r-s*o)},${uv(a-c*o)}Z`}function fv(t,e,n,i,o,r=1){const a=Math.atan2(i-e,n-t);return{x:n-Math.cos(a)*(o+r),y:i-Math.sin(a)*(o+r),angle:a}}function mv(t){const e=Number.isFinite(t)?Math.max(0,t):1;return Math.max(6,Math.min(3*e,Math.max(12,1.5*e)))}function pv(t,e,n,i){const o="function"==typeof t?t(e,n):t;return"number"==typeof o?o:mv(i)}function gv(t,e){const n=Number.isFinite(t)?Math.max(0,t):0,i=Number.isFinite(e)?Math.max(0,e):0;return Math.min(n,Math.max(n/2,i/1.2))}function yv(t,e){return 1===e?t:"number"==typeof t?t*e:"function"==typeof t?(n,i)=>{const o=t(n,i);return"number"==typeof o?o*e:o}:t}function xv(t,e){if(1===e)return t;return("number"==typeof t&&t?t:1)*e}function bv(t){const e=t(1);if(!e.arrows.length)return e;const n=t(Sf.hover.width),i=t(Sf.active.width),o=t=>"path"===t?.type?t.d:void 0;return{d:e.d,arrows:e.arrows.map((t,e)=>"path"===t.type?{...t,emphasis:{...t.emphasis,d:{hover:o(n.arrows[e]),active:o(i.arrows[e])}}}:t),emphasis:{d:{hover:n.d,active:i.d}}}}function kv(t){const e=hv(t.arrows,t.datum,t.i),n="number"==typeof t.strokeWidth?t.strokeWidth:1,i=e.source||e.target?pv(t.arrowSize,t.datum,t.i,n):0,o=gv(i,n);return{ends:e,size:i,source:e.source?o:0,target:e.target?o:0}}function _v(t,e,n,i){const o=e[0]-t[0],r=e[1]-t[1],a=Math.hypot(o,r),s=Math.max(0,n),c=Math.max(0,i);if(!a)return[t,e];if(s+c>=a){const e=Math.min(1,s/(s+c||1)),n=[t[0]+o*e,t[1]+r*e];return[n,n]}const l=e=>[t[0]+o*e,t[1]+r*e];return[l(s/a),l(1-c/a)]}function vv([t,e,n,i],o){const r=(t,e)=>[t[0]+(e[0]-t[0])*o,t[1]+(e[1]-t[1])*o],a=r(t,e),s=r(e,n),c=r(n,i),l=r(a,s),h=r(s,c),u=r(l,h);return[[t,a,l,u],[u,h,c,i]]}function wv(t,e,n,i=64){const o=Math.max(0,e),r=Math.max(0,n);if(!o&&!r)return t;const[a,s,c,l]=t,h=[0];let u=a;for(let t=1;t<=i;t++){const e=J_(a,s,c,l,t/i);h.push(h[t-1]+Math.hypot(e[0]-u[0],e[1]-u[1])),u=e}const d=h[i],f=t=>{if(t<=0)return 0;if(t>=d)return 1;let e=1;for(;e<i&&h[e]<t;)e++;const n=h[e]-h[e-1];return(e-1+(n?(t-h[e-1])/n:0))/i};if(o+r>=d){const t=J_(a,s,c,l,f(d*o/(o+r||1)));return[t,t,t,t]}const m=f(o),p=f(d-r),g=p<1?vv(t,p)[0]:t;return m>0?vv(g,m/p)[1]:g}function Mv([t,e,n,i]){return`M${uv(t[0])},${uv(t[1])}C${uv(e[0])},${uv(e[1])} ${uv(n[0])},${uv(n[1])} ${uv(i[0])},${uv(i[1])}`}function Sv(t,e,n){const[i,o]=_v([t.x,t.y],[e.x,e.y],n.source?(t.r??0)+1+n.source:0,n.target?(e.r??0)+1+n.target:0);return`M${i[0]},${i[1]} ${o[0]},${o[1]}`}function Cv(t){const e=hv(t.arrows,t.datum,t.i);if(!e.source&&!e.target)return[];const n=pv(t.arrowSize,t.datum,t.i,"number"==typeof t.strokeWidth?t.strokeWidth:1),{source:i,target:o,datum:r,fill:a,keyPrefix:s}=t,c=[];if(e.target){const t=fv(i.x,i.y,o.x,o.y,o.r??0,1);c.push($v({key:`${s}-t`,datum:r,x:t.x,y:t.y,angle:t.angle,size:n,fill:a}))}if(e.source){const t=fv(o.x,o.y,i.x,i.y,i.r??0,1);c.push($v({key:`${s}-s`,datum:r,x:t.x,y:t.y,angle:t.angle,size:n,fill:a}))}return c}function $v(t){return{type:"path",key:t.key,d:dv(t.x,t.y,t.angle,t.size),emphasis:{fill:!0},datum:t.datum,interactive:!1,paint:{fill:t.fill,...void 0!==t.opacity?{opacity:t.opacity}:{}}}}const Av=(t,e)=>Math.abs(t-e)<=1e-9*e;class zv{get size(){return this.nodes.length}push(t,e){const{nodes:n,keys:i}=this;let o=n.length;for(n.push(t),i.push(e);o>0;){const t=o-1>>1;if(i[t]<=e)break;n[o]=n[t],i[o]=i[t],o=t}n[o]=t,i[o]=e}pop(){const{nodes:t,keys:e}=this,n=t[0];this.key=e[0];const i=t.pop(),o=e.pop(),r=t.length;if(r){let n=0;for(;;){let i=2*n+1;if(i>=r)break;if(i+1<r&&e[i+1]<e[i]&&i++,e[i]>=o)break;t[n]=t[i],e[n]=e[i],n=i}t[n]=i,e[n]=o}return n}constructor(){this.nodes=[],this.keys=[],this.key=0}}function Dv(t,e,n){const{dist:i,sigma:o,order:r}=n,{offsets:a,targets:s}=t;i.fill(1/0),o.fill(0),i[e]=0,o[e]=1,r[0]=e;let c=0,l=1;for(;c<l;){const t=r[c++],e=i[t]+1,n=a[t+1];for(let c=a[t];c<n;c++){const n=s[c];i[n]===1/0&&(i[n]=e,r[l++]=n),i[n]===e&&(o[n]+=o[t])}}n.reached=l}function Lv(t,e,n){const{dist:i,sigma:o,order:r}=n;i.fill(1/0),o.fill(0);const{offsets:a,targets:s,lengths:c}=t,l=n.done;l.fill(0),i[e]=0,o[e]=1;const h=new zv;h.push(e,0);let u=0;for(;h.size;){const t=h.pop(),e=h.key;if(l[t]||e>i[t])continue;l[t]=1,r[u++]=t;const n=a[t+1];for(let r=a[t];r<n;r++){const n=s[r];if(l[n])continue;const a=e+c[r];i[n]!==1/0&&Av(a,i[n])?o[n]+=o[t]:a<i[n]&&(i[n]=a,o[n]=o[t],h.push(n,a))}}n.reached=u}function Fv(t,e,n,i){const{dist:o,sigma:r,delta:a,order:s}=n,{offsets:c,targets:l,lengths:h,unit:u}=t;for(let t=n.reached-1;t>=0;t--){const n=s[t],d=o[n];let f=0;const m=c[n+1];for(let t=c[n];t<m;t++){const e=l[t],n=o[e];(u?n===d+1:n!==1/0&&Av(d+h[t],n))&&(f+=(1+a[e])/r[e])}a[n]=f*r[n],n!==e&&(i[n]+=a[n])}}const Nv=()=>"undefined"!=typeof performance?performance.now():Date.now();function Bv(t,e){const n=new Map;for(const e of t)n.has(e)||n.set(e,n.size);const i=n.size,o=function(t,e){const n=t.size,i=Array.from({length:n},()=>new Map);for(const n of e){const e=t.get(n.source),o=t.get(n.target),r=n.length??1;if(void 0===e||void 0===o||e===o)continue;if(!(r>0&&Number.isFinite(r)))continue;const a=i[e].get(o);(void 0===a||r<a)&&i[e].set(o,r)}const o=new Int32Array(n+1);for(let t=0;t<n;t++)o[t+1]=o[t]+i[t].size;const r=new Int32Array(o[n]),a=new Float64Array(o[n]);let s=!0;return i.forEach((t,e)=>{let n=o[e];for(const[e,i]of t)r[n]=e,a[n++]=i,1!==i&&(s=!1)}),{offsets:o,targets:r,lengths:a,unit:s}}(n,e),r={dist:new Float64Array(i),sigma:new Float64Array(i),delta:new Float64Array(i),order:new Int32Array(i),reached:0,done:new Uint8Array(i)},a=new Float64Array(i),s=new Float64Array(i);let c=0;return{step(t=1/0){const e=Nv();for(;c<i;){o.unit?Dv(o,c,r):Lv(o,c,r);let n=0;for(let t=1;t<r.reached;t++)n+=r.dist[r.order[t]];const l=r.reached-1;if(s[c]=l>0&&n>0?l/n*(l/(i-1)):0,Fv(o,c,r,a),c++,Nv()-e>=t)break}return c>=i},result(){const t=i>2?1/((i-1)*(i-2)):0,e=new Map,o=new Map;for(const[i,r]of n)e.set(i,a[r]*t),o.set(i,s[r]);return{betweenness:e,closeness:o}}}}function Ev(t,e){const n=Bv(t,e);return n.step(),n.result()}const Rv=["degree","betweenness","closeness","cluster"];function Pv(){return[{key:"nodeTooltipStats",default:!0},{key:"nodeTooltipStatsConfig",merge:!0,default:{}}]}function Tv(t){return!0===t?[...Rv]:Array.isArray(t)?[...new Set(t)].filter(t=>Rv.includes(t)):[]}const Ov=t=>void 0!==t&&t>0&&Number.isFinite(t)?t:1;function Wv(t,e,n,i){const o=()=>new Map(t.map(t=>[t,0])),r=o(),a=o(),s=o(),c=(t,e)=>t.set(e,(t.get(e)??0)+1),l=i?e.reduce((t,e)=>Math.max(t,Ov(e.value)),1e-300):1;let h=!1;const u=[];for(const t of e){const e=n?hv(n,t.datum,t.index):{source:!1,target:!1},o=e.target&&!e.source,d=e.source&&!e.target;(o||d)&&(h=!0);const f=i?l/Ov(t.value):1;c(r,t.source),t.target!==t.source&&c(r,t.target),d||(u.push({source:t.source,target:t.target,length:f}),c(s,t.source),c(a,t.target)),o||(u.push({source:t.target,target:t.source,length:f}),c(s,t.target),c(a,t.source))}return{directed:h,degree:r,inDegree:a,outDegree:s,nodes:t,arcs:u}}const jv=new WeakMap;const Hv=t=>{var e,n;return(e=t).key??(e.key=`${(n=t.stats).nodes.join("\0")}|${n.arcs.map(t=>`${t.source}>${t.target}:${t.length}`).join("\0")}`)};function Iv(t,e,n){const i=function(t){return!0===t.ctx.linksDirected||t.schema.arrows}(t),o=function(t){const e=t.schema.nodeTooltipStatsConfig;return!0===e?.weighted}(t),r=jv.get(e);if(r&&r.arrows===i&&r.weighted===o)return r;const a={arrows:i,weighted:o,stats:Wv([...e.byNode.keys()],n(),i,o)};return jv.set(e,a),a}function Gv(t){let e=t.ctx.nodeStatsCache;return e instanceof Map||(t.ctx.nodeStatsCache=e=new Map),e}function qv(t){return!t._ssr&&"undefined"!=typeof window}function Vv(t,e,n){const i=Hv(e),o=Je(t);if(Gv(t).has(i)||o.has(i))return;const r=Bv(e.stats.nodes,e.stats.arcs);o.add(i,{step:e=>!1===t._select?.node()?.isConnected||!!r.step(e)&&(Gv(t).set(i,r.result()),n(),!0)})}const Kv=new WeakMap;function Yv(t,e){const n=new Set;if(function(t){const e=Tv(t.schema.nodeTooltipStats);return e.includes("betweenness")||e.includes("closeness")}(t))for(const i of e){const e=Iv(t,i.graph,i.links);n.add(Hv(e)),Vv(t,e,i.refresh)}Je(t).keep(n);const i=Gv(t);for(const t of[...i.keys()])n.has(t)||i.delete(t)}function Uv(t,e,n,i){if(!qv(t)||void 0===t.schema.nodeTooltipStats)return;let o=Kv.get(t);o||(Kv.set(t,o=[]),queueMicrotask(()=>{const e=Kv.get(t)??[];Kv.delete(t),Je(t).beforeNext(()=>Yv(t,e))})),o.push({graph:e,links:n,refresh:i})}function Xv(t,e,n){const i=Hv(e),o=Gv(t),r=o.get(i);if(r)return r;if(qv(t))return void Vv(t,e,n);const a=Ev(e.stats.nodes,e.stats.arcs);return o.set(i,a),a}function Qv(t,e){const n=t.ctx.clusterState;if(!n?.active)return;const i=n.names.get(e);return n.clusters.some(t=>t.name===i)?i:void 0}function Zv(t,e,n,i,o=()=>{}){const r=Tv(t.schema.nodeTooltipStats);if(!r.length)return{rows:[],degree:!1};const a=e=>`${t.schema.translate(e)}`,s=t.schema.locale;let c;const l=()=>c??(c=Iv(t,e,i)),h=[];for(const e of r)if("degree"===e){const{stats:t}=l();t.directed?(h.push([a("In-degree"),`${t.inDegree.get(n)??0}`]),h.push([a("Out-degree"),`${t.outDegree.get(n)??0}`])):h.push([a("Degree"),`${t.degree.get(n)??0}`])}else if("cluster"===e){const e=Qv(t,n);void 0!==e&&h.push([a("Cluster"),e])}else{const i=Xv(t,l(),o);h.push([a("betweenness"===e?"Betweenness":"Closeness"),i?p.formatAbbreviate(i[e].get(n)??0,s):"…"])}return{rows:h,degree:r.includes("degree")}}const Jv=new WeakMap,tw=new WeakMap;function ew(t){return t&&"object"==typeof t?Jv.get(t):void 0}function nw(t){return void 0!==ew(t)}function iw(t,e,n,i,o=["source","target"]){const r={...t,source:e.data,target:n.data};return Jv.set(r,{index:i,raw:t,source:e,target:n,endKeys:o}),r}function ow(t,e){const n=ew(t),i="number"==typeof e?e:Number(e);return n&&null!==e&&""!==e&&Number.isFinite(i)&&(n.value=i),e}function rw(t,e,n){const i=new Set(e.map(t=>ew(t)?.value)),o=new Map(n.map(t=>[t.id,[]])),r={links:e,sized:i.size>1,byNode:o};for(const t of e){const e=ew(t);e.graph=r;const n=new Set([e.source.id,e.target.id]);for(const e of n)o.has(e)||o.set(e,[]),o.get(e).push(t)}let a=tw.get(t);a||tw.set(t,a=new WeakMap);for(const t of n)t.data&&"object"==typeof t.data&&a.set(t.data,{id:t.id,graph:r});return t.ctx.linkGraph=r,Uv(t,r,()=>_w(r),()=>vw(t)),r}function aw(t){tw.delete(t)}function sw(t,e){if(e&&"object"==typeof e)return tw.get(t)?.get(e)}const cw=new Set(["ar","dv","fa","he","ps","ur","yi"]);function lw(t){const e=`${t??""}`.split(/[-_]/)[0].toLowerCase();return cw.has(e)}function hw(t){return lw(t.schema.locale)||"undefined"!=typeof document&&!!document.body&&r.rtl()?["←","→"]:["→","←"]}function uw(t,e){return void 0!==e.label?e.label:`${t._drawLabel(e.data,e.i)??e.id}`}function dw(t,e){const n=ew(e);if(!n)return"";const[i]=hw(t);return`${uw(t,n.source)} ${i} ${uw(t,n.target)}`}function fw(t,e){const n=t.schema.locale;return"number"==typeof e?Number.isFinite(e)?p.formatAbbreviate(e,n):null:"string"==typeof e?e:"boolean"==typeof e?`${e}`:e instanceof Date&&!isNaN(e.getTime())?e.toLocaleDateString(n):null}function mw(t,e){const n=ew(e);if(!n)return[];const i=[];let o=!1;for(const[e,r]of Object.entries(n.raw)){if(n.endKeys.includes(e)||e.startsWith("__"))continue;const a=fw(t,r);null!==a&&(r===n.value&&(o=!0),i.push([e,a]))}const r=[];return n.graph?.sized&&void 0!==n.value&&!o&&r.push([t.schema.translate("Value"),fw(t,n.value)]),r.concat(i)}function pw(t,e){const n=ew(e);if(!n)return"";const i=n.graph?.sized&&void 0!==n.value?`, ${n.value}`:"";return`${uw(t,n.source)} ${t.schema.translate("to")} ${uw(t,n.target)}${i}.`}function gw(t,e,n){const i=ew(e),o=new Set([i.source.id,i.target.id]);return(e,r)=>{const a=ew(e);if(a)return a.index===i.index;const s=sw(t,e)?.id??n?.(e,r);return void 0!==s&&o.has(`${s}`)}}function yw(t,e,n){const i=(e,n)=>[].concat(t._id(e,n)).map(t=>`${t}`),o=new Set(i(e,n));return(t,e)=>{const n=ew(t);if(n)return o.has(n.source.id)&&o.has(n.target.id);const r=i(t,e);return r.length>0&&r.every(t=>o.has(t))}}function xw(t,e){return(t.byNode.get(e)??[]).map(t=>{const n=ew(t),i=n.source.id===e;return{link:t,other:i?n.target:n.source,outgoing:i,loop:n.source.id===n.target.id,value:n.value,index:n.index}}).sort((t,e)=>(e.value??-1/0)-(t.value??-1/0)||t.index-e.index).map(({link:t,other:e,outgoing:n,loop:i,value:o})=>({link:t,other:e,outgoing:n,loop:i,value:o}))}function bw(t,e,n){const i=sw(t,e);if(!i)return null;const o=xw(i.graph,i.id),r=new Set([i.id,...o.map(t=>t.other.id)]),a=new Set(o.map(t=>ew(t.link).index));return(e,i)=>{const o=ew(e);if(o)return a.has(o.index);const s=sw(t,e)?.id??n?.(e,i);return void 0!==s&&r.has(`${s}`)}}function kw(t,e){const n=t.schema.nodeTooltipLinks;return!1===n?0:!0===n?3:"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.floor(n)):e.sized?3:0}function _w(t){return t.links.map(t=>{const e=ew(t);return{source:e.source.id,target:e.target.id,index:e.index,value:e.value,datum:t}})}function vw(t){const e=t._tooltipClass,n=e?.data();Array.isArray(n)&&n.some(e=>sw(t,e))&&e.render()}function ww(t,e){const n=sw(t,e);if(!n)return[];const{graph:i,id:o}=n,r=xw(i,o),a=Zv(t,i,o,()=>_w(i),()=>vw(t)),s=a.degree?a.rows:[[t.schema.translate("Connections"),`${r.length}`],...a.rows],[c,l]=hw(t);for(const e of r.slice(0,kw(t,i))){const n=i.sized&&void 0!==e.value?fw(t,e.value):"";s.push([`${e.loop?"↻":e.outgoing?c:l} ${uw(t,e.other)}`,n])}return s}function Mw(t){return{title:(e,n)=>nw(e)?dw(t,e):function(t,e,n){const i=t._id?.(e,n);if(!Array.isArray(i)||i.length<2)return;const o=t.schema.color;return"function"==typeof o?Ol(o(e,n)):void 0}(t,e,n)??t._drawLabel(e,"number"==typeof e.i?e.i:n),tbody:e=>nw(e)?mw(t,e):ww(t,e)}}function Sw(t,e,n,i){const o="number"==typeof i?i:1;return{type:"path",key:`${t}::hit`,d:e,datum:n,index:ew(n)?.index??0,paint:{fill:"none",stroke:"transparent",strokeWidth:Math.max(8,o+4)}}}function Cw(t){return!!t&&("source"===t||"target"===t||"function"==typeof t?t:G(t))}function $w(t,e){const n=t.datum??t;return{row:n,index:ew(n)?.index??e}}function Aw(t,n){if(oh(n)){const e=ch(t,n);return"string"==typeof e?e:void 0}if("string"==typeof n&&""!==n)return i.color(n)?n:e.colorAssign(n,Te(t))}function zw(t){const e=t.schema.linkColor;if(!e)return()=>{};if("source"===e||"target"===e){const n=new Map;return(i,o)=>{const r=ew(i)?.[e];if(!r)return;const a=o?.[e]?.shape,s="string"==typeof a?a:"Circle";n.has(s)||n.set(s,Hg(t,s));const c=Tg(n.get(s).fill,r.data,r.i);return"string"==typeof c?c:void 0}}return"function"!=typeof e?()=>{}:n=>{const i=e(n,ew(n)?.index??0);return oh(i)&&rh(t,n,i),Aw(t,i)}}const Dw=t=>r.fontExists(t??s.fontFamily);function Lw(t,e,n){const i=r.parseSides(e.padding??0),o=e.width-i.left-i.right,a=e.height-i.top-i.bottom,c=n.lineHeight??1.2*n.size;if(!t||o<=n.size||a<c)return!1;const l=s.textWrap().fontFamily(Dw(n.family)).fontSize(n.size).fontWeight(n.weight??400).lineHeight(c).shape(e.shape??"square").width(o).height(a)(t);return!l.truncated&&l.lines.some(t=>""!==t)}function Fw(t,e){const n=r.textWidth(t,{"font-family":Dw(e.family),"font-size":e.size,"font-weight":e.weight??400}),i=e.lineHeight??1.2*e.size;return{width:Math.ceil(n)+2,height:Math.ceil(i)+1}}function Nw(t){const e=t.schema.pointLabelConfig??{},n=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,{fontMin:i,fontSize:o,padding:r,...a}=e;return{fontMin:n(i,10),fontSize:n(o,11),padding:n(r,3),text:a}}function Bw(t,e,n){const i=t.schema.labelPosition,o="function"==typeof i?i(e,n):i;return"inside"===o||"outside"===o?o:"auto"}function Ew(t,e,n){const i=Nw(t),o=function(t){const{fontFamily:e,fontWeight:n}=t.text;return{size:t.fontSize,family:e,weight:n}}(i),r=[];e.forEach((t,e)=>{const n=t.text;("string"==typeof n&&n.trim()||"number"==typeof n)&&r.push({item:t,at:e,text:`${n}`.trim()})});const a=r.map(({item:e,at:n,text:r})=>{const a=Bw(t,e.datum,e.index),s=e.inside??{width:2*e.r,height:2*e.r},c="auto"===a&&Lw(r,s,{...s.font,size:i.fontMin}),l="inside"===a||c?{width:0,height:0}:Fw(r,function(t,e){const n=t=>"function"==typeof t?t(e.datum,e.index):t;return{size:t.size,family:n(t.family),weight:n(t.weight)}}(o,e));return{circle:n,...l,position:a,fitsInside:c}}),s=Q_(e.map(({x:t,y:e,r:n})=>({x:t,y:e,r:Number.isFinite(n)?n:0})),a,n,{gap:i.padding}),c=new Map;return r.forEach(({item:t,text:e},n)=>c.set(t.key,{...s[n],mode:a[n].position,text:e})),c}function Rw(t){const e=t.endsWith("right")?"start":t.endsWith("left")?"end":"middle";return"middle"!==e&&r.rtl()?"start"===e?"end":"start":e}function Pw(t,e,n={}){if(!e.length)return[];const i=Nw(t),o=new Map(e.map(t=>[`${t.id}_0`,t])),r=1.2*i.fontSize;return e_({data:e,label:t=>t.text,labelBounds:t=>({...t.box}),x:W(0),y:W(0),aes:W({}),rotate:W(0),id:t=>t.id,datum:t=>t.datum,labelConfig:{fontColor:()=>Oc(t),...n,fontResize:!1,fontSize:i.fontSize,lineHeight:r,padding:0,pointerEvents:"none",textAnchor:t=>Rw((t=>o.get(String(t.id))?.side??"right")(t)),verticalAlign:"middle",...i.text}})}function Tw(t,e){const n=[];for(const[i,o]of t)"outside"===o.position&&n.push({...e(i),text:o.text,side:o.side,box:o.box});return n}function Ow(t,e,n){return e&&"auto"===e.mode&&"inside"===e.position?Math.max(n,Nw(t).fontMin):n}const Ww=t=>Math.round(100*t)/100;function jw(t){return t.map(([t,e],n)=>`${n?"L":"M"}${Ww(t)},${Ww(e)}`).join("")}function Hw(t,e,n){const i=Iw(t),o=Math.max(0,e),r=Math.max(0,n);if(!o&&!r)return t.slice();if(o+r>=i){const e=Gw(t,i*o/(o+r||1));return[[e.x,e.y],[e.x,e.y]]}const a=[];let s=0;const c=Gw(t,o),l=Gw(t,i-r);a.push([c.x,c.y]);for(let e=1;e<t.length-1;e++)s+=Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]),s>o&&s<i-r&&a.push(t[e]);return a.push([l.x,l.y]),a}function Iw(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n][0]-t[n-1][0],t[n][1]-t[n-1][1]);return e}function Gw(t,e){const n=t.length-1;let i=Math.max(0,e);for(let e=1;e<=n;e++){const[o,r]=t[e-1],[a,s]=t[e],c=Math.hypot(a-o,s-r);if(!c)continue;const l=Math.atan2(s-r,a-o);if(i<=c||e===n){const t=Math.min(1,i/c);return{x:o+(a-o)*t,y:r+(s-r)*t,angle:l}}i-=c}const[o,r]=t[0]??[0,0];return{x:o,y:r,angle:0}}function qw(t){return Gw(t,Iw(t)/2)}function Vw(t){const e=t.map(t=>t[0]),n=t.map(t=>t[1]);return[[Math.min(...e),Math.min(...n)],[Math.max(...e),Math.max(...n)]]}function Kw(t,e){if(!t.length||e<=0)return 0;const[n,i]=t[0];let o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=c-a,u=l-s,d=Math.hypot(h,u);if(Math.hypot(c-n,l-i)>=e&&d){const t=a-n,r=s-i,c=h*h+u*u,l=2*(t*h+r*u),f=t*t+r*r-e*e,m=(-l+Math.sqrt(Math.max(0,l*l-4*c*f)))/(2*c);return o+Math.min(1,Math.max(0,m))*d}o+=d}return o}const Yw=.75*Math.PI;function Uw(t){return a.samplePath(t).points.map(([t,e])=>[t,e])}function Xw(t,e=0,n=0){if(t.length<2)return[];const i=Wy(t),o=Kw(t,e),r=i-Kw([...t].reverse(),n);return r>o?Iy(t,o,r):[]}function Qw(t,e){let n=1/0,i=0,o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=c-a,u=l-s,d=h*h+u*u,f=d?Math.max(0,Math.min(1,((e[0]-a)*h+(e[1]-s)*u)/d)):0,m=Math.hypot(a+h*f-e[0],s+u*f-e[1]);m<n&&(n=m,i=o+f*Math.sqrt(d)),o+=Math.sqrt(d)}return i}function Zw(t,e){const n=[],i=[];let o=0,r=null;for(let e=1;e<t.length;e++){const a=t[e][0]-t[e-1][0],s=t[e][1]-t[e-1][1],c=Math.hypot(a,s);if(!c)continue;const l=Math.atan2(s,a);if(null!==r){let t=Math.abs(l-r);t>Math.PI&&(t=2*Math.PI-t),n.push(o),i.push(t)}r=l,o+=c}let a=0,s=0,c=0;for(let t=0;t<i.length;t++){for(s+=i[t];n[t]-n[c]>e;)s-=i[c++];a=Math.max(a,s)}return a}function Jw(t,e,n,i=Yw,o=0){const r=Wy(t);let a=Math.max(0,Math.min(n,r));for(;;){const n=Math.max(a/2,Math.min(r-a/2,e)),s=Iy(t,n-a/2,n+a/2),c=Math.min(o,Wy(s)),l=Rx(s)<=i&&(!o||Zw(s,c)<=(c+2)/o);if(a<1||l)return jy(s);a*=.9}}function tM(t,e,n,i,o,r=2){if(t.length<2)return null;const a=Jw(t,e,n+i+2*o,Yw,r*i);if(a.length<2)return null;if(Rx(a)<=.03)return null;const s=Wy(a);if(s-2*o<Math.min(n,2*i))return null;return{stretch:a,text:Hy(Iy(a,o,s-o),-.3*i)}}function eM(t,e,n){const i=Wy(t.stretch),o=Wy(t.text),r=o?e*Math.max(0,i-2*n)/o:0,a=Math.min(i/2,r/2+n);return Iy(t.stretch,i/2-a,i/2+a)}const nM={rotate:"along",fontSize:10,padding:2,backgroundOpacity:.85,minRadius:2};function iM(t){const e=t.schema.linkLabelConfig??{},n=(t,e)=>"number"==typeof t&&Number.isFinite(t)&&t>=0?t:e,{rotate:i,fontSize:o,padding:r,backgroundOpacity:a,minRadius:s,...c}=e;return{rotate:"horizontal"===i?"horizontal":"along",fontSize:n(o,nM.fontSize)||1,padding:n(r,nM.padding),backgroundOpacity:Math.min(1,n(a,nM.backgroundOpacity)),minRadius:n(s,nM.minRadius),text:c}}function oM(t,e){return"number"==typeof t?Number.isFinite(t)?p.formatAbbreviate(t,e):"":"string"==typeof t&&t.trim()?t:""}function rM(t){const e=[],n=t=>{const i=t.children;if(i&&i.forEach(n),"text"!==t.type)return;const o=t.font?.size??0,r=t.transform??{},[s,c]=r.rotateAnchor??[0,0],l=r.rotate??0,h=l*Math.PI/180,u=Math.cos(h),d=Math.sin(h);if(t.path)for(const n of a.pathTextBoxes(t)){const t=n.x-s,i=n.y-c;e.push({x:(r.x??0)+s+t*u-i*d,y:(r.y??0)+c+t*d+i*u,width:n.width,height:n.height,angle:l+n.angle})}else for(const n of t.lines??[]){if(!n.text||!o)continue;const i=n.width||Fw(n.text,{family:t.font.family,size:o,weight:t.font.weight}).width,h=a.lineLeft({x:n.x,width:i},t.font)+i/2-s,f=n.y-.3*o-c;e.push({x:(r.x??0)+s+h*u-f*d,y:(r.y??0)+c+h*d+f*u,width:i,height:o,angle:l})}};return t.forEach(n),e}function aM(t,e,n){const i=t.schema.linkLabel;if("function"!=typeof i||!e.length)return[];const o=iM(t),r={family:o.text.fontFamily,size:o.fontSize,weight:o.text.fontWeight},a=o.padding,s=[],c=[];e.forEach((e,n)=>{const{row:l,index:h}=$w(e.link,e.i),u=oM(i(l,h),t.schema.locale);if(!u)return;const d=Fw(u,r),f={key:e.key,link:l,text:u,textWidth:d.width,textHeight:d.height,priority:e.priority??0,order:n},m="along"===o.rotate?e.path:null;if(m&&m.length>1){const t=tM(m,e.anchor?Qw(m,[e.anchor.x,e.anchor.y]):Wy(m)/2,d.width,o.fontSize,a,o.minRadius);if(t){const[e,n]=t.stretch[Math.floor(t.stretch.length/2)];return void c.push({base:{...f,box:{x:e,y:n,width:0,height:0,angle:0}},spot:t})}}e.anchor&&s.push({...f,box:{x:e.anchor.x,y:e.anchor.y,width:d.width+2*a,height:d.height+2*a,angle:"horizontal"===o.rotate?0:nv(e.anchor.angle)}})}),s.push(...function(t,e,n){if(!e.length)return[];const i=n.padding,o=Ky(t,e.map(({base:t,spot:e})=>({key:`${t.key}-label`,text:t.text,d:qy(e.text),color:"",anchor:"middle"})),{fontColor:()=>Oc(t),fontWeight:400,...n.text,fontResize:!1,fontSize:n.fontSize,lineHeight:1.2*n.fontSize,pointerEvents:"none"},{halo:!1}),r=new Map(o.map(t=>[String(t.key),t]));return e.flatMap(({base:t,spot:e})=>{const n=r.get(`${t.key}-label`),o="text"===n?.type?n.lines[0]:void 0;if(!n||!o||sM(o.text,t.text))return[];const a=rM([n]).map(t=>({...t,width:t.width+2*i,height:t.height+2*i}));return a.length?[{...t,box:a[Math.floor(a.length/2)],boxes:a,curve:{node:n,pad:eM(e,o.width??0,i)}}]:[]})}(t,c,o)),s.sort((t,e)=>e.priority-t.priority||t.order-e.order);return lv(s,n).map(e=>e.curve?function(t,e,n,i){const o={type:"path",key:`${e.key}-label-pad`,d:qy(n.pad),interactive:!1,paint:{fill:"none",stroke:Tc(t),strokeOpacity:i.backgroundOpacity,strokeWidth:e.textHeight+2*i.padding,strokeLinecap:"butt"}};return{type:"group",key:`${e.key}-label-group`,datum:e.link,interactive:!1,children:[o,n.node]}}(t,e,e.curve,o):function(t,e,n){const{box:i}=e,o={type:"rect",key:`${e.key}-label-pad`,x:-i.width/2,y:-i.height/2,width:i.width,height:i.height,rx:Math.min(i.height/2,3),interactive:!1,paint:{fill:Tc(t),fillOpacity:n.backgroundOpacity}},r=e_({data:[{text:e.text}],label:t=>t.text,labelBounds:()=>({x:-e.textWidth/2,y:-e.textHeight/2,width:e.textWidth,height:e.textHeight}),x:W(0),y:W(0),aes:W({}),rotate:W(0),id:()=>`${e.key}-label`,labelConfig:{fontColor:()=>Oc(t),...n.text,fontResize:!1,fontSize:n.fontSize,lineHeight:1.2*n.fontSize,padding:0,pointerEvents:"none",textAnchor:"middle",verticalAlign:"middle"}}).map(t=>{const{datum:e,...n}=t;return{...n,interactive:!1}});return{type:"group",key:`${e.key}-label-group`,datum:e.link,interactive:!1,transform:i.angle?{x:i.x,y:i.y,rotate:i.angle}:{x:i.x,y:i.y},children:[o,...r]}}(t,e,o))}const sM=(t,e)=>t!==e&&t.replace(/[\s.\u2026]+$/,"").length<3;function cM(){return[{key:"linkColor",default:!1,coerce:Cw},{key:"linkLabel",coerce:Rl},{key:"linkLabelConfig",merge:!0,default:{...nM}}]}function lM(t){return void 0===t?{key:"linkSizeMax"}:{key:"linkSizeMax",default:t}}function hM(){return[{key:"linkBundle",default:!1},{key:"linkBundleConfig",merge:!0,default:{...y_}}]}function uM(t,e){if(!t.length)return[NaN,NaN];let n=Math.max(0,e);for(let e=t.length-1;e>0;e--){const i=t[e],o=t[e-1],r=Math.hypot(i[0]-o[0],i[1]-o[1]);if(r>=n){const t=r?n/r:0;return[i[0]+(o[0]-i[0])*t,i[1]+(o[1]-i[1])*t]}n-=r}return t[0]}function dM(t,e=64){return Array.from({length:e+1},(n,i)=>J_(...t,i/e))}function fM(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function mM(t,e,n){const i=fM(e,t);return{tip:t,angle:i,base:e,cut:[t[0]-Math.cos(i)*n,t[1]-Math.sin(i)*n]}}function pM(t,e,n={source:0,target:0}){const{ends:i,size:o}=e;if(!i.source&&!i.target)return{d:Mv(t)};const r=dM(t),a=wv(t,i.source?n.source+o:0,i.target?n.target+o:0),s=i.target?mM(uM(r,n.target),a[3],e.target):void 0,c=i.source?mM(uM([...r].reverse(),n.source),a[0],e.source):void 0;return{d:kM(Mv(a),c,s),source:c,target:s}}function gM(t){return t.map((t,e)=>{const n=Mv(t);return e?n.replace(/^M[^C]*/,""):n}).join("")}function yM(t,e,n={source:0,target:0}){if(1===t.length)return pM(t[0],e,n);const{ends:i,size:o}=e;if(!i.source&&!i.target)return{d:gM(t)};const r=t[0],a=t[t.length-1],s=t.slice();s[0]=wv(r,i.source?n.source+o:0,0),s[s.length-1]=wv(a,0,i.target?n.target+o:0);const c=i.target?mM(uM(dM(a),n.target),s[s.length-1][3],e.target):void 0,l=i.source?mM(uM([...dM(r)].reverse(),n.source),s[0][0],e.source):void 0;return{d:kM(gM(s),l,c),source:l,target:c}}function xM(t,e,n={source:0,target:0}){const i=((t=>Array.isArray(t[0]?.[0]))(t)?t:[t]).filter(t=>t.length),{ends:o,size:r}=e,a=i[0],s=i[i.length-1],c=(t,e,n)=>mM(uM(t,e),uM(t,e+r),n),l=o.source&&a?c([...a].reverse(),n.source,e.source):void 0,h=o.target&&s?c(s,n.target,e.target):void 0;return{d:kM(i.map((t,e)=>Hw(t,0===e&&l?n.source+r:0,e===i.length-1&&h?n.target+r:0)).map(jw).join(""),l,h),source:l,target:h}}const bM=t=>Math.round(100*t)/100;function kM(t,e,n){const i=t=>`${bM(t[0])},${bM(t[1])}`,o=e?`M${i(e.cut)}L${i(e.base)}${t.replace(/^M[^A-Za-z]*/,"")}`:t;return n?`${o}L${i(n.cut)}`:o}function _M(t){const e=[];for(const n of["target","source"]){const i=t.ends[n];i&&e.push($v({key:t.keys?.[n]??`${t.keyPrefix}-${"target"===n?"t":"s"}`,datum:t.datum,x:i.tip[0],y:i.tip[1],angle:i.angle,size:t.size,fill:t.fill,opacity:t.opacity}))}return e}function vM(t){return!(!t.source||!t.target||t.source!==t.target&&t.source.id!==t.target.id)}function wM(t){if("path"!==t.type)return!1;const e=ew(t.datum);return!!e&&e.source.id===e.target.id}const MM=t=>Number.isFinite(t)?Math.max(0,t):0;function SM(t){return Math.max(1.25*(Number.isFinite(t)?t:0),10)}function CM(t,e=0){return $M(t,e)+MM(e)}function $M(t,e=0){return Math.max(0,t)+MM(e)}function AM(t,e,n,i=0){const o=Math.max(0,t.r||0),r=MM(i)/2,a=$M(n,i),s=Math.cos(e),c=Math.sin(e),l=-c,h=s,u=o>0?Math.min(.5,Math.asin(Math.min(1,.3*a/o))):0,d=o*Math.sin(u),f=o>0?Math.min(1.2,Math.asin(Math.min(1,(d+r)/o))):0,m=o*Math.cos(f),p=o*Math.sin(f),g=(8*(o+a+r)-2*m)/6,y=.8*a+d+1.5*r,x=(e,n)=>[t.x+s*e+l*n,t.y+c*e+h*n];return[x(m,-p),x(g,-y),x(g,y),x(m,p)]}function zM(t,e,n,i=0){const[o,r,a,s]=AM(t,e,Math.max(0,n),i),c=MM(i)/2,l=J_(o,r,a,s,.5),h=(t,e)=>{const n=e[0]-t[0],i=e[1]-t[1],o=Math.hypot(n,i)||1;return{x:e[0]-n/o,y:e[1]-i/o,angle:Math.atan2(i,n)}},u=Array.from({length:25},(t,e)=>J_(o,r,a,s,e/24)),d=u.map(t=>t[0]),f=u.map(t=>t[1]);return{d:Mv([o,r,a,s]),apex:{x:l[0],y:l[1],angle:e+Math.PI/2},source:h(r,o),target:h(a,s),box:[[Math.min(...d)-c,Math.min(...f)-c],[Math.max(...d)+c,Math.max(...f)+c]],angle:e,points:[o,r,a,s]}}const DM={source:1,target:1};function LM(t,e){return e.ends.source||e.ends.target?pM(t.points,e,DM).d:t.d}function FM(t,e,n=0){const i={x:0,y:0,r:t.r},o=MM(n),[r,a,s,c]=AM(i,0,Math.max(0,e),o);let l=0;for(let t=0;t<=24;t++){const[e,n]=J_(r,a,s,c,t/24);l=Math.max(l,Math.abs(Math.atan2(n,e)))}return 2*(l+Math.atan2(o/2,Math.max(0,t.r)+e/2))*1.1}function NM(t,e){const n=e.length;if(!n)return[];const i=e.slice(1).map((t,n)=>(e[n]+t)/2),o=i.reduce((t,e)=>t+e,0),r=o+(e[0]+e[n-1])/2,a=n>1&&r>2*Math.PI?2*Math.PI/r:1;let s=t-o*a/2;return e.map((t,e)=>(e&&(s+=i[e-1]*a),s))}function BM(t){const e=Math.floor((t-1)/2),n=[];for(let i=0;n.length<t;i++){const o=e+(i%2?(i+1)/2:-i/2);o>=0&&o<t&&n.push(o)}return n}function EM(t,e,n){const i=e.filter(e=>e[0]!==t[0]||e[1]!==t[1]).map(e=>Math.atan2(e[1]-t[1],e[0]-t[0])).sort((t,e)=>t-e);if(!i.length)return n;let o=2*Math.PI-(i[i.length-1]-i[0]),r=i[i.length-1];for(let t=1;t<i.length;t++){const e=i[t]-i[t-1];e>o+1e-9&&(o=e,r=i[t-1])}const a=r+o/2;return Math.atan2(Math.sin(a),Math.cos(a))}function RM(t,e,n=-Math.PI/2){const i=t[0]-e[0],o=t[1]-e[1];return i||o?Math.atan2(o,i):n}function PM(t,e){const n=new Map;for(const i of t){const t=e.node(i).id;n.has(t)||n.set(t,[]),n.get(t).push(i)}const i=new Map;for(const t of n.values()){const n=e.node(t[0]);if(![n.x,n.y].every(Number.isFinite))continue;const o=Math.max(...t.map(t=>e.reach(t))),r=t.map((t,n)=>({loop:t,k:n,w:MM(e.strokeWidth?.(t)??0)})).sort((t,e)=>e.w-t.w||t.k-e.k),a=BM(t.length),s=new Array(t.length);r.forEach((t,e)=>s[a[e]]=t);const c=NM(e.angle(n),s.map(({w:t})=>FM(n,o,t)));s.forEach(({loop:t,w:e},r)=>i.set(t,zM(n,c[r],o,e)))}return i}function TM(t,e){return[[Math.min(t[0][0],e[0][0]),Math.min(t[0][1],e[0][1])],[Math.max(t[1][0],e[1][0]),Math.max(t[1][1],e[1][1])]]}function OM(t){const e=kv(t);return e.ends.source||e.ends.target?_M({ends:pM(t.loop.points,e,DM),size:e.size,datum:t.datum,keyPrefix:t.keyPrefix,fill:t.fill}):[]}function WM(t){t.links=function(){return arguments.length?(_n(this,"links",arguments),this):this.schema.links},t.nodes=function(){return arguments.length?(_n(this,"nodes",arguments),this):this.schema.nodes},t.nodeGroupBy=function(t){if(!arguments.length)return this.schema.nodeGroupBy;const e=t instanceof Array?t:[t];return this.schema.nodeGroupBy=e.map(t=>{if("function"==typeof t)return t;const e=t;return this.schema.aggs[e]||(this.schema.aggs[e]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),G(e)}),this},t.size=function(t){return arguments.length?(this._size="function"!=typeof t&&t?G(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size},t.hover=mk}const jM=t=>({data:t.data,i:t.i,id:t.id});function HM(t,e,n){return`${t._id(e,n)||t.schema.nodeGroupBy[d.min([t._drawDepth,t.schema.nodeGroupBy.length-1])](e,n)}`}function IM(t){const e=t.schema.nodes;if(e.length)return e;const n=t._filteredData,i=[...n],o=new Set(n.map((e,n)=>HM(t,e,n)));for(const e of t.schema.links)for(const n of[e.source,e.target]){if("number"==typeof n||null==n)continue;const e="object"==typeof n?n:{id:n},r=HM(t,e,i.length);o.has(r)||(o.add(r),i.push(e))}return i}function GM(t){const e=t._filteredData.reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),n=IM(t).reduce((e,n,i)=>(e[HM(t,n,i)]=n,e),{}),i=t=>"function"==typeof t?t:void 0,o=i(t._x),r=i(t._y);return Array.from(new Set(Object.keys(e).concat(Object.keys(n)))).map((i,a)=>{const s=e[i],c=n[i];if(void 0===c)return!1;const l=(t,e=t=>void 0!==t)=>void 0!==s&&e(t(s))?t(s):t(c),h=t=>!isNaN(t);return{__d3plus__:!0,data:s||c,i:a,id:i,fx:o?l(o,h):void 0,fy:r?l(r,h):void 0,node:c,r:t._size?l(t._size):t.schema.sizeMin,shape:l(t.schema.shape)}}).filter(t=>!!t)}function qM(t,e){const n=e.reduce((t,e)=>(t[e.id]=e,t),{});t.ctx.nodeLookup=n;const i=new Map;for(const t of e)i.set(t.node,t);const o=(e,o)=>"number"===o?i.get(t.schema.nodes[e]):"string"===o?n[e]:n[e.id],r=t.schema.links.map((e,n)=>{const i=typeof e.source,r=o(e.source,i),a=o(e.target,i);if(!r||!a)return{size:t.schema.linkSize(e,n),source:r,target:a};const s=iw(e,jM(r),jM(a),n);return{size:ow(s,t.schema.linkSize(s,n)),source:r,target:a,datum:s}});return t.ctx.linkLookup=r.reduce((t,e)=>e.source&&e.target&&e.source!==e.target?(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e.target),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e.source),t):t,{}),r}function VM(t,e,n){const i=h.zoomTransform((t._zoomEventTarget||t._container).node()),{x:o=0,y:r=0}=t._chartTransform||{};t._zoomToBounds([[(e[0]+o)*i.k+i.x,(n[0]+r)*i.k+i.y],[(e[1]+o)*i.k+i.x,(n[1]+r)*i.k+i.y]])}function KM(){return[{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}}]}function YM(t,e){const n=t.shapeConfig??{},i=t=>(n[t]??{}).fill;return!1!==t.cluster&&!t.colorScale&&!t.colorOrdinal&&t.color===e.color&&n.fill===e.fill&&void 0===i("Circle")&&void 0===i("Rect")&&Array.isArray(t.groupBy)&&1===t.groupBy.length}function UM(t,e){var n,i;const o=u.louvain({nodes:t.map(t=>t.id),links:e.flatMap(t=>t.source&&t.target&&t.source.id!==t.target.id?[{source:t.source.id,target:t.target.id,weight:QM(t.size)}]:[])}),r=[];for(const[t,e]of o)((n=r)[i=e]??(n[i]=[])).push(`${t}`);return r}function XM(t){return t.filter(t=>t.length>1).length>1}const QM=t=>t>0&&Number.isFinite(t)?t:1;function ZM(t,e,n){const i=t.map((t,e)=>({ids:[...t],order:e})).filter(t=>t.ids.length>1),o=t.filter(t=>t.length<2);if(!(n>=1)||i.length<=n)return t;const r=new Map;for(const t of i)for(const e of t.ids)r.set(e,t);const a=(t,e)=>e.ids.length-t.ids.length||t.order-e.order;for(;i.length>n;){const t=i.reduce((t,e)=>a(t,e)<0?e:t),n=new Map;for(const i of e){if(!i.source||!i.target)continue;const e=r.get(i.source.id),o=r.get(i.target.id);if(!e||!o||e===o||e!==t&&o!==t)continue;const a=e===t?o:e;n.set(a,(n.get(a)??0)+QM(i.size))}let o=i.filter(e=>e!==t).sort(a)[0];for(const[t,e]of n){const i=n.get(o)??0;(e>i||e===i&&a(t,o)<0)&&(o=t)}o.ids.push(...t.ids);for(const e of t.ids)r.set(e,o);i.splice(i.indexOf(t),1)}return[...i.sort(a).map(t=>t.ids),...o]}function JM(t,e){const n=new Map,i=new Map;for(const t of e)if(t.source&&t.target&&t.source.id!==t.target.id)for(const e of[t.source.id,t.target.id])n.set(e,(n.get(e)??0)+1),i.set(e,(i.get(e)??0)+(t.size||0));return t.map(t=>t.reduce((t,e)=>(n.get(e)??0)>(n.get(t)??0)||(n.get(e)??0)===(n.get(t)??0)&&(i.get(e)??0)>(i.get(t)??0)?e:t))}function tS(t,e){return t("{node} cluster").replace("{node}",e)}function eS(t,e,i){const o=new Map(i.map(t=>[t.id,t])),r=new Set(e.flatMap(t=>t.ids)),a=t.schema.aggs??{},s=e.map(t=>{const e=t.ids.map(t=>o.get(t).data),i=Object.keys(e[0]).filter(n=>e.every((e,i)=>`${e[n]}`===t.ids[i])),r={...a};for(const t of i)r[t]=(t,e)=>t.map(e);return n.merge(e,r)});return[...s,...i.filter(t=>!r.has(t.id)).map(t=>t.data)]}function nS(t){const n=t.ctx.clusterDefaults,i={active:!1,names:new Map,clusters:[]};if(t.ctx.clusterState=i,!YM(t.schema,n)||!Array.isArray(t.schema.nodes)||!Array.isArray(t.schema.links))return;const{nodes:o,links:r}=function(t){const{nodeLookup:e,linkLookup:n}=t.ctx,i=GM(t),o=qM(t,i);return t.ctx.nodeLookup=e,t.ctx.linkLookup=n,{nodes:i,links:o}}(t),a=(t.schema.clusterConfig??{}).max,s=ZM(function(t,e,n){const i=`${e.map(t=>t.id).join("\0")}|${n.map(t=>`${t.source?.id}>${t.target?.id}:${t.size}`).join("\0")}`,o=t.ctx.clusterCache;if(o&&o.key===i)return o.clusters;const r=UM(e,n);return t.ctx.clusterCache={key:i,clusters:r},r}(t,o,r),r,"number"==typeof a?a:12);if(!XM(s))return;const c=new Map(o.map(t=>[t.id,t])),l=function(t,e,n,i){const o=(t.schema.clusterConfig??{}).label,r=e=>`${t.schema.translate(e)}`;return e.flatMap((e,a)=>{if(e.length<2)return[];const s=i.get(n[a]);return[{index:a,name:"function"==typeof o?`${o(s.data,a,e.map(t=>i.get(t).data))}`:tS(r,`${t._drawLabel(s.data,s.i)}`),ids:e,hub:s.id}]})}(t,s,JM(s,r),c).sort((t,e)=>e.ids.length-t.ids.length||t.name.localeCompare(e.name)),h=new Map;for(const e of o)h.set(e.id,`${t._drawLabel(e.data,e.i)}`);for(const t of l)for(const e of t.ids)h.set(e,t.name);t.ctx.clusterState={active:!0,names:h,clusters:l},t._legendData=eS(t,l,o);const u=Te(t);for(const t of l)e.colorAssign(t.name,u)}function iS(t,e,n){const i=t.ctx.clusterState;if(!i?.active)return;const o=t._id?.(e,n),r=Array.isArray(o)?o:[HM(t,e,n)],a=new Set(r.map(t=>i.names.get(`${t}`)));return 1===a.size?[...a][0]:void 0}function oS(t,e){return(n,i)=>{const o=t.ctx.clusterState;if(!o?.active)return e(n,i);const r=e=>{const n=iS(t,e,0),i=o.clusters.findIndex(t=>t.name===n);return i<0?o.clusters.length:i};return r(n)-r(i)||e(n,i)}}function rS(t){const e=t.schema.color,n=(n,i)=>iS(t,n,i)??e(n,i);t.schema.color=n,t.schema.legendSort=oS(t,t.schema.legendSort),t.ctx.clusterDefaults={color:n,fill:t.schema.shapeConfig.fill};const i=t._preDraw.bind(t);t._preDraw=()=>{i(),nS(t)}}function aS(t){const e=new Map;for(const n of t)e.set(n.source.id,(e.get(n.source.id)??0)+1),e.set(n.target.id,(e.get(n.target.id)??0)+1);return e}function sS(t,e){const n=t=>null==t||""===t;return n(t)||n(e)?n(t)?n(e)?0:1:-1:"number"==typeof t&&"number"==typeof e?t-e:String(t).localeCompare(String(e),void 0,{numeric:!0})}function cS(t,e){const n=(t,e)=>sS(t.label,e.label),i="function"==typeof e?(t,n)=>e(t.datum,n.datum):"label"===e?n:"group"===e?(t,e)=>sS(t.group,e.group)||n(t,e):"degree"===e?(t,e)=>e.degree-t.degree||n(t,e):()=>0;return[...t].sort((t,e)=>i(t,e)||((t,e)=>t.order-e.order)(t,e))}function lS(t,e,n){if(t<=0)return[];const i=n/t;return Array.from({length:t},(t,n)=>e+(n+.5)*i)}function hS(t,e,n){return"below"===n?"below":"both"===n?t<=e?"above":"below":"above"}function uS(t,e,n){const i=(Math.max(0,t)+Math.max(0,e))/2,o=i>0?Math.max(0,Math.min(1,n/i)):1;return{scale:o,above:o*Math.max(0,t)/2,below:o*Math.max(0,e)/2}}const dS=t=>Math.round(100*t)/100;function fS(t,e,n){const i="above"===t.side?1:-1;return"vertical"===t.orient?[t.base+n*i,e]:[e,t.base-n*i]}function mS(t){const e=Math.abs(t.to-t.from)/2,n=e*t.scale,[i,o]=fS(t,t.from,0),[r,a]=fS(t,t.to,0),s=t.to>t.from===("above"===t.side)?1:0,[c,l]="vertical"===t.orient?[n,e]:[e,n];return`M${dS(i)},${dS(o)}A${dS(c)},${dS(l)} 0 0,${s} ${dS(r)},${dS(a)}`}function pS(t){const e=Math.abs(t.to-t.from)/2;return fS(t,(t.from+t.to)/2,e*t.scale)}function gS(t,e,n){const[i,o]="target"===e?[t.to,t.from]:[t.from,t.to],r=Math.abs(i-o)/2,a=r*t.scale,s=(i+o)/2,c=i>=o?1:-1,l=a>0?Math.min(1,Math.max(0,n)/a):0,h=Math.sqrt(1-l*l),[u,d]=fS(t,s+c*r*h,a*l),f=c*r*l,m=-a*h,p="above"===t.side?1:-1,[g,y]="vertical"===t.orient?[m*p,f]:[f,-m*p];return{x:u,y:d,angle:Math.atan2(y,g)}}function yS(t,e,n,i){const[o,r]="target"===e?[t.to,t.from]:[t.from,t.to],a=Math.abs(o-r)/2,s=a*t.scale,c=(o+r)/2,l=o>=r?1:-1;let h=s>0?Math.asin(Math.min(1,Math.max(0,n)/s)):0;const u=Math.PI/2/512;let d=Math.max(0,i);for(;d>0&&h<Math.PI/2;){const t=Math.min(Math.PI/2,h+u),e=(h+t)/2,n=Math.hypot(a*Math.sin(e),s*Math.cos(e))*(t-h);n>=d?(h+=(t-h)*(n?d/n:0),d=0):(d-=n,h=t)}return fS(t,c+l*a*Math.cos(h),s*Math.sin(h))}function xS(t,e,n){const{ends:i,size:o}=e;if(!i.source&&!i.target)return{d:mS(t)};const r=r=>{if(!i[r])return;const a=gS(t,r,n[r]);return mM([a.x,a.y],yS(t,r,n[r],o),e[r])},a=r("source"),s=r("target"),c=Math.abs(t.to-t.from)/2,l=c*t.scale,[h,u]=a?a.base:fS(t,t.from,0),[d,f]=s?s.base:fS(t,t.to,0),m=t.to>t.from===("above"===t.side)?1:0,[p,g]="vertical"===t.orient?[l,c]:[c,l];return{d:kM(`M${dS(h)},${dS(u)}A${dS(p)},${dS(g)} 0 0,${m} ${dS(d)},${dS(f)}`,a,s),source:a,target:s}}function bS(t){const e=[fS(t,t.from,0),fS(t,t.to,0),pS(t)],n=e.map(t=>t[0]),i=e.map(t=>t[1]);return[[Math.min(...n),Math.min(...i)],[Math.max(...n),Math.max(...i)]]}function kS(t){const{cross:e,spans:n,labelSide:i,labelBand:o,rMax:r,strokePad:a}=t,s=t.loops??{above:0,below:0},c=Math.max(0,e-2*a),[l,h]="above"===i?[n.above,n.below]:[n.below,n.above],u=Math.min(uS(h,l,c).scale,uS(h,0,c-o).scale),d=(t,e,n)=>Math.max(u*t/2,e?o:r,n),f=d(n.above,"above"===i,s.above),m=d(n.below,"below"===i,s.below),[p,g]="horizontal"===t.orient?[f,m]:[m,f],y=Math.max(0,(e-p-g-2*a)/2);return{scale:u,base:y+a+p}}const _S=Math.SQRT1_2;function vS(t,e,n,i){const o=t=>e>=t?1:Math.ceil(t/Math.max(e,1e-6));return"vertical"===i?{angle:0,step:o(n)}:t<=e?{angle:0,step:1}:e*_S>=n?{angle:-45,step:1}:{angle:-90,step:o(n)}}function wS(t,e,n,i){return"vertical"===i?{depth:e,spread:n/2}:0===t?{depth:n,spread:e/2}:-90===t?{depth:e,spread:n/2}:{depth:(e+n/2)*_S,spread:(e+n/2)*_S}}function MS(t,e,n,i){return"horizontal"===i&&0===t?1/0:"horizontal"===i&&-45===t?Math.max(0,e/_S-n/2):Math.max(0,e)}function SS(t){const{at:e,base:n,gap:i,width:o,spacing:r,lineHeight:a,angle:s,side:c}=t,l="below"===c?1:-1,h={id:t.id,datum:t.datum,text:t.text,angle:s};if("vertical"===t.orient)return{...h,x:n-l*i,y:e,box:{x:"below"===c?-o:0,y:-a/2,width:o,height:a},anchor:"below"===c?"end":"start",verticalAlign:"middle"};const u=n+l*i;return 0===s?{...h,x:e,y:u,box:{x:-r/2,y:"below"===c?0:-a,width:r,height:a},anchor:"middle",verticalAlign:"below"===c?"top":"bottom"}:{...h,x:e,y:u,box:{x:"below"===c?-o:0,y:-a/2,width:o,height:a},anchor:"below"===c?"end":"start",verticalAlign:"middle"}}function CS(t,e,n=!1){if(!e.length)return[];const i=Nw(t),o=new Map(e.map(t=>[`${t.id}_0`,t])),a=t=>o.get(String(t.id)),s=e_({data:e,label:t=>t.text,labelBounds:t=>({...t.box}),x:t=>t.x,y:t=>t.y,aes:W({}),rotate:t=>t.angle,id:t=>t.id,datum:t=>t.datum,labelConfig:{fontColor:()=>Oc(t),fontResize:!1,fontSize:i.fontSize,lineHeight:1.2*i.fontSize,padding:0,pointerEvents:"none",textAnchor:t=>{return"middle"!==(e=a(t)?.anchor??"middle")&&r.rtl()?"start"===e?"end":"start":e;var e},verticalAlign:t=>a(t)?.verticalAlign??"middle",...i.text}});return n?Vy(s,Tc(t),Math.max(2,Math.round(i.fontSize/4))):s}function $S(t){return"below"===t?"below":"above"}function AS(t,e){return Math.max(SM(t),Math.min(.3*Math.max(0,e),40))}function zS(t,e){return"vertical"===e?"above"===t?0:Math.PI:"above"===t?-Math.PI/2:Math.PI/2}function DS(t,e,n){const{spacing:i,...o}=n,r=new Map(e.map(t=>[t.id,t])),a=t.filter(t=>r.has(t.id)),s=PM(a,{node:t=>r.get(t.id),angle:()=>zS(n.side,n.orient),reach:t=>AS(r.get(t.id).r,i),strokeWidth:t=>t.size});return a.flatMap(t=>{const e=r.get(t.id),i=s.get(t);if(!i)return[];const a="horizontal"===n.orient?e.x:e.y;return[{datum:t.datum,source:e,target:e,size:t.size,index:t.index,arc:{...o,from:a,to:a},d:i.d,loop:i}]})}function LS(t,e,n,i){let o=0;for(const i of t){const t=e.get(i.id)??0;o=Math.max(o,t+CM(AS(t,n),i.size))}return"above"===$S(i)?{above:o,below:0}:{above:0,below:o}}const FS=t=>{const e=`scale${t.charAt(0).toUpperCase()}${t.slice(1)}`;return(E[e]??E.scaleSqrt)()};function NS(t,e){const n="number"==typeof e.sizeMax?e.sizeMax:Math.max(1,Math.min(.45*e.spacing,20));if(!t){const t=Math.min(e.sizeMin,n);return Object.assign(()=>t,{domain:void 0,range:void 0})}const i=d.extent(t);if(void 0===i[0]||i[0]===i[1]){return E.scaleLinear().domain([0,1]).range([n,n])}return FS(e.sizeScale).domain(i).range([Math.min(n/2,e.sizeMin),n])}function BS(t,e){const n=t=>Array.isArray(t)&&t.length>1?t[0]:void 0,i=n(t.schema.groupBy);if(i)return i(e.data,e.i);const o=n(t.schema.nodeGroupBy);if(o)return o(e.node,e.i);const r=t.schema.color;return"function"==typeof r?r(e.data,e.i):void 0}function ES(t,e,n){const i=e.length?n/e.length:n;return NS(t._size?e.map(t=>t.r):null,{sizeMin:t.schema.sizeMin,sizeMax:t.schema.sizeMax,sizeScale:t.schema.sizeScale||"sqrt",spacing:i})}function RS(t,e){const n=Nw(t),i=Math.ceil(1.2*n.fontSize)+1,o={size:n.fontSize,lineHeight:1.2*n.fontSize},r=function(t){return!1!==Hg(t,"Circle").label}(t);return{settings:n,lineHeight:i,widths:e.map(t=>r&&t.label?Fw(t.label,o).width:0)}}function PS(t,e,n,i){const o=function(t,e,n){const i=d.extent(e);if(void 0===i[0]||i[0]===i[1])return e;const o=t.schema.linkSizeMin,r=FS(t.schema.linkSizeScale||"sqrt").domain(i).range([o,Math.max(o,n)]);return e.map(t=>r(t))}(t,[...e,...n].map(t=>t.size),i),r=n.map((t,n)=>({index:t.index,datum:t.datum,size:o[e.length+n],id:t.source.id}));return{allSizes:o,sizes:o.slice(0,e.length),loopItems:r}}function TS(t,e,n){if(!t._size||!Array.isArray(t.schema.nodes))return null;if(!Array.isArray(t._filteredData)||!Array.isArray(t.schema.links))return null;const{nodeLookup:i,linkLookup:o}=t.ctx,r=GM(t);if(t.ctx.nodeLookup=i,t.ctx.linkLookup=o,!r.length)return null;return ES(t,r,"vertical"===t.schema.orient?n:e)}const OS=({viz:t})=>{const e=t,{width:n,height:i}=wt(e);Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]);const o="vertical"===e.schema.orient?"vertical":"horizontal",r=e.schema.arcSide||"above",a="below"===r?"above":"below",{nodes:s,links:c,loops:l}=function(t){const e=GM(t),n=qM(t,e).map((t,e)=>({...t,index:e})).filter(t=>t.source&&t.target),i=aS(n),o=new Map(t.schema.nodes.map((t,e)=>[t,e]));return{nodes:cS(e.map(e=>({...e,datum:e.data,label:`${t._drawLabel(e.data,e.i)??""}`,group:BS(t,e),degree:i.get(e.id)??0,order:o.get(e.node)??e.i})),t.schema.nodeSort),links:n.filter(t=>!vM(t)),loops:n.filter(t=>vM(t))}}(e),h="horizontal"===o?n:i,u="horizontal"===o?i:n,{settings:f,lineHeight:m,widths:p}=RS(e,s),g=function(t,e,n,i,o,r){const a=t.length;let s=0,c=e,l={angle:0,step:1},h=1/0;for(let u=0;u<3;u++){const u=a?c/a:c;if(l=vS(d.max(t)??0,u,n,o),h=MS(l.angle,i,n,o),"horizontal"!==o||-45!==l.angle)break;let f=0;t.forEach((t,e)=>{if(e%l.step)return;const{spread:i}=wS(-45,Math.min(t,h),n,o),s=("below"===r?e+.5:a-e-.5)*u;f=Math.max(f,i-s)}),s="below"===r?f:0,c=e-f}return{start:s,length:c,fit:l,widthCap:h}}(p,h,m,.3*u,o,a),y=lS(s.length,g.start,g.length),x=s.length?g.length/s.length:g.length,b=ES(e,s,g.length);e._sizeLegendFinal=e._size?b:null;const k=s.map(t=>b(t.r)||1),_=d.max(k)??0,v=s.map((t,e)=>({...t,rank:e,at:y[e]})),w=new Map(v.map(t=>[t.id,t])),M=c.map(t=>({index:t.index,datum:t.datum,size:t.size,source:w.get(t.source.id),target:w.get(t.target.id)})),S=function(t,e){let n=0,i=0;const o=t.map(t=>{const o=hS(t.source.rank,t.target.rank,e),r=Math.abs(t.target.at-t.source.at);return"above"===o?n=Math.max(n,r):i=Math.max(i,r),o});return{above:n,below:i,sides:o}}(M,r),C=_+f.padding,{shown:$,depth:A}=function(t,e,n,i){const o=t.map((t,n)=>n%e.fit.step?0:Math.min(t,e.widthCap)),r=d.max(o)??0;return{shown:o,depth:r?wS(e.fit.angle,r,n,i).depth:0}}(p,g,m,o),{allSizes:z,sizes:D,loopItems:L}=PS(e,M,l,d.min(k)??1),F=LS(L,new Map(v.map((t,e)=>[t.id,k[e]])),x,r),{scale:N,base:B}=kS({cross:u,spans:S,labelSide:a,labelBand:A?C+A:_,rMax:_,strokePad:(d.max(z)??1)/2+2,orient:o,loops:F}),E=function(t,e,n,i){return t.map((t,o)=>{const[r,a]="horizontal"===i?[t.at,n]:[n,t.at];return{__d3plus__:!0,data:t.data,i:t.i,id:t.id,fx:r,fy:a,node:t.node,shape:t.shape,x:r,y:a,r:e[o],width:2*e[o],height:2*e[o],rank:t.rank,label:t.label,group:t.group,degree:t.degree}})}(v,k,B,o),R=function(t,e,n,i,o){const r=new Map(e.map(t=>[t.id,t]));return t.map((t,e)=>{const a={...n,from:t.source.at,to:t.target.at,side:i[e]};return{datum:t.datum,source:r.get(t.source.id),target:r.get(t.target.id),size:o[e],index:t.index,arc:a,d:mS(a)}}).sort((t,e)=>Math.abs(e.arc.to-e.arc.from)-Math.abs(t.arc.to-t.arc.from)||t.index-e.index)}(M,E,{base:B,scale:N,orient:o},S.sides,D).concat(DS(L,E,{base:B,scale:N,orient:o,side:$S(r),spacing:x})),P=function(t,e,n,i){return t.flatMap((t,o)=>e[o]&&t.label?[SS({...i,id:`arc-label-${t.id}`,datum:t.data,text:t.label,at:n[o],width:e[o]})]:[])}(E,$,y,{base:B,gap:C,spacing:x,lineHeight:m,angle:g.fit.angle,side:a,orient:o}),T=Hg(e,"Path",e.schema.shapeConfig,"edge");return delete T.on,function(t,e){rw(t,[...e.links].sort((t,e)=>t.index-e.index).map(t=>t.datum),e.nodes.map(jM)),t.ctx.arcCtx=e,t.ctx.nodeLookup=Object.fromEntries(e.nodes.map(t=>[t.id,t]));const n={};for(const t of e.links){var i,o,r,a;t.loop||(((i=n)[o=t.source.id]??(i[o]=[])).push(t.target),((r=n)[a=t.target.id]??(r[a]=[])).push(t.source))}t.ctx.linkLookup=n}(e,{nodes:E,links:R,labels:P,labelHalo:S.sides.includes(a),linkConfig:T}),{shapeData:E}};function WS(t,e,n,i){if("none"===e.paint?.fill)return null;const o=Tg(t.backgroundImage,n,i);if("string"!=typeof o||!o)return null;const r=Hr(e,[],"contain"===Tg(t.backgroundImageFit,n,i)?"contain":"cover");if(!(r&&r.box.width>0&&r.box.height>0))return null;const a=e.paint?.opacity,[s]=Ir([{key:e.key,index:e.index??i??0,datum:e.datum,url:o,box:r.box,clip:r.clip,preserveAspectRatio:r.preserveAspectRatio,opacity:"number"==typeof a?a:void 0,transform:e.transform}],null,0);return s}function jS(t,e,n){if(!t.backgroundImage)return[];const i=[];return e.forEach((e,o)=>{const[r,a]=n(o),s=WS(t,e,r,a);s&&i.push(s)}),i}function HS(t){if(t.loop)return t.loop.apex;const[e,n]=pS(t.arc);return{x:e,y:n,angle:"vertical"===t.arc.orient?Math.PI/2:0}}function IS(t){return t.loop?Uw(t.loop.d):Xw(Uw(mS(t.arc)),t.source.r,t.target.r)}function GS(t,e){return aM(t,e.links.map((t,e)=>({key:qS(t),link:t,i:e,anchor:HS(t),path:IS(t),priority:t.size})),{circles:e.nodes.map(t=>({x:t.x,y:t.y,r:t.r}))})}const qS=t=>`arc-link-${t.source.id}-${t.target.id}-${t.index}`;function VS(t,e,n,i,o=1){const r=e.datum;if(e.loop)return OM({arrows:t.schema.arrows,arrowSize:yv(t.schema.arrowSize,o),strokeWidth:xv(e.size,o),datum:r,i:e.index,keyPrefix:i,fill:n,loop:e.loop});const a=YS(t,e,o);return a.ends.source||a.ends.target?_M({ends:xS(e.arc,a,US(e)),size:a.size,datum:r,keyPrefix:i,fill:n}):[]}function KS(t,e,n=1){const i=YS(t,e,n);return i.source||i.target?e.loop?LM(e.loop,i):xS(e.arc,i,US(e)).d:e.d}const YS=(t,e,n=1)=>kv({arrows:t.schema.arrows,arrowSize:yv(t.schema.arrowSize,n),strokeWidth:xv(e.size,n),datum:e.datum,i:e.index}),US=t=>({source:t.source.r+1,target:t.target.r+1});function XS(t,e,n){const i=function(t,e){return Wg(t,e.data,e.i)}(n,e);void 0===i.vectorEffect&&(i.vectorEffect="non-scaling-stroke");const o=t._size,r=o?`, ${o(e.data,e.i)}`:"",a={datum:e.data,index:e.i,paint:i,aria:{label:`${e.label}${r}.`}};if("Rect"===e.shape){const t=2*e.r;return{type:"rect",key:`arc-node-${e.id}`,x:e.x-e.r,y:e.y-e.r,width:t,height:t,...a}}return{type:"circle",key:`arc-node-${e.id}`,cx:e.x,cy:e.y,r:e.r,...a}}const QS=({viz:t})=>{const e=t.ctx.arcCtx;if(!e)return[];const n=function(t,e){const n=zw(t),i=[],o=[],r=[];for(const a of e.links){const s=a.datum,c=Wg(e.linkConfig,s,a.index);c.fill="none",c.strokeWidth=a.size;const l=n(s,a);l&&(c.stroke=l);const h=qS(a),u="string"==typeof c.stroke?c.stroke:void 0,d=`arc-arrow-${a.source.id}-${a.target.id}-${a.index}`,f=bv(e=>({d:KS(t,a,e),arrows:VS(t,a,u,d,e)}));i.push({type:"path",key:h,d:f.d,...f.emphasis?{emphasis:f.emphasis}:{},datum:s,index:a.index,paint:c,aria:{label:pw(t,s)}}),o.push(Sw(h,a.d,s,a.size)),r.push(...f.arrows)}return[...i,...o,...r,...GS(t,e)]}(t,e),i=[];for(const o of e.nodes){const e=Hg(t,"Rect"===o.shape?"Rect":"Circle"),r=XS(t,o,e);n.push(r);const a=WS(e,r,o.data,o.i);a&&i.push(a)}return n.push(...i,...CS(t,e.labels,e.labelHalo)),n};function ZS(t,e,n){const i=t.ctx.arcCtx;if(!i)return null;const o=(e,n)=>HM(t,e,n);let r,a,s;const c=ew(e);if(c)r=new Set([c.source.id,c.target.id]),s=t=>t.index===c.index,a=i.links.filter(s);else{const c=o(e,n),l=t.ctx.nodeLookup;if(!l||!l[c])return null;s=t=>t.source.id===c||t.target.id===c,a=i.links.filter(s),r=new Set([c,...a.flatMap(t=>[t.source.id,t.target.id])])}const l=new Set(a.map(t=>t.index));return{predicate:(t,e)=>{const n=ew(t);return n?l.has(n.index):r.has(o(t,e))},box:JS(i,r,a)}}function JS(t,e,n){const i=t.nodes.filter(t=>e.has(t.id)).map(t=>[[t.x-t.r,t.y-t.r],[t.x+t.r,t.y+t.r]]).concat(n.map(t=>t.loop?t.loop.box:bS(t.arc)));return[[Math.min(...i.map(t=>t[0][0])),Math.min(...i.map(t=>t[0][1]))],[Math.max(...i.map(t=>t[1][0])),Math.max(...i.map(t=>t[1][1]))]]}const tC=(t,e)=>VM(t,[e[0][0],e[1][0]],[e[0][1],e[1][1]]);function eC(t){const e=t;t.schema.on.mouseenter=()=>{},t.schema.on["mouseenter.legend"]=(n,i)=>{e.hover(yw(t,n,i))},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=ZS(t,i,o);s&&e.hover(s.predicate)},t.schema.on["click.shape"]=(n,i)=>{t._tooltipClass.data([]).render();const o=((t,e,n)=>nw(e)?`link:${ew(e).index}`:HM(t,e,n))(t,n,i);if(void 0!==t._focus&&t._focus===o)return e.active(!1),t._focus=void 0,void t._zoomToBounds(null);const r=ZS(t,n,i);r&&(e.hover(!1),e.active(r.predicate),t._focus=o,tC(t,r.box))},t.schema.on["click.legend"]=(n,i)=>{const o=t.ctx.arcCtx;if(!o)return;const r=t._ids(n,i),a=`legend:${r[r.length-1]}`;if(t._focus===a)return e.active(!1),t._focus=void 0,void t._zoomToBounds(null);const s=(e,n)=>`${t._ids(e,n)[r.length-1]}`,c=t._id(n,i),l=new Set((Array.isArray(c)?c:[r[r.length-1]]).map(String)),h=new Set(o.nodes.filter(t=>l.has(s(t.data,t.i))).map(t=>t.id));if(!h.size)return;const u=o.links.filter(t=>h.has(t.source.id)&&h.has(t.target.id)),d=new Set(u.map(t=>t.index));e.hover(!1),e.active((t,e)=>{const n=ew(t);return n?d.has(n.index):l.has(s(t,e))}),t._focus=a,tC(t,JS(o,h,u))}}function nC(t){const e=t.ctx.arcCtx;if(!e)return null;const n=e=>t.schema.translate(e);return[...e.nodes.map(t=>({...t.data,[n("Connections")]:t.degree})),...[...e.links].sort((t,e)=>t.index-e.index).map(t=>{const{raw:e,endKeys:i}=ew(t.datum),o=Object.fromEntries(Object.entries(e).filter(([t])=>!i.includes(t)));return{[n("From")]:t.source.label,[n("To")]:t.target.label,...o}})]}const iC={name:"ArcDiagram",layoutStage:OS,sizeLegendScale:(t,{width:e,height:n})=>TS(t,e,n),emit:QS,insetRegion:Ay,tableData:nC,setup:t=>{eC(t),WM(t),rS(t);const e=t,n=e._draw.bind(t);e._draw=function(e){const i=n(e),{width:o,height:r}=wt(t);return An(t,{kind:"network",width:o,height:r,duration:Jt(t)}),i}},pointMark:(t,e)=>mu(e)||wM(e),ctx:{},fields:[{key:"arcSide",default:"above"},{key:"arrows",default:!1},{key:"arrowSize"},{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}},...cM(),...Mn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:W(1),coerce:t=>"function"==typeof t?t:W(t)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[H("id")]},{key:"nodes",default:[]},{key:"nodeTooltipLinks"},{key:"nodeTooltipStats",default:!0},{key:"nodeTooltipStatsConfig",merge:!0,default:{}},{key:"nodeSort",default:"data"},{key:"orient",default:"horizontal"},{key:"shape",default:W("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({Path:{fill:"none",label:!1,stroke:()=>Z(t._theme,t=>t.link,"#adb5bd")}})},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"tooltipConfig",merge:!0,factory:t=>Mw(t)}]};var oC=fk(iC);function rC({stackKey:t,fromZero:e}){return function({data:n,x:i,y:o,x2:r,y2:a,buffer:s=10}){const c=r?"x2":"x",l=a?"y2":"y",h="x"===this.schema.discrete?o:i,u=h.domain().slice(),f="x"===this.schema.discrete;let m,p;if(f&&u.reverse(),this.schema.stacked){const e=d.groups(n,e=>t(e,this.schema.discrete)).map(([,t])=>t.map(t=>t[f?l:c]));p=e.map(t=>d.sum(t.filter(t=>t>0))),m=e.map(t=>d.sum(t.filter(t=>t<0)))}else{const t=n.map(t=>t[f?l:c]);p=e?t.filter(t=>t>0):t,m=e?t.filter(t=>t<0):t}let g=h(d.max(p));e&&!(f?g<h(0):g>h(0))||(g+=f?-s:s),g=h.invert(g);let y=h(d.min(m));return e&&!(f?y>h(0):y<h(0))||(y+=f?s:-s),y=h.invert(y),g>u[1]&&(u[1]=g),y<u[0]&&(u[0]=y),f&&u.reverse(),h.domain(u),[i,o]}}var aC=rC({stackKey:(t,e)=>`${t[e]}_${t.group}`,fromZero:!0}),sC=rC({stackKey:(t,e)=>t[e],fromZero:!1});const cC=(t,e,n)=>{if(t.padding)t.padding(.5);else{const i=Array.from(new Set(e.map(t=>+t[n]))).reduce((e,n,i,o)=>{if(!i)return e;const r=o[i-1],a=$o(t,r,n);return!e||a<e?a:e},0),o=t.domain().slice();"y"===n&&o.reverse(),o[0]=Ao(t,+o[0],-i/2),o[1]=Ao(t,+o[1],i/2),"y"===n&&o.reverse(),t.domain(o)}},lC=t=>Math.pow(10,Math.ceil(Math.log10(Math.abs(t))))*Math.pow(-1,t<0?1:0);function hC(t,e,n,i,o,r,a){if(void 0===n||isNaN(o[0])||isNaN(o[1]))return o;if(a&&(o=o.slice().reverse()),o[0]===o[1]){if(o=o.slice(),"log"===e)(o=[(s=o[0],Math.pow(10,Math.floor(Math.log10(Math.abs(s))))*Math.pow(-1,s<0?1:0)),lC(o[0])])[1]<o[0]&&o.reverse();else{const t=Math.abs(parseFloat(o[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));o[0]-=t,o[1]+=t}return t.domain(a?o.slice().reverse():o),a?o.reverse():o}var s;const l=o[0]===o[1]?10:Math.abs(Math.log(o[1]-o[0])/100),h=()=>{let o=t.copy(),s=!1;if("log"===e){let e=t.domain().slice(),n=t.range().slice();if(a&&(e=e.reverse(),n=n.reverse()),s=e[0]*e[1]<0,s){const t=c.scaleLog().domain([1e-6,Math.abs(e[r])]).range([0,1])(Math.abs(e[r?0:1])),i=t/(t+1)*(n[1]-n[0]);e=(0===r?[e[0],1e-6]:[1e-6,e[1]]).map(Math.abs),n=0===r?[n[0],n[0]+i]:[n[0]+i,n[1]]}o=c.scaleLog().domain(e).range(n)}let l=!1;const h=o.range();let u;return u=o("log"===e&&s?Math.abs(n):n),a?0===r?l=u+i>h[r]:1===r&&(l=u-i<h[r]):0===r?l=u-i<h[r]:1===r&&(l=u+i>h[r]),l};if(t.invert&&h()){const s=10;if("log"===e){let e=0;for(;e<10&&h();){const n=(0===r?-1:1)*(o[r]<0?-1:1);o[r]+=o[r]*l*n,t.domain(a?o.slice().reverse():o),e++}}else if(0===r){const e=t.invert(t(n)+(i+s)*(a?1:-1));e<o[r]&&(o[r]=e,t.domain(a?o.slice().reverse():o))}else if(1===r){const e=t.invert(t(n)+(i+s)*(a?-1:1));e>o[r]&&(o[r]=e,t.domain(a?o.slice().reverse():o))}}return a?o.reverse():o}const uC={Bar:aC,Box:sC,Circle:function({data:t,x:e,y:n,x2:i,y2:o,yScale:r,xScale:a,config:s,buffer:c}){e=e.copy(),n=n.copy();const l=i?"x2":"x",h=o?"y2":"y";let u=e.domain().slice(),d=n.domain().slice();return!e.invert&&e.padding&&cC(e,t,this.schema.discrete),!n.invert&&n.padding&&cC(n,t,this.schema.discrete),(e.invert||n.invert)&&t.forEach(t=>{const i=s?.r,o=c||2*("function"==typeof i?i(t.data,t.i):Number(i)||0);e.invert&&(u=hC(e,a??"linear",t[l],o,u,0,!1),u=hC(e,a??"linear",t[l],o,u,1,!1)),n.invert&&(d=hC(n,r??"linear",t[h],o,d,0,!0),d=hC(n,r??"linear",t[h],o,d,1,!0))}),[e,n]},Line:function({data:t,x:e,y:n,x2:i,y2:o}){const r=i?"x2":"x",a=o?"y2":"y",s="x"===this.schema.discrete?n:e,c=s.domain().slice();"x"===this.schema.discrete&&c.reverse();const l=t.map(t=>t["x"===this.schema.discrete?a:r]),h=s.invert(s(d.max(l))+("x"===this.schema.discrete?-10:10));return h>c[1]&&(c[1]=h),"x"===this.schema.discrete&&c.reverse(),s.domain(c),[e,n]},Rect:function({data:t,x:e,y:n,x2:i,y2:o,yScale:r,xScale:a,config:s}){e=e.copy(),n=n.copy();const c=i?"x2":"x",l=o?"y2":"y";let h=e.domain().slice(),u=n.domain().slice();return!e.invert&&e.padding&&cC(e,t,this.schema.discrete),!n.invert&&n.padding&&cC(n,t,this.schema.discrete),(e.invert||n.invert)&&t.forEach(t=>{if(e.invert){const n=(s?.width)(t.data,t.i);h=hC(e,a??"linear",t[c],n,h,0,!1),h=hC(e,a??"linear",t[c],n,h,1,!1)}if(n.invert){const e=(s?.height)(t.data,t.i);u=hC(n,r??"linear",t[l],e,u,0,!0),u=hC(n,r??"linear",t[l],e,u,1,!0)}}),[e,n]}};function dC(t,e,n){const i="x"===t?[e.x,n.bottom]:"x2"===t?[e.x,n.top]:"y"===t?[n.left,e.y]:[n.right,e.y];return[[e.x,e.y],i]}function fC(t,e){return"function"==typeof t?t(e.datum,e.index):t}function mC(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",t}function pC(t,e,n,i){const o=t.schema.axisHoverConfig.guideConfig||{},r=fC(o.strokeDasharray,e);return e.badges.filter(t=>t.guide).map(t=>mC({type:"line",key:`plot-axis-hover-guide-${t.axis}`,points:dC(t.axis,e.point,n),paint:{fill:"none",stroke:fC(o.stroke,e)??i,strokeWidth:fC(o.strokeWidth,e)??1,strokeOpacity:fC(o.strokeOpacity,e)??1,strokeDasharray:Array.isArray(r)?r:Vr(r)}}))}function gC(t,n){const i=t._plotArea;if(!i)return{guides:[],badges:[]};const o=function(t){return{left:t.x,right:t.x+t.width,top:t.y,bottom:t.y+t.height}}(i),a=n.color||Z(t._theme,t=>t.textMuted,e.colorGray[500]);return{guides:pC(t,n,o,a),badges:n.badges.map(i=>function(t,n,i,o,a){const s=t.schema.axisHoverConfig.badgeConfig||{},c=fC(s.fontSize,n)??12,l=fC(s.fontFamily,n)||`${t.schema.fontFamily}`,h=fC(s.fontWeight,n)??400,u=fC(s.padding,n)??4,d=fC(s.fill,n)??a,f=fC(s.fontColor,n)??e.colorContrast(d,t.schema.colorDefaults),m=r.textWidth(i.text,{"font-family":l,"font-size":c,"font-weight":h}),p=function(t,e,n,i){const{width:o,height:r}=n;return"x"===t?{x:e-o/2,y:i.bottom,width:o,height:r}:"x2"===t?{x:e-o/2,y:i.top-r,width:o,height:r}:"y"===t?{x:i.left-o,y:e-r/2,width:o,height:r}:{x:i.right,y:e-r/2,width:o,height:r}}(i.axis,i.at,{width:m+2*u,height:c+2*u},o),g=`plot-axis-hover-badge-${i.axis}`;return mC({type:"group",key:g,children:[mC({type:"rect",key:`${g}-box`,...p,rx:fC(s.rx,n)??0,paint:{fill:d}}),mC({type:"text",key:`${g}-text`,x:0,y:0,transform:{x:p.x+p.width/2,y:p.y+p.height/2},lines:[{text:i.text,x:0,y:0,width:m}],font:{family:l,size:c,weight:h,anchor:"middle",baseline:"middle"},paint:{fill:f}})]})}(t,n,i,o,a))}}function yC(t){const e=`curve${t.charAt(0).toUpperCase()}${t.slice(1)}`,n=R[e];return"function"==typeof n?n:R.curveLinear}function xC(t,e){const n=Hg(t,"Line").curve,i="function"==typeof n?e?n(e,e.i):void 0:n;return"string"==typeof i&&i?i:"linear"}const bC="fill-between",kC=1e5;function _C(){return{fillOpacity:.25}}function vC(t,e){let n=[];!0===t?n=e.length>=2?[[e[0],e[1]]]:[]:Array.isArray(t)&&(n=t.every(Array.isArray)?t:[t]);const i=new Set(e);return n.filter(t=>t.length>=2).map(t=>[`${t[0]}`,`${t[1]}`]).filter(([t,e])=>t!==e&&i.has(t)&&i.has(e))}function wC(t,e,n,i){const o=new Map;e.forEach(t=>o.set(`${t.discrete}`,t));const r=[];return t.forEach(t=>{const e=o.get(`${t.discrete}`);if(!e)return;const a={pos:n(t),a:i(t),b:i(e)};[a.pos,a.a,a.b].every(Number.isFinite)&&r.push(a)}),r}function MC(t,e,n,i){const o=b.area().curve(yC(i));return n?o.x(t=>t.pos).y0(e).y1(t=>t.a):o.y(t=>t.pos).x0(e).x1(t=>t.a),o(t)||""}function SC(t){const{viz:e}=t,n=t.values,i=vC(e.schema.fillBetween,function(t){return Array.from(new Set(t.map(t=>`${t.id}`)))}(n));if(!i.length)return[];const o="x"===(e.schema.discrete||"x"),r=t.shapeConfig.x,a=t.shapeConfig.y,s=o?r:a,c=o?a:r,l=xC(e,n[0]);return i.flatMap(t=>function(t,e,[n,i],o){const r=e.filter(t=>`${t.id}`===n),a=e.filter(t=>`${t.id}`===i),s=wC(r,a,o.pos,o.val);if(s.length<2)return[];const c=CC(e,o.val,o.horizontal?"y":"x"),l=`${bC}-${n}-${i}`,h=[{id:`${l}-${n}`,above:n,below:i,rep:r[0],edge:-c*kC},{id:`${l}-${i}`,above:i,below:n,rep:a[0],edge:c*kC}],u=h.flatMap(t=>{const e={...t.rep.data,above:t.above,below:t.below};return s.map(n=>({__d3plus__:!0,data:e,i:t.rep.i,id:t.id,...n}))}),d=o.horizontal?{x:t=>t.pos,x0:t=>t.pos,x1:null,y:t=>t.a,y0:t=>t.b,y1:t=>t.a}:{y:t=>t.pos,y0:t=>t.pos,y1:null,x:t=>t.a,x0:t=>t.b,x1:t=>t.a},f=Pg("Area").renderMode("compute").data(u).config({...d,curve:o.curve,duration:Jt(t),label:!1,fill:zC(t),strokeWidth:0}).config(function(t){return Hg(t,"Area",{...AC(t),...t.schema.fillBetweenConfig})}(t));f.render();const m=Gg(f);return h.flatMap(t=>{const e=m.filter(e=>e.key===t.id||e.key===`${t.id}-bgimage`);if(!e.some(e=>e.key===t.id))return[];e.forEach(t=>t.interactive=!1);const n=MC(s,t.edge,o.horizontal,o.curve);return[{type:"group",key:`${t.id}::clip`,interactive:!1,clip:{type:"path",d:n},children:e}]})}(e,n,t,{pos:s,val:c,horizontal:o,curve:l}))}function CC(t,e,n){const i=t[0];for(const o of t){const t=Number(o[n])-Number(i[n]),r=e(o)-e(i);if(t&&r)return Math.sign(t)===Math.sign(r)?1:-1}return"y"===n?-1:1}const $C=["texture","textureDefault","backgroundImage","backgroundImageFit"];function AC(t){const e=t.schema.shapeConfig??{},n=e.Area??{},i={};for(const t of $C){const o=void 0!==n[t]?n[t]:e[t];void 0!==o&&(i[t]=o)}return i}function zC(t){return(e,n)=>{const{Line:i,stroke:o}=t.schema.shapeConfig,r=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof r?r(e,n):r}}function DC(){return{fillOpacity:.05,fontSize:12,fontOpacity:.7,lineDasharray:"6 4",strokeDasharray:"4 4",strokeOpacity:.4,strokeWidth:1}}function LC(t,e){return t instanceof Date?+t:u.finite(t)?t:e}function FC(t){const e=new Map;return t.forEach((t,n)=>{e.has(`${t}`)||e.set(`${t}`,n)}),t=>LC(t,e.get(`${t}`)??NaN)}function NC(t){return t.reduce((t,e)=>!t||e.at<t.at?e:t,void 0)}function BC(t,e=!1){const n=FC(t.map(t=>t.value)),i=new Map;t.forEach(t=>{const e=i.get(t.series)??[];e.push({value:t.value,at:n(t.value),forecast:t.forecast}),i.set(t.series,e)});const o=new Map;for(const[t,n]of i){const i=NC(n.filter(t=>t.forecast&&Number.isFinite(t.at)));if(!i)continue;const r=n.filter(t=>t.at<i.at);if(r.length){const e=r.reduce((t,e)=>e.at>t.at?e:t);o.set(t,{value:e.value,next:i.value,at:e.at})}else e&&o.set(t,{value:i.value,next:i.value,at:i.at})}return o}function EC(t,e){const n=t.schema.discrete||"x",i=t.schema.forecast;let o;if("function"==typeof i)o=Boolean(i(e.data,e.i));else{const i=e["x"===n?"y":"x"];o=(t._confidence||[]).some(t=>{const n=t?t(e.data,e.i):void 0;return u.finite(n)&&n!==i})}return{series:`${e.id}`,value:e[n],forecast:o}}function RC(t){let e;const n=[];for(const i of t._trendFits||[])i.samples.forEach((t,o)=>{const r=t[i.axis],a=LC(r,o);t.step?n.push({value:r,at:a}):t.projected||e&&!(a>e.at)||(e={value:r,at:a})});if(!e)return null;const i=NC(n.filter(t=>t.at>e.at));return i?{value:e.value,next:i.value,series:new Map}:null}function PC(t,e){const n=t.schema.forecast;if(!1===n||null===n)return null;const i=function(t,e){const n=t.schema.forecast;if(!1===n||null==n)return null;const i=t.schema.discrete||"x";if(!0===n||"auto"===n||"function"==typeof n){const i=BC(e.map(e=>EC(t,e)),"function"==typeof n),o=NC(Array.from(i.values()));if(!o)return null;const r=new Map(Array.from(i,([t,e])=>[t,e.value]));return{value:o.value,next:o.next,series:r}}const o=("x"===i?t._xTime:t._yTime)?r.date(n):n,a=e.map(t=>t[i]),s=FC([...a,o]),c=s(o),l=NC(a.map(t=>({value:t,at:s(t)})).filter(t=>t.at>c));return l?{value:o,next:l.value}:{value:o}}(t,e);if(void 0!==n&&!0!==n&&"auto"!==n&&"function"!=typeof n)return i;const o=RC(t);if(!i||!o)return i||o;const a=t.schema.discrete||"x",s=FC(e.map(t=>t[a]));return s(o.value)<s(i.value)?{...o,series:i.series}:i}function TC(t,e,i){if(!i){const i=t.map(t=>t[e]);if(i.every(t=>"number"==typeof t))return function(t){let e=!1,i=!1,o=!1;for(const n of t)n!=n?e=!0:0===n&&(Object.is(n,-0)?o=!0:i=!0);if(e||i&&o)return n.unique([...t].sort((t,e)=>t-e));const r=Float64Array.from(t).sort(),a=[];for(let t=0;t<r.length;t++)0!==t&&r[t]===r[t-1]||a.push(r[t]);return a}(i)}return n.unique(t.sort(i??((t,n)=>t[e]-n[e])).map(t=>t[e]),t=>`${t}`)}function OC(t,e){return Boolean(t._discreteExtent)&&t.schema.discrete===e}function WC(t,e){return t._discreteExtent(e.data)}function jC(t,e){const n=e.filter(t=>t.data).map(e=>WC(t,e));return[d.min(n,t=>t[0]),d.max(n,t=>t[1])]}const HC={method:"confidenceConfig",shapes:{Area:"Area",Bar:"Path"},extra:{"":["bandOpacity","capWidth","tooltip"],Bar:["capWidth"]}};const IC=[.15,.6],GC=t=>!!t&&"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype;function qC(t){const[e,n,i]=Array.isArray(t)?t:GC(t)?[t.lower,t.upper,t.label]:[],o=function(t){const e=t=>"function"==typeof t?t:!("string"!=typeof t||!t)&&G(t),n=Array.isArray(t)?[e(t[0]),e(t[1])]:[!1,!1];return!(!n[0]&&!n[1])&&n}([e,n]);if(!o)return null;const r={lower:o[0],upper:o[1]};return"string"!=typeof i&&"number"!=typeof i||(r.label=`${i}`),r}function VC(t){const e=function(t){return Array.isArray(t)&&t.length>0&&t.every(t=>Array.isArray(t)||GC(t))}(t)?t:[t];return e.map(qC).filter(t=>null!==t)}function KC(t){const e=t._confidence;if(!e)return[];const n=t._confidenceBands;return n&&n.length?n:[{lower:e[0],upper:e[1]}]}function YC(t,e,n){return e?KC(t).map((i,o)=>{const r={label:i.label??`${t.schema.translate("Band")} ${o+1}`},a=i.lower?i.lower(e,n):void 0,s=i.upper?i.upper(e,n):void 0;return u.finite(a)&&(r.lower=a),u.finite(s)&&(r.upper=s),r}):[]}function UC(t,e){if(e<=0)return[];if(u.finite(t))return Array.from({length:e},()=>t);const n=Array.isArray(t)&&t.length&&t.every(u.finite)?t:IC;if(1===n.length)return Array.from({length:e},()=>n[0]);const i=k.piecewise(k.interpolateNumber,n);return Array.from({length:e},(t,n)=>i(1===e?1:n/(e-1)))}function XC(t){let e=0;return t.map(t=>{const n=Math.min(1,Math.max(0,t)),i=e>=1?0:Math.max(0,1-(1-n)/(1-e));return e=1-(1-e)*(1-i),+i.toFixed(6)})}function QC(t,e){return null==t||"number"==typeof t&&Number.isNaN(t)?e:t}function ZC(t,e){const n=KC(t).slice(1),i=[];for(const t of n)for(const n of e){const e=n.data,o=n.i;for(const n of[t.lower,t.upper]){const t=n?n(e,o):void 0;u.finite(t)&&i.push(t)}}return i}function JC(t){if(!t.length)return 0;const e=t.slice().sort((t,e)=>t[0]-e[0]);let[n,i]=e[0];for(let t=1;t<=e.length;t++){const o=e[t];if(o&&o[0]<i)o[1]>i&&(i=o[1]);else{if(n<0&&i>0)return-n<=i?n:i;o&&([n,i]=o)}}return 0}function t$(t,e=0){const n=t.map(()=>0);if(t.length<2)return n;const i=t.map((t,e)=>e).sort((e,n)=>t[e].value-t[n].value||e-n),o=2*Math.max(...t.map(t=>t.r))+e,r=[];let a=0;for(const s of i){const{value:i,r:c}=t[s];for(;a<r.length&&t[r[a]].value<i-o;)a++;const l=[];for(let o=a;o<r.length;o++){const a=r[o],s=i-t[a].value,h=c+t[a].r+e;if(s<h){const t=Math.sqrt(h*h-s*s);l.push([n[a]-t,n[a]+t])}}n[s]=JC(l),r.push(s)}return n}function e$(t,e,n=1){let i=0;return t.forEach((t,o)=>{i=Math.max(i,Math.abs(e[o])+t.r*n)}),i}const n$=(t,e)=>1===e?t:t.map(t=>({value:t.value,r:t.r*e}));function i$(t,e,n){let i=1;for(let o=0;o<12;o++){const o=e$(t,t$(n$(t,i),e*i),i);if(o<=n||0===o)break;i*=Math.max(.5,.98*Math.sqrt(n/o))}return i}function o$(t,e){const{padding:n,extent:i,overflow:o}=e,r="shrink"===o&&i>0?Math.min(1,...t.map(t=>i$(t,n,i))):1,a=t.map(t=>{const e=t$(n$(t,r),n*r);return"visible"===o?e:e.map((e,n)=>{const o=Math.max(0,i-t[n].r*r);return Math.max(-o,Math.min(o,e))})});return{offsets:a,scale:r}}const r$=t=>null==t||""===t,a$=t=>"number"==typeof t&&Number.isFinite(t)||t instanceof Date,s$=t=>t.some(a$)&&t.every(t=>r$(t)||a$(t));function c$(t,e){if(!t||!e.length)return null;const n=e.map(t=>t.x),i=e.map(t=>t.y);let o;if("x"===t||"y"===t)o=t;else if("auto"===t){if(!e.every(t=>"Circle"===t.shape))return null;i.every(r$)?o="x":n.every(r$)&&(o="y")}else o=s$(n)?"x":"y";if(!o||!s$("x"===o?n:i))return null;const r="x"===o?"y":"x",a=e.some(t=>!r$(t[r])&&!a$(t[r]));return{axis:o,cross:r,lanes:a}}function l$(t,e){const{cross:n,lanes:i}=e;for(const e of t)e[n]=i&&!r$(e[n])?`${e[n]}`:""}const h$=(t,e)=>!!t._swarm&&t._swarm.cross===e&&!t._swarm.lanes;function u$(t,e){const n=t._swarm,i=t.schema.swarmConfig||{},{axis:o,cross:r}=n,a="x"===o?e.x:e.y,s="x"===r?e.x:e.y,c="x"===r?e.xRange:e.yRange,l=Math.abs(c[c.length-1]-c[0]),h=new Map;n.lanes&&e.lanes.forEach(t=>h.set(`${t}`,s(t,r)));const u=Array.from(h.values()).sort((t,e)=>t-e);let d=u.length>1?1/0:l;for(let t=1;t<u.length;t++)d=Math.min(d,u[t]-u[t-1]);const f=(c[0]+c[c.length-1])/2,m=new Map;e.values.forEach((t,n)=>{const i=`${t[r]}`;m.has(i)||m.set(i,{rows:[],nodes:[]});const s=m.get(i);s.rows.push(t),s.nodes.push({value:a(t[o]),r:Math.max(0,Number(e.r(t,n))||0)})});const p=i.padding??1,g=Array.from(m.values()),y=o$(g.map(t=>t.nodes),{padding:p,extent:Math.max(0,d/2-p/2),overflow:i.overflow??"shrink"}),x=new Map;return g.forEach((t,e)=>{t.rows.forEach((n,i)=>{const a=h.get(`${n[r]}`)??f,s=t.nodes[i].value,c=a+y.offsets[e][i];x.set(n,{x:"x"===o?s:c,y:"x"===o?c:s,r:t.nodes[i].r*y.scale})})}),x}const d$=["x","x2","y","y2"];function f$(t,e){const n=t._plotFacetScales?.padded;if(!n)return e;const i={...e};for(const t of d$){const e=i[t];e&&n[t]&&"function"==typeof e.invert&&(i[t]=e.copy().domain(n[t]))}return i}function m$(t,e,n){if(!dx(t)||!e)return;const i=t=>null!=t,o=e.slice();return"number"==typeof n&&(o[0]>n?o[0]=n:o[1]<n&&(o[1]=n)),{pinned:[i(t[0]),i(t[1])],auto:o}}function p$(t,e,n,i){const o=e.pinned[0]?1:0,r=ar(o?[+e.auto[0],t[1]]:[t[0],+e.auto[1]],n,i);if(!r)return;const a=r[o];if(o?a<=t[0]:a>=t[1])return;const s=t.slice();return s[o]=a,s}const g$=(t,e)=>t[`_${e}Config`]?.rounding??t._plotAxisDefaults?.[e]?.rounding??"outside",y$=({viz:t,plotScales:e,plotConfigScales:n,plotOpenEnds:i})=>{if(!e||!n||!i)return{};const o={...e};for(const e of["x","y"]){const r=i[e],a=n[`${e}ConfigScale`],s=g$(t,e);if(!r||!rr.includes(a)||"none"===s)continue;const c=o[e],l=t=>"y"===e?t.slice().reverse():t,h=p$(l(c.domain().map(Number)),r,s,a);h&&(o[e]=c.copy().domain(l(h)))}return{plotScales:o}},x$=t=>"y"===t[0],b$=t=>t instanceof Date?""+ +t:`${t}`;function k$(t,e,n,i="data"){if(null==n||""===n)return NaN;const{plot:o}=t;if("plot"===i){const t=Number(n);return Number.isFinite(t)?x$(e)?o.y1-t*(o.y1-o.y0):o.x0+t*(o.x1-o.x0):NaN}const a=t.axes[e];if(!a)return NaN;const s=a.time?r.date(n):n;if(!1===s||void 0===s)return NaN;if(a.categories){const t=b$(s);if(!a.categories.some(e=>b$(e)===t))return function(t,e){const n=_$(e),i=t.categories||[];if(!Number.isFinite(n)||!i.length)return NaN;const o=i.map(e=>[_$(e),t.scale(e)]).sort((t,e)=>t[0]-e[0]);if(o.some(([t,e])=>!Number.isFinite(t)||!Number.isFinite(e)))return NaN;for(let t=1;t<o.length;t++){const[e,i]=o[t-1],[r,a]=o[t];if(n>=e&&n<=r)return i+(n-e)/(r-e)*(a-i)}return NaN}(a,s)}const c=a.scale(s);return"number"==typeof c&&Number.isFinite(c)?c:NaN}const _$=t=>t instanceof Date?+t:"number"==typeof t?t:NaN;function v$(t,e){const n=t.axes[e];if(!(n&&n.slots&&n.categories&&n.categories.length))return 0;const i=n.categories.map(t=>n.scale(t)).filter(t=>Number.isFinite(t)).sort((t,e)=>t-e);let o=1/0;for(let t=1;t<i.length;t++){const e=i[t]-i[t-1];e>.5&&e<o&&(o=e)}if(Number.isFinite(o))return o/2;const{plot:r}=t;return(x$(e)?r.y1-r.y0:r.x1-r.x0)/2}function w$(t,e,n,i="data"){const o=k$(t,e,n[0],i),r=k$(t,e,n[1],i);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const a="data"===i?v$(t,e):0;return[Math.min(o,r)-a,Math.max(o,r)+a]}function M$(t,e,n){const i=Math.max(t[0],e),o=Math.min(t[1],n);return o-i>=.5?[i,o]:null}function S$([t,e],n,i=.5){return t>=n.x0-i&&t<=n.x1+i&&e>=n.y0-i&&e<=n.y1+i}function C$(t,e,n="data",i="data"){const o=void 0===e.x&&void 0!==e.x2?"x2":"x",r=void 0===e.y&&void 0!==e.y2?"y2":"y";return[k$(t,o,e[o],n),k$(t,r,e[r],i)]}const $$=new Set(["band","ordinal","point"]);function A$(t,e,n,i){if(!t||!t._d3Scale)return;const o=t.schema.scale,r={scale:e,time:n||"time"===o};return $$.has(o)&&(r.categories=t._d3Scale.domain(),i&&(r.slots=!0)),r}function z$(t,e){const{x:n,y:i,xRange:o,yRange:r,x2Height:a}=e,s=[r[0],r[1]].map(t=>t-a),c={x0:Math.min(o[0],o[1]),y0:Math.min(s[0],s[1]),x1:Math.max(o[0],o[1]),y1:Math.max(s[0],s[1])},l=t.schema.discrete||"x",h=t=>!!e.slots&&t[0]===l,u={x:A$(t._xAxis,t=>n(t),!!t._xTime,h("x")),y:A$(t._yAxis,t=>i(t),!!t._yTime,h("y"))};return e.x2Exists&&(u.x2=A$(t._x2Axis,t=>n(t,"x2"),!!t._x2Time,h("x2"))),e.y2Exists&&(u.y2=A$(t._y2Axis,t=>i(t,"y2"),!!t._y2Time,h("y2"))),{plot:c,axes:u}}const D$=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function L$(t,e){const n=D$(e("fontSize"),12),i=e("fontFamily")??t.schema.fontFamily;return{fontColor:e("fontColor")||Oc(t),fontFamily:"string"==typeof i||Array.isArray(i)?s.fontFamilyStringify(i):"sans-serif",fontSize:n,fontWeight:e("fontWeight")??400,lineHeight:D$(e("lineHeight"),Math.round(1.3*n)),maxWidth:Math.max(1,D$(e("maxWidth"),150))}}function F$(t,e){const n=s.textWrap().fontFamily(e.fontFamily).fontSize(e.fontSize).fontWeight(e.fontWeight).lineHeight(e.lineHeight).width(e.maxWidth).height(Number.MAX_SAFE_INTEGER)(t),i=[],o=[];return n.lines.forEach((t,e)=>{""!==t&&(i.push(t),o.push(n.widths[e]??0))}),{lines:i,widths:o,width:o.length?Math.ceil(Math.max(...o)):0,height:i.length*e.lineHeight,lineHeight:e.lineHeight}}function N$(t,e,n){return{type:"text",key:n.key,interactive:!1,x:0,y:0,transform:{x:n.x,y:n.y},lines:t.lines.map((e,n)=>({text:e,x:0,y:t.lineHeight*(n+.5),width:t.widths[n]})),font:{family:e.fontFamily,size:e.fontSize,weight:e.fontWeight,anchor:n.align,baseline:"middle"},paint:{fill:e.fontColor,opacity:n.opacity??1}}}const B$=new WeakMap;function E$(t,e,n){B$.set(t,{block:e,spots:n})}function R$(t,e){const n="end"===t.align?e.width:"middle"===t.align?e.width/2:0;return{x:t.x-n,y:t.y,width:e.width,height:e.height}}function P$(t,e,n,i){return t.find((t,o)=>{const r=R$(t,e);return(!o||((t,e)=>t.x>=e.x0-.5&&t.y>=e.y0-.5&&t.x+t.width<=e.x1+.5&&t.y+t.height<=e.y1+.5)(r,i))&&!n.some(t=>((t,e)=>t.x<e.x+e.width-.5&&e.x<t.x+t.width-.5&&t.y<e.y+e.height-.5&&e.y<t.y+t.height-.5)(r,t))})??null}function T$(t,e){const n=Math.floor(Math.abs(e-t)/6),i=e<t?-1:1,o=Array.from({length:n+1},(e,n)=>t+i*n*6);return o[o.length-1]!==e&&o.push(e),o}function O$(t,e,n){const i=[...e],o=t=>t.flatMap(t=>{if("group"===t.type)return[{...t,children:o(t.children)}];const e=B$.get(t);if(!e||"text"!==t.type)return[t];const r=P$(e.spots,e.block,i,n);if(!r)return[];i.push(R$(r,e.block));return[{...t,transform:{...t.transform,x:r.x,y:r.y},font:{...t.font,anchor:r.align}}]});return o(t)}const W$="ReferenceLine",j$="ReferenceBand",H$=["x","y","x2","y2"],I$=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function G$(t){return(Array.isArray(t)?t:t?[t]:[]).filter(t=>!!t&&"object"==typeof t)}function q$(t){return G$(t).map(t=>({layer:"back",...t,shape:W$}))}function V$(t){return G$(t).map(t=>({layer:"back",...t,shape:j$}))}function K$(t){return H$.find(e=>void 0!==t[e]&&null!==t[e])??null}const Y$=(t,e)=>x$(e)?[t.plot.y0,t.plot.y1]:[t.plot.x0,t.plot.x1];function U$(t,e){const n=K$(e);if(!n)return null;const i=k$(t,n,e[n],e.ref),[o,r]=Y$(t,n);if(!Number.isFinite(i)||i<o-.5||i>r+.5)return null;const{plot:a}=t;return{axis:n,at:i,points:x$(n)?[[a.x0,i],[a.x1,i]]:[[i,a.y1],[i,a.y0]]}}function X$(t,e){const n=K$(e),i=n?e[n]:void 0;if(!n||!Array.isArray(i)||i.length<2)return null;const o=w$(t,n,[i[0],i[1]],e.ref),[r,a]=Y$(t,n),s=o&&M$(o,r,a);if(!s)return null;const{plot:c}=t;return{axis:n,box:x$(n)?{x:c.x0,y:s[0],width:c.x1-c.x0,height:s[1]-s[0]}:{x:s[0],y:c.y0,width:s[1]-s[0],height:c.y1-c.y0}}}function Q$(t,e,n,i="end"){const{plot:o}=t;if(x$(e.axis)){const t=e.at-4-n.height;return{x:"start"===i?o.x0+4:o.x1-4,y:t>=o.y0?t:e.at+4,align:"start"===i?"start":"end"}}const r=e.at+4+n.width<=o.x1;return{x:r?e.at+4:e.at-4,y:"start"===i?o.y1-4-n.height:o.y0+4,align:r?"start":"end"}}const Z$=(t,e)=>t.flatMap(t=>e.map(e=>[t,e]));function J$(t,e,n,i="end"){const{plot:o}=t,r=Q$(t,e,n,i),a="start"===i?"end":"start";if(x$(e.axis)){const t=[r.y,r.y===e.at+4?e.at-4-n.height:e.at+4],i=[[r.x,r.align],"start"===a?[o.x0+4,"start"]:[o.x1-4,"end"]],s=T$("end"===r.align?o.x1-4-n.width:o.x0+4,"end"===r.align?o.x0+4:o.x1-4-n.width);return[...Z$(i,t).map(([[t,e],n])=>({x:t,y:n,align:e})),...Z$(s,t).map(([t,e])=>({x:t,y:e,align:"start"}))]}const s=[[r.x,r.align],"start"===r.align?[e.at-4,"end"]:[e.at+4,"start"]],c=o.y0+4,l=o.y1-4-n.height,h=[r.y,r.y===c?l:c],u=T$(r.y,r.y===c?l:c);return Z$([...h,...u],s).map(([t,[e,n]])=>({x:e,y:t,align:n}))}function tA(t,e,n,i="start"){const o=[t.x+4,"start"],r=[t.x+t.width-4,"end"],a="end"===i?[r,o]:[o,r],s=t.y+4,c=t.y+t.height-4-n.height,l=Z$([s,c],a).map(([t,[e,n]])=>({x:e,y:t,align:n}));if(x$(e)){const[[t],[e]]=a,o="end"===i?t-n.width:t,r="end"===i?e:e-n.width;return[...l,...Z$(T$(o,r),[s,c]).map(([t,e])=>({x:t,y:e,align:"start"}))]}return[...l,...Z$(T$(s,c),a).map(([t,[e,n]])=>({x:e,y:t,align:n}))]}function eA(t,e,n,i){const o=e.label;if(null==o||!1===o||""===o)return null;const r=L$(t,t=>e[t]),a=F$(`${o}`,r);if(!a.lines.length)return null;const s=i(a),c=N$(a,r,{key:n,...s[0]});return E$(c,a,s),c}function nA(t,e,n,i){const o=U$(n,e);if(!o)return[];const r=L$(t,t=>e[t]),a={fill:"none",stroke:e.stroke||r.fontColor,strokeWidth:I$(e.strokeWidth,1),strokeOpacity:I$(e.strokeOpacity,.6)},s=function(t){const e=t.dash??t.strokeDasharray;return!0===e?[4,4]:!1!==e?Vr(e):void 0}(e);s&&(a.strokeDasharray=s);const c=[{type:"line",key:`${i}-line`,interactive:!1,points:o.points,curve:"linear",paint:a}],l=eA(t,e,`${i}-label`,t=>J$(n,o,t,"start"===e.labelPosition?"start":"end"));return l&&c.push(l),c}function iA(t,e,n,i){const o=X$(n,e);if(!o)return[];const r=L$(t,t=>e[t]),a={fill:e.fill||r.fontColor,fillOpacity:I$(e.fillOpacity,.08)};e.stroke&&(a.stroke=e.stroke,a.strokeWidth=I$(e.strokeWidth,1),a.strokeOpacity=I$(e.strokeOpacity,.4));const s=[{type:"rect",key:`${i}-band`,interactive:!1,...o.box,paint:a}],c=eA(t,e,`${i}-label`,t=>tA(o.box,o.axis,t,"end"===e.labelPosition?"end":"start"));return c&&s.push(c),s}function oA(t){const e={x:[],y:[],x2:[],y2:[]};return t.forEach(t=>{if(t.shape!==W$&&t.shape!==j$)return;if("plot"===t.ref)return;const n=K$(t);if(!n)return;const i=t[n];t.shape===j$?Array.isArray(i)&&e[n].push(i[0],i[1]):e[n].push(i)}),e}function rA(t,e){if(null==t||""===t)return NaN;if(e){const e=t instanceof Date?t:r.date(t);return e instanceof Date?+e:NaN}return"number"==typeof t||"string"==typeof t?Number(t):NaN}function aA(t,e,n={}){const{time:i=!1,log:o=!1,open:r=[!0,!0]}=n;if(!t||2!==t.length||!e.length)return t;const a=t.map(t=>rA(t,i));if(!a.every(Number.isFinite))return t;const s=e.map(t=>rA(t,i)).filter(t=>Number.isFinite(t)&&(!o||t>0));if(!s.length)return t;const c=a[0]<=a[1],[l,h]=c?[0,1]:[1,0],u=Math.min(...s),d=Math.max(...s),f=t.slice();let m=!1;return r[l]&&u<a[l]&&(f[l]=i?new Date(u):u,m=!0),r[h]&&d>a[h]&&(f[h]=i?new Date(d):d,m=!0),m?f:t}function sA(t){if(!Array.isArray(t))return[!0,!0];const e=t=>null==t;return[e(t[0]),t.length<2||e(t[1])]}const cA=new Set(["Linear","Time"]);function lA(t,e,n,i){const o=oA([...V$(t.schema.referenceBands),...q$(t.schema.referenceLines),...t._annotations||[]]),r={...e};return["x","y","x2","y2"].forEach(a=>{const s=e[a];if(!s||!o[a].length)return;if(!cA.has(n[a].type))return;const c=t[`_${a}Config`]?.domain,l=1===a.length?i[a]??c:t.schema[`${a}Domain`]??c;r[a]=aA(s,o[a],{time:"Time"===n[a].type,log:"log"===n[a].config,open:sA(l)})}),r}const hA=E;function uA(t,e){return e?t.map(t=>void 0===t?t:r.date(t)):t.slice()}function dA(t,e,n,i){const o=t[`_${e}Time`]?"Time":!OC(t,e)&&(t.schema.discrete===e||t.schema[`${e}Sort`])||t._swarm?.cross===e?"Point":"Linear",r=n[e]?uA(n[e],t[`_${e}Time`]):i[e],a=t.schema[`${e}2Domain`]?uA(t.schema[`${e}2Domain`],t[`_${e}2Time`]):i[`${e}2`];return"Point"!==o&&(r&&void 0===r[0]&&(r[0]=i[e][0]),r&&void 0===r[1]&&(r[1]=i[e][1]),a&&void 0===a[0]&&(a[0]=i[`${e}2`][0]),a&&void 0===a[1]&&(a[1]=i[`${e}2`][1])),[r,o,a,o]}function fA(t,e,n,i){const o=t[`_${n}Config`].scale;if("auto"===o){if(t.schema.discrete===n)return i;const o=e.map(t=>t[n]);return d.deviation(o)/d.mean(o)>3?"log":"linear"}return o||i}const mA=(t,e)=>t.map(t=>t[e]).filter(t=>![NaN,void 0,!1].includes(t));const pA=({viz:t,plotFormattedData:e,plotAxisData:n,plotInitialDomains:i})=>{const o=e||[],r=n||[];let a=i;const s=t.schema.width-t._margin.left-t._margin.right,c=t.schema.height-t._margin.top-t._margin.bottom,l=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,h=t.schema.discrete?"x"===t.schema.discrete?"y2":"x2":void 0,u=[l,h].filter(t=>t),f={x:vx(t,"x",a.x),y:vx(t,"y",a.y)},m={x:m$(f.x,a.x,u.includes("x")?t.schema.baseline:void 0),y:m$(f.y,a.y,u.includes("y")?t.schema.baseline:void 0)},[p,g,y,x]=dA(t,"x",f,a),[b,k,_,v]=dA(t,"y",f,a),w=fA(t,r,"y",k).toLowerCase(),M=fA(t,r,"y2",v).toLowerCase(),S=fA(t,r,"x",g).toLowerCase(),C=fA(t,r,"x2",x).toLowerCase(),$=lA(t,{x:p,y:b,x2:y,y2:_},{x:{type:g,config:S},y:{type:k,config:w},x2:{type:x,config:C},y2:{type:v,config:M}},f);a={x:$.x,x2:$.x2||$.x.slice(),y:$.y,y2:$.y2||$.y.slice()},function(t,e,n,i){Object.keys(e).forEach(o=>{"log"===t[`_${o}ConfigScale`]&&e[o].includes(0)&&(d.min(e[o])<0?e[o][1]=d.max(mA(n,o)):e[o][0]=d.min(mA(i,o)))})}(t,a,o,r),function(t,e,n,i,o){n.forEach(n=>{if(t[`_${n}Config`].domain&&!fx(t,n)){const i=t[`_${n}Config`].domain.slice();"x"===t.schema.discrete&&i.reverse(),e[n]=i}else if(n&&void 0!==t.schema.baseline&&!Sx(t,n,n.startsWith("x")?i.x:i.y,o[n])){const i=t.schema.baseline;e[n]&&e[n][0]>i?e[n][0]=i:e[n]&&e[n][1]<i&&(e[n][1]=i)}})}(t,a,u,{x:S,y:w},f);const A=(e,n,i,o)=>function(t,e,n,i,o){return ng(t,e,hA[`scale${n}`]().domain(i).range(d.range(0,o+1,o/(i.length-1))))}(t,e,n,i,o),z=A("x",g,a.x,s),D=A("x2",x,a.x2,s),L=A("y",k,a.y.slice().reverse(),c),F=A("y2",v,a.y2.slice().reverse(),c);return{plotDomains:a,plotScales:{x:z,y:L,x2:D,y2:F,xScale:g,yScale:k,x2Scale:x,y2Scale:v},plotConfigScales:{xConfigScale:S,yConfigScale:w,x2ConfigScale:C,y2ConfigScale:M},plotOpps:{opp:l,opp2:h,opps:u},plotOpenEnds:m}},gA="::confidence";function yA(t,e,n){const i=e<0?n[0]:n[1],o=e<0?n[1]:n[0];return i+(t-e)*(e?(i-o)/e:1)}function xA(t,e,n){const i=t[e],o={};for(const[e,r]of[["lower",t.lci],["upper",t.hci]])u.finite(r)&&(n&&u.finite(i)&&u.finite(n[0])&&u.finite(n[1])?o[e]=yA(r,i,n):n||(o[e]=r));return o}function bA(t,e,n,i){const o={lower:u.finite(t),upper:u.finite(e)};if(!i)return{lower:t,upper:e,end:n,caps:o};const[r,a]=i,s=(t,e)=>{if(!u.finite(t))return t;const n=u.clamp(t,r,a);return n!==t&&(o[e]=!1),n};return{lower:s(t,"lower"),upper:s(e,"upper"),end:u.clamp(n,r,a),caps:o}}function kA(t){return{capWidth:"50%",stroke:(e,n)=>{const{Bar:o,fill:r}=t.schema.shapeConfig,a=o&&void 0!==o.fill?o.fill:r,s="function"==typeof a?a(e,n):a,c=i.color(s);return c?c.darker(1.5).formatHex():s},strokeWidth:2}}function _A(t,e){return!(!u.finite(e)||!t)&&t.some(t=>e>Math.min(t.start,t.end)&&e<Math.max(t.start,t.end))}function vA(t,e){const{viz:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:r}=t,a="y"===n.schema.discrete?"y":"x",s="x"===a?"y":"x",c="x"===a?t.y:t.x,l=function(t,e,n){const i="y"===e?t.viz._yAxis:t.viz._xAxis,o=i&&!i._d3ScaleNegative&&i._d3Scale?i._d3Scale.domain():[],r=o.length?[o[0],o[o.length-1]].map(t=>n(t)):[];if(2!==r.length||!r.every(u.finite))return t.valueExtent;const a=Math.min(r[0],r[1]),s=Math.max(r[0],r[1]);return t.valueExtent?[Math.max(a,t.valueExtent[0]),Math.min(s,t.valueExtent[1])]:[a,s]}(t,s,c),h=("y"===s?n._yAxis:n._xAxis)?._breaks,d=new Map;for(const t of e){if("rect"!==t.type||"Bar"!==t.shapeType||`${t.key}`.endsWith("::hit"))continue;const e=t.datum;if(!e||d.has(e))continue;const f=n.schema.stacked?i[o.get(e.id)??-1]?.[r.get(e.discrete)??-1]:void 0;if(n.schema.stacked&&!f)continue;const m=xA(e,s,f);if(!u.finite(m.lower)&&!u.finite(m.upper))continue;const p=void 0!==e[`${s}2`]?`${s}2`:void 0,g=t=>u.finite(t)?c(t,p):void 0,y=t.transform??{},x=e[s],b=bA(g(m.lower),g(m.upper),c(f?x<0?f[0]:f[1]:x,p),l);_A(h,m.lower)&&(b.caps.lower=!1),_A(h,m.upper)&&(b.caps.upper=!1),d.set(e,{key:t.key,center:"x"===a?(y.x??0)+t.x+t.width/2:(y.y??0)+t.y+t.height/2,thickness:"x"===a?t.width:t.height,...b})}return d}function wA(t,e){const{viz:n}=t;if(!n._confidence)return[];const i=vA(t,e);if(!i.size)return[];const o=Hg(n,"Bar",{...kA(n),...n._confidenceConfig??{}}),r=o.capWidth;delete o.capWidth,delete o.tooltip;const a="y"===n.schema.discrete?"y":"x",s=t=>i.get(t),c=Pg("Path").renderMode("compute").config(o).config({d:(t,e)=>{const n=s(t),i="function"==typeof r?r(t,e):r;return function(t,e,n,i,o,r,a={}){const s=u.finite(o)?o:i,c=u.finite(r)?r:i,l=n/2,h=(e,n)=>"x"===t?`${n},${e}`:`${e},${n}`;let d=`M${h(s,e)}L${h(c,e)}`;for(const[t,n]of[[o,a.lower],[r,a.upper]])u.finite(t)&&!1!==n&&l>0&&(d+=`M${h(t,e-l)}L${h(t,e+l)}`);return d}(a,n.center,function(t,e){if(u.finite(t))return Math.max(0,t);if("string"==typeof t&&t.trim().endsWith("%")){const n=parseFloat(t);if(u.finite(n))return Math.max(0,e*n/100)}return e/2}(i,n.thickness),n.end,n.lower,n.upper,n.caps)},fill:"none",hitArea:{"stroke-width":10},id:t=>`${s(t).key}${gA}`,label:!1,x:0,y:0}).data(Array.from(i.keys()));return n._wirePlotShapeEvents(c,"Bar",t.events),Gg(c).map(t=>({...t,shapeType:"Bar"}))}function MA(t){return t.__d3plusStackOrder=!0,t}function SA(t){let e,n=-1,i=0;const o=t.length;for(;++n<o;)(e=+t[n][1])&&(i+=e);return i}const CA=MA(t=>R.stackOrderAscending(t)),$A=MA(t=>R.stackOrderDescending(t)),AA=MA(t=>{const e=t.map(SA),n=t.map(t=>t.key.split("_")[0]);return R.stackOrderNone(t).sort((t,i)=>n[t].localeCompare(n[i])||e[t]-e[i])}),zA=MA(t=>AA(t).reverse());function DA(t,e="descending"){return MA(n=>{const i=n.map(e=>{let n=0;for(let i=0;i<e.length;i++){const o=(e[i].data||[]).find(t=>t.id===e.key);if(o&&o.data){const e=+t(o.data);isNaN(e)||(n+=e)}}return n});return R.stackOrderNone(n).sort((t,n)=>"ascending"===e?i[t]-i[n]:i[n]-i[t])})}const LA={ascending:CA,descending:$A,key:AA,keyReverse:zA,none:MA(t=>R.stackOrderNone(t)),data:MA(t=>R.stackOrderNone(t)),insideOut:MA(t=>R.stackOrderInsideOut(t)),appearance:MA(t=>R.stackOrderAppearance(t)),reverse:MA(t=>R.stackOrderReverse(t))},FA=Object.keys(LA);function NA(t){if("function"==typeof t)return t.__d3plusStackOrder?t:DA(t);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const{value:i,order:o}=t;return"function"==typeof i?DA(i,o):(e=DA(H(i),o),n=i,I.set(e,n),e)}var e,n;return"string"==typeof t?t in LA?LA[t]:(console.warn(`[d3plus] Unknown stackOrder "${t}". Expected one of: ${FA.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),$A):$A}function BA(t,e){let n,i,o,r,a,s;if(!((n=t.length)>0))return;const c=t[e[0]].length;for(let l=0;l<c;++l)for(s=a=0,r=0;r<n;++r)(o=(i=t[e[r]][l])[1]-i[0])>=0?(i[0]=s,i[1]=s+=o):o<0?(i[1]=a,i[0]=a+=o):i[0]=s}const EA={diverging:BA,none:R.stackOffsetNone,expand:R.stackOffsetExpand,silhouette:R.stackOffsetSilhouette,wiggle:R.stackOffsetWiggle},RA=Object.keys(EA);function PA(t){return"function"==typeof t?t:"string"==typeof t&&t in EA?EA[t]:(console.warn(`[d3plus] Unknown stackOffset "${t}". Expected one of: ${RA.join(", ")}; or an offset function. Falling back to "diverging".`),BA)}function TA(t,e,n){const i=new Map,o=Math.max(0,...t.map(t=>t.length));for(let r=0;r<o;r++){const o=[];t.forEach((t,i)=>{const a=t[r],s=n(`${e[i]}`);if(!a||void 0===s)return;const[c,l]=[+a[0],+a[1]];Number.isFinite(c)&&Number.isFinite(l)&&c!==l&&o.push({series:s,order:t.index??i})}),o.sort((t,e)=>t.order-e.order),o.forEach(({series:t},e)=>{const n=i.get(t)??{total:0,count:0};n.total+=(e+.5)/o.length,n.count+=1,i.set(t,n)})}return i}function OA(t){const e=new Map;for(const n of t)n.forEach(({total:t,count:n},i)=>{const o=e.get(i)??{total:0,count:0};e.set(i,{total:o.total+t,count:o.count+n})});return e}function WA(t){const e=e=>{const{total:n,count:i}=t.get(e);return n/i};return Array.from(t.keys()).sort((t,n)=>e(t)-e(n))}function jA(t,e,n){const i=e.slice(),o=new Set(e);let r;for(const e of t){if(!o.has(e)){if(!n.has(e))continue;const t=void 0===r?0:i.indexOf(r)+1;i.splice(t,0,e),o.add(e)}r=e}return i}function HA(t,e,n){let i=[[]];const o=t._drawDepth??0;for(let r=0;r<=o;r++){const o=t.schema.groupBy?.[r];if("function"!=typeof o)break;const a=o.bind(t)(e,n),s=(Array.isArray(a)?a:[a]).map(t=>`${t}`).filter(Boolean);s.length&&(i=i.flatMap(t=>s.map(e=>[...t,e])))}return i.map(t=>t.join("_"))}function IA(t,e){if(!e?.size)return void(t._stackLegendOrder=void 0);const n=new Set((t._legendData??[]).flatMap((e,n)=>HA(t,e,n)));t._stackLegendOrder=jA(t._stackLegendOrder??[],WA(e),n)}function GA(t,e){let n,i=new Map;const o=e=>{const n=HA(t,e,0).map(t=>i.get(t)).filter(t=>void 0!==t);return n.length?n.reduce((t,e)=>t+e,0)/n.length:1/0};return(r,a)=>{const s=t.schema.stacked?t._stackLegendOrder:void 0;if(s?.length){s!==n&&(n=s,i=new Map(s.map((t,e)=>[t,e])));const t=o(r),e=o(a);if(t!==e)return t<e?-1:1}return e(r,a)}}const qA=[x.timeYear,x.timeMonth,x.timeDay,x.timeHour,x.timeMinute,x.timeSecond];function VA(t){const e=t.slice().sort((t,e)=>t-e),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function KA(t,e){if(!e)return[];const n=function(t){const e=t.some(t=>t instanceof Date);if(t.some(t=>!(t instanceof Date)&&"number"!=typeof t))return null;const n=Array.from(new Set(t.map(Number).filter(Number.isFinite))).sort((t,e)=>t-e);if(n.length<2)return null;const i=n.slice(1).map((t,e)=>t-n[e]);if(!e){const t=VA(i);return(e,n)=>+(e+t*n).toPrecision(12)}const o=n.map(t=>new Date(t)),r=qA.find(t=>o.every(e=>+t.floor(e)===+e));if(r){const t=Math.round(VA(o.slice(1).map((t,e)=>r.count(o[e],t))));if(t>0)return(e,n)=>r.offset(e,t*n)}const a=VA(i);return(t,e)=>new Date(+t+a*e)}(t);if(!n)return[];const i=t.some(t=>t instanceof Date),o=t.reduce((t,e)=>+e>+t?e:t,t[0]);if("number"==typeof e){const t=Math.min(Math.floor(e),1e3);return Array.from({length:Math.max(t,0)},(t,e)=>n(o,e+1))}const a=e.to;if(null==a)return[];const s=i?r.date(a):+a;if(!Number.isFinite(+s))return[];const c=[];for(let t=1;t<=1e3;t++){const e=n(o,t);if(+e>+s)break;c.push(e)}return c}const YA=["linear","exponential","logarithmic","power","polynomial"];function UA(t){return!0===t?"linear":YA.includes(t)?t:null}function XA(t){return"y"===t?"y":"x"}function QA(t,e,n=50){const[i,o]=t;return e?e.filter(t=>t>=i&&t<=o):i===o?[i]:Array.from({length:n},(t,e)=>i+(o-i)*e/(n-1))}function ZA(t,e,n){const[i,o]=t,r=Math.max(...e);if(!(r>o))return[];if(n)return[o,...n.filter(t=>t>o&&t<=r)];const a=o>i?Math.round(50*(r-o)/(o-i)):50,s=QA([o,r],null,Math.min(Math.max(a,2),50)+1);return Array.from(new Set([...s,...e.filter(t=>t>o)])).sort((t,e)=>t-e)}function JA(t,e,n,i=[]){const o=UA(t._trendLine);if(!o||!e.length)return[];const r=t._trendLineConfig||{},a=XA(t.schema.discrete),s="x"===a?"y":"x",{toNumber:c,fromNumber:l}=function(t){const e=t.map(t=>`${t}`),n=t.some(t=>!(t instanceof Date)&&"number"!=typeof t),i=t.some(t=>t instanceof Date);return{toNumber:t=>{if(t instanceof Date)return+t;if(!n&&"number"==typeof t)return t;const i=e.indexOf(`${t}`);return i<0?NaN:i},fromNumber:e=>n?t[Math.round(e)]:i?new Date(e):e}}(n.concat(i)),h=function(t,e){return!t[`_${e}Time`]&&(t.schema.discrete===e&&!OC(t,e)||!!t.schema[`${e}Sort`])}(t,a)?n.concat(i).map(c).filter(Number.isFinite):null,f=i.length?n.concat(i).map(c).filter(Number.isFinite):[],m="log"===`${t[`_${s}Config`]?.scale}`.toLowerCase(),p=t.schema.shapeConfig.fill,g=[];for(const[n,i,y,x]of function(t,e,n,i){const o="x"===n?"y":"x",r=t=>[i(t[n]),+t[o]];if(t.schema.stacked)return[["all",d.groups(e,t=>i(t[n])).map(([t,e])=>[t,e.reduce((t,e)=>t+(+e[o]||0),0)]),void 0,-1]];const a=[["all",e.map(r),void 0,-1]];if("all"===t._trendLineConfig?.group)return a;const s=n=>d.groups(e,e=>function(t,e,n){return t._ids(e.data,e.i).slice(0,n+1).join("_")}(t,e,n)).map(([t,e])=>[t,e.map(r),e[0],n]),c=t._drawDepth,l=s(c);return l.some(([,t])=>t.length>1)?l:c>0?s(c-1):a}(t,e,a,c)){const e=u.regression(i,o,{order:r.order});if(!e)continue;const c=r.confidence&&"linear"===o,d=r.confidenceLevel,b=c?u.linearConfidence(i,d):null,k=c?u.linearPrediction(i,d):null,_=[],v=(t,n)=>{const i=e.predict(t);if(!Number.isFinite(i)||m&&i<=0)return;const o={[a]:l(t),[s]:i},r=n?k:b;r&&([o.lci,o.hci]=r(t)),n&&(o.projected=!0),n&&t>e.extent[1]&&f.includes(t)&&(o.step=!0),_.push(o)};if(QA(e.extent,h).forEach(t=>v(t,!1)),ZA(e.extent,f,h).forEach(t=>v(t,!0)),_.length<2)continue;const w=y?y.data:void 0,M=r.stroke?r.stroke:w?"function"==typeof p?p(w,y.i):p:"#444",S=w?t._drawLabel(w,y.i,x):t.schema.translate("Trend Line");g.push({id:n,label:S,color:M,axis:a,fit:e,samples:_,row:w})}return g}function tz(t){const e=[];for(const{axis:n,samples:i}of t){const t="x"===n?"y":"x";for(const n of i)e.push(n[t]),void 0!==n.lci&&e.push(n.lci,n.hci)}return e.filter(Number.isFinite)}const ez=({viz:t,plotFormattedData:e,xData:n,yData:i})=>{const o=XA(t.schema.discrete),r=("x"===o?n:i)||[],a=UA(t._trendLine)?KA(r,t._trendLineConfig?.projection):[],s=t._trendFits=t._swarm?[]:JA(t,e||[],r,a);if(!s.length)return{};const c=tz(s),l="x"===o?{yData:(i||[]).concat(c)}:{xData:(n||[]).concat(c)};return s.some(t=>t.samples.some(t=>t.projected))?{...l,[`${o}Data`]:r.concat(a)}:l};function nz(t,e){const{data:n,axisData:i,xData:o,yData:r,opp:a,stackGroup:s}=e;!function(t,e,n){const i=e.filter(t=>["Area","Bar"].includes(t.shape)),o=d.groups(i,t=>t.group).reduce((t,[e,i])=>(t[e]||(t[e]=0),t[e]+=d.sum(i,t=>t[n]),t),{});e.sort((e,i)=>{if(t.schema[`${t.schema.discrete}Sort`])return t.schema[`${t.schema.discrete}Sort`](e.data,i.data);const r=e[t.schema.discrete],a=i[t.schema.discrete];return r-a!==0?r-a:e.group!==i.group?o[i.group]-o[e.group]:i[n]-e[n]})}(t,i,a);const c=Array.from(new Set(i.map(t=>t.discrete))),l=Array.from(new Set(i.map(t=>t.id))),h=d.groups(i,t=>t.discrete).map(([,t])=>t);!1!==t._stackShares&&function(t,e){const n=t.filter(t=>["Area","Bar"].includes(t.shape)),i=new Map;for(const t of n)i.set(t.discrete,(i.get(t.discrete)||0)+Math.abs(+t[e]||0));for(const t of n){const n=i.get(t.discrete),o=n?Math.abs(+t[e]||0)/n:0;Mh(t,o),t.data&&Mh(t.data,o)}}(n,a),function(t,e){const{axisData:n,data:i,stackData:o,stackKeys:r,stackGroup:a,opp:s}=e;o.forEach(e=>{const o=Array.from(new Set(e.map(t=>t.id)));o.length<r.length&&r.forEach(r=>{if(!o.includes(r)){const o=n.filter(t=>t.id===r)[0],c=o.shape;if("Area"===c){const n=a(o.data,o.i),l={__d3plus__:!0,data:o.data,discrete:"Bar"===o.shape?`${e[0][t.schema.discrete]}_${n}`:`${e[0][t.schema.discrete]}`,group:n,id:o.id,ids:r,shape:c,[t.schema.discrete]:e[0][t.schema.discrete],[s]:0};i.push(l)}}})})}(t,{axisData:i,data:n,stackData:h,stackKeys:l,stackGroup:s,opp:a}),t.schema[`${t.schema.discrete}Sort`]?n.sort((e,n)=>t.schema[`${t.schema.discrete}Sort`](e.data,n.data)):n.sort((e,n)=>e[t.schema.discrete]-n[t.schema.discrete]);const f=new Set(i.filter(t=>t.data?._isAggregation).map(t=>t.id)),m=function(t,e,n,i,o){const r=t._stackOrder;Array.isArray(r)&&e.sort((t,e)=>r.indexOf(t)-r.indexOf(e));const a=Array.isArray(r)?R.stackOrderNone:r;return R.stack().keys(e).offset(t._stackOffset).order(o.size?function(t,e){return n=>{const i=t(n),o=t=>e.has(n[t].key);return i.filter(t=>!o(t)).concat(i.filter(o))}}(a,o):a).value((t,e)=>{const n=t.filter(t=>t.id===e);return n.length?n[0][i]:0})(n)}(t,l,h,a,f),p="x"===t.schema.discrete?o:r,g=tz(t._trendFits||[]);!t._confidence||"x"!==a&&"y"!==a||g.push(...function(t,e,n,i,o){const r=[];for(const a of t){if("Bar"!==a.shape)continue;const t=n[i.indexOf(a.id)],s=t&&t[o.indexOf(a.discrete)];if(!s)continue;const{lower:c,upper:l}=xA(a,e,s);u.finite(c)&&r.push(c),u.finite(l)&&r.push(l)}return r}(i,a,m,l,c));const y="x"===t.schema.discrete?t._xTime:t._yTime;return{plotInitialDomains:{[t.schema.discrete]:t._discreteExtent?jC(t,i):y?d.extent(p):p,[a]:[d.min([...m.map(t=>d.min(t.map(t=>t[0]))),...g]),d.max([...m.map(t=>d.max(t.map(t=>t[1]))),...g])]},plotDiscreteKeys:c,plotStackData:m,plotStackKeys:l,plotStackPositions:iz(t,i,m,l)}}function iz(t,e,n,i){const o=new Map;for(const n of e){const e=`${n.id}`;if(o.has(e)||!n.data)continue;const i=HA(t,n.data,n.i);i.length&&o.set(e,i[0])}return TA(n,i,t=>o.get(t))}const oz=({viz:t,plotFormattedData:e,plotAxisData:n,xData:i,x2Data:o,yData:r,y2Data:a,plotStackGroup:s})=>{const c=e||[],l=n||[],h=s,u=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,f=t.schema.stacked?nz(t,{data:c,axisData:l,xData:i||[],yData:r||[],opp:u,stackGroup:h}):function(t,e){const{axisData:n,xData:i,x2Data:o,yData:r,y2Data:a}=e,s=t._xTime,c=t._x2Time,l=t._yTime,h=t._y2Time,u=t.schema.discrete||"x";return t.schema[`${t.schema.discrete}Sort`]?n.sort((e,n)=>t.schema[`${t.schema.discrete}Sort`](e.data,n.data)):n.sort((t,e)=>t[u]-e[u]),{plotInitialDomains:{x:OC(t,"x")?jC(t,n):!s&&"x"===t.schema.discrete||t.schema.xSort||"x"===t._swarm?.cross?i:d.extent(i),x2:OC(t,"x")?jC(t,n):!c&&"x"===t.schema.discrete||t.schema.x2Sort?o:d.extent(o),y:OC(t,"y")?jC(t,n):!l&&"y"===t.schema.discrete||t.schema.ySort||"y"===t._swarm?.cross?r:d.extent(r),y2:OC(t,"y")?jC(t,n):!h&&"y"===t.schema.discrete||t.schema.y2Sort?a:d.extent(a)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(t,{axisData:l,xData:i||[],x2Data:o||[],yData:r||[],y2Data:a||[]}),m=t._plotFacetScales?.domains;return m&&f.plotInitialDomains&&(f.plotInitialDomains={...f.plotInitialDomains,...m}),f};function rz(t){return!!t._confidence&&!1!==t._confidenceConfig?.tooltip}function az(t,e,n){const i={},o=t._confidence;if(!o||!e)return i;const[r,a]=o,s=r?r(e,n):void 0,c=a?a(e,n):void 0;return u.finite(s)&&(i.lower=s),u.finite(c)&&(i.upper=c),i}function sz(t,e,n,i){if(!rz(t))return[];if(KC(t).length>1)return cz(t,e,n,i);const{lower:o,upper:r}=az(t,e,n),a=[];return u.finite(o)&&a.push([t.schema.translate("Lower Bound"),i(o)]),u.finite(r)&&a.push([t.schema.translate("Upper Bound"),i(r)]),a}function cz(t,e,n,i){return YC(t,e,n).map(({label:t,lower:e,upper:n})=>[t,hz(e,n,i)]).filter(([,t])=>t)}function lz(t,e,n){const i=hz(t,e,n);return i?` (${i})`:""}function hz(t,e,n){const i=u.finite(t),o=u.finite(e);return i&&o?`${n(t)} – ${n(e)}`:i?`≥ ${n(t)}`:o?`≤ ${n(e)}`:""}const uz=t=>"x"===t?"y":"x";function dz(t,e){const n=t[`_${e}Config`];if(n&&"string"==typeof n.title)return n.title;const i=t[`_${e}Key`];return"string"==typeof i?i:""}function fz(t,e,n){const i=t[`_${e}Config`];if(i&&"function"==typeof i.tickFormat)return i.tickFormat(n);const o=function(t,e,n){if(!t[`_${e}Time`])return;const i=Lo(n);if(!i)return;const o=t[`_${e}Axis`];return o&&"time"===o.schema.scale?Po(o,i):p.formatDateFull(i,[i])}(t,e,n);if(void 0!==o)return o;if(Wo(n)){const i=t[`_${e}Axis`];return i?Po(i,n):p.formatDateFull(n,[n])}if("number"==typeof n&&e!==t.schema.discrete){const i=t[`_${e}Axis`];return i&&Zo(i)?Jo(n,t.schema.locale):p.formatAbbreviate(n,t.schema.locale)}return String(n)}function mz(t,e,n){const i=n.rows[0],o=t[`_${e}`],r=o&&!i.projected?o(i.datum,i.index):n.value;return[dz(t,e),fz(t,e,r)]}function pz(t,e,n){const i=n.nativeEvent,o=i&&i.touches&&i.touches.length?[i.touches[0].clientX,i.touches[0].clientY]:i?[i.clientX,i.clientY]:n.point,r=t._zoomTransform,a=t._chartTransform,s=e.axis,c=(e.px+(a?.[s]??0))*(r?.scale??1)+(r?.[s]??0),l="x"===s?0:1,h=[o[0],o[1]];return h[l]=o[l]-n.point[l]+c,h}function gz(t){const e=t._tooltipClass;t._sharedTooltipSaved||(t._sharedTooltipSaved={arrow:e.arrow(),thead:e.thead(),tbody:e.tbody()});const n=t._sharedTooltipSaved;return e.thead(n.thead).tbody(n.tbody).titleSwatch(!0)}function yz(t,e,n){const i=n=>fz(t,e,n),o=n.projected;return o?void 0===o.lci||void 0===o.hci?"":lz(o.lci,o.hci,i):function(t,e,n,i){if(!rz(t))return"";const{lower:o,upper:r}=az(t,e,n);return lz(o,r,i)}(t,n.datum,n.index,i)}function xz(t,e,n){const i=uz(e.axis),{header:o,names:r}=function(t,e){const n=` (${t.schema.translate("Projected")})`,i=mz(t,e.axis,e),o=e.rows.every(t=>t.projected);return{header:o?[i[0],`${i[1]}${n}`]:i,names:e.rows.map(t=>t.projected&&!o?`${t.name}${n}`:t.name)}}(t,e);gz(t).data([e.rows[0].datum]).config(te.bind(t)(t.schema.tooltipConfig)).title(()=>dz(t,i)).thead(o).tbody(e.rows.flatMap((e,n)=>[[Th(Ph(e.color,e.shape),r[n]),`${fz(t,i,e.value)}${yz(t,i,e)}`],...Nh(t,e.datum,5)])).footer(!1).arrow(!1).position(pz(t,e,n)).render()}function bz(t,e,n){const i=e.rows[0],o=gz(t).data([i.datum]).title(()=>t._drawLabel(i.datum,i.index)).footer(function(t){return!!(t._drawDepth<t.schema.groupBy.length-1&&Jl(t,"click.shape"))&&t.schema.translate("Click to Expand")}(t)).config(te.bind(t)(t.schema.tooltipConfig)),r=o.tbody(),a="function"==typeof r?r(i.datum,i.index):r;Xh(o,Ph(i.color,i.shape)).tbody([...!1===t._tooltipAxisRows?[]:[mz(t,"x",e),mz(t,"y",e)],...i.projected?[]:sz(t,i.datum,i.index,n=>fz(t,uz(e.axis),n)),...Jh(t,i.datum,i.index),...Array.isArray(a)?a:[],...Nh(t,i.datum)]).arrow(!1).position(pz(t,e,n)).render()}function kz(t,e,n,i){if(i(void 0===e?t:Fx(t,e))<=n)return void 0===e?{name:t}:{name:t,value:e};if(void 0!==e&&i(t)<=n)return{name:t};const o=e=>`${t.slice(0,e).trimEnd()}…`;let r=1,a=t.length-1,s=0;for(;r<=a;){const t=r+a>>1;i(o(t))<=n?(s=t,r=t+1):a=t-1}return s?{name:o(s)}:null}function _z(t,e=0){return Math.max(0,t-e)/4}function vz(t){let e,n=t;for(;n.__d3plus__&&n.data;)n=n.data,e=n.i;return{d:n,i:e}}function wz([t,e],n,i="end"){const{labelFunction:o,fontColorAccessor:a,fontSizeAccessor:s,fontWeightAccessor:c,fontFamilyAccessor:l,paddingAccessor:h,xEstimate:u,yEstimate:f}=n,m="end"===i,{d:p,i:g}=vz(e[m?e.length-1:0]),y="function"==typeof o?o(p,g):o,x="function"==typeof a?a(p,g):a,b="function"==typeof s?s(p,g):s,k="function"==typeof c?c(p,g):c;let _="function"==typeof l?l(p,g):l;Array.isArray(_)&&(_=_.map(t=>`'${t}'`).join(", "));const v="function"==typeof h?h(p,g):h,w=e.map(t=>[u(t.x),f(t.y)]),M=e.map(t=>u(t.x)),S=m?d.max(M):d.min(M),C=e.find(t=>u(t.x)===S),$=C.y;let A=n.valueText($,C);const z={"font-size":b,"font-family":_,"font-weight":k};let D,L=r.textWidth(void 0===A?y:Fx(y,A),z);if(void 0!==n.maxSpace&&L+4*v>n.maxSpace){const t=kz(`${y}`,A,n.maxSpace-4*v,t=>r.textWidth(t,z));if(!t)return null;D=t.name,A=t.value,L=r.textWidth(void 0===A?D:Fx(D,A),z)}return{id:t,side:i,name:D,valueText:A,labelWidth:L+2*v,spaceNeeded:L+4*v,value:$,yEstimate:f($),padding:v,fontSize:b,fontColor:x,edgeX:S,xValue:C.x,coords:w}}function Mz(t,e){const{fontSize:n,id:i,labelWidth:o,edgeX:r,side:a,yEstimate:s}=t,c="start"===a?-1:1;return 0!==e.filter(t=>t.id!==i&&t.coords.some(e=>((e[0]-r)*c>0||e[0]===r&&t.edgeX!==r)&&(r+o*c-e[0])*c>=0&&e[1]<=s+.75*n&&e[1]>=s-.75*n)).length}function Sz(t,e,n){const i=Hg(t,"Line");e.config(i);const o=e.labelConfig(),r=void 0!==o.fontColor?o.fontColor:n.fontColor(),a=void 0!==o.fontSize?o.fontSize:n.fontSize(),s=void 0!==o.fontWeight?o.fontWeight:n.fontWeight(),c=void 0!==o.fontFamily?o.fontFamily:n.fontFamily(),l=void 0!==o.padding?o.padding:n.padding();return{labelFunction:i.label||t._drawLabel,fontColorAccessor:r,fontSizeAccessor:a,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l}}function Cz(t,e,n){return i=>("log"===e&&0===i&&(i=t._givenDomain()[n[0]<0?1:0]),t._getPosition.bind(t)(i))}function $z(t,e,n,i){return t.map(t=>wz(t,e,n)).filter(t=>null!==t).sort((t,e)=>i[1]>i[0]?t.value-e.value:e.value-t.value).filter((t,e,n)=>!Mz(t,n))}function Az(t,e,n){const i=d.max(t.filter(t=>t.edgeX===e),t=>t.spaceNeeded);return i?d.min([i,n]):0}const zz=({viz:t,plotFormattedData:e,plotScales:n,plotConfigScales:i,plotTestAxes:o,plotLineLabelTest:r,y2Exists:a})=>{const s=e||[],c=t.schema.lineLabels;if(!c||a)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0,plotStartLabelSpace:0};const l=t=>Dx(c,t.data,t.i),h=s.filter(t=>"Line"===t.shape&&l(t).length>0),u=d.groups(h,t=>t.id);if(!u.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0,plotStartLabelSpace:0};const{testLineShape:f,testTextBox:m}=r,{xTest:p,yTest:g}=o,y=n.x.domain(),x=n.y.domain(),b=i.xConfigScale,k=i.yConfigScale,_=t.schema.width-t._margin.left-t._margin.right,v=t.schema.lineLabelConfig,w={...Sz(t,f,m),xEstimate:Cz(p,b,y),yEstimate:Cz(g,k,x),valueText:(e,n)=>{const{d:i,i:o}=vz(n);return Lx(v,e,i,o,e=>fz(t,"y",e))}},M=t=>u.filter(([,e])=>{const n="end"===t?e[e.length-1]:e[0];return l(n).includes(t)}),[S,C]=[M("start"),M("end")],$=g.outerBounds(),A=_z(_,$.width?$.width+g.padding():0),z={...w,maxSpace:A},D=$z(S,z,"start",x),L=$z(C,z,"end",x),[F,N]=p._getRange.bind(p)(),B=Az(L,d.max(L,t=>t.edgeX),A),E=Az(D,d.min(D,t=>t.edgeX),A);return{plotLabelWidths:[...D,...L],plotLargestLabel:d.max(L.map(t=>t.labelWidth)),plotXRangeMax:B&&d.max(L,t=>t.edgeX)===N?_-B:void 0,plotStartLabelSpace:E&&d.min(D,t=>t.edgeX)===F?E:0}};function Dz(t,e){const n=()=>Oc(t);return r.assign({barConfig:{stroke:n},baselineBreakConfig:{stroke:n},breakConfig:{stroke:n},shapeConfig:{fill:n,labelConfig:{fontColor:n},stroke:n},titleConfig:{fontColor:n}},e)}function Lz(t){return gx(t,"x")||t._discreteExtent&&"x"===t.schema.discrete?"none":"outside"}function Fz(t,e){const{xData:n,xScalePadding:i}=e;return Dz(t,{data:n,locale:t.schema.locale,rounding:xx(t,"x",Lz(t)),scalePadding:i,...Mx(t,"x")})}const Nz=({viz:t,plotAxisData:e,plotScales:i,x2Exists:o,y2Exists:r,x2Data:a,y2Data:s,yData:c})=>{const l=e||[],{x:h,y:u,x2:d,y2:f,xScale:m,yScale:p,x2Scale:g,y2Scale:y}=i,x=h.domain(),b=d.domain(),k=u.domain(),_=f.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},w=gx(t,"y")||OC(t,"y")?"none":"outside",M={...o?{data:a}:v,...sx(t,"x2"),baselineBreak:!1,rounding:bx(t,"x2",Lz(t))},S={...r?{data:s}:v,...sx(t,"y2"),baselineBreak:!1,rounding:bx(t,"y2",w)},{showX:C,showY:$}=function(t){return{showX:"x"===t.schema.discrete?t.schema.width>t._discreteCutoff&&t.schema.width>t.schema.xCutoff:t.schema.width>t.schema.xCutoff&&!h$(t,"x"),showY:"y"===t.schema.discrete?t.schema.height>t._discreteCutoff&&t.schema.height>t.schema.yCutoff:t.schema.height>t.schema.yCutoff&&!h$(t,"y")}}(t),A=function(t,e,n,i,o){const r={data:n,locale:t.schema.locale,rounding:xx(t,"y",i),scalePadding:e.padding?e.padding():0,scaleAlign:e.align?e.align():.5,...Mx(t,"y")};return o.showX||!o.showY||t._swarm||(r.barConfig={stroke:"transparent"},r.tickSize=0,r.shapeConfig={labelBounds:(e,n)=>{const{width:i,y:o}=e.labelBounds,r=t.schema.height/2;return{x:n?-r:0,y:o,width:i,height:r}},labelConfig:{padding:0,rotate:0},labelRotation:!1}),r}(t,u,c,w,{showX:C,showY:$}),z=function(t,e){const n=Hg(t,"Bar"),i=void 0!==n.label?"function"==typeof n.label?n.label:()=>n.label:t._drawLabel,o=[],r=[];for(const t of e){if("Box"===t.shape)continue;const e=i(t.data,t.i);("number"==typeof e||e)&&(o.push(String(e)),r.push(t))}return{labels:o,rows:r}}(t,l),D=z.labels;let L;const F=(e,i)=>{if(OC(t,e))return function(t,e){const n=new Set;return e.filter(t=>t.data).forEach(e=>WC(t,e).forEach(t=>n.add(t))),Array.from(n).sort((t,e)=>t-e)}(t,l);if("Point"!==i)return null;return n.unique(l.map(t=>t[e])).every(t=>D.includes(`${t}`))?("x"!==e&&"y"!==e||e===t.schema.discrete&&("x"===e?C:$)&&(L={axis:e,...z}),[]):null},N=F("x",m),B=F("x2",g),E=F("y",p),R=F("y2",y);return{plotDefaultConfig:v,plotDefaultX2Config:Dz(t,M),plotDefaultY2Config:Dz(t,S),plotShowX:C,plotShowY:$,plotYC:Dz(t,A),plotBarLabels:D,plotBarLabelCheck:L,plotXTicks:N,plotX2Ticks:B,plotYTicks:E,plotY2Ticks:R,plotXDomain:x,plotX2Domain:b,plotYDomain:k,plotY2Domain:_}},Bz=t=>null===t||"number"==typeof t&&!Number.isFinite(t)||Array.isArray(t)&&0===t.length,Ez=t=>!(Bz(t.x)||Bz(t.y)||void 0!==t.x2&&Bz(t.x2)||void 0!==t.y2&&Bz(t.y2));function Rz(t,e,n){const i="y"===t.schema.discrete?"y":"x";return e.filter(e=>"Line"===e.shape&&!Ez(e)&&void 0!==e[i]&&!Bz(e[i])&&(!n||n.has(e[t.schema.discrete])))}function Pz(t,e){const n=d.extent(e),{sizeMax:i,sizeMin:o,sizeScale:r,sizeZero:a}=t.schema,s=hA[`scale${r.charAt(0).toUpperCase()}${r.slice(1)}`],c=a?Tz(s,n,i):NaN;return s().domain(n).range([n[0]===n[1]?i:Number.isFinite(c)?c:d.min([i/2,o]),i])}function Tz(t,[e,n],i){if(!(e>=0&&n>0))return NaN;const o=t().domain([0,n]).range([0,i])(e);return Number.isFinite(o)?o:NaN}const Oz=(t,e)=>(t._plotCircleShapes??["Circle"]).includes(e);function Wz(t,e){const{xTime:n,x2Time:i,yTime:o,y2Time:a}=e,s=n||i||o||a,c=(e,n)=>`${!s&&t.schema.time?t.schema.time(e,n):"time"}_${t.schema.stacked?((e,n)=>t._stackGroup?t._stackGroup(e,n):t.schema.groupBy.length>1?t._ids(e,n).slice(0,-1).join("_"):"group")(e,n):`${t._ids(e,n).join("_")}`}`;return{prepData:(e,s)=>{const l={__d3plus__:!0,data:e,group:c(e,s),i:s,hci:t._confidence&&t._confidence[1]&&t._confidence[1](e,s),id:t._ids(e,s).slice(0,t._drawDepth+1).join("_"),lci:t._confidence&&t._confidence[0]&&t._confidence[0](e,s),shape:t.schema.shape(e,s),x:n?r.date(t._x(e,s)):t._x(e,s),x2:i?r.date(t._x2(e,s)):t._x2(e,s),y:o?r.date(t._y(e,s)):t._y(e,s),y2:a?r.date(t._y2(e,s)):t._y2(e,s)};return l.discrete="Bar"===l.shape?`${l[t.schema.discrete]}_${l.group}`:`${l[t.schema.discrete]}`,l.id="Bar"===l.shape?`${l.id}_${l[t.schema.discrete]}`:l.id,l},stackGroup:c}}const jz=({viz:t})=>{if(!t._filteredData||!t._filteredData.length)return t._sizeLegendFinal=null,t._swarm=null,{plotFormattedData:[],plotAxisData:[],plotMissingRows:[],x2Exists:!1,y2Exists:!1};const{prepData:e,stackGroup:n}=Wz(t,function(t){const e=t._filteredData[0],n=!!t.schema.time&&t.schema.time(e,0),i=i=>{const o=t[`_${i}`](e,0);return Boolean(n&&o===n)||Zp(t,i,o)},o=t._x2Time=i("x2"),r=t._xTime=i("x"),a=t._y2Time=i("y2");return{xTime:r,x2Time:o,yTime:t._yTime=i("y"),y2Time:a}}(t)),i=function(t){const e=t.schema.discrete;if(!e||OC(t,e))return null;if("x"===e?t._xTime:t._yTime)return null;const n=("x"===e?t._xConfig:t._yConfig)?.domain,i=Array.isArray(n)?n:t.schema[`${e}Domain`];return Array.isArray(i)&&i.length?new d.InternSet(i):null}(t),o=e=>Ez(e)&&(!i||i.has(e[t.schema.discrete])),r=t._filteredData.map(e),a=eg(t,r.filter(o)),[s,c]=ex(t,a,t._axisPersist?eg(t,t._data.map(e).filter(o)):a);t._formattedData=s;const l=t._swarm=c$(t.schema.swarm,c);l&&(l$(s,l),c!==s&&l$(c,l)),function(t,e){t._sizeScaleD3=t._size?t._plotFacetScales?.size??Pz(t,e.map(e=>t._size(e.data))):()=>t.schema.sizeMin,t._sizeLegendFinal=t._size&&e.some(e=>Oz(t,e.shape))?t._sizeScaleD3:null}(t,c);const h=ax(t),u="x2"===h||c.some(t=>void 0!==t.x2),f="y2"===h||c.some(t=>void 0!==t.y2);return{plotFormattedData:s,plotAxisData:c,x2Exists:u,y2Exists:f,plotStackGroup:n,plotMissingRows:Rz(t,r,i)}},Hz=({viz:t,plotFormattedData:e,plotAxisData:i})=>{const o=e||[],a=i||[];function s(e){const i=t[`_${e}Time`],s=i?o:a,c=t._plotAxisRows?t._plotAxisRows(s,e):s,l=c.filter(t=>![NaN,void 0,!1].includes(t[e])),h=t._plotAxisValues?t._plotAxisValues(c,e):[];if(!l.length)return h;const u="number"==typeof l[0][e];let f=t.schema.discrete===e?d.rollups(l,e=>1===e.length?e[0].data:n.merge(e.map(t=>t.data),t.schema.aggs),t=>t[e]).sort((n,o)=>{if(t.schema[`${e}Sort`])return t.schema[`${e}Sort`](n[1],o[1]);return(i||u?parseFloat(n[0]):n[0])-(i||u?parseFloat(o[0]):o[0])}).map(([t])=>i?r.date(t):u?parseFloat(t):t):TC(l,e,t.schema[`${e}Sort`]?(n,i)=>t.schema[`${e}Sort`](n.data,i.data):void 0);return t.schema.discrete!==e.charAt(0)&&t._confidence&&(t._confidence[0]&&(f=f.concat(c.map(t=>t.lci))),t._confidence[1]&&(f=f.concat(c.map(t=>t.hci))),f=f.concat(ZC(t,c))),h.length?f.concat(h):f}return{xData:s("x"),x2Data:s("x2"),yData:s("y"),y2Data:s("y2")}},Iz=({viz:t,plotFormattedData:e,plotAxisData:n,plotScales:i,plotConfigScales:o})=>{const r=e||[],a=n||[];let{x:s,y:c,x2:l,y2:h}=i;const{xConfigScale:u,yConfigScale:f,x2ConfigScale:m,y2ConfigScale:p}=o,g=i.xScale,y=i.yScale;if("Point"!==("x"===t.schema.discrete||"y"===t._swarm?.axis?y:g)){d.groups(a,t=>t.shape).forEach(([e,n])=>{if(["Bar","Box"].includes(e)&&!t._discreteExtent&&cC("x"===t.schema.discrete?s:c,r,t.schema.discrete),t._buffer[e]){const i=t._buffer[e].bind(t)({data:n,x:s,y:c,yScale:f,xScale:u,config:t.schema.shapeConfig[e]});s=i[0],c=i[1];const o=t._buffer[e].bind(t)({data:n,x:l,y:h,yScale:p,xScale:m,x2:!0,y2:!0,config:t.schema.shapeConfig[e]});l=o[0],h=o[1]}})}return{plotScales:f$(t,{...i,x:s,y:c,x2:l,y2:h})}},Gz={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:W("Circle"),tooltipShared:!0,trendLine:!1}};function qz(t){return this._sizeScaleD3(this._size?this._size(t):null)}function Vz(t,e,n,i){const o=("y"===e?t._y:t._x)(n,i),r="y"===e?t._yAxis:t._xAxis;return o<0!==Boolean(r?.schema?.reverse)}function Kz(t,e){if(this.schema.stacked)return!1;const n=this.schema.labelPosition(t,e);if("outside"===n)return!0;if("inside"===n)return!1;const i="x"===this.schema.discrete.charAt(0)?"y":"x",o=this.schema.discrete.replace(this.schema.discrete.charAt(0),i),r="y"===o?this._yAxis:this._xAxis,a="y"===o?this._y:this._x,s=r._d3Scale.range(),c=a(t,e),l=Vz(this,o,t,e),h=r._getPosition(0),u="y"===o?l?s[1]-h:h-s[0]:l?h-s[0]:s[1]-h,d=r._getPosition(c);return Math.abs(l?h-d:d-h)<u/2}function Yz(t){return{label:(e,n)=>!!t.schema.stacked&&t._drawLabel(e,n),labelBounds:(e,n,i)=>{const o=Cx(t,i.points);let r=u.largestRect(o,{angle:d.range(-20,20,5)});if((!r||r.height<20||r.width<50)&&(r=u.largestRect(o,{angle:d.range(-80,80,5)})),!r)return null;const a=d.min(i.points,t=>t[0]),s=d.max(i.points.filter(t=>t[0]===a),t=>t[1]);return{angle:r.angle,width:r.width,height:r.height,x:r.cx-r.width/2-a,y:r.cy-r.height/2-s}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}function Uz(t){const e=(e,n)=>Wo(n)?fz(t,e,n):n;return(n,i)=>{let o;return n.nested?o=`${t._drawLabel(n.data,n.i)}`:(o=`${t._drawLabel(n,i)}`,void 0!==t._x(n,i)&&(o+=`, x: ${e("x",t._x(n,i))}`),void 0!==t._y(n,i)&&(o+=`, y: ${e("y",t._y(n,i))}`),void 0!==t._x2(n,i)&&(o+=`, x2: ${e("x",t._x2(n,i))}`),void 0!==t._y2(n,i)&&(o+=`, y2: ${e("y",t._y2(n,i))}`)),`${o}.`}}function Xz(t){return{curve:()=>t.schema.discrete?`monotone${t.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:W("none"),labelConfig:{fontColor:(e,n)=>{const i="function"==typeof t.schema.shapeConfig.Line.stroke?t.schema.shapeConfig.Line.stroke(e,n):t.schema.shapeConfig.Line.stroke;return null==i?Z(t._theme,t=>t.text,"rgb(0, 0, 0)"):Si(i,Boolean(t._theme?.dark))},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:W(2)}}function Qz(){return{Area:Yz(this),ariaLabel:Uz(this),Bar:{labelBounds(t,e,n){const i="y"===this.schema.discrete?"width":"height",o="y"===this.schema.discrete?"height":"width",r="x"===this.schema.discrete.charAt(0)?"y":"x",a="y"===r,s=this.schema.discrete.replace(this.schema.discrete.charAt(0),r),c=("y"===s?this._yAxis:this._xAxis)._d3Scale.range(),l=Math.abs(c[1]-c[0]),h=Vz(this,s,t,e);return Kz.bind(this)(t,e)?{[i]:l-n[i],[o]:n[o],x:a?-n.width/2:h?-l:n.width+1,y:a?h?n.height+1:-l:-n.height/2+1}:{[i]:n[i],[o]:n[o],x:a?-n.width/2:h?(this.schema.stacked,1-n.width):-1,y:a?h?(this.schema.stacked,1):1-n.height:-n.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(t,n){if(Kz.bind(this)(t,n)){const t="transparent"===this._backgroundConfig.fill?Tc(this):this._backgroundConfig.fill;return e.colorContrast(t,this.schema.colorDefaults)}return e.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(t,n):this.schema.shapeConfig.fill,this.schema.colorDefaults)},fontStroke(t,n){if(Kz.bind(this)(t,n)){const t="transparent"===this._backgroundConfig.fill?Tc(this):this._backgroundConfig.fill;return e.colorContrast(t,this.schema.colorDefaults)}return"transparent"},fontStrokeWidth(t,e){return Kz.bind(this)(t,e)?.1:0},padding:3,textAnchor(t,e){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=Vz(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),t,e),a=i?"middle":Kz.bind(this)(t,e)?o?"end":"start":o?"start":"end";return r.rtl()?"start"===a?"end":"end"===a?"start":a:a},verticalAlign(t,e){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=Vz(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),t,e);return i?Kz.bind(this)(t,e)?o?"top":"bottom":o?"bottom":"top":"middle"}}},Circle:{r:qz.bind(this),trail:!0},Line:Xz(this),Rect:{height:t=>2*qz.bind(this)(t),width:t=>2*qz.bind(this)(t),trail:!0}}}const Zz=["Bar","Circle","Rect"];function Jz(t){const e=t._filteredData??[];if(!e.length)return!1;const n=t.schema.shape,i=t.schema.shapeConfig??{};if(!1===i.label)return!1;return[...new Set(e.map((t,e)=>"function"==typeof n?n(t,e):n))].every(t=>Zz.includes(t)&&!1!==i[t]?.label)}const tD=t=>t.map(t=>t.text).join(" ").replace(/\s+/g," ").trim();const eD=[{key:"axisHover",coerce:"identity",default:!0},{key:"axisHoverConfig",merge:!0,factory:function(){return{guideConfig:{strokeDasharray:"4 3",strokeWidth:1},badgeConfig:{fontSize:12,fontWeight:400,padding:4,rx:2}}}},{key:"barPadding",coerce:"identity"},{key:"connectGaps",coerce:"identity",default:!0},{key:"baselineBreak",coerce:"identity"},{key:"fillBetween",coerce:"identity",default:!1},{key:"fillBetweenConfig",merge:!0,factory:_C},{key:"forecast",coerce:"identity"},{key:"forecastConfig",merge:!0,factory:DC},{key:"lineLabels",coerce:"identity"},{key:"lineLabelConfig",merge:!0,factory:()=>({value:!1})},{key:"referenceBands",coerce:"identity",factory:()=>[]},{key:"referenceLines",coerce:"identity",factory:()=>[]},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"sizeZero",coerce:"identity",default:!1},{key:"stacked",coerce:"identity"},{key:"swarm",coerce:"identity",default:"auto"},{key:"swarmConfig",merge:!0,factory:()=>({padding:1,overflow:"shrink"})},{key:"tooltipShared",coerce:"identity"},{key:"xBreak",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yBreak",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}];function nD(t){const n=Gz.defaults;t._axisPersist=n.axisPersist,t._annotations=n.annotations,t._backgroundConfig={duration:0,fill:"transparent"},t.schema.barPadding=n.barPadding,t._buffer=r.assign({},uC,{Bar:!1,Line:!1}),t._confidence=!1,t._confidenceConfig={fill:(e,n)=>{const{Line:i,stroke:o}=t.schema.shapeConfig,r=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof r?r(e,n):r},fillOpacity:W(.5)},t._crosshairConfig={stroke:()=>Z(t._theme,t=>t.textMuted,e.colorGray[500]),strokeDasharray:"4 3",strokeWidth:1},t._discreteCutoff=n.discreteCutoff,t._groupPadding=n.groupPadding,t._labelConnectorConfig={strokeDasharray:"1 1"},t._lineMarkerConfig={fill:(n,i)=>e.colorAssign(t._id(n,i),Te(t)),r:W(3)},t._lineMarkers=n.lineMarkers,t._previousAnnotations={back:[],front:[]},t._previousShapes=[],t._alongLabelsPossible=Jz,t.schema.shape=n.shape,t.schema.shapeConfig=r.assign(t.schema.shapeConfig,Qz.call(t)),t._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],t.schema.shapeSort=(e,n)=>t._shapeOrder.indexOf(e)-t._shapeOrder.indexOf(n),t.schema.tooltipShared=n.tooltipShared,t.schema.sizeMax=20,t.schema.sizeMin=5,t.schema.sizeScale="sqrt",t._stackOffset=BA,t._stackOrder=$A,t.schema.legendSort=GA(t,t.schema.legendSort),t.schema.threshold=W(0),t._thresholdMemberFormat=e=>fz(t,"y"===t.schema.discrete?"x":"y",e),t.schema.timelineConfig=r.assign(t.schema.timelineConfig,{brushMin:()=>t._xTime||t._yTime||t._x2Time||t._y2Time?2:1})}const iD=["ellipsis","fontFamily","fontMax","fontMin","fontResize","fontSize","fontWeight","lineHeight","maxLines","overflow","padding","split"];function oD(t,e,n,i){if(!t.length)return!0;const o=function(t,e){const n=new ei;for(const i of iD){const o=t[i];if(void 0!==o)if("split"===i||"function"!=typeof o)n[i](o);else{const t=o;n[i]((n,i)=>t(e[i].data,e[i].i))}}return n}(i,e);return t.every((t,e)=>{const i=Hn(o,{text:t,width:n.width,height:n.height},e);return!!i&&!i.truncated&&""!==i.lines.join("")})}function rD(t,e,n,i,o){const r="y"===t.schema.discrete?"y":"x",a=new Map;for(const t of e){const e=String(t[r]);a.set(e,(a.get(e)??0)+1)}const s=t.schema.stacked?1:d.max(Array.from(a.values()))??1,c=function(t,e,n,i,o){const r="x"===t?e.width:e.height,a=("x"===t?e.height:e.width)/2;let s=r/Math.max(1,n);return o.group<s&&(s-=o.group),i>1&&(s=(s-o.bar*i-1)/i),s=Math.max(0,s),"x"===t?{width:s,height:a}:{width:a,height:s}}(r,i,a.size,s,{group:t._groupPadding??0,bar:t.schema.barPadding??0});return oD(n,e,c,o)}function aD(t,e,n){const i=Hg(t,"Bar").labelConfig||{};return!rD(t,e.rows,e.labels,n,i)}function sD(t,e,n){const{xTest:i,x2Test:o,showX:r,x2Exists:a,width:s}=t,c=t.xRangeMax||void 0;r&&i.range([e,c]).measure(),a&&o.range([e,c]).measure();const l=i._getRange()[1],h=o._getRange()[1];return d.max([0,n,s-l,s-h])}function cD(t,e,n){const{yDomain:i,y2Domain:o,yConfigScale:r,y2ConfigScale:a}=e,{defaultY2Config:s,showY:c,y2Exists:l,yC:h}=e,{yTicks:u,x2TestRange:f,xTestRange:m,height:p,width:g}=e,{yTest:y,y2Test:x}=e;let{xOffsetRight:b}=e;if(c){const e=wx(t,"y");y.domain(i).height(p).maxSize(g/2).range(n).ticks(u).width(g).config(h).config(e).scale(r),Ni(y,h,e).measure()}const k=y.outerBounds(),_=k.width?k.width+y.padding():void 0,{startLabelSpace:v}=e,w=d.max([0,_,m[0],f[0],t._plotMinLeft?.(),v&&(_??0)+v]);l&&(x.config(h).domain(o).gridSize(0).height(p).range(n).width(g-d.max([0,b-e.y2Width])).title(!1).config(t._y2Config).config(s).scale(a),Fi(x,g).measure());const M=x.outerBounds(),S=M.width?M.width+x.padding():void 0;return b=sD(e,w,S),{yBounds:k,yWidth:_,y2Bounds:M,y2Width:S,xOffsetLeft:w,xOffsetRight:b}}function lD(t,e){const{xTest:n,showX:i,xLabelMode:o}=t;if(i&&(!o||"axis"===o))return n.range(e).measure(),n.outerBounds().height+n.padding()}function hD(t,e,n){const{x2Height:i,topOffset:o,height:r,horizontalMargin:a,verticalMargin:s}=e,c=(e,a=0)=>{const c=r-(e+o+s),l=n?.insetBottom??Math.max(0,t._plotInsetBottom?.(c-i)??0)+a;return{yBottom:c,insetBottom:l,yRange:[i,c-l]}};let l=c(e.xHeight),h=n||cD(t,e,l.yRange);for(let i=0;!n&&i<3;i++){const n=lD(e,[h.xOffsetLeft,e.width-(h.xOffsetRight+a)]);if(void 0===n||n===e.xHeight)break;t._padding.bottom+=n-e.xHeight,e={...e,xHeight:n},l=c(n),h=cD(t,e,l.yRange)}const u=n?0:function(t,e){const n=[t.yTest,...t.y2Exists?[t.y2Test]:[]],i=Math.max(0,...n.map(t=>t._labelOverflow?.[1]??0));return Math.max(0,Math.ceil(i-(t.xHeight+e)))}(e,l.insetBottom);return u&&(l=c(e.xHeight,u),h=cD(t,e,l.yRange)),{pCtx:e,...l,solved:h}}const uD={labels:[]};function dD(t,e,n){const i=!(n||h$(t,"y")&&t.schema.height>t.schema.yCutoff);return e&&i&&void 0===t._xConfig?.labels}function fD(t){const e=t._getDomain();if(!e.length)return[];const n="time"===t.schema.scale,[i,o]=[e[0],e[e.length-1]].map(t=>n?+t:t);return i===o||i instanceof Date&&o instanceof Date&&+i===+o?[i]:[i,o]}function mD(t){const e=t.schema.shapeConfig,n=e.labelConfig||{},i=t._labelFormat||(t=>`${t}`);let o=0,a=0;const c=fD(t).map((t,c)=>{const l=Dn(n.fontSize??12,t,c),h=Ln(e,t,c,l),u=`${i(t)??""}`,d=s.textWrap().fontFamily(r.fontExists(Dn(n.fontFamily??s.fontFamily,t,c))).fontSize(l).fontWeight(Dn(n.fontWeight??400,t,c)).lineHeight(h).width(Number.MAX_SAFE_INTEGER).height(h)(u),f=d.lines.filter(t=>""!==t);return f.length&&(o=Math.max(o,Math.floor(f.length*h)+1)),a=Math.max(a,Dn(n.padding??0,t,c)),{value:t,text:u,width:f.length?Math.ceil(Math.max(...d.widths)):0}});return{labels:c,padding:a,height:o}}function pD(t,e){const n=t.height?t.padding+t.height:0;return e-n>=n?n:0}function gD(t,e,n,i){const o=Math.max(0,n-i);if(t+e<=o)return[o-e,o-t];const r=o/2;return t<=r?[t,o-t]:e<=r?[o-e,e]:[r,r]}function yD(t,e,n,i=!1){const{labels:o,padding:r,height:a}=t;if(!o.length||!a)return[];const[s,c]=[e[0],e[e.length-1]],l=n+r;if(1===o.length){const[{value:t,text:e}]=o;return[{value:t,text:e,x:s,y:l,width:c-s,height:a,textAnchor:"middle"}]}const[h,u]=o,d=gD(h.width,u.width,c-s,r);return[{value:h.value,text:h.text,x:s,y:l,width:d[0],height:a,textAnchor:i?"end":"start"},{value:u.value,text:u.text,x:c-d[1],y:l,width:d[1],height:a,textAnchor:i?"start":"end"}]}function xD(t,e,n){return yD(mD(t),e,n,r.rtl())}function bD(t,e){t.measure();const n=t._outerBounds.y+t._margin.top;t.height(t.height()+e-n)}function kD(t,e){if(!e.length)return null;const n=t.schema.shapeConfig.labelConfig||{},i=(new ei).renderMode("compute").config(n).config({fontResize:!1,lineHeight:e=>Ln(t.schema.shapeConfig,e.value,e.i),padding:0,rotate:0,textAnchor:t=>t.textAnchor,verticalAlign:"top"}).data(e.map((t,n)=>({...t,id:1===e.length?"middle":n?"end":"start",i:n,data:{id:t.value,text:t.text}}))),{children:o}=i.toScene();return o.length?{type:"group",key:"plot-x-end-labels",children:o}:null}function _D(t,e,n,i,o,r,a){const{xTest:s,x2Test:c,yTest:l,showX:h,showY:u,x2Exists:f,height:m,width:p}=e,{labelWidths:g,largestLabel:y,xRangeMax:x,startLabelSpace:b=0}=function(t,e,n,i,o){const{xTest:r,x2Test:a,xDomain:s,x2Domain:c,xTicks:l,x2Ticks:h,xConfigScale:u,x2ConfigScale:d,defaultX2Config:f,showX:m,x2Exists:p,height:g,width:y}=e;let x;const b=o?uD:{};if(m){const e=wx(t,"x");r.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(e).config(b).scale(u),Ni(r,n,e,b).measure()}const{labelWidths:k,largestLabel:_,xRangeMax:v,startLabelSpace:w=0}=i();if(void 0!==v&&(x=v),m&&x){const e=wx(t,"x");r.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(e).config(b).scale(u),Ni(r,n,e,b).measure()}return p&&a.domain(c).height(g).range([void 0,x]).ticks(h).width(y).config(n).tickSize(0).config(f).config(t._x2Config).scale(d).measure(),{labelWidths:k,largestLabel:_,xRangeMax:x,startLabelSpace:w}}(t,e,n,r,a),k=s._getRange(),_=c._getRange(),v=c.outerBounds(),w=f?v.height+c.padding():0,M=d.max([0,i,k[0],_[0],t._plotMinLeft?.(),b&&(i??0)+b]),S=MD(t,l,u),C=sD({xTest:s,x2Test:c,showX:h,x2Exists:f,xRangeMax:x,width:p},M,o),$=s.outerBounds(),A=a?pD(mD(s),m-w):0;return{xRangeMax:x,labelWidths:g,largestLabel:y,startLabelSpace:b,xTestRange:k,x2TestRange:_,x2Height:w,xOffsetLeft:M,xOffsetRight:C,topOffset:S,xHeight:a?A:$.height+(u||h?s.padding():0),xLabelMode:a?A?"ends":"none":"axis"}}function vD(t,e,n){let i=e;const o=i.barLabelCheck,r="y"===o?.axis&&aD(t,o,wD(t,i,0,function(t,e){if(!e.showX)return 0;const n=(new qa).align("end").gridSize(0),i=Fz(t,e),o=wx(t,"x");return n.domain(e.xDomain).height(e.height).maxSize(e.height/2).range([void 0,void 0]).ticks(e.xTicks).width(e.width).config(i).config(o).scale(e.xConfigScale),Ni(n,i,o).measure(),n.outerBounds().height+n.padding()}(t,i)+function(t,e){const{yTest:n,yC:i,showY:o}=e;o&&n.config(i).config(wx(t,"y"));return MD(t,n,o)}(t,i)));r&&(i={...i,yTicks:null});const{yBounds:a,yWidth:s,y2Bounds:c,y2Width:l}=function(t,e){const{yTest:n,y2Test:i,yDomain:o,y2Domain:r,yTicks:a,y2Ticks:s,yConfigScale:c,y2ConfigScale:l,defaultY2Config:h,yC:u,showY:d,y2Exists:f,height:m,width:p}=e;if(d){const e=wx(t,"y");n.domain(o).height(m).maxSize(p/2).range([void 0,void 0]).ticks(a).width(p).config(u).config(e).scale(c),Ni(n,u,e).measure()}const g=n.outerBounds(),y=g.width?g.width+n.padding():void 0;f&&i.domain(r).height(m).range([void 0,void 0]).ticks(s).width(p).config(u).config(h).config(t._y2Config).scale(l).measure();const x=i.outerBounds();return{yBounds:g,yWidth:y,y2Bounds:x,y2Width:x.width?x.width+i.padding():void 0}}(t,i),h="x"===o?.axis&&aD(t,o,wD(t,i,(s??0)+(l??0),0));h&&(i={...i,xTicks:null});const u=dD(t,i.showX,i.showY),d=Fz(t,i),f=_D(t,i,d,s,l,n,u);return t._padding.left+=f.xOffsetLeft,t._padding.right+=f.xOffsetRight,t._padding.bottom+=f.xHeight,t._padding.top+=f.x2Height+f.topOffset,{yBounds:a,y2Bounds:c,yWidth:s,y2Width:l,xC:d,...f,barLabelsOnAxis:r||h,xTicks:i.xTicks,yTicks:i.yTicks}}function wD(t,e,n,i){const o="panel"===t._facetStep?0:ly(t);return{width:e.width-n,height:e.height-i-o}}function MD(t,e,n){const{fontSize:i}=e.shapeConfig().labelConfig;return(n?Dn(i)/2:0)+(t._plotInsetTop??0)}const SD=new Ma,CD=new ei,$D=(t,e)=>dk.prototype._draw.call(t,e);function AD(t,e,n,i,o){const r={...t._margin};$D(t,e);const a=t._margin.left+t._margin.right-r.left-r.right,s=t._margin.top+t._margin.bottom-r.top-r.bottom,{topOffset:c,x2Height:l}=n,h=function(t,e,n){const{xLabelMode:i,xHeight:o}=t;return"ends"!==i||pD(e(),n)?{xLabelMode:i,xHeight:o}:{xLabelMode:"none",xHeight:0}}(n,()=>mD(i),o-s-c-l);return t._padding.bottom+=h.xHeight-n.xHeight,{horizontalMargin:a,verticalMargin:s,...h}}function zD(t,e){if(t._axisHoverState=null,"chrome"===t._facetStep||!t._filteredData.length&&!t._annotations?.length)return $D(t,e),t;const n={xTest:(new qa).align("end").gridSize(0),x2Test:(new Ya).align("start").gridSize(0),yTest:(new Va).align("start").gridSize(0),y2Test:(new Va).align("end").gridSize(0)},i=function(t){const e=vt({viz:t},[jz,Hz,ez]);return{data:e.plotFormattedData,axisData:e.plotAxisData,x2Exists:e.x2Exists,y2Exists:e.y2Exists,xData:e.xData,x2Data:e.x2Data,yData:e.yData,y2Data:e.y2Data,stackGroup:e.plotStackGroup,missingRows:e.plotMissingRows??[]}}(t),{data:o,axisData:r,x2Exists:a,y2Exists:s,xData:c,x2Data:l,yData:h,y2Data:u}=i,f=t.schema.height-t._margin.top-t._margin.bottom,m=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,p=t.schema.width-t._margin.left-t._margin.right,g=function(t,e,n,i,o){const{xData:r,x2Data:a,yData:s,y2Data:c}=o,l=vt({viz:t,plotFormattedData:e,plotAxisData:n,xData:r,x2Data:a,yData:s,y2Data:c,plotStackGroup:i},[oz,pA]);return"panel"!==t._facetStep&&IA(t,l.plotStackPositions),{plotInitialDomains:l.plotInitialDomains,plotDiscreteKeys:l.plotDiscreteKeys,plotStackData:l.plotStackData,plotStackKeys:l.plotStackKeys,plotDomains:l.plotDomains,plotScales:l.plotScales,plotConfigScales:l.plotConfigScales,plotOpps:l.plotOpps,plotOpenEnds:l.plotOpenEnds}}(t,o,r,i.stackGroup,{xData:c,x2Data:l,yData:h,y2Data:u}),{x:y,y:x,x2:b,y2:k,xScale:_,yScale:v}=g.plotScales,w=d.groups(o,t=>t.shape).sort(([e],[n])=>t.schema.shapeSort(e,n)),M=function(t,e,n,i,o){const r=vt({viz:t,plotFormattedData:e,plotAxisData:n,plotScales:{...i.plotScales,...o},plotConfigScales:i.plotConfigScales,plotOpenEnds:i.plotOpenEnds},[Iz,y$]).plotScales;return{x:r.x,y:r.y,x2:r.x2,y2:r.y2}}(t,o,r,g,{x:y,y:x,x2:b,y2:k}),S=function(t,e,n,i,o,r){const{x2Exists:a,y2Exists:s}=o,{x2Data:c,y2Data:l,yData:h}=r,u=vt({viz:t,plotAxisData:e,plotScales:{...n.plotScales,...i},x2Exists:a,y2Exists:s,x2Data:c,y2Data:l,yData:h},[Nz]);return{xDomain:u.plotXDomain,x2Domain:u.plotX2Domain,yDomain:u.plotYDomain,y2Domain:u.plotY2Domain,defaultConfig:u.plotDefaultConfig,defaultX2Config:u.plotDefaultX2Config,defaultY2Config:u.plotDefaultY2Config,showX:u.plotShowX,showY:u.plotShowY,yC:u.plotYC,xTicks:u.plotXTicks,x2Ticks:u.plotX2Ticks,yTicks:u.plotYTicks,y2Ticks:u.plotY2Ticks,barLabels:u.plotBarLabels,barLabelCheck:u.plotBarLabelCheck}}(t,r,g,M,{x2Exists:a,y2Exists:s},{x2Data:l,y2Data:u,yData:h}),C=t.schema.lineLabels&&!s,$=function(t,e,n,i,o){const{xTest:r,yTest:a}=o;return()=>{const o=vt({viz:t,plotFormattedData:e,plotScales:n.plotScales,plotConfigScales:n.plotConfigScales,plotTestAxes:{xTest:r,yTest:a},plotLineLabelTest:{testLineShape:SD,testTextBox:CD},y2Exists:i},[zz]);return{labelWidths:o.plotLabelWidths,largestLabel:o.plotLargestLabel,xRangeMax:o.plotXRangeMax,startLabelSpace:o.plotStartLabelSpace??0}}}(t,o,g,s,n),A=vD(t,function(t,e,n,i){const{x2Exists:o,y2Exists:r,height:a,width:s,xData:c,x:l}=i;return{...t,xDomain:e.xDomain,x2Domain:e.x2Domain,yDomain:e.yDomain,y2Domain:e.y2Domain,xTicks:e.xTicks,x2Ticks:e.x2Ticks,yTicks:e.yTicks,y2Ticks:e.y2Ticks,xConfigScale:n.xConfigScale,x2ConfigScale:n.x2ConfigScale,yConfigScale:n.yConfigScale,y2ConfigScale:n.y2ConfigScale,defaultX2Config:e.defaultX2Config,defaultY2Config:e.defaultY2Config,yC:e.yC,showX:e.showX,showY:e.showY,x2Exists:o,y2Exists:r,height:a,width:s,xData:c,xScalePadding:l.padding?l.padding():0,barLabelCheck:e.barLabelCheck}}(n,S,g.plotConfigScales,{x2Exists:a,y2Exists:s,height:f,width:p,xData:c,x:M.x}),$),z=AD(t,e,A,n.xTest,f),D={...i,domains:g.plotDomains,shapeData:w,discreteKeys:g.plotDiscreteKeys,stackData:g.plotStackData,stackKeys:g.plotStackKeys,...M,xScale:_,yScale:v,...g.plotConfigScales,...S,...A,...n,height:f,width:p,opp:m,showLineLabels:C,...z};return t._paint(D)}function DD(t){const e=Object.create(t);return e._d3Scale=t._d3Scale?t._d3Scale.copy():null,e._d3ScaleNegative=t._d3ScaleNegative?t._d3ScaleNegative.copy():null,e.schema={...t.schema},e}function LD(t,e,n){const i=t.length;if(!i)return[];const o=[0];for(let t=1;t<i;t++)o.push(o[t-1]+(e[t-1]+e[t])/2);const r=(t,e)=>o[e]-o[t.start],a=e=>{let n=0;for(let i=e.start;i<=e.end;i++)n+=t[i]-r(e,i);return n/(e.end-e.start+1)},s=[];for(let n=0;n<i;n++){let i={start:n,end:n,top:t[n]};for(;;){const t=s[s.length-1];if(!t)break;const n=t.top+r(t,t.end),o=(e[t.end]+e[i.start])/2;if(i.top>=n+o)break;s.pop(),i={start:t.start,end:i.end,top:0},i.top=a(i)}s.push(i)}const c=[];for(const t of s)for(let e=t.start;e<=t.end;e++)c.push(t.top+r(t,e));const[l,h]=[Math.min(...n),Math.max(...n)];c[0]=Math.max(c[0],l);for(let t=1;t<i;t++)c[t]=Math.max(c[t],c[t-1]+(e[t-1]+e[t])/2);c[i-1]=Math.min(c[i-1],h);for(let t=i-2;t>=0;t--)c[t]=Math.min(c[t],c[t+1]-(e[t]+e[t+1])/2);c[0]=Math.max(c[0],l);for(let t=1;t<i;t++)c[t]=Math.max(c[t],c[t-1]+(e[t-1]+e[t])/2);return c}function FD(t,e,n){return e?(d.groups(e,t=>t.side??"end",t=>t.xValue).forEach(([,e])=>e.forEach(([,e])=>function(t,e,n){const i=e.map(e=>(e.defaultY||(e.defaultY=t._yAxis._getPosition(e.value)),e)).sort((t,e)=>t.defaultY-e.defaultY),o=LD(i.map(t=>t.defaultY),i.map(t=>1.2*t.fontSize),n),r=Math.max(...n)+.5,a=o.filter(t=>t<=r).length;i.forEach((t,e)=>{if(a<i.length&&e>=a-1){if(e!==a-1)return void(t.hidden=!0);t.collapsed=i.length-e}Math.abs(o[e]-t.defaultY)>.5&&(t.newY=o[e])})}(t,e,n))),e.reduce((t,e)=>(e.newY&&(t[Nx(e.side,e.id)]=e.newY),t),{})):{}}function ND(t,e){const n=e.filter(t=>void 0!==t.newY&&!t.hidden);if(!n.length)return[];const i=n.map(e=>r.assign({x:t._xAxis._getPosition.bind(t._xAxis)(e.xValue),y:e.defaultY},e)).concat(n.map(e=>r.assign({x:"start"===e.side?t._xAxis._getPosition.bind(t._xAxis)(e.xValue)-e.padding+1:t._xAxis._getPosition.bind(t._xAxis)(e.xValue)+e.padding-1,y:e.newY||e.defaultY},e))),o=Pg("Line").config({data:i,id:t=>"start"===t.side?Nx("start",t.id):t.id,stroke:t=>t.fontColor,x:t=>t.x,y:t=>t.y}).config(t._labelConnectorConfig).renderMode("compute");return o.render(),Gg(o)}const BD={domainTicks:!0,fixedSize:void 0};const ED=t=>!!t._labelRotation&&t._labelAngle;const RD=([t,e])=>[t,Math.max(t,e)];function PD(t,e,n){const{labelWidths:i}=e,o=hD(t,e,n);e=o.pCtx;const{x2Height:r,horizontalMargin:a}=e;let s=o.yRange;const{insetBottom:c,yBottom:l}=o,{yBounds:h,yWidth:u,y2Bounds:f,y2Width:m,xOffsetLeft:p,xOffsetRight:g}=o.solved,y=n?.xRange??RD([p,e.width-(g+a)]),x=function(t,e,n,i){const{x2Height:o,topOffset:r}=e,a={x:t._margin.left,y:t._margin.top+o+r};t._chartTransform=a;const s=i,c=Math.max(0,n-s-(e.startLabelSpace??0))||0,l={x:{x:t._margin.left,y:t._margin.top+o+r},x2:{x:t._margin.left,y:t._margin.top+r},y:{x:t._margin.left+c,y:t._margin.top+r},y2:{x:t._margin.left-e.horizontalMargin,y:t._margin.top+r}};return t=>({x:l[t].x-a.x,y:l[t].y-a.y})}(t,e,p,u),b=[],k=(n?.yRange??s)[1]+c-r,_=function(t,e,n,i,o,r){const{xDomain:a,x2Domain:s,xConfigScale:c,x2ConfigScale:l}=e,{defaultX2Config:h,showX:u,x2Exists:d,xC:f}=e,{xTicks:m,x2Ticks:p,x2Height:g,topOffset:y,height:x,width:b,verticalMargin:k}=e,_=t._xAxis,v=t._x2Axis,w=wx(t,"x");_.renderMode("compute").select(null).domain(a).height(x-(g+y+k)).maxSize(x/2).range(n).ticks(m).width(b).labelRotation(ED(e.xTest)).config({...BD,...f}).config(w).config(e.zoomAxes?.x??{}).scale(c),Ni(_,f,w),Fi(_,x);const M=Boolean(e.xLabelMode&&"axis"!==e.xLabelMode);M&&bD(_,r),_.render(),u&&o.push({key:"plot-x-axis",transform:i("x"),axis:_,gridOnly:M}),d&&(v.renderMode("compute").select(null).domain(s).height(x-(e.xHeight+y+k)).range(n).ticks(p).width(b).labelRotation(ED(e.x2Test)).config({...BD,...f}).config(h).config(t._x2Config).config(e.zoomAxes?.x2??{}).scale(l),Fi(v,x).render(),o.push({key:"plot-x2-axis",transform:i("x2"),axis:v}));const S=DD(_),C=DD(v),$=(t,e)=>"x2"===e?("log"===l&&0===t&&(t=C._givenDomain()[s[0]<0?1:0]),C._getPosition(t)):("log"===c&&0===t&&(t=S._givenDomain()[a[0]<0?1:0]),S._getPosition(t));return t._xFunc=$,$}(t,e,y,x,b,k),v="ends"===e.xLabelMode?xD(t._xAxis,y,k):[];s=n?.yRange??RD([t._xAxis.outerBounds().y+r,l-c]);const w=function(t,e,n,i,o,r,a,s){const{yDomain:c,y2Domain:l,yConfigScale:h,y2ConfigScale:u}=e,{defaultY2Config:f,showY:m,y2Exists:p,yC:g}=e,{yTicks:y,x2Height:x,height:b,width:k}=e,_=t._yAxis,v=t._y2Axis,w=wx(t,"y");_.renderMode("compute").select(null).domain(c).height(b).maxSize(k/2).range(i).ticks(y).width(n[n.length-1]).config({...BD,...g}).config(w).config(e.zoomAxes?.y??{}).scale(h),Ni(_,g,w),Fi(_,k).render(),m&&s.push({key:"plot-y-axis",transform:a("y"),axis:_}),p&&(v.renderMode("compute").select(null).config({...BD,...g}).domain(p?l:c).gridSize(0).height(b).range(i).width(k-d.max([0,o-r])).title(!1).config(t._y2Config).config(f).config(e.zoomAxes?.y2??{}).scale(u),Fi(v,k).render(),s.push({key:"plot-y2-axis",transform:a("y2"),axis:v}));const M=DD(_),S=DD(v),C=(t,e)=>"y2"===e?("log"===u&&0===t&&(t=l[1]<0?S._givenDomain(!0)[0]:S._givenDomain()[1]),S._getPosition(t)-x):("log"===h&&0===t&&(t=c[1]<0?M._givenDomain(!0)[0]:M._givenDomain()[1]),M._getPosition(t)-x);return t._yFunc=C,C}(t,e,y,s,g,m,x,b),M=FD(t,i,s);let S=t._xAxis.barConfig()["stroke-width"];return S&&(S/=2),{x:_,y:w,xRange:y,yRange:s,xOffsetLeft:p,xOffsetRight:g,yWidth:u,y2Width:m,yBounds:h,y2Bounds:f,axisSceneQueue:b,yOffset:S||0,labelPositions:M,xEndLabels:v,insetBottom:c}}const TD=t=>"text"===t.type||"htmlOverlay"===t.type,OD="plot-break-mask";function WD(t,e){return["y","x"].flatMap(n=>{const i=t[`_${n}Axis`];if(!i||!i._breaks||!i._breaks.length)return[];const o="y"===n,r=o?e.x2Height:0,a=(o?e.xRange:e.yRange.map(t=>t-e.x2Height)).slice(0,2).sort((t,e)=>t-e);return i._breaks.map(t=>({axis:i,brk:t,vertical:o,gap:co(i,t).map(t=>t-r),extent:a}))})}const jD=t=>t.baseline?"baselineBreakConfig":"breakConfig";function HD(t,e){return{...Fr(t,t.schema.barConfig),...Fr(t,(t.schema[jD(e)]||{}).lineConfig||{})}}function ID(t,e){return WD(t,e).flatMap(({axis:t,brk:e,vertical:n,gap:i,extent:o},r)=>{if(!eo(t,jD(e)).lines)return[];const a=HD(t,e),s=`break-line-${n?"y":"x"}-${r}`;return i.map((t,e)=>({type:"line",key:`${s}-${e}`,points:n?[[o[0],t],[o[1],t]]:[[t,o[0]],[t,o[1]]],paint:a,interactive:!1,interactionGroup:"axis"}))})}const GD=t=>t.reduce((e,[n,i],o)=>{const[r,a]=t[(o+1)%t.length];return e+n*a-r*i},0)/2;function qD(t,e){const n=Math.sign(GD(t));return[t,...e.map(t=>Math.sign(GD(t))===n?t.slice().reverse():t)].map(t=>`M${t.map(([t,e])=>`${t},${e}`).join("L")}Z`).join("")}function VD(t,e,n,i=0){const o=t[0]+i,r=t[1]-i,[a,s]=e;return n?[[a,o],[s,o],[s,r],[a,r]]:[[o,a],[r,a],[r,s],[o,s]]}function KD(t,e,n){const i=[[-1e6,-1e6],[1e6,-1e6],[1e6,1e6],[-1e6,1e6]],o=WD(t,n),r=[!0,!1].flatMap(t=>{const e=o.filter(e=>e.vertical===t&&e.brk.mask).map(({axis:e,brk:n,gap:i,extent:o})=>{const r=eo(e,jD(n)).lines?(HD(e,n).strokeWidth??1)/2:0;return VD(i,o,t,r)});return e.length?[{axis:t?"y":"x",d:qD(i,e)}]:[]});if(!r.length)return e;const a=[];let s=[],c=0;const l=()=>{if(!s.length)return;const t=c++?"-"+(c-1):"",e=r.reduce((e,{axis:n,d:i})=>[{type:"group",key:`${OD}-${n}${t}`,clip:{type:"path",d:i},children:e}],s);a.push(...e),s=[]};for(const t of e)TD(t)?(l(),a.push(t)):s.push(t);return l(),a}const YD=t=>"group"===t.type&&String(t.key).startsWith(OD);function UD(t){return t.some(YD)?t.flatMap(t=>YD(t)?UD(t.children):[t]):t}const XD="plot-domain-clip",QD=t=>String(t.key).endsWith("::hit"),ZD=t=>"text"===t.type||"htmlOverlay"===t.type||"axis"===t.interactionGroup,JD=t=>"circle"===t.type;function tL(t){const e=t.paint;if(!e||!e.stroke||"none"===e.stroke||"transparent"===e.stroke)return 0;const n=Number(e.strokeWidth??1);return Number.isFinite(n)&&n>0?n/2:0}function eL(t){return t.reduce((t,e)=>Math.max(t,function(t){if(QD(t))return 0;if("group"===t.type)return eL(t.children);const e=Math.abs(t.transform?.scale??1);return("circle"===t.type?t.r+tL(t):tL(t))*e}(e)),0)}function nL(t,e,n=[]){if(QD(t))return!1;const i=t.transform?[t.transform,...n]:n;return"group"===t.type?t.children.some(t=>nL(t,e,i)):function(t){switch(t.type){case"circle":return[[t.cx,t.cy]];case"rect":case"image":return[[t.x,t.y],[t.x+t.width,t.y+t.height]];case"path":{const e=u.pathBounds(t.d);return[[e.x,e.y],[e.x+e.width,e.y+e.height]]}case"line":return t.points;case"area":return[...t.topline,...t.baseline];default:return[]}}(t).some(t=>{const[n,o]=i.reduce((t,e)=>qc(t,e),t);return Number.isFinite(n)&&Number.isFinite(o)&&(n<e.x0||n>e.x1||o<e.y0||o>e.y1)})}const iL=(t,e,n=0)=>({x0:t.x0-e,y0:t.y0-e-n,x1:t.x1+e,y1:t.y1+e+n});function oL(t,e){const n=function(t){const e=t.xRange.slice(0,2).map(Number),n=t.yRange.slice(0,2).map(e=>Number(e)-t.x2Height);return{x0:Math.min(...e),y0:Math.min(...n),x1:Math.max(...e),y1:Math.max(...n)}}(e);if(![n.x0,n.y0,n.x1,n.y1].every(Number.isFinite))return t;const i=iL(n,1,e.yOffset??0),o=[];let r=[],a=0,s=!1;const c=()=>{if(!r.length)return;const t=`${XD}-${a++}`;if(r.some(t=>nL(t,i))){const e=iL(n,eL(r)),i=r.map(t=>t.z).filter(t=>"number"==typeof t);o.push({type:"group",key:t,clip:{type:"rect",x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0},children:r,...i.length?{z:Math.min(...i)}:{}}),s=!0}else o.push(...r);r=[]};for(const e of t)ZD(e)?(c(),o.push(e)):(r.length&&JD(r[0])!==JD(e)&&c(),r.push(e));return c(),s?o:t}const rL=new RegExp(`(^|/)${XD}-\\d+$`),aL=t=>"group"===t.type&&rL.test(String(t.key));function sL(t){return t.some(aL)?t.flatMap(t=>"group"===t.type&&aL(t)?t.children:[t]):t}function cL(t,e,n,i){return{x:t[0]+n-e.width/2,y:t[1]+i-e.height/2,width:e.width,height:e.height}}const lL=(t,e,n,i)=>Math.max(n,Math.min(t,i-e));function hL(t,e){return{...t,x:lL(t.x,t.width,e.x0,e.x1),y:lL(t.y,t.height,e.y0,e.y1)}}function uL(t,e,n=0){const i=t.x+t.width/2,o=t.y+t.height/2,r=e[0]-i,a=e[1]-o,s=r?t.width/2/Math.abs(r):1/0,c=a?t.height/2/Math.abs(a):1/0,l=Math.min(s,c);if(!(l<1))return null;const h=[i+r*l,o+a*l],u=Math.hypot(e[0]-h[0],e[1]-h[1]),d=Math.min(Math.max(n,0),u),f=u?d/u:0,m=[e[0]-(e[0]-h[0])*f,e[1]-(e[1]-h[1])*f];return Math.hypot(m[0]-h[0],m[1]-h[1])<1?null:{from:h,to:m}}function dL(t,e,n){const i=Math.hypot(e[0]-t[0],e[1]-t[1])||1,o=(e[0]-t[0])/i,r=(e[1]-t[1])/i,a=e[0]-o*n,s=e[1]-r*n,c=n/2;return[e,[a-r*c,s+o*c],[a+r*c,s-o*c]]}function fL(t,e,n){const i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(!i)return e;const o=Math.min(n,i)/i;return[e[0]-(e[0]-t[0])*o,e[1]-(e[1]-t[1])*o]}const mL=(t,[e,n])=>e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height;function pL(t,e,[n,i],o,r=!0){const a=cL(t,e,n,i);if(!r)return a;const s=hL(a,o);if(!mL(s,t)||mL(a,t))return s;const c=hL(cL(t,e,-n,-i),o);return mL(c,t)?s:c}const gL=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,yL=t=>!1===t||"none"===t;function xL(t,e,n){return i=>{const o=t[i];return"function"==typeof o?o(e,n):void 0!==e[i]?e[i]:o}}function bL(t,e,n,i){const o=xL(e,i.d,i.i),r=C$(n,i.d,e.xRef,e.yRef);if(!r.every(Number.isFinite)||!S$(r,n.plot))return[];const a=o("label");if(null==a||!1===a||""===a)return[];const s=L$(t,o),c=F$(`${a}`,s);if(!c.lines.length)return[];const l=Math.max(0,gL(o("padding"),6)),h=pL(r,{width:c.width+2*l,height:c.height+2*l},[gL(o("dx"),0),gL(o("dy"),-40)],n.plot,!1!==o("clamp")),u=o("textAlign")||"middle",d="start"===u?h.x+l:"end"===u?h.x+h.width-l:h.x+h.width/2,f=s.fontColor,m=function(t,e,n,i,o){if(!1===t("connector"))return[];const r=uL(e,n,gL(t("standoff"),0));if(!r)return[];const a=t("connectorStroke")||o,s=gL(t("connectorStrokeOpacity"),1),c=t("marker")??"arrow",l=Math.max(0,gL(t("markerSize"),6)),h=gL(t("connectorStrokeWidth"),1),u=[],d="arrow"===c&&l?fL(r.from,r.to,l):r.to,f={fill:"none",stroke:a,strokeWidth:h,strokeOpacity:s},m=Vr(t("connectorStrokeDasharray"));if(m&&(f.strokeDasharray=m),u.push({type:"line",key:`${i}-connector`,interactive:!1,points:[r.from,d],curve:"linear",paint:f}),"arrow"===c&&l){const[t,e,n]=dL(r.from,r.to,l);u.push({type:"path",key:`${i}-marker`,interactive:!1,d:`M${t[0]},${t[1]}L${e[0]},${e[1]}L${n[0]},${n[1]}Z`,paint:{fill:a,opacity:s}})}else"dot"===c&&l&&u.push({type:"circle",key:`${i}-marker`,interactive:!1,cx:r.to[0],cy:r.to[1],r:l/2,paint:{fill:a,opacity:s}});return u}(o,h,r,i.key,f),p=function(t,e,n,i,o){const r=e("fill"),a=e("stroke");if(yL(r)&&yL(a))return null;const s=yL(r)?{fill:"none"}:{fill:r||Tc(t),fillOpacity:gL(e("fillOpacity"),1)};return yL(a)||(s.stroke=a||o,s.strokeWidth=gL(e("strokeWidth"),1),s.strokeOpacity=gL(e("strokeOpacity"),.25)),{type:"rect",key:i,interactive:!1,...n,rx:gL(e("rx"),3),paint:s}}(t,o,h,`${i.key}-box`,f);return p&&m.push(p),m.push(N$(c,s,{key:`${i.key}-label`,x:d,y:h.y+l,align:u})),m}function kL(t,e,n,i){return(Array.isArray(e.data)?e.data:[]).flatMap((o,r)=>bL(t,e,n,{d:o,i:r,key:`${i}-${r}`}))}function _L(t){const e=t=>{t.interactive=!1;const n=t.children;if(n)for(const t of n)e(t)};return t.forEach(e),t}function vL(t,e){const n=[];try{const e=t.toScene();e&&Array.isArray(e.children)&&e.children.length&&n.push(e);const i=t._labelClass;if(i&&"function"==typeof i.toScene){const t=i.toScene();t&&Array.isArray(t.children)&&t.children.length&&n.push(t)}}catch{return null}if(!n.length)return null;const i={type:"group",key:e,children:n};return _L([i]),i}function wL(t,e,n,i,o,r){const a=Object.assign({},e);delete a.shape,delete a.layer;const s=Pg(e.shape).renderMode("compute").duration(Jt(t)).config(a).config(Nt({x:t=>t.x2?n(t.x2,"x2"):n(t.x),x0:"x"===t.schema.discrete?t=>t.x2?n(t.x2,"x2"):n(t.x):n(o.x[0]),x1:"x"===t.schema.discrete?null:t=>t.x2?n(t.x2,"x2"):n(t.x),y:t=>t.y2?i(t.y2,"y2"):i(t.y),y0:"y"===t.schema.discrete?t=>t.y2?i(t.y2,"y2"):i(t.y):i(o.y[1])-r,y1:"y"===t.schema.discrete?null:t=>t.y2?i(t.y2,"y2"):i(t.y)-r}));return s.render(),s}const ML={Callout:kL,[j$]:iA,[W$]:nA};function SL(t){return t.layer||("Callout"===t.shape?"front":"back")}function CL(t){const e=t._annotations||[];return[...V$(t.schema.referenceBands),...q$(t.schema.referenceLines),...e.filter(t=>!!t&&"string"==typeof t.shape)]}function $L(t,e,n,i,o){const{x:r,y:a,frame:s}=n,c=[],l=CL(t);return Object.keys(t._previousAnnotations).forEach(n=>{const h=l.filter(t=>SL(t)===n);h.forEach((l,h)=>{const u=`annotation-${n}-${h}`,d=ML[l.shape];if(!d){const s=vL(wL(t,l,r,a,i,o),u);return void(s&&("front"===n?c:e).push(s))}const f=d(t,l,s,u),m="back"===n&&"Callout"!==l.shape,p=AL(m?f.filter(t=>"text"!==t.type):f,u);p&&("front"===n?c:e).push(p);const g=m&&AL(f.filter(t=>"text"===t.type),`${u}-labels`);g&&c.push(g)});const u=h.map(t=>t.shape).filter(t=>!ML[t]);t._previousAnnotations[n].filter(t=>!u.includes(t)).forEach(t=>{Pg(t).renderMode("compute").data([]).render()}),t._previousAnnotations[n]=u}),c}function AL(t,e){if(!t.length)return null;const n={type:"group",key:e,children:t};return _L([n]),n}const zL=(t,e,n)=>"function"==typeof t?t(e,n):t;function DL(t,e,n){if(n.labelBounds)return null;const{viz:i,values:o}=t,r=e.schema,a=r.labelConfig,s=o.map((t,e)=>{const n=t,i=Number(r.r(t,e));return{key:t,datum:n.data??t,index:"number"==typeof n.i?n.i:e,x:Number(r.x(t,e)),y:Number(r.y(t,e)),r:i,text:r.label(t,e),inside:{width:2*i,height:2*i,shape:"circle",padding:zL(a.padding,t,e),font:{family:zL(a.fontFamily,t,e),weight:zL(a.fontWeight,t,e)}}}}),c=Ew(i,s,function(t){const e=t.xRange.slice(0,2).map(Number),n=t.yRange.slice(0,2).map(e=>Number(e)-(t.x2Height??0)),i=Math.min(...e),o=Math.min(...n);return{x:i,y:o,width:Math.max(...e)-i,height:Math.max(...n)-o}}(t));if(!c.size)return null;const l=r.labelBounds,h=a.fontMin;r.labelBounds=function(t,e,n){const i=c.get(t);return i&&"inside"!==i.position?null:l.call(this,t,e,n)},e.config({labelConfig:{fontMin:(t,e)=>Ow(i,c.get(t.data),zL(h,t,e)??8)}});const u=new Map(o.map((t,e)=>[t,e])),d=Tw(c,t=>({id:`${zL(r.id,t,u.get(t)??0)}`,datum:t}));return()=>Pw(i,d,{fontOpacity:a.fontOpacity})}function LL(t){let e=-1/0;for(const n of t)"number"==typeof n.z&&(e=Math.max(e,n.z));return e===-1/0?t:t.map(t=>"text"===t.type?{...t,z:e+1}:t)}const FL=["bandOpacity","capWidth","tooltip"];function NL(t){const{viz:e,x:n,y:i,values:o}=t,a=KC(e);if(!a.length)return[];const s=e.schema.discrete||"x",c="x"===s?"y":"x",l="x"===s?i:n,h=Object.assign({},e.schema.shapeConfig,e._confidenceConfig),u=r.assign(Hg(e,"Line",h),Hg(e,"Area",h));FL.forEach(t=>delete u[t]);const d=a.length>1,f=d?XC(UC(e._confidenceConfig?.bandOpacity,a.length)):[],m=[];return a.forEach((e,n)=>{const i=(t,e,n)=>l(t?QC(t(e.data,e.i),n):n),r=Nt(Object.assign({},t.shapeConfig));r[`${c}0`]=t=>i(e.lower,t,t[c]),r[`${c}1`]=t=>i(e.upper,t,t[c]),n&&(r.id=t=>`${t.id}::band-${n}`);const a=Pg("Area").renderMode("compute").config(r).data(o);a.config(u),d&&a.config({fillOpacity:f[n]}),a.render(),m.push(...Gg(a))}),m}function BL(t,e,n,i){const{viz:o}=t;if(e.hidden)return!1;if(e.collapsed)return`+${p.formatAbbreviate(e.collapsed,o.schema.locale)} ${o.schema.translate("more")}`;const r=void 0!==e.name?e.name:void 0===t.name||null===t.name?o._drawLabel(n,i):"function"==typeof t.name?t.name(n,i):t.name;return void 0===e.valueText?r:Fx(r,e.valueText)}function EL(t,e,n){const{viz:i,labelWidths:o}=t;if(!Dx(i.schema.lineLabels,e.data,e.i).length)return[];const r=[];for(const i of["start","end"]){const a=o.find(t=>t.id===e.id&&(t.side??"end")===i);if(!a)continue;const s=BL(t,a,e,n);!1!==s&&r.push({side:i,text:s,measure:a})}return r}function RL(t,e,n,i,o){const[r,a]=t[0],[s,c]=t.reduce((t,n)=>"end"===e?n[0]>=t[0]?n:t:n[0]<t[0]?n:t),l=i/4;return{x:s-r-("start"===e?n:0),y:c-a-l/2-(o?c-o:0),width:n,height:l}}function PL(t){const{viz:e,labelWidths:n,largestLabel:i,labelPositions:o}=t,r=d.max(n.filter(t=>"start"===t.side),t=>t.labelWidth)??0,a=new Map,s=t=>1===t.length?t[0]:t;return{label:(e,n)=>{const i=EL(t,e,n);return a.set(e.id,i.map(t=>t.side)),!!i.length&&s(i.map(t=>t.text))},labelBounds:(n,a,c)=>s(EL(t,n,a).map(({side:t})=>RL(c.points,t,"start"===t?r:i,e.schema.height,o[Nx(t,n.id)]))),textAnchor:t=>(e,n)=>{const i=void 0===e.l?e.data:e,o=i?.data?.id;return"start"===a.get(o)?.[i?.l]?"end":"function"==typeof t?t(e,n):t}}}const TL=[2,4];function OL(t){if(!1===t)return{bridge:null};if("dashed"===t)return{bridge:{strokeDasharray:TL,opacity:1}};if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,n=void 0===e.strokeDasharray?TL:!1===e.strokeDasharray?void 0:Vr(Array.isArray(e.strokeDasharray)?e.strokeDasharray.join(" "):e.strokeDasharray),i={opacity:"number"==typeof e.opacity&&Number.isFinite(e.opacity)?e.opacity:1};return n&&n.some(t=>t>0)&&(i.strokeDasharray=n),"string"==typeof e.stroke&&e.stroke&&(i.stroke=e.stroke),"number"==typeof e.strokeWidth&&(i.strokeWidth=e.strokeWidth),{bridge:i}}function WL(t,e){const n=Array.from(new Set(e.filter(Number.isFinite))).sort((t,e)=>t-e),i=[];for(let e=0;e<t.length-1;e++){const o=Math.min(t[e],t[e+1]),r=Math.max(t[e],t[e+1]);if(!Number.isFinite(o)||!Number.isFinite(r))continue;let a=0,s=n.length;for(;a<s;){const t=a+s>>1;n[t]<=o?a=t+1:s=t}a<n.length&&n[a]<r&&i.push(e)}return i}function jL(t,e,n){const i=[0];for(let e=1;e<t.length;e++)i.push(i[e-1]+Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]));const o=i[i.length-1]??0;let r=0;return{at:n.map(n=>{for(;r<t.length-1;r++){const o=t[r][e],a=t[r+1][e];if(o===n)return i[r];if((o-n)*(a-n)<0){const t=(n-o)/(a-o);return i[r]+t*(i[r+1]-i[r])}}return o}),total:o}}function HL(t,e,n){if(!(n>e))return[];const i=t&&t.length%2?t.concat(t):t,o=i?i.reduce((t,e)=>t+e,0):0;if(!(i&&o>0&&i.some((t,e)=>!(e%2)&&t>0)))return[[e,n]];const r=[];let a=e;for(let t=0;a<n;t=(t+1)%i.length){const e=Math.min(n,a+i[t]);!(t%2)&&e>a&&r.push([a,e]),a=e}return r}function IL(t,e){const n=[];let i=0,o=0;for(;i<t.length&&o<e.length;){const r=Math.max(t[i][0],e[o][0]),a=Math.min(t[i][1],e[o][1]);a>r&&n.push([r,a]),t[i][1]<e[o][1]?i++:o++}return n}function GL(t,e){const n=[];let i=0;return t.forEach(([t,e])=>{t>i&&n.push([i,t]),i=Math.max(i,e)}),e>i&&n.push([i,e]),n}function qL(t,e){const n=t=>+Math.max(0,t).toFixed(2),i=[];let o=0;return t.forEach(([t,e],r)=>{r?i.push(n(t-o)):n(t)>0&&i.push(0,n(t)),i.push(n(e-t)),o=e}),i.length?(i.push(n(e-o)+n(e)+1),i):[0,n(e)+1]}function VL(t,e,n,i,o=3){const r=new Set(e),a=[[]];t.forEach((e,n)=>{a[a.length-1].push(e),r.has(n)&&n<t.length-1&&a.push([])});const s=b.line().curve(yC(n));return a.map(t=>{if(t.length>1)return s(t)||"";const[e,n]=t[0];return i?`M${e},${n-o}L${e},${n+o}`:`M${e-o},${n}L${e+o},${n}`}).join("")}function KL(t,e){if(!t)return[];const n=[];let i=0;return[...e].sort((t,e)=>t-e).forEach(e=>{e<i||e>=t-1||(n.push([i,e]),i=e+1)}),n.push([i,t-1]),n}function YL(t,e,n=16){const i=[];let o=0,r=0;const a=(t,e)=>{i.push([t,e]),o=t,r=e},s={moveTo:a,lineTo:a,closePath:()=>{},bezierCurveTo(t,e,a,s,c,l){const h=o,u=r;for(let o=1;o<=n;o++){const r=o/n,d=1-r,f=d*d*d,m=3*d*d*r,p=3*d*r*r,g=r*r*r;i.push([f*h+m*t+p*a+g*c,f*u+m*e+p*s+g*l])}o=c,r=l},quadraticCurveTo(t,e,a,s){const c=o,l=r;for(let o=1;o<=n;o++){const r=o/n,h=1-r;i.push([h*h*c+2*h*r*t+r*r*a,h*h*l+2*h*r*e+r*r*s])}o=a,r=s}};return b.line().curve(yC(e)).context(s)(t),i}function UL(t,e,n){let i,o=0;if(t.length){const o=Math.sign(t[t.length-1][e]-t[0][e])||1;(t[0][e]-n)*o>=0&&(i=0)}for(let r=1;r<t.length;r++){const a=t[r-1],s=t[r],c=Math.hypot(s[0]-a[0],s[1]-a[1]);void 0===i&&(a[e]-n)*(s[e]-n)<=0&&s[e]!==a[e]&&(i=o+c*((n-a[e])/(s[e]-a[e]))),o+=c}return[i??o,o]}function XL(t,e,n){const i=n.length%2?n.concat(n):n,o=i.reduce((t,e)=>t+e,0);if(!(o>0)||t>=e)return;const r=[+t.toFixed(2),0];for(let n=0;n<e-t;n+=o)r.push(...i);return r}const QL=1e5;function ZL(t){const{viz:e,values:n}=t,i=OL(e.schema.connectGaps);if(!i||!n.length)return null;const o=n,r=t.missingRows??[],a="y"===e.schema.discrete?"y":"x",s="y"===a?1:0,c=FC([...o.map(t=>t[a]),...r.map(t=>t[a])]),l=o.map(t=>c(t[a])),h=new Map;r.forEach(t=>{const e=`${t.id}`;h.has(e)||h.set(e,[]),h.get(e).push(c(t[a]))});const u=new Map;o.forEach(t=>{const e=`${t.id}`;u.has(e)||u.set(e,[]),u.get(e).push(t)});const d=t.shapeConfig.x,f=t.shapeConfig.y,m=xC(e,o[0]),p=new Map;return u.forEach((t,e)=>{const n=WL(t.map(t=>c(t[a])),l.concat(h.get(e)??[]));if(!n.length)return;const i=t.map(t=>[d(t),f(t)]),{at:o,total:r}=jL(YL(i,m),s,i.map(t=>t[s])),u=n.map(t=>[o[t],o[t+1]]);p.set(e,{points:i,gaps:n,gapIntervals:u,total:r})}),p.size?{series:p,bridge:i.bridge,curve:m,axis:s}:null}function JL(t){const e=t.interactionPoints?.[0]?.datum;return e?`${e.id}`:void 0}function tF(t,e){const n=GL(e.gapIntervals,e.total);return qL(IL(HL(t,0,e.total),n),e.total)}function eF(t,e,n){const i=t.paint??{},o=qL(e.gapIntervals.flatMap(([t,e])=>HL(n.strokeDasharray,t,e)),e.total);return{...t,key:`${t.key}::gap`,interactive:!1,interactionPoints:void 0,aria:{hidden:!0},paint:{...i,stroke:n.stroke??i.stroke,strokeWidth:n.strokeWidth??i.strokeWidth,strokeDasharray:o,opacity:(i.opacity??1)*n.opacity}}}function nF(t,e){return t.flatMap(t=>{if("path"!==t.type||"Line"!==t.shapeType)return[t];const n=JL(t),i=void 0===n?void 0:e.series.get(n);if(!i)return[t];const o=t.transform?.x??0,r=t.transform?.y??0;if(String(t.key).endsWith("::hit")){const n=i.points.map(([t,e])=>[t-o,e-r]);return[{...t,d:VL(n,i.gaps,e.curve,e.axis)}]}const a=Vr(t.paint?.strokeDasharray),s={...t,paint:{...t.paint,strokeDasharray:tF(a,i)}};return e.bridge?[s,eF(t,i,e.bridge)]:[s]})}function iF(t,e){const{points:n}=t,i=KL(n.length,t.gaps),o=n[n.length-1][e]>=n[0][e];return i.map(([t,r],a)=>{const s=n[t][e],c=n[r][e];let l=Math.min(s,c),h=Math.max(s,c);return!a&&o&&(l=-QL),a||o||(h=QL),a===i.length-1&&o&&(h=QL),a!==i.length-1||o||(l=-QL),e?`M-100000,${l}H100000V${h}H-100000Z`:`M${l},-100000H${h}V100000H${l}Z`}).join("")}function oF(t,e){return t.map(t=>{const n=JL(t),i=void 0===n?void 0:e.series.get(n);if(!i||"Area"!==t.shapeType)return t;return{type:"group",key:`${t.key}::gaps`,clip:{type:"path",d:iF(i,e.axis)},children:[t]}})}function rF(t,e,n,i){const o=t/2;if(e<2)return[-o,o];const r=2*i/(e-1),a=n*r-i;return[(n<=0?-o:a-r/2)-a,(n>=e-1?o:a+r/2)-a]}const aF=t=>"Bar"===t.shapeType&&String(t.key).endsWith("::hit");function sF(t,e){const n=t=>Sh(t),i=e.label(),o=e.labelBounds(),r=e.labelConfig(),a="number"==typeof r.padding?r.padding:0,s=r.verticalAlign;if("function"!=typeof o)return;const c=new WeakSet,l=(t,e)=>{const o=i(t,e);return!(!1===o||null==o||Array.isArray(o)||!Number.isFinite(n(t)))&&o};e.label((e,o)=>{const r=l(e,o);return!1===r?i(e,o):[r,`${p.formatAbbreviate(100*n(e),t.schema.locale)}%`]}),e.labelBounds((t,e,n)=>{const i=o(t,e,n);if(!i||Array.isArray(i)||!1===l(t,e))return i;const r=function(t,e){const n=Math.min(14,.4*(t.height-2*e));if(n<8)return null;const i=t.height-e-n;return[{...t,height:i+e},{...t,height:n+2*e,y:t.y+i-e}]}(i,a);return r?(c.add((t=>t.__d3plusShape__?t.data:t)(t)),r):[i,{...i,height:0,width:0}]}),e.labelConfig({verticalAlign:(t,e)=>!!t&&c.has(t.data)?1===t.l?"top":"bottom":"function"==typeof s?s(t,e):s})}function cF(t,e){return{start:a.cubicInOut(t/e),end:a.cubicInOut((t+1)/e)}}function lF(t,e){const{viz:n}=t;if(!n.schema.stacked||function(t){const e=t=>"rect"===t.type&&"Bar"===t.shapeType||"group"===t.type&&t.children.some(e);return!!t&&e(t.root)}(n._paintedScene))return e;const{levels:i,depth:o}=function(t,e){const{opp:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:r}=e,a=new Map;for(const e of t){const t=Number(e[n??"y"]),s=i[o.get(e.id)??-1],c=r.get(e.discrete);if(!t||!Number.isFinite(t)||!s||void 0===c)continue;const l=s.index??o.get(e.id),h=`${c}|${e.group}|${t<0?"-":"+"}`;a.has(h)||a.set(h,[]),a.get(h).push({row:e,order:l})}const s=new Map;let c=0;for(const t of a.values())t.sort((t,e)=>t.order-e.order),t.forEach(({row:t},e)=>s.set(t,e)),c=Math.max(c,t.length);return{levels:s,depth:c}}(t.values,t);if(o<2)return e;const r=new Map;for(const t of e){const e="Bar"===t.shapeType?i.get(t.datum):void 0;void 0!==e&&r.set(t.datum,cF(e,o))}return e.map(t=>{const e=t.datum,n=r.get(e)??r.get(e?.data);return n?{...t,enterWindow:n}:t})}function hF(t,e,n){return n?n.rotate?null:(t-(n[e]??0))/(n.scale??1):t}function uF(t,e,n){const i=(t,o)=>{if("group"===t.type){const n=n=>{const i=o(n);return null===i?null:hF(i,e,t.transform)};return void t.children.forEach(t=>i(t,n))}if("path"!==t.type)return;const r=n.get(`${t.key}`.replace(/::hit$/,""));if(void 0===r)return;const s=o(r),c=null===s?null:hF(s,e,t.transform);null!==c&&Number.isFinite(c)&&(t.enterD=a.flattenPath(t.d,e,c))};t.forEach(t=>i(t,t=>t))}function dF(t,e){t.forEach(t=>{if("group"===t.type)dF(t.children,e);else if("rect"===t.type){const{x:n,y:i,width:o,height:r}=t;t.enterRect="x"===e?{x:n+o/2,y:i,width:0,height:r}:{x:n,y:i+r/2,width:o,height:0}}})}const fF={start:.7,end:1};function mF(t){for(const e of t)"text"===e.type?e.enterWindow=fF:"group"===e.type&&mF(e.children);return t}function pF(t,e=[]){for(const n of t)"group"===n.type?pF(n.children,e):"path"===n.type&&"Area"===n.shapeType&&e.push(`${n.key}`);return e}function gF(t,e){const n=function(t){const{viz:e}=t,n="y"===e.schema.discrete?"x":"y",i=t.shapeConfig[`${n}0`];if(!e.schema.stacked&&"number"==typeof i&&Number.isFinite(i))return i;const o=("x"===n?t.xDomain:t.yDomain).map(Number),r=e.schema.baseline,a="number"==typeof r?r:0,s=Math.min(...o),c=Math.max(...o);if(!Number.isFinite(s)||!Number.isFinite(c))return null;const l=("x"===n?t.x:t.y)(Math.max(s,Math.min(c,a)));return Number.isFinite(l)?l:null}(t);if(null===n)return;const i="y"===t.viz.schema.discrete?"x":"y",o=pF(e);o.length&&(uF(e,i,new Map(o.map(t=>[t,n]))),mF(e))}const yF="plot-forecast",xF=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function bF(t,e,n){return"x"===(t.schema.discrete||"x")?e.x(n):e.y(n)}function kF(t,e,n){const i=t.schema.discrete||"x",o=FC(n.map(t=>t[i])),r=n.map(n=>({at:o(n[i]),px:bF(t,e,n[i])})).filter(t=>Number.isFinite(t.px)).sort((t,e)=>t.at-e.at);return r.length<2?1:r[r.length-1].px<r[0].px?-1:1}function _F(t,e,n,i,o){if(void 0===i.next)return NaN;const r=bF(t,e,i.next);if(!Number.isFinite(r))return NaN;const a=bF(t,e,i.value);if(Number.isFinite(a)&&Math.abs(a-r)>=.5)return(a+r)/2;const s=t.schema.discrete||"x",c=n.map(n=>bF(t,e,n[s])).filter(t=>Number.isFinite(t)),l=t=>c.filter(e=>(e-r)*o*t>.5).reduce((t,e)=>void 0===t||Math.abs(e-r)<Math.abs(t-r)?e:t,void 0),h=l(-1);if(void 0!==h)return(h+r)/2;const u=l(1);return void 0!==u?r-(u-r)/2:r}function vF(t,e,n,i=!1){const o=PC(t,e);if(!o||!e.length)return[];const a="x"===(t.schema.discrete||"x"),s=kF(t,n,e),c=i?_F(t,n,e,o,s):bF(t,n,o.value);if(!Number.isFinite(c))return[];const l=a?n.xRange:[0,n.yRange[1]-n.yRange[0]],h=a?[0,n.yRange[1]-n.yRange[0]]:n.xRange,u=Math.min(l[0],l[1]),d=Math.max(l[0],l[1]),f=s>0?d:u,m=Math.min(Math.max(c,u),d);if(Math.abs(f-m)<1)return[];const p=c>=u-.5&&c<=d+.5,g=t.schema.forecastConfig,y=function(t){return Oc(t)}(t),x=Math.min(m,f),b=Math.abs(f-m),k={type:"rect",key:`${yF}-region`,x:a?x:h[0],y:a?h[0]:x,width:a?b:h[1]-h[0],height:a?h[1]-h[0]:b,paint:{fill:g.fill||y,fillOpacity:xF(g.fillOpacity,.05)},interactive:!1},_=[];if(!1!==g.fill&&"none"!==g.fill&&_.push(k),_.push(...wF(g,k,y)),p&&!1!==g.stroke&&"none"!==g.stroke){const t={fill:"none",stroke:g.stroke||y,strokeWidth:xF(g.strokeWidth,1),strokeOpacity:xF(g.strokeOpacity,.4)},e=Vr(g.strokeDasharray);e&&(t.strokeDasharray=e),_.push({type:"line",key:`${yF}-rule`,points:a?[[m,h[0]],[m,h[1]]]:[[h[0],m],[h[1],m]],curve:"linear",paint:t,interactive:!1})}const v=p?function(t,e){const n=e.label;return!1===n||null===n||""===n?"":"function"==typeof n?`${n(t.schema.locale)}`:"string"==typeof n?n:t.schema.translate("Forecast")}(t,g):"";return v&&_.push(function(t,e,n,i){const o=xF(e.fontSize,12),a=e.fontFamily||`${t.schema.fontFamily}`,s=r.textWidth(n,{"font-family":a,"font-size":o}),c=5,l=i.dir>=0,h=i.horizontal?i.from+(l?c:-c):i.cross[0]+c,u=i.horizontal?i.cross[0]+c+o/2:i.from+(l?c+o/2:-c-o/2);return{type:"text",key:`${yF}-label`,interactive:!1,x:0,y:0,transform:{x:h,y:u},lines:[{text:n,x:0,y:0,width:s}],font:{family:a,size:o,weight:e.fontWeight??400,anchor:i.horizontal&&!l?"end":"start",baseline:"middle"},paint:{fill:e.fontColor||i.ink,opacity:xF(e.fontOpacity,.7)}}}(t,g,v,{from:m,dir:Math.sign(f-m),horizontal:a,cross:h,ink:y})),_.length?[{type:"group",key:yF,interactive:!1,children:_}]:[]}function wF(t,e,n){const i=[],o="string"==typeof t.fill&&"none"!==t.fill?t.fill:n,r=Pr(t.texture,()=>"transparent",()=>o,t.textureDefault||void 0);r&&i.push({...e,key:`${yF}-texture`,paint:{fill:`pattern:${r}`,opacity:xF(t.textureOpacity,.3)}});const a=t.backgroundImage,s="string"==typeof a&&WS({backgroundImage:a,backgroundImageFit:t.backgroundImageFit},{...e,paint:{}},void 0,0);return s&&i.push(s),i}function MF(t,e,n,i){const o=Vr(t.schema.forecastConfig.lineDasharray);if(!o||!o.some(t=>t>0))return null;const r=PC(t,e);if(!r||r.series&&!r.series.size)return null;const a="x"===(t.schema.discrete||"x")?0:1,s=n.x,c=n.y,l=xC(t,e[0]),h=new Map;return(n,u)=>{const d=`${e[u]?.id}`;if(!h.has(d)){const n=(e=>{const n=r.series?r.series.get(e):r.value;return void 0===n?NaN:bF(t,i,n)})(d);if(Number.isFinite(n)){const t=e.filter(t=>`${t.id}`===d).map(t=>[s(t),c(t)]),[i,r]=UL(YL(t,l),a,n);h.set(d,XL(i,r,o))}else h.set(d,void 0)}return h.get(d)}}function SF(t,e){return(n,i)=>{const o=t(n,i);return o||("function"==typeof e?e(n,i):e)}}function CF(t){const e=t.map(([t])=>t),n=t.flatMap(([,t])=>t);return{rows:n,slots:e.includes("Bar")&&!e.includes("Line")&&!e.includes("Area")}}function $F(t,e){const{viz:n,opp:i,x:o,y:r,stackData:a,domains:s,stackKeyIndex:c,discreteKeyIndex:l}=t,h=Nt(Object.assign({},t.shapeConfig));if("Circle"===e&&n._size){const t=n._size;h.sort=(e,n)=>(Number(t(n))||0)-(Number(t(e))||0)}if("Box"===e&&(h.id=t=>t.discrete),n.schema.stacked&&["Area","Bar"].includes(e)){const t="x"===i?o:r;h[`${i}`]=h[`${i}0`]=e=>{const n=c.get(e.id)??-1,o=l.get(e.discrete)??-1,r=e[i]<0?1:0;return t(n>=0?a[n][o][r]:s[i]["x"===i?0:1])},h[`${i}1`]=e=>{const n=c.get(e.id)??-1,o=l.get(e.discrete)??-1,r=e[i]<0?0:1;return t(n>=0?a[n][o][r]:s[i]["x"===i?0:1])}}return h}function AF(t,e,n,i){const{viz:o,events:r}=t;o._wirePlotShapeEvents(n,e,r);const a=Hg(o,e);void 0===o.schema.shapeConfig.duration&&delete a.duration,n.config(a),i&&n.config(i(a)),"Bar"===e&&t.barLabelsOnAxis&&n.label(!1),"Area"===e&&o.schema.stacked&&n.label(eb(o,n.label())),o.schema.stacked&&"Bar"===e&&sF(o,n);const s="Circle"===e?DL(t,n,a):null;n.render();const c=Gg(n);if("Circle"===e)return LL([...c,...s?.()??[]]);if("Area"===e&&gF(t,c),"Bar"!==e)return c;const l=wA(t,c);if(!l.length)return lF(t,c);let h=-1;return c.forEach((t,e)=>{"Bar"===t.shapeType&&(h=e)}),lF(t,[...c.slice(0,h+1),...l,...c.slice(h+1)])}const zF=(t,e)=>AF(t,e,Pg(e).renderMode("compute").config($F(t,e)).data(t.values));function DF(t){const{viz:e,values:n}=t,i=e.schema.discrete;if("Time"!==("x"===i?t.xScale:t.yScale))return n;const o=t.zoomRanges?.[i];if(o){const e="x"===i?t.x:t.y,[r,a]=d.extent(o);return n.filter(t=>{const n=e(t[i]);return n>=r-.5&&n<=a+.5})}const[r,a]=d.extent(("x"===i?t.xDomain:t.yDomain).map(Number));return n.filter(t=>{const e=+t[i];return e>=r&&e<=a})}function LF(t,e,n){const{viz:i}=t;i.schema.stacked||function(t,e,n,i){n&&t.config({hitArea:(o,r)=>function(t,e,n,i){const[o,r]=e,[a,s]=n;return"x"===t?{x:o,y:a-(i.y??0),width:r-o,height:s-a}:{x:a-(i.x??0),y:o,width:s-a,height:r-o}}(e,i(o,r),n,t._sceneTransform(o,r))})}(e,"y"===i.schema.discrete?"y":"x",t.valueExtent,n)}const FF={Bar:t=>{const e={...t,values:DF(t)},{viz:n,x:i,y:o,xScale:r,yScale:a,xDomain:s,yDomain:c,xRange:l,yRange:h,values:u,zoomRanges:f}=e,m=Pg("Bar").renderMode("compute").config(Ax($F(e,"Bar"),ux(n),e.valueExtent)).data(u),p="x"===n.schema.discrete?i:o;if(n._discreteExtent)return function(t,e,n){const{viz:i,values:o}=t,r=t=>{const[e,o]=WC(i,t);return Math.max(1,Math.abs(n(o)-n(e))-i._groupPadding)},a=t=>{const[e,o]=WC(i,t);return Math.abs(n(o)-n(e))},s=i.schema.discrete,c=i._barSpans?function(t,e){const n=new Map,i=new Set;let o=!1;for(const r of t){const t=Xy(r[e]),a=n.get(t)??new Set;a.add(r.group),n.set(t,a),i.add(r.group),a.size>1&&(o=!0)}return o?Array.from(i):[]}(o,s):[];if(c.length<2)return e.width(r),e.height(r),LF(t,e,t=>rF(a(t),1,0,0)),AF(t,"Bar",e);const l=t=>function(t,e,n,i){const o=Math.max(1,(t-i*e-1)/e);if(e<2)return{size:o,offset:0};const r=Math.max(0,t-o)/2;return{size:o,offset:n*r*2/(e-1)-r}}(r(t),c.length,c.indexOf(t.group),i.schema.barPadding),h=t.shapeConfig[s];return e[s]((t,e)=>h(t,e)+l(t).offset),e.width(t=>l(t).size),e.height(t=>l(t).size),LF(t,e,t=>rF(a(t),c.length,c.indexOf(t.group),Math.max(0,r(t)-l(t).size)/2)),AF(t,"Bar",e)}(e,m,p);let g;const y="x"===n.schema.discrete?r:a,x="x"===n.schema.discrete?s:c,b="x"===n.schema.discrete?l:h,k=f?.[n.schema.discrete];if("Point"!==y&&2===x.length){const t=Array.from(new Set(u.map(t=>p(t[n.schema.discrete]))));t[0]>t[t.length-1]&&t.reverse();const e=t[0],i=t[t.length-1];t.unshift(k?2*k[0]-e:b[0]-e-b[0]),t.push(k?2*k[1]-i:b[1]+b[1]-i),g=t.reduce((t,e,n,i)=>{if(n){const o=Math.abs(e-i[n-1]);o<t&&(t=o)}return t},1/0)}else g=x.length>1?Math.abs(p(x[1])-p(x[0])):b[b.length-1]-b[0];const _=g;n._groupPadding<g&&(g-=n._groupPadding);let v=g||1;const w=d.groups(u,t=>t[n.schema.discrete],t=>t.group),M=d.merge(w.map(([,t])=>t.map(([t])=>t))),S=Array.from(new Set(M)),C=n.schema.discrete,$=e.shapeConfig[C];let A=()=>rF(_,1,0,0);if(1===d.max(w.map(([,t])=>t.length)))m[C]((t,e)=>$(t,e));else{v=(v-n.schema.barPadding*S.length-1)/S.length;const t=g/2-v/2,e=E.scaleLinear().domain([0,S.length-1]).range([-t,t]);m[C]((t,n)=>$(t,n)+e(S.indexOf(t.group))),A=e=>rF(_,S.length,S.indexOf(e.group),t)}return m.width(v),m.height(v),LF(e,m,A),AF(e,"Bar",m)},Circle:(t,e)=>{if(!t.viz._swarm)return zF(t,e);const{viz:n,values:i,x:o,y:r,xRange:a,yRange:s}=t,c=Pg("Circle").renderMode("compute").config($F(t,"Circle")).data(i);return AF(t,"Circle",c,e=>{const c=e.r,l=u$(n,{values:i,x:o,y:r,xRange:a,yRange:s,lanes:"x"===n._swarm.cross?t.xDomain:t.yDomain,r:"function"==typeof c?c:()=>c}),h=t=>l.get(t);return{x:t=>h(t).x,y:t=>h(t).y,r:t=>h(t).r}})},Line:t=>{const{viz:e,values:n,width:i,showLineLabels:o,labelWidths:r,largestLabel:a,labelPositions:s}=t,c=[],l=Pg("Line").renderMode("compute").config($F(t,"Line")).data(n);e.schema.fillBetween&&c.push(...SC(t)),l.duration(1.5*i);const h=ZL(t);if(e._confidence){const e=NL(t);c.push(...h?oF(e,h):e)}const u={viz:e,labelWidths:r,largestLabel:a,labelPositions:s},d=o?PL(u):void 0;l.config({discrete:t.shapeConfig.discrete||"x",label:!!d&&d.label,labelBounds:!!d&&d.labelBounds});const f=MF(e,n,t.shapeConfig,t),m=d&&r.some(t=>"start"===t.side||t.valueText||void 0!==t.name)?t=>{const e=PL({...u,name:t.label});return{label:e.label,labelBounds:e.labelBounds,labelConfig:{textAnchor:e.textAnchor(l.labelConfig().textAnchor)}}}:void 0,p=AF(t,"Line",l,f||m?t=>({...f&&{strokeDasharray:SF(f,t.strokeDasharray)},...m?.(t)}):void 0);c.push(...h?nF(p,h):p);const g=e._lineMarkers?n:[],y=function(t,e){const n=new Map,i=new Map;for(const o of t){const t=e?`${o.id}_${o.discrete}`:`${o.id}_${o.x}_${o.y}`,r=n.get(t)??0;n.set(t,r+1),i.set(o,r?`${t}_${r}`:t)}return i}(g,e.schema.discrete),x=Pg("Circle").renderMode("compute").data(g).config(t.shapeConfig).config(e._lineMarkerConfig).id(t=>y.get(t));return e._wirePlotShapeEvents(x,"Circle",t.events),x.render(),c.push(...Gg(x)),c}};const NF=["group","order","confidence","confidenceLevel","confidenceConfig","projection","projectionConfig","tooltip","stroke","label","labelConfig"];function BF(t,e,n){const i=t;return i.interactive=n,i.interactionGroup="trend",n&&(i.trendFit=e),i.datum=e.row,i.children&&i.children.forEach(t=>BF(t,e,n)),t}function EF(t,e,n){return(t._trendFits||[]).map(i=>function(t,e,n,i){const o=t._trendLineConfig||{},r=[],a=()=>`trend-${e.id}`;if(void 0!==e.samples[0].lci){const s=Pg("Area").renderMode("compute").duration(Jt(t)).data(e.samples).config({id:a,label:!1,fill:e.color,stroke:"none",strokeWidth:0}).config(o.confidenceConfig||{}).config(function(t,e,n){const i=i=>"x"===t.axis?e(i.x):n(i.y),o=i=>"x"===t.axis?n(i.lci):e(i.lci),r=i=>"x"===t.axis?n(i.hci):e(i.hci);return"x"===t.axis?{x:i,x0:i,x1:null,y:o,y0:o,y1:r}:{y:i,y0:i,y1:null,x:o,x0:o,x1:r}}(e,n,i));r.push(...Gg(s).map(t=>BF(t,e,!1)))}const s=Object.fromEntries(Object.entries(o).filter(([t])=>!NF.includes(t))),c=(a,c,l)=>{if(a.length<2)return;const h=Pg("Line").renderMode("compute").duration(Jt(t)).data(a).config({...s,id:c,label:!1,stroke:e.color}).config(l).config({x:t=>n(t.x),y:t=>i(t.y)});r.push(...Gg(h).map(t=>BF(t,e,!1!==o.tooltip)))};return c(e.samples.filter(t=>!t.projected),a,{}),c(e.samples.filter(t=>t.projected),()=>`trend-${e.id}-projection`,o.projectionConfig||{}),r.length?{type:"group",key:`plot-trend-${e.id}`,children:r}:null}(t,i,e,n)).filter(t=>null!==t)}const RF={2:"²",3:"³"},PF={exponential:"Exponential",linear:"Linear",logarithmic:"Logarithmic",polynomial:"Polynomial",power:"Power"};function TF(t,e){const n=t.filter(([t])=>0!==t);return n.length?n.map(([t,n],i)=>{const o=`${e(Math.abs(t))}${n}`;return 0===i?t<0?`−${o}`:o:t<0?` − ${o}`:` + ${o}`}).join(""):e(0)}function OF(t,e=String,n="x"){const i=n,o="x"===n?"y":"x",r=t.coefficients;let a;if("exponential"===t.type)a=`${e(r[0])}e^(${e(r[1])}${i})`;else if("power"===t.type)a=`${e(r[0])}${i}^${e(r[1])}`;else if("logarithmic"===t.type)a=TF([[r[1],`ln(${i})`],[r[0],""]],e);else{a=TF(r.map((t,e)=>[t,0===e?"":1===e?i:`${i}${RF[e]||`^${e}`}`]).reverse(),e)}return`${o} = ${a}`}function WF(t){return e=>0!==e&&Math.abs(e)<.001?e.toPrecision(3):p.formatAbbreviate(e,t)}function jF(t,e,n,i){const o=n.nativeEvent,r=o&&o.touches&&o.touches.length?[o.touches[0].clientX,o.touches[0].clientY]:o?[o.clientX,o.clientY]:n.point;Xh(gz(t).data([e.row||{}]).config(te.bind(t)(t.schema.tooltipConfig)).title(()=>e.label),Ph(e.color,"Line")).thead([]).tbody(function(t,e,n){const{fit:i,axis:o}=e,r=e=>t.schema.translate(e),a=[];if(n&&n.projected){const e="x"===o?"y":"x",i=n=>fz(t,e,n),s=void 0!==n.lci?` (${i(n.lci)} – ${i(n.hci)})`:"";a.push([dz(t,o),`${fz(t,o,n[o])} (${r("Projected")})`],[dz(t,e),`${i(n[e])}${s}`])}return a.push([r("Trend Line"),r(PF[i.type])]),t[`_${o}Time`]||a.push([r("Equation"),OF(i,WF(t.schema.locale),o)]),a.push(["R²",i.r2.toFixed(3)],[r("Observations"),`${i.n}`]),a}(t,e,i?function(t,e,n){const i="x"===e.axis?t._xFunc:t._yFunc;if(!i)return;const o="x"===e.axis?n[0]:n[1],r=t=>{let n,r=1/0;for(const a of t){const t=Math.abs(i(a[e.axis])-o);t<r&&([n,r]=[a,t])}return n},a=r(e.samples);return a&&a.projected?r(e.samples.filter(t=>t.step)):void 0}(t,e,i):void 0)).footer(!1).position(r).render()}function HF(t,e,n){if(!n)return null;if("function"==typeof n){const t=n(e);return!1===t||null==t||""===t?null:`${t}`}return"equation"===n?function(t,e,n=!1){const i=`R² = ${t.fit.r2.toFixed(2)}`;return n?i:`${OF(t.fit,WF(e),t.axis)}, ${i}`}(e,t.schema.locale,Boolean(t[`_${e.axis}Time`])):e.row?e.label:t.schema.translate("Trend")}function IF(t,e,n){return a.pathTextBoxes({type:"text",key:"",x:0,y:0,font:{size:n,anchor:"start"},lines:[{text:" ",x:0,y:0,width:e}],path:{d:t}})}const GF=(t,e)=>{const n={...t,width:t.width+12,height:t.height+4};return e.some(t=>av(n,t))};function qF(t,e,n){const{fontSize:i,lift:o,width:r,obstacles:a}=n,s=jy(function(t,e){const n=([t,n])=>t>=e.x0-.5&&t<=e.x1+.5&&n>=e.y0-.5&&n<=e.y1+.5;let i=[],o=[];for(const e of t)Number.isFinite(e[0])&&Number.isFinite(e[1])&&n(e)?o.push(e):o=[],Wy(o)>Wy(i)&&(i=o.slice());return i}(t,e)),c=Wy(s)-6;if(c<4*i)return null;const l=Math.min(r,c),h=i/2;for(const t of[o,-(o+.75*i)])for(let e=c;e-l>=-1e-9;e-=h){const n=qy(Hy(Iy(s,Math.max(0,e-l),e),t)),o=IF(n,l,i);if(!o.some(t=>GF(t,a)))return{d:n,boxes:o};if(l>=c)break}return null}function VF(t,e,n,i,o=[]){const a=t._trendLineConfig||{},c=a.label,l=t._trendFits||[];if(!c||!l.length)return[];const h=a.labelConfig||{},u="number"==typeof h.fontSize?h.fontSize:11,d="number"==typeof a.strokeWidth?a.strokeWidth:2,f={"font-family":r.fontExists(h.fontFamily??s.fontFamily),"font-size":u,"font-weight":h.fontWeight??600},m=function(t){const e=[],n=(t,i,o)=>{const r=i+(t.transform?.x??0),a=o+(t.transform?.y??0);if("group"===t.type&&t.children.forEach(t=>n(t,r,a)),"text"!==t.type)return;const s=t.datum;if(/^(line-label-along|contour-label)-/.test(`${t.key}`)||"Line"===s?.data?.shape)for(const n of rM([t]))e.push({...n,x:n.x+i,y:n.y+o})};return t.forEach(t=>n(t,0,0)),e}(o),p=l.flatMap(o=>{const a=HF(t,o,c);if(!a)return[];const s=qF(o.samples.filter(t=>!t.projected).map(t=>[e(t.x),n(t.y)]),i,{fontSize:u,lift:d/2+2,width:r.textWidth(a,f)+2,obstacles:m});return s?(m.push(...s.boxes),[{key:`trend-label-${o.id}`,text:a,d:s.d,color:o.color,anchor:"end"}]):[]});return Ky(t,p,h)}function KF(t,e,n,i,o){const{shapeData:r,domains:a,discreteKeys:s,stackData:c,stackKeys:l,xDomain:h,yDomain:u}=n,{xScale:d,yScale:f}=n,{labelWidths:m,largestLabel:p}=n,{width:g}=n,{opp:y,showLineLabels:x}=n,{x:b,y:k,xRange:_,yRange:v,labelPositions:w,yOffset:M}=i,S=Object.keys(t.schema.on),C=new Map;for(let t=0;t<l.length;t++)C.set(l[t],t);const $=new Map;for(let t=0;t<s.length;t++)$.set(s[t],t);const A={viz:t,shapeConfig:o,events:S,x:b,y:k,xScale:d,yScale:f,xDomain:h,yDomain:u,xRange:_,yRange:v,opp:y,domains:a,stackData:c,stackKeyIndex:C,discreteKeyIndex:$,showLineLabels:x,labelWidths:m,largestLabel:p,labelPositions:w,width:g,values:[],valueExtent:$x(t,{x2Height:n.x2Height,yOffset:M}),barLabelsOnAxis:n.barLabelsOnAxis,insetBottom:i.insetBottom??0,x2Height:n.x2Height,zoomRanges:n.zoomRanges,missingRows:n.missingRows};var z;e.push(...(z=r.flatMap(([t,e])=>function(t,e){return(t.viz._plotShapeEmitters?.[e]??FF[e]??zF)(t,e)}({...A,values:e},t)),z.some(aF)?[...z.filter(aF),...z.filter(t=>!aF(t))]:z))}const YF=t=>"string"==typeof t.key&&t.key.startsWith("grid-"),UF=t=>{t.interactionGroup="axis";const e=t.children;if(e)for(const t of e)UF(t)};function XF(t,e,n,i){const o=[],{shapeData:r,domains:a}=e,{labelWidths:s}=e,{x:c,y:l,xRange:h,yRange:u,yOffset:d,axisSceneQueue:f}=n,m=function(t){const e=[],n=[];return t.forEach(({key:t,transform:i,axis:o,gridOnly:r})=>{if(!o||"function"!=typeof o.toScene)return;const a=o.toScene();if(!a)return;(t=>["band","ordinal","point"].includes(`${t?.schema?.scale}`))(o)&&wf(a,t.replace(/^plot-|-axis$/g,""));const s=a.children||[],c=s.filter(YF),l=s.filter(t=>!YF(t));if(c.length){const n={type:"group",key:`${t}-grid`,transform:i,children:c};UF(n),e.push(n)}if(l.length&&!r){const e={type:"group",key:t,transform:i,children:l};UF(e),n.push(e)}}),{grid:e,rest:n}}(f);!function(t,e,n,i){const o=t._backgroundConfig;if(o&&o.fill&&"transparent"!==o.fill){const t=Pg("Rect").renderMode("compute").data([{}]).x(n[0]+(n[1]-n[0])/2).width(n[1]-n[0]).y((i[1]-i[0])/2).height(i[1]-i[0]).config(o);t.render();const r=Gg(t);e.unshift(...r)}}(t,o,h,u),o.push(...m.grid),o.push(...ID(t,{xRange:h,yRange:u,x2Height:e.x2Height})),o.push(...ND(t,s));const p=CF(r),g=z$(t,{x:c,y:l,xRange:h,yRange:u,x2Height:e.x2Height,x2Exists:e.x2Exists,y2Exists:e.y2Exists,slots:p.slots}),y=$L(t,o,{x:c,y:l,frame:g},a,d);o.push(...vF(t,p.rows,{x:c,y:l,xRange:h,yRange:u},p.slots));const x=EF(t,c,l),b=function(t,e,n,i,o){const r=t.schema.discrete||"x";return Nt({discrete:t.schema.discrete,duration:Jt(t),label:e=>t._drawLabel(e.data,e.i),x:t=>void 0!==t.x2?e(t.x2,"x2"):e(t.x),x0:"x"===r?t=>t.x2?e(t.x2,"x2"):e(t.x):e("number"==typeof t.schema.baseline?t.schema.baseline:i.x[0]),x1:"x"===r?null:t=>t.x2?e(t.x2,"x2"):e(t.x),y:t=>void 0!==t.y2?n(t.y2,"y2"):n(t.y),y0:"y"===r?t=>t.y2?n(t.y2,"y2"):n(t.y):n("number"==typeof t.schema.baseline?t.schema.baseline:i.y[1])-o,y1:"y"===r?null:t=>t.y2?n(t.y2,"y2"):n(t.y)-o})}(t,c,l,a,d),k=x.length;KF(t,x,e,n,b);const _=function(t,e){const n=[];for(let i=t.length-1;i>=e;i--)"axis"===t[i].interactionGroup&&n.unshift(...t.splice(i,1));return n}(x,k);t._plotUnderlay&&x.splice(k,0,...t._plotUnderlay(x.slice(k),c,l)),function(t,e){const n=t._alongStats;if(!n||!Jz(t))return;const i=[],o=new Map,r=t=>{for(const e of t){if("text"===e.type){const t=e.datum?.data;t&&o.set(t,[...o.get(t)??[],tD(e.lines)])}else e.datum&&Zz.includes(e.shapeType)&&!`${e.key}`.endsWith("::hit")&&i.push(e);"group"===e.type&&r(e.children)}};r(e);const a=i.filter(e=>{if(t._legendCategories)return!1;const n=e.datum,i=tD([{text:t._drawLabel(n,Number(n.i)||0,t._legendDepth)}]);return!!i&&(o.get(n)??[]).includes(i)});n.series+=i.length,n.requested+=a.length,n.placed+=a.length}(t,x.slice(k));const v=function(t,e,n=0){const i=t.slice(0,2).map(Number),o=e.slice(0,2).map(t=>Number(t)-n);return{x0:Math.min(...i),y0:Math.min(...o),x1:Math.max(...i),y1:Math.max(...o)}}(h,u,e.x2Height);x.push(...Gx(t,x,v)),x.push(...mF(tb(t,x,v))),x.push(...VF(t,c,l,v,x));const w=[u[0],u[1]+(n.insetBottom??0)];o.push(...i?x:oL(x,{xRange:h,yRange:w,x2Height:e.x2Height,yOffset:d})),function(t,e,n){const i=e.map(([t])=>t);i.includes("Line")&&(t._confidence&&i.push("Area"),t._lineMarkers&&i.push("Circle")),t._previousShapes.filter(e=>!i.includes(e)&&!t._plotShapeEmitters?.[e]).forEach(t=>{const e=Pg(t);"function"==typeof e.renderMode&&e.renderMode("compute"),"function"==typeof e.select&&e.select(null),e.config(n).data([]).render()}),t._previousShapes=i}(t,r,b),o.push(...O$(y,Xc(x,void 0,QF,!0),g.plot));const M=KD(t,o,{xRange:h,yRange:u,x2Height:e.x2Height}),S=t.schema.zoom?[{type:"group",key:ZF,...i?{clip:i}:{},children:M}]:M,C=kD(t._xAxis,n.xEndLabels??[]);return C&&UF(C),[...S,..._,...m.rest,...C?[C]:[]]}const QF=t=>"group"!==t.type&&"text"!==t.type;const ZF="plot-zoom-content";function JF(t,e,n,i){const o=PD(t,e,n),{xRange:r,yRange:a}=o;return t._bodyRect={x:r[0],y:a[0],width:r[1]-r[0],height:a[1]-a[0]},t._plotAxisDomains={x:t._xAxis?._d3Scale?.domain()??[],y:t._yAxis?._d3Scale?.domain()??[]},t._plotArea={x:r[0],y:0,width:r[1]-r[0],height:a[1]-a[0]+(o.insetBottom??0)},{nodes:XF(t,e,o,i),layout:o}}const tN=(t,e)=>"time"===e||"Linear"===t&&["linear","pow","sqrt"].includes(e);function eN(t,e,n){const{nodes:i,layout:o}=JF(t,e);if(clearTimeout(t._plotUnclipTimer),t._plotZoomBase=void 0,t._zoomShapes=void 0,!t.schema.zoom)return i;const r={},a={},s={},c={};for(const n of function(t){const e=[];return tN(t.xScale,t.xConfigScale)&&e.push("x"),t.x2Exists&&tN(t.xScale,t.x2ConfigScale)&&e.push("x2"),tN(t.yScale,t.yConfigScale)&&e.push("y"),t.y2Exists&&tN(t.yScale,t.y2ConfigScale)&&e.push("y2"),e}(e)){const e=t[`_${n}Axis`],i=e?._d3Scale;i&&"function"==typeof i.invert&&(r[n]=i.copy(),a[n]=e?._labelSpace,s[n]=Boolean(e?._baselineBreak),c[n]=Boolean(e?.schema.reverse))}if(t._zoomShapes=function(t){const e=t.find(t=>t.key===ZF);return e&&"group"===e.type?sL(UD(e.children)):void 0}(i),!Object.keys(r).length)return i;const{x:l=0,y:h=0}=t._chartTransform||{};if(t._plotZoomBase={pCtx:e,layout:o,chartTransform:{x:l,y:h},scales:r,labelSpace:a,breaks:s,reversed:c},n&&(1!==n.k||n.x||n.y)){const e=nN(t,n);if(e)return e}return i}function nN(t,e,n=!1){const i=t._plotZoomBase;if(!i)return;const{pCtx:o,layout:r}=i,a=1===e.k&&!e.x&&!e.y,s=a?{}:function(t,e){const{pCtx:n,layout:i,chartTransform:o,scales:r}=t,a=i=>{const a=r[i],s="y"===i[0],c=s?o.y:o.x,l=s?e.y:e.x,h=s?-n.x2Height:0,u=a.range().map(t=>a.invert((t+h+c-l)/e.k-c-h)),[d,f]=a.domain();return(+f-+d)*(+u[1]-+u[0])<0!==Boolean(t.reversed[i])?u.reverse():u},s={};for(const t of Object.keys(r))s[`${t}Domain`]=a(t);s.zoomAxes={};for(const e of Object.keys(r))s.zoomAxes[e]={rounding:"none",domainTicks:!1,fixedSize:t.labelSpace[e],domain:s[`${e}Domain`],...t.breaks[e]?{}:{baselineBreak:!1}};const c=(t,i)=>{const r=i?o.y:o.x,a=i?-n.x2Height:0;return(t+a+r)*e.k+(i?e.y:e.x)-r-a};return s.zoomRanges={},r.x&&(s.zoomRanges.x=i.xRange.map(t=>c(t,!1))),r.y&&(s.zoomRanges.y=i.yRange.map(t=>c(t,!0))),s}(i,e),c=a&&!n?void 0:{type:"rect",x:r.xRange[0],y:r.yRange[0]-o.x2Height,width:r.xRange[1]-r.xRange[0],height:r.yRange[1]-r.yRange[0]+(r.insetBottom??0)};return JF(t,{...o,...s},r,c).nodes}function iN(t,e){const n=t._zoomTransform,i=n&&n.scale?n.scale:1,o=t._chartTransform;return[(e[0]-(n?.x??0))/i-(o?.x??0),(e[1]-(n?.y??0))/i-(o?.y??0)]}const oN=t=>t instanceof Date?String(t.getTime()):String(t);function rN(t,e){return!(!e.shapeType||!e.datum||"Box"===e.shapeType)&&("Bar"!==e.shapeType||!!t.schema.stacked)}function aN(t,e,n){const i=new Map,o="x"===e?t._xFunc:t._yFunc,r=(t,o,r,a)=>{if(!t||!Number.isFinite(o))return null;const s=oN(t[e]);let c=i.get(s);if(c||(c={px:o,value:t[e],members:new Map,bars:new Set,markers:[]},i.set(s,c)),"Bar"===a){const e=t.data||t;c.bars.add(e),n.bars.add(e)}const l=String(t.id),h=c.members.get(l);return h?h.color||(h.color=r):c.members.set(l,{wrapped:t,color:r,shape:a}),c},a=new Set,s=i=>{if(i.interactionGroup||!1===i.interactive)return;if(i.children&&i.children.forEach(t=>s(t)),"Box"===i.shapeType&&(n.box=!0),!rN(t,i))return;const c=i.paint||{},l=Oh(c.stroke)??Oh(c.fill);if("Area"===i.shapeType&&(n.area=!0),i.interactionPoints)for(const t of i.interactionPoints){const n=r(t.datum,t[e],l,i.shapeType);n&&"Line"===i.shapeType&&!a.has(t.datum)&&(a.add(t.datum),n.markers.push({datum:t.datum,x:t.x,y:t.y}))}else if(o&&!i.datum.__d3plusShape__){const t=i.datum;r(t,o(t[e]),l,i.shapeType)}};return(t._chartScene||[]).forEach(t=>s(t)),o&&function(t,e,n,i){for(const o of t._trendFits||[])if(o.axis===e&&!1!==t._trendLineConfig?.tooltip)for(const t of o.samples){if(!t.step)continue;const r=t[e],a=i(r);if(!Number.isFinite(a))continue;const s=oN(r);let c=n.get(s);c||(c={px:a,value:r,members:new Map,bars:new Set,markers:[]},n.set(s,c));const l=o.row||{};c.members.set(`${o.id}::projected`,{wrapped:l,color:o.color,shape:"Line",trend:{fit:o,sample:t}})}}(t,e,i,o),i}function sN(t,e,n,i){if(i.trend){const{fit:t,sample:o}=i.trend,r=Number(o["x"===e?"y":"x"]);if(!Number.isFinite(r))return null;const a=String(t.label),s=t.row||{};return{id:n,name:a,value:r,color:i.color,shape:"Line",datum:s,index:0,projected:{lci:o.lci,hci:o.hci}}}const o="x"===e?t._y:t._x,r=i.wrapped.data||i.wrapped,a="number"==typeof i.wrapped.i?i.wrapped.i:0,s=o?Number(o(r,a)):NaN;if(!Number.isFinite(s)||!Yl(t,r,a))return null;return{id:n,name:String(t._drawLabel(r,a)),value:s,color:i.color,shape:i.shape,datum:r,index:a}}function cN(t,e,n){let i=null;for(const o of t.values())(void 0===n||o.members.has(n))&&(!i||Math.abs(o.px-e)<Math.abs(i.px-e))&&(i=o);return i}const lN=t=>!(!t||!t.shapeType||!t.datum||t.interactionGroup||!1===t.interactive);function hN(t,e){const n=e?.datum?.data;if(!n||lN(e))return;let i;const o=t=>{i||(lN(t)&&t.datum===n?i=t:t.children&&t.children.forEach(t=>o(t)))};return(t._chartScene||[]).forEach(t=>o(t)),i}function uN(t,e,n,i){const o=t.schema.discrete;if("x"!==o&&"y"!==o)return null;const r=o,a="x"===r?n[0]:n[1],s={bars:new Set,area:!1,box:!1},c=aN(t,r,s);if(s.box)return null;const l=s.area?"front":"back",h=e.pick?e.pick.node:void 0,u=hN(t,h)??h,d=lN(u)&&"Box"!==u.shapeType,f=(e,n,i,o)=>{const a=e?.members.get(n)??(o?{wrapped:o,color:Ih(t,u),shape:u?.shapeType}:void 0),s=a?sN(t,r,n,a):null;if(!s||!Number.isFinite(i))return null;const c=e?e.markers.filter(t=>String(t.datum.id)===n):[],h=e?e.value:a.wrapped[r];return{mode:"single",axis:r,px:i,value:h,rows:[s],markers:c,layer:l}};if(i&&t.schema.tooltipShared){const e=cN(c,a);if(e){const n=[];if(e.members.forEach((e,i)=>{const o=sN(t,r,i,e);o&&n.push(o)}),n.length>=2||n.some(t=>t.projected)){!function(t,e,n){const i="x"===e?t._yFunc:t._xFunc,o=t=>{const n=i?i(t):NaN;return Number.isFinite(n)?"x"===e?n:-n:-t};n.sort((t,e)=>o(t.value)-o(e.value))}(t,r,n);const i=e.bars.size?{rows:e.bars,bars:s.bars}:void 0;return{mode:"shared",axis:r,px:e.px,value:e.value,rows:n,markers:e.markers,layer:l,stack:i}}if(1===n.length&&!d)return f(e,n[0].id,e.px)}}if(!d)return null;const m=u.datum,p=String(m.id);if(u.interactionPoints){const t=cN(c,a,p);return t?f(t,p,t.px):null}return f(null,p,function(t,e){const n=t,i=n.transform?.[e]??0;return"rect"===n.type?i+(n[e]??0)+(("x"===e?n.width:n.height)??0)/2:"circle"===n.type?i+(("x"===e?n.cx:n.cy)??0):NaN}(Hh(t,u)??u,r),m)}function dN(t,e){let n=null;const i=t._plotArea;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;const o=e.pick&&e.pick.node;if(o&&o.trendFit)return void function(t,e,n){const i=t._sharedHoverState;t._sharedHoverActive=!0,t._sharedHoverState=null;const o=Array.isArray(n.point)?iN(t,n.point):void 0;jF(t,e,n,o),i&&("shared"===i.mode&&"function"==typeof t._hover&&t.hover(!1),t._scheduleSceneRepaint())}(t,o.trendFit,e);if(i&&Array.isArray(e.point)&&(!o||"legend"!==o.interactionGroup)){const[o,r]=iN(t,e.point);n=uN(t,e,[o,r],o>=i.x&&o<=i.x+i.width&&r>=i.y&&r<=i.y+i.height)}}else if("mouseleave"!==e.type||e.nativeEvent&&"mouseleave"!==e.nativeEvent.type)return;const o=t._sharedHoverState;if(n){t._sharedHoverActive=!0;const{mode:i,axis:r,px:a,value:s,markers:c,layer:l}=n,h=su(t,e.point)?.key;t._sharedHoverState={mode:i,axis:r,px:a,value:s,markers:c,layer:l,panel:h},"shared"===i?xz(t,n,e):bz(t,n,e),o&&o.px===a&&o.mode===i&&o.panel===h||(!function(t,e,n){const i=e.stack,o=()=>{"function"==typeof t._hover&&t.hover(!1)},r=t._plotColumnHighlight;if(r&&1===t.schema.shapeConfig.hoverOpacity)o();else if(r){const n=new Set(e.rows.map(t=>t.datum));He(t,t=>n.has(t)),t.hover(r(n))}else"single"===e.mode?"shared"===n&&o():i?(He(t,t=>i.rows.has(t)),t.hover(t=>i.rows.has(t)||!i.bars.has(t))):o()}(t,n,o?.mode),t._scheduleSceneRepaint())}else t._sharedHoverActive&&(t._sharedHoverActive=!1,t._sharedHoverState=null,t._tooltipClass.data([]).render(),function(t){const e=t._sharedTooltipSaved;e&&t._tooltipClass.arrow(e.arrow).thead(e.thead).tbody(e.tbody),t._sharedTooltipSaved=void 0}(t),"function"==typeof t._hover&&t.hover(!1),t._scheduleSceneRepaint())}const fN=/::(hit|stem|confidence)$/;function mN(t,e){return Math.abs(t)>=Math.abs(t+e)?t:t+e}function pN(t,e,n){return Number.isFinite(e)?{...t,[n]:e,span:[t[n],e]}:t}function gN(t,e,n){const i=t,o=i.datum;if(!o||"string"==typeof i.key&&fN.test(i.key))return[];const r=i.shapeType;if(i.interactionPoints)return i.interactionPoints.map(t=>({x:t.x,y:t.y,datum:t.datum,color:n,shape:r}));const a=i.transform?.x??0,s=i.transform?.y??0;if("circle"===i.type)return[{x:a+(i.cx??0),y:s+(i.cy??0),datum:o,color:n,shape:r}];if("rect"!==i.type)return[];const c=i.x??0,l=i.y??0,h=i.width??0,u=i.height??0;if("Bar"!==r)return[{x:a+c+h/2,y:s+l+u/2,datum:o,color:n,shape:r}];if("x"===e){const t=a+mN(c,h);return[{x:t,y:s+l+u/2,datum:o,color:n,shape:r,span:[a,t]}]}const d=s+mN(l,u);return[{x:a+c+h/2,y:d,datum:o,color:n,shape:r,span:[s,d]}]}function yN(t){return!(!t||!t.shapeType||!t.datum||"Box"===t.shapeType||t.interactionGroup||!1===t.interactive||t.datum.__d3plusShape__)}function xN(t,e,n){let i=null,o=1/0;for(const r of t){const t=r.span,a=t&&n>=Math.min(t[0],t[1])&&n<=Math.max(t[0],t[1])?0:Math.abs(r[e]-n);a<o&&(o=a,i=r)}return i}const bN=(t,e,n)=>t(e,n);function kN(t,e,n,i){return Number.isFinite(e)&&Math.abs(e-n)<=1?t:i?i(n):t}function _N(t,e){if(null==e)return"";if("number"==typeof e&&!Number.isFinite(e))return"";return`${(t?t(e):`${e}`)??""}`.replace(/<[^>]*>/g,"").trim()}function vN(t,e,n,i){const o=t[`_${e}Axis`]?._d3Scale;if(!o||"function"!=typeof o.invert)return;const r=bN(n,i,e)-o(i);return Number.isFinite(r)?t=>o.invert(t-r):void 0}function wN(t,e,n){if("Area"!==e.shape)return e;const i=void 0!==e.datum[`${n}2`]?`${n}2`:n,o="x"===n?t._xFunc:t._yFunc,r=Number(e.datum[i]);if(!o||!Number.isFinite(r))return e;if(!t.schema.stacked)return pN(e,bN(o,r,i),n);const a=vN(t,i,o,r),s=a?Number(a(e[n])):NaN;return Number.isFinite(s)?pN(e,bN(o,s+r,i),n):e}function MN(t){const e=t.schema.discrete;return"x"===e||"y"===e?e:void 0}function SN(t,e,n){const i=MN(t),o=e.pick?e.pick.node:void 0,r=Hh(t,hN(t,o)??o),a=yN(r);if(i){const e=t._sharedHoverState;if(!e)return a?function(t,e,n,i){const o="x"===n?"y":"x",r=gN(e,o,Ih(t,e));return r.length&&void 0!==r[0].datum[`${o}2`]?xN(r.map(e=>wN(t,e,o)),n,i["x"===n?0:1]):null}(t,r,i,n):null;const o="single"===e.mode&&a?String(r.datum.id):void 0,s="x"===i?"y":"x",c=function(t){const e="y"===t.schema.discrete?"x":"y",n=[],i=o=>{o.interactionGroup||!1===o.interactive||(o.children&&o.children.forEach(t=>i(t)),yN(o)&&n.push(...gN(o,e,Ih(t,o))))};return(t._chartScene||[]).forEach(t=>i(t)),n}(t).map(e=>wN(t,e,s)).filter(t=>Math.abs(t[i]-e.px)<=1&&(void 0===o||String(t.datum.id)===o)),l="x"===i?"y":"x";return xN(c,l,n["x"===l?0:1])}if(!a)return null;return function(t,e){let n=null,i=1/0;for(const o of t){const t=Math.hypot(o.x-e[0],o.y-e[1]);t<i&&(i=t,n=o)}return n}(gN(r,"y",Ih(t,r)).map(e=>wN(t,e,"y")),n)}const CN=t=>t?JSON.stringify([t.point,t.color,t.panel,t.badges]):"";function $N(t,e){let n=null;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;const i=e.pick?.node;if(!1!==t.schema.axisHover&&t._plotArea&&Array.isArray(e.point)&&(!i||"legend"!==i.interactionGroup)&&(n=function(t,e,n){const i=SN(t,e,n);if(!i||!function(t,e){const n=t._plotArea;return!!n&&e.x>=n.x-1&&e.x<=n.x+n.width+1&&e.y>=n.y-1&&e.y<=n.y+n.height+1}(t,i))return null;const o=MN(t),r=o?t._sharedHoverState:null,a=t.schema.axisHover,s=function(t,e){const n=[];for(const i of["x","y"])e.bar&&i===(e.discrete??"x")||e.cross!==i&&(e.only&&e.only!==i||n.push(void 0!==t[`${i}2`]?`${i}2`:i));return n}(i.datum,{discrete:o,bar:"Bar"===i.shape,cross:t._swarm?.cross,only:"x"===a||"y"===a?a:void 0}),c=[];for(const e of s){const n=e.charAt(0),a=!!r&&n===o,s=a?r.px:i[n],l="x"===n?t._xFunc:t._yFunc,h=a?r.value:i.datum[e],u=_N(n=>fz(t,e,n),a||!l?h:kN(h,bN(l,h,e),s,vN(t,e,l,h)));u&&c.push({axis:e,at:s,text:u,guide:!a})}if(!c.length)return null;const l=i.datum.data||i.datum;return{point:{x:i.x,y:i.y},color:i.color,datum:l,index:"number"==typeof i.datum.i?i.datum.i:0,badges:c}}(t,e,iN(t,e.point)),n)){const i=su(t,e.point)?.key;void 0!==i&&(n.panel=i)}}else if("mouseleave"!==e.type)return;const i=t._axisHoverState;CN(i)!==CN(n)&&(t._axisHoverState=n,t._scheduleSceneRepaint())}function AN(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",e.children&&e.children.forEach(AN),t}const zN=t=>{const e=t,n=e.datum;return!!e.shapeType&&!e.interactionGroup&&!1!==e.interactive&&!!n&&void 0!==n.id};function DN(t,e,n,i){const o=[...t];if(e.length){const t=o.findIndex(t=>zN(t)||aL(t)&&t.children.some(zN));"back"===i&&t>=0?o.splice(t,0,...e):o.push(...e)}return o.push(...n),o}function LN(t,e,n,i){const o=t._plotArea;if(!o)return e;const{state:r,axis:a}=n,s="x"===t.schema.discrete||"y"===t.schema.discrete,c=s&&t.schema.tooltipShared&&function(t){const e=n=>!n.interactionGroup&&!1!==n.interactive&&(!!rN(t,n)||!!n.children&&n.children.some(t=>e(t)));return(t._chartScene||[]).some(t=>e(t))}(t)?[{type:"rect",key:i("plot-hover-surface"),...o,interactionGroup:"axis",paint:{fill:"transparent"}}]:[];let l=e;const h=r&&s?function(t,e){const n=()=>e.px,i="x"===e.axis?n:t._xFunc,o="y"===e.axis?n:t._yFunc,r=t._plotAxisDomains?.x,a=t._plotAxisDomains?.y;if(!(i&&o&&r?.length&&a?.length))return null;const s="x"===e.axis?a:r,c=vL(wL(t,{shape:"Line",data:[s[0],s[s.length-1]].map(t=>"x"===e.axis?{x:e.value,y:t}:{x:t,y:e.value}),id:()=>"crosshair",...t._crosshairConfig},i,o,{x:r,y:a},0),"plot-crosshair");return c?AN(c):null}(t,r):null,u=a?gC(t,a):null,d=pb([...h?[h]:[],...u?u.guides:[]],i),f=pb(r&&s?function(t,e){if(t._lineMarkers||!e.markers.length)return[];const n=new Map(e.markers.map(t=>[t.datum,t])),i=Pg("Circle").renderMode("compute").data(e.markers.map(t=>t.datum)).config(t._lineMarkerConfig).x(t=>n.get(t).x).y(t=>n.get(t).y).id(t=>`${t.id}_shared`);return i.render(),[{type:"group",key:"plot-shared-markers",children:Gg(i)}].map(AN)}(t,r):[],i);if(d.length||f.length){const t=r?r.layer:"back",e=l.findIndex(t=>t.key===i(ZF));if(e>=0){const n=l[e];l=[...l],l[e]={...n,children:DN(n.children||[],d,f,t)}}else l=DN(l,d,f,t)}const m=u?pb(u.badges,i):[];return[...c,...l,...m]}function FN(t,e){const n=t.schema.discrete;if("x"!==n&&"y"!==n&&!t._axisHoverState)return;const i=e.root.children.find(t=>"viz-chart-cells"===t.key),o=i&&i.children&&i.children[0],r=o&&o.children&&o.children[0];if(!r||!r.children)return;const a=t._facetPanels;r.children=a?r.children.map(e=>{const n=a.find(t=>t.key===e.key);return n?function(t,e,n){const i=e.children||[],o=i.findIndex(t=>t.key===`${n.key}/cells`),r=i[o],a=r&&r.children&&r.children[0];if(!r||!a||!a.children)return e;const s=t._sharedHoverState,c=t._axisHoverState,l=cu(t,n,()=>LN(t,a.children,{state:s&&s.panel===n.key?s:null,axis:c&&c.panel===n.key?c:null},t=>`${n.key}/${t}`)),h=[...i];return h[o]={...r,children:[{...a,children:l},...r.children.slice(1)]},{...e,children:h}}(t,e,n):e}):LN(t,r.children,{state:t._sharedHoverState,axis:t._axisHoverState},t=>t)}const NN=/^plot-(x|x2|y|y2)-axis$/;function BN(t,e){if(t.schema[`${e}Sort`])return!0;if(OC(t,e))return!1;const n=t[`_${e}Time`];return t.schema.discrete===e.charAt(0)&&!n}function EN(t){let e,n;for(const i of t)for(const t of i)null==t||Number.isNaN(+t)||((void 0===e||+t<+e)&&(e=t),(void 0===n||+t>+n)&&(n=t));return void 0===e||void 0===n?void 0:[e,n]}function RN(t,e){t._filteredData=e;const n=vt({viz:t},[jz,Hz,ez,oz]);return{formatted:n.plotFormattedData||[],domains:n.plotInitialDomains||{},positions:n.plotStackPositions}}function PN(t,e){if(!t.schema.stacked)return IA(t,void 0);const n=e.filter(t=>t.length).map(e=>RN(t,e).positions).filter(t=>void 0!==t);IA(t,OA(n))}function TN(t,e){const n=e.filter(t=>t.length).map(e=>RN(t,e)),i=n.flatMap(t=>t.formatted),o=vt({viz:t,plotFormattedData:i,plotAxisData:i},[Hz]),r={};for(const e of d$)if(n.some(t=>t.domains[e]))if(BN(t,e)){const t=o[`${e}Data`];t&&t.length&&(r[e]=t)}else{const t=EN(n.map(t=>t.domains[e]||[]));t&&(r[e]=t)}const a=t._size?i.map(e=>t._size(e.data)):[],s=a.length?Pz(t,a):void 0;return{domains:r,size:s,padded:ON(t,i,r,s)}}function ON(t,e,n,i){const o=t._sizeScaleD3;i&&(t._sizeScaleD3=i);const r=vt({viz:t,plotFormattedData:e,plotAxisData:e,plotInitialDomains:{...n}},[pA,Iz]);t._sizeScaleD3=o;const a={},s=r.plotScales;if(!s)return a;for(const t of d$){const e=s[t];e&&"function"==typeof e.invert&&(a[t]=e.domain())}return a}function WN(t,e){const n=t||{};return{...n,labels:e?n.labels:[],title:!!e&&n.title}}function jN(t,e){t&&t.config({labels:e?.labels,title:e?.title})}function HN(t,e){const n={scales:t._plotFacetScales,x:t._xConfig,y:t._yConfig};return t._plotFacetScales=e.shared?e.scales:void 0,t._xConfig=WN(n.x,e.labels.x),t._yConfig=WN(n.y,e.labels.y),()=>{t._plotFacetScales=n.scales,t._xConfig=n.x,t._yConfig=n.y,jN(t._xAxis,n.x),jN(t._yAxis,n.y)}}function IN(t){const e=t._plotArea,n=t._chartTransform;if(!e||!n)return{top:0,right:0,bottom:0,left:0};const i=e.x+(n.x??0),o=e.y+(n.y??0);return{top:o-t._margin.top,right:t.schema.width-t._margin.right-(i+e.width),bottom:t.schema.height-t._margin.bottom-(o+e.height),left:i-t._margin.left}}const GN={aspect:4/3,chrome:PN,share:TN,panel:HN,insets:IN,capture:t=>({_plotArea:t._plotArea,_plotAxisDomains:t._plotAxisDomains,_xFunc:t._xFunc,_yFunc:t._yFunc,_trendFits:t._trendFits,_barSpans:t._barSpans})},qN=t=>Array.isArray(t)?t.map(qN).join(""):t instanceof Date?+t:t;function VN(t,e){const{aggs:i,id:o,position:r,threshold:a,value:s}=e,c=Math.min(1,Math.max(0,+a(t)));if(!(c>0))return null;const l=new Map,h=new Map;let u=0;if(t.forEach((t,e)=>{const n=`${o(t,e)}`,i=Math.abs(+s(t,e))||0;l.set(n,(l.get(n)??0)+i);const r=h.get(n);r?r.push(t):h.set(n,[t]),u+=i}),!(u>0))return null;const d=new Set;if(l.forEach((t,e)=>{t<c*u&&d.add(e)}),d.size<2)return null;const f=function(t,e,i){const o=new Set;t.forEach(t=>t.forEach(t=>Object.keys(t).forEach(t=>o.add(t))));const r=Array.from(o).filter(n=>t.every(t=>{let i;return t.every((t,o)=>{const r=t[n];if("number"==typeof r)return!1;const a=qN(r);return!e.some(e=>qN(e(t,o))===a)&&(0===o&&(i=a),a===i)})})),a=t.filter(t=>t.length).map(t=>{const e={};for(const n of r)e[n]=t[0][n];return e});return n.merge(a,i)}(Array.from(d,t=>h.get(t)),r,i);return{members:d,percent:c,identity:f}}function KN(t,e,i){const{aggs:o,id:r,position:a}=i,s=i.label??r,c=i.measure??i.value,l=[],h=new Map;if(t.forEach((t,n)=>{if(!e.members.has(`${r(t,n)}`))return void l.push(t);const i=a.map(e=>`${qN(e(t,n))}`).join(""),o=h.get(i);o?o.push(t):h.set(i,[t])}),!h.size)return t;const u=Array.from(h.values(),t=>{const i=n.merge(t,o),l=t[0],h=a.map(t=>qN(t(l,0)));for(const e of Object.keys(l))h.some(n=>t.every(t=>qN(t[e])===n))&&(i[e]=l[e]);return{...i,...e.identity,_isAggregation:!0,_threshold:e.percent,[Dh]:Lh(t,r,s,c)}});return l.concat(u)}function YN(t){const e="y"===t.schema.discrete?"y":"x",n="x"===e?"y":"x",i=[t[`_${e}`]];return t.schema.time&&i.push(t.schema.time),{aggs:t.schema.aggs,id:t._id,label:t._drawLabel,measure:t[`_${n}`],position:i,threshold:t.schema.threshold,value:t.schema.thresholdKey??t[`_${n}`]}}function UN(t){const e=t?.domain;return Array.isArray(e)?{...t,domain:e.slice().reverse()}:t}class XN extends dk{_preDraw(){["x","y","x2","y2"].forEach(t=>{if(this[`_${t}Key`]){const e=this[`_${t}Key`];this.schema.aggs[e]||this.schema.discrete!==t||(this.schema.aggs[e]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),e!==t&&this[`_${t}Title`]===this[`_${t}Config`].title&&this.schema.discrete!==t&&(this[`_${t}Title`]=e,this[`_${t}Config`].title=e)}}),super._preDraw()}_thresholdLegend(t){return function(t,e){if(!t.schema.stacked||!e.length)return e;const n=YN(t),i=VN(e,n);return i?KN(e,i,{...n,position:[]}):e}(this,t)}_thresholdFunction(t,e,n){return function(t,e,n=e){if(!t.schema.stacked)return e;const i=YN(t),o=VN(n,i);return o?KN(e,o,i):e}(this,t,n)}toScene(){const t=dk.prototype.toScene.call(this);if(Array.isArray(this._filteredData)&&0===this._filteredData.length&&(!this._annotations||0===this._annotations.length))return t;const e=[];for(const t of["_xAxis","_x2Axis","_yAxis","_y2Axis"]){const n=this[t];n&&"function"==typeof n.toScene&&n._select&&"function"==typeof n._select.node&&n._select.node()&&e.push({type:"group",key:`plot-${t}`,children:[n.toScene()]})}return t.root.children.unshift(...e),FN(this,t),t}_wirePlotShapeEvents(t,e,n){const i=n.filter(t=>t.includes(`.${e}`)),o=n.filter(t=>!t.includes(".")),r=n.filter(t=>t.includes(".shape")),a=t=>(e,n,i,o)=>this.schema.on[t](e.data,e.i,i,o);for(const e of o)t.on(e,a(e));for(const e of r)t.on(e,a(e));for(const e of i)t.on(e,a(e))}_interactionDatum(t,e){const n=t.node,i=n&&n.interactionPoints;if(n&&"legend"!==n.interactionGroup&&Array.isArray(i)&&i.length&&e&&Array.isArray(e.point)){const t=this._nearestInteractionPoint(i,e.point);if(t){const e=t.datum;return{d:e&&e.data?e.data:e,i:"number"==typeof e.i?e.i:t.index,x:e}}}return super._interactionDatum(t,e)}_pointMark(t){return mu(t)}_nearestInteractionPoint(t,e){const[n,i]=iN(this,e),o="y"===this.schema.discrete?"y":"x",r="y"===o?i:n;let a=null,s=1/0;for(const e of t){const t=Math.abs(e[o]-r);t<s&&(s=t,a=e)}return a}_sharedHover(t){dN(this,t),$N(this,t)}_draw(t){return zD(this,t)}_facetHooks(){return GN}_sizeLegendScale(){return function(t){if(!t._size)return null;const e=t._axisPersist?t._data:t._filteredData||[],n=[];let i=!1;return e.forEach((e,o)=>{Bz(t._x(e,o))||Bz(t._y(e,o))||(n.push(t._size(e,o)),Oz(t,t.schema.shape(e,o))&&(i=!0))}),i?Pz(t,n):null}(this)}_insetRegion(){return function(t){const e=t._plotArea,n=t._chartTransform;return e&&n?Ay(t,{x:e.x+(n.x??0),y:e.y+(n.y??0),width:e.width,height:e.height},t=>NN.test(String(t.key))):null}(this)}_paint(t){const e=this,n=e._zoomEventTarget||e._container;return this._chartScene=eN(e,t,n&&n.node()?h.zoomTransform(n.node()):void 0),this}_zoomRescale(t,e=0){if(this._facetPanels)return!1;const n=function(t,e,n){clearTimeout(t._plotUnclipTimer);const i=t._chartScene?.find(t=>t.key===ZF),o="group"===i?.type&&!!i.clip&&n>0&&1===e.k&&!e.x&&!e.y,r=nN(t,e,o);return r&&o&&(t._plotUnclipTimer=setTimeout(()=>{const n=nN(t,e);n&&(t._chartScene=n,t._drawSceneToTarget(0))},n)),r}(this,t,e);return!!n&&(this._chartScene=n,!0)}annotations(t){return arguments.length?(this._annotations=t instanceof Array?t:[t],this):this._annotations}axisPersist(t){return arguments.length?(this._axisPersist=t,this):this._axisPersist}baseline(t){return arguments.length?(function(t,e){t._userBaseline=e===nt||void 0===e?void 0:e}(this,t),this):(e=this)._userBaseline??e.schema.baseline;var e}backgroundConfig(t){return arguments.length?(this._backgroundConfig=ht(this,"backgroundConfig",t,this._backgroundConfig),this):this._backgroundConfig}buffer(t){if(arguments.length){if(t)if(!0===t)this._buffer=uC;else{this._buffer=r.assign({},this._buffer,t);for(const t in this._buffer){const e=this._buffer;!0===e[t]&&(e[t]=uC[t])}}else this._buffer={};return this}return this._buffer}confidence(t){if(!arguments.length)return this._confidenceBands&&this._confidenceBands.length>1?this._confidenceBands:this._confidence;const e=this._confidenceBands=VC(t);return this._confidence=!!e.length&&[e[0].lower,e[0].upper],this}confidenceConfig(t){return arguments.length?(e=qt(this),(n=t)&&"object"==typeof n&&Object.getPrototypeOf(n)===Object.prototype&&kf(e,n,HC),this._confidenceConfig=ht(this,"confidenceConfig",t,this._confidenceConfig),this):this._confidenceConfig;var e,n}discreteCutoff(t){return arguments.length?(this._discreteCutoff=t,this):this._discreteCutoff}groupPadding(t){return arguments.length?(this._groupPadding=t,this):this._groupPadding}labelConnectorConfig(t){return arguments.length?(this._labelConnectorConfig=ht(this,"labelConnectorConfig",t,this._labelConnectorConfig),this):this._labelConnectorConfig}crosshairConfig(t){return arguments.length?(this._crosshairConfig=ht(this,"crosshairConfig",t,this._crosshairConfig),this):this._crosshairConfig}trendLine(t){return arguments.length?(this._trendLine=t,this):this._trendLine}trendLineConfig(t){return arguments.length?(this._trendLineConfig=ht(this,"trendLineConfig",t,this._trendLineConfig),this):this._trendLineConfig}lineMarkerConfig(t){return arguments.length?(this._lineMarkerConfig=ht(this,"lineMarkerConfig",t,this._lineMarkerConfig),this):this._lineMarkerConfig}lineMarkers(t){return arguments.length?(this._lineMarkers=t,this):this._lineMarkers}size(t){return arguments.length?(this._size="function"!=typeof t&&t?G(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size}stackOffset(t){return arguments.length?(this._stackOffset=PA(t),this):this._stackOffset}stackOrder(t){return arguments.length?(this._stackOrder=NA(t),this):this._stackOrder}x(t){return arguments.length?("function"==typeof t?this._x=t:(this._x=G(t),this._xKey=t),this):this._x}x2(t){return arguments.length?("function"==typeof t?this._x2=t:(this._x2=G(t),this._x2Key=t),this):this._x2}xConfig(t){return arguments.length?(this._xConfig=ht(this,"xConfig",t,this._xConfig),this):this._xConfig}x2Config(t){return arguments.length?(this._x2Config=ht(this,"x2Config",t,this._x2Config),this):this._x2Config}y(t){return arguments.length?("function"==typeof t?this._y=t:(this._y=G(t),this._yKey=t),this):this._y}y2(t){return arguments.length?("function"==typeof t?this._y2=t:(this._y2=G(t),this._y2Key=t),this):this._y2}yConfig(t){return arguments.length?(this._yConfig=ht(this,"yConfig",UN(t),this._yConfig),this):this._yConfig}y2Config(t){return arguments.length?(this._y2Config=ht(this,"y2Config",UN(t),this._y2Config),this):this._y2Config}constructor(){var t;super(),this._trendLine=Gz.defaults.trendLine,this._trendLineConfig={confidence:!1,confidenceConfig:{fillOpacity:.15},confidenceLevel:.95,group:"series",label:"equation",order:2,projection:0,projectionConfig:{strokeDasharray:"2 4"},strokeDasharray:"6 4",strokeWidth:2,tooltip:!0},kt(this,eD),nD(this),(t=this)._x=H("x"),t._xKey="x",t._xAxis=(new qa).align("end"),t._xConfig={gridConfig:{stroke:e=>{if("x"===t.schema.discrete?.charAt(0)||"x"===t._swarm?.cross)return"transparent";const n=t._xAxis.range(),i=t._xAxis._getPosition.bind(t._xAxis)(e.id);return n[0]===i?"transparent":Wc(t)}}},t.schema.xCutoff=150,t._x2=H("x2"),t._x2Key="x2",t._x2Axis=(new Ya).align("start"),t._x2Config={},t._y=H("y"),t._yKey="y",t._yAxis=(new Va).align("start"),t._yAxis._domainEndFirst=!0,t._yKey="y",t._yConfig={gridConfig:{stroke:e=>{if("y"===t.schema.discrete?.charAt(0)||"y"===t._swarm?.cross)return"transparent";const n=t._yAxis.range(),i=t._yAxis._getPosition.bind(t._yAxis)(e.id);return n[n.length-1]===i?"transparent":Wc(t)}}},t.schema.yCutoff=150,t._y2=H("y2"),t._y2Key="y2",t._y2Axis=(new Ka).align("end"),t._y2Axis._domainEndFirst=!0,t._y2Config={}}}XN._displayName="Plot",dt(XN.prototype,"backgroundConfig","baseline","confidenceConfig","crosshairConfig","labelConnectorConfig","lineMarkerConfig","trendLineConfig","xConfig","x2Config","yConfig","y2Config");var QN=fk({name:"AreaPlot",paintDriven:!0,ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:W("Area"),coerce:"const"}]},XN);function ZN(t){const e=[()=>t.schema.translate("Share"),(e,n,i)=>{const o=$h(i);let r=Sh(o);if(!Number.isFinite(r)){const e=t["_"+("y"===t.schema.discrete?"x":"y")];r=o?Ah(o,t._legendData||[],e):NaN}return Number.isFinite(r)?`${p.formatAbbreviate(100*r,t.schema.locale)}%`:""}];return{tbody:()=>t.schema.stacked?[e]:[]}}const JN={name:"BarChart",paintDriven:!0,ctx:{},fields:[{key:"barWidth",coerce:Qy},{key:"barWidthShare",default:!1},{key:"barWidthShareFormat"},{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:W("Bar"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:function(t){const e=ZN(t);return{tbody:n=>[...hx(t,n),...e.tbody()]}}},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{if(t._legendCategories)return e.call(t,n,i);return i.map(t.schema.groupBy[t._legendDepth].bind(t)).sort().join()!==t._filteredData.map(t.schema.groupBy[t._legendDepth].bind(t)).sort().join()&&e.call(t,n,i)}}}]};var tB=fk(JN,XN);const eB={name:"Beeswarm",paintDriven:!0,ctx:{},fields:[{key:"shapeConfig",merge:!0,default:{Circle:{label:!1,trail:!1}}},{key:"swarm",default:!0}]};var nB=fk(eB,XN);const iB=new WeakMap;function oB(t,e){for(;t.__d3plus__&&t.data;)e=t.i,t=t.data;return[t,e]}function rB(t){const e=t.schema.shapeConfig||{},n=(e.Box||{}).whiskerMode??e.whiskerMode;return void 0===n?["tukey","tukey"]:ra(n)}function aB(t,e,n){if(!e)return[];const i=e=>void 0===e?"":p.formatAbbreviate(e,t.schema.locale),o=e=>t.schema.translate(e),[r,a]=oB(e,n);if(pa(t.schema)){const e=ka(t.schema,r,a);return e?[[o("Maximum"),i(e.max)],[o("Upper Quartile"),i(e.q3)],[o("Median"),i(e.median)],[o("Lower Quartile"),i(e.q1)],[o("Minimum"),i(e.min)]]:[]}const s=function(t,e){const n=iB.get(e);if(!n)return null;const i="vertical"===n.orient,o=n.values.map(t=>{const e=i?t.y2??t.y:t.x2??t.x;return"number"==typeof e||e instanceof Date?+e:NaN}).filter(Number.isFinite).sort((t,e)=>t-e);return o.length?aa(o,rB(t)):null}(t,r);if(!s)return[];const c=rB(t);return[["extent"===c[1]?"Maximum":"Upper Whisker",s.upperLimit],["Upper Quartile",s.third],["Median",s.median],["Lower Quartile",s.first],["extent"===c[0]?"Minimum":"Lower Whisker",s.lowerLimit]].filter(([,t])=>void 0!==t).map(([t,e])=>[o(t),i(e)])}const sB=t=>"y"===t.schema.discrete?"x":"y";function cB(t){const e=Hg(t,"Box").outlier;return"function"==typeof e?e:void 0===e||oa(e)?null:()=>e}const lB=(t,e)=>{const n=t[e];return"number"==typeof n||n instanceof Date?+n:NaN};function hB(t,e,n){if(pa(t.schema)||n.charAt(0)!==sB(t))return e;const i=cB(t);return i?function(t,e){const n=t.schema.discrete,i="function"==typeof t.schema.facet?t.schema.facet:void 0;return d.groups(e,t=>i?`${t[n]}\0${i(t.data,t.i)}`:`${t[n]}`).map(([,t])=>t)}(t,e).flatMap(e=>function(t,e,n,i){const o=e.map(t=>lB(t,n)).filter(Number.isFinite).sort((t,e)=>t-e);if(!o.length)return e;const{lowerLimit:r,upperLimit:a}=aa(o,rB(t)),s=e.filter(t=>{const e=lB(t,n);return!(e<r||e>a)||oa(i(t,t.i))});if(s.length===e.length)return e;const c=e[0][n]instanceof Date,l=[r,a].filter(t=>Number.isFinite(t)).map(t=>({...e[0],[n]:c?new Date(t):t}));return s.concat(l)}(t,e,n,i)):e}const uB=t=>pa(t.schema);function dB(t){const e=function(t){const e=cB(t);return t=>!e||oa(e(t,t.i))}(t);return n=>function(t,e,n,i=!0){const o=[];for(const i of fa){const r=t[i],a="function"==typeof r?xa(r(e,n)):NaN;ya(a)&&o.push(a)}return i?o.concat(ba(t,e,n)):o}(t.schema,n.data,n.i,e(n))}function fB(t){const e=sC,n=this,i=sB(this);if(!uB(this)){const o=hB(this,t.data,t.x2?`${i}2`:i);return e.call(n,{...t,data:o})}if(t.x2)return e.call(n,t);const o=dB(this),r=t.data.flatMap(t=>o(t).map(e=>({...t,[i]:e})));return e.call(n,{...t,data:r})}function mB(t,e){const n=t=>"number"==typeof t||t instanceof Date?e(t):NaN;return e=>{const i=t(e.data,e.i);return Array.isArray(i)?i.map(n):n(i)}}const pB=(t,e)=>{const{viz:n}=t;if(!uB(n))return function(t){const e=t=>{for(const n of t){"group"===n.type&&e(n.children);for(const t of n.owners||[])"Box"===t.shapeType&&t.datum&&iB.set(oB(t.datum,t.index)[0],t.datum)}};return e(t),t}(zF(t,e));const i="y"===sB(n)?t.y:t.x,o={};for(const t of[...fa,"boxOutliers"]){const e=n.schema[t];"function"==typeof e&&(o[t]=mB(e,i))}return zF({...t,shapeConfig:{...t.shapeConfig,...o}},e)};var gB=fk({name:"BoxWhisker",paintDriven:!0,setup:t=>{t._buffer={...t._buffer,Box:fB},t._plotShapeEmitters={Box:pB},t._plotAxisValues=(e,n)=>function(t,e,n){return uB(t)&&n===sB(t)?e.flatMap(dB(t)):[]}(t,e,n),t._plotAxisRows=(e,n)=>hB(t,e,n)},ctx:{},fields:[{key:"boxMax",coerce:ma},{key:"boxMedian",coerce:ma},{key:"boxMin",coerce:ma},{key:"boxOutliers",coerce:ma},{key:"boxQ1",coerce:ma},{key:"boxQ3",coerce:ma},{key:"discrete",default:"x"},{key:"shape",default:W("Box"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>{const e=()=>Z(t._theme,t=>t.text,"black");return{Box:{whiskerConfig:{lineConfig:{stroke:e},endpointConfig:{fill:e}}}}}},{key:"tooltipShared",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>{if(!e)return"";for(;e.__d3plus__&&e.data;)n=(e=e.data).i;const i=t.schema.label;if(i)return i(e,n);const o=t._drawDepth+(uB(t)?1:0),r=t._ids(e,n).slice(0,o);return r[r.length-1]},tbody:(e,n)=>aB(t,e,n)})}]},XN);const yB={name:"Scatter",paintDriven:!0,ctx:{},fields:[{key:"shape",default:W("Circle"),coerce:"const"}]};var xB=fk(yB,XN);const bB=t=>String(t.key).split("::")[0];function kB(t){const e=new Map;for(const n of t)"circle"===n.type&&e.set(String(n.key),n.r);const n=[];t.forEach((t,i)=>{e.has(bB(t))&&n.push(i)});const i=n.map(n=>({node:t[n],r:e.get(bB(t[n]))})).sort((t,e)=>t.r===e.r?0:t.r<e.r?1:-1),o=t.slice();return n.forEach((t,e)=>o[t]=i[e].node),o}const _B=(t,e)=>kB(FF.Circle(t,e)),vB={name:"BubbleChart",paintDriven:!0,setup:t=>{t._plotShapeEmitters={...t._plotShapeEmitters,Circle:_B}},ctx:{},fields:[{key:"sizeMax",default:40},{key:"sizeScale",default:"sqrt"},{key:"sizeZero",default:!0},{key:"shapeConfig",merge:!0,factory:t=>({Circle:{stroke:()=>Tc(t),strokeWidth:W(1)}})}]};var wB=fk(vB,xB);const MB=t=>t*Math.PI/180,SB=t=>180*t/Math.PI;function CB(t,e,n,i){const[o,r]=e,a=r-o,s=Number.isFinite(t)&&a?(t-o)/a:0;return n+Math.max(0,Math.min(1,s))*(i-n)}function $B(t,e=[],n=void 0,i=10){const o=[0,...t,...e.flatMap(t=>[t.min,t.max])].filter(t=>"number"==typeof t&&Number.isFinite(t)),[r,a]=n??[],s=Number.isFinite(r)?r:Math.min(...o);let l=Number.isFinite(a)?a:Math.max(...o);l>s||(l=s+1);const[h,u]=c.scaleLinear().domain([s,l]).nice(i).domain();return[Number.isFinite(r)?s:h,Number.isFinite(a)?l:u]}function AB(t,e){return Math.max(2,Math.round(Math.abs(SB(e-t))/45))}function zB(t,e,n,i){const[o,r]=t,a=r-o;if(!1===e)return{major:[],minor:[]};const s=c.scaleLinear().domain(t),l="number"==typeof e?Math.max(1,e):i;let h;if(Array.isArray(e))h=e.filter(t=>Number.isFinite(t)&&t>=o&&t<=r).sort((t,e)=>t-e);else{const t=s.ticks(l),e=t.length>1?t[1]-t[0]:a;h=[o,...t.filter(t=>t-o>=e/2&&r-t>=e/2),r]}const u=n?s.ticks(Math.max(1,5*(h.length-1||l))).filter(t=>t>o&&t<r&&!h.some(e=>((t,e,n)=>Math.abs(t-e)<=1e-9*n)(e,t,a))):[];return{major:h,minor:u}}function DB(t,e,n){const[i,o]=e,r=[];let a=i;for(const e of t??[]){if(!e)continue;const t=u.clamp(Number.isFinite(e.min)?e.min:a,i,o),s=u.clamp(Number.isFinite(e.max)?e.max:o,i,o);a=s,s>t&&r.push({min:t,max:s,color:e.color??n})}return r}function LB(t,e){const n=Math.min(t,e),i=Math.max(t,e),o=[n,i],r=Math.PI/2;for(let t=Math.ceil(n/r);t*r<=i;t++)o.push(t*r);const a=[0,...o.map(t=>Math.sin(t))],s=[0,...o.map(t=>-Math.cos(t))];return{x0:Math.min(...a),x1:Math.max(...a),y0:Math.min(...s),y1:Math.max(...s)}}function FB(t,e){return{x0:Math.min(t.x0,e.x0),x1:Math.max(t.x1,e.x1),y0:Math.min(t.y0,e.y0),y1:Math.max(t.y1,e.y1)}}function NB(t,e,n){const i=n.x1-n.x0||1,o=n.y1-n.y0||1,r=Math.max(0,Math.min(t/i,e/o));return{cx:t/2-(n.x0+n.x1)/2*r,cy:e/2-(n.y0+n.y1)/2*r,radius:r}}function BB(t,e,n){const i=.2*e,o=.7*e;return`M${-e},0L${-i},${-t}L${i},${-t}L${e},0L${o},${n}L${-o},${n}Z`}function EB(t,e){const{indicator:n,hasBands:i,hasValue:o,extent:r}=e,a=e.hasName&&o,s="progress"!==n,c=function(t,e,n,i){const o=i?Math.max(1,n):1,r=o>1?Math.max(2,.02*t):0;let a=t*e;return o>1&&o*a+(o-1)*r>.5*t&&(a=Math.max(1,(.5*t-(o-1)*r)/o)),Array.from({length:o},(e,n)=>{const i=t-n*(a+r);return{inner:Math.max(0,i-a),outer:i}})}(t,u.clamp(e.thickness,.02,1),e.rows,!s),l=t,h=c[c.length-1].inner,d=s?l:h-.025*t,f=s?h:d-Math.max(2,.035*t),m=(s||!i?h:f)-.03*t,p=.07*t,g=e.tickFontSize??u.clamp(.075*t,8,16),y=m-p-.03*t-.8*g,x=Math.max(3,.055*t),b=o?u.clamp(t*(s?.2:.3),10,72):0,k=a?u.clamp(.085*t,9,20):0,_=.03*t,v=b+(a?_+k:0);let w;w=s?x+.06*t:r.y1>=.3?-v/2:-v-_;const M=w+b/2;return{outer:l,inner:h,rings:c,bandOuter:d,bandInner:f,tickOuter:m,majorLength:p,minorLength:p/2,tickLabelRadius:y,tickFontSize:g,hubRadius:x,needleLength:(h+l)/2,needleHalfWidth:Math.max(2,.03*t),needleTail:.12*t,valueY:M,valueFontSize:b,valueMaxWidth:Math.max(0,y)*(s?1.3:1.6),nameY:M+b/2+_+k/2,nameFontSize:k,nameMaxWidth:1.2*t}}function RB(t,e,n){if(t.schema.label)return!0;return(t.schema.groupBy??[]).some(t=>void 0!==t(e,n))}function PB(t){const e=t.schema.axisConfig??{},n=e.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?n:void 0}const TB=({viz:t})=>{const{width:e,height:n}=wt(t),i=t._filteredData??[],o=t.schema.value,r=i.map((t,e)=>Number(o(t,e))),a=Array.isArray(t.schema.bands)?t.schema.bands:[],s=MB(Number(t.schema.startAngle)||0),c=MB(Number(t.schema.endAngle)||0),l=t.schema.ticks,h="number"==typeof l?l:AB(s,c),u=$B(r,a,t.schema.domain,h),d=DB(a,u,t.schema.colorDefaults?.missing??"#ced4da"),f=zB(u,l,!1!==t.schema.minorTicks,h),m=1===i.length,p={indicator:"progress"===t.schema.indicator?"progress":"needle",thickness:Number(t.schema.thickness)||.2,hasBands:d.length>0,rows:i.length,hasValue:m,hasName:m&&RB(t,i[0],0),extent:LB(s,c),tickFontSize:PB(t)},g=NB(Math.max(0,e-4),Math.max(0,n-4),function(t){const e=100,n=EB(e,t);if(!n.valueFontSize){const i="progress"===t.indicator?0:n.needleTail/e;return FB(t.extent,{x0:0,x1:0,y0:0,y1:i})}const i=(n.nameFontSize?n.nameY+n.nameFontSize/2:n.valueY+n.valueFontSize/2)/e,o=(n.valueY-n.valueFontSize/2)/e,r="progress"===t.indicator?0:n.needleTail/e;return FB(t.extent,{x0:-.5,x1:.5,y0:Math.min(o,0),y1:Math.max(i,r)})}(p)),y=i.map((t,e)=>({__d3plus__:!0,data:t,i:e,value:r[e],angle:CB(r[e],u,s,c)}));return t.ctx.gauge={cx:g.cx+2,cy:g.cy+2,radius:g.radius,domain:u,start:s,end:c,ticks:f,bands:d,dial:p},{shapeData:y}};function OB(t){if(!Array.isArray(t))return[];const e=[];let n=!1;for(const i of t)"number"==typeof i?Number.isFinite(i)&&(e.push({max:i}),n=!0):i&&"object"==typeof i&&e.push({...i});const i=e[e.length-1];return n&&i&&void 0!==i.max&&e.push({}),e}function WB(t,e,n){const i=[...t,...e.flatMap(t=>[t.min,t.max])].filter(t=>"number"==typeof t&&Number.isFinite(t));return{extent:i.length?[Math.min(...i),Math.max(...i)]:[],input:n}}function jB(t,e=5){return $B(t.extent,[],t.input,e)}function HB(t,e,n,i,o){const r=e[1]-e[0]||1;return t.every((e,a)=>{if(!a)return!0;return(e-t[a-1])/r*n>=(i(e)+i(t[a-1]))/2+o})}function IB(t,e,n,i,o=70,r=8){if(!1===e)return{domain:jB(t),ticks:[]};if(Array.isArray(e)){const n=jB(t);return{domain:n,ticks:zB(n,e,!1,5).major}}if("number"==typeof e){const n=Math.max(1,e),i=jB(t,n);return{domain:i,ticks:zB(i,n,!1,n).major}}const a=Math.max(1,Math.floor(Math.max(0,n)/o));let s={domain:jB(t,1),ticks:[]};for(let e=a;e>=1;e--){const o=jB(t,e),a=zB(o,e,!1,e).major;if(s={domain:o,ticks:a},HB(a,o,n,i,r))return s}return{domain:s.domain,ticks:s.domain.slice()}}function GB(t,e){const n=function(t,e){const[n,i]=e,o=i-n;return Number.isFinite(t)&&o?Math.max(0,Math.min(1,(t-n)/o)):0}(e,t.domain),{band:i}=t;return"vertical"===t.orient?i.y+i.height*(1-n):i.x+i.width*n}function qB(t){const[e,n]=t;return Math.max(e,Math.min(n,0))}function VB(t,e,n,i){const{band:o}=t,r=GB(t,e),a=GB(t,n),s=Math.min(r,a),c=Math.abs(a-r),l=Math.max(0,Math.min(1,i));if("vertical"===t.orient){const t=o.width*l;return{x:o.x+(o.width-t)/2,y:s,width:t,height:c}}const h=o.height*l;return{x:s,y:o.y+(o.height-h)/2,width:c,height:h}}function KB(t,e,n){const i=GB(t,e);return"vertical"===t.orient?{...n,y:i,height:0}:{...n,x:i,width:0}}function YB(t,e,n){const{band:i}=t,o=GB(t,e),r=Math.max(0,Math.min(1,n));if("vertical"===t.orient){const t=i.width*(1-r)/2;return[[i.x+t,o],[i.x+i.width-t,o]]}const a=i.height*(1-r)/2;return[[o,i.y+a],[o,i.y+i.height-a]]}function UB(t){return t.axis?"vertical"===t.orient?7+t.tickLabelWidth:7+t.tickFontSize:0}function XB(t){return t.count>0&&t.width>0&&t.height>0?"vertical"===t.orient?function(t){const{width:e,height:n,count:i,labelHeight:o}=t,r=UB(t),a="row"===t.axis?r:0,s="shared"===t.axis?r:0,c=o?o+12:0,l=t.axis?t.tickFontSize/2:0,h=2+c+l,d=Math.max(0,n-h-Math.max(2,l)-2),f=Math.max(0,e-s-4),m=f/i,p=Math.min(Math.max(0,m-a),u.clamp(.45*(m-a),4,t.bulletSize)),g=a+p,y=Math.min(m,Math.max(g+Math.max(16,p),t.labelWidth+12)),x=2+s+(f-y*i)/2;return Array.from({length:i},(e,n)=>{const i=x+n*y,o=i+(y-p)/2+a/2;return{band:{x:o,y:h,width:p,height:d},label:{x:o+p/2,y:2,anchor:"middle",maxWidth:Math.max(0,y-8)},axis:"row"===t.axis||"shared"===t.axis&&0===n,hit:{x:i,y:2,width:y,height:h+d-2}}})}(t):function(t){const{width:e,height:n,count:i,labelHeight:o}=t,r=UB(t),a="row"===t.axis?r:0,s="shared"===t.axis?r:0,c=Math.min(t.labelWidth,.35*e),[l,h]=t.axis?t.tickOverhang:[0,0],d=c?2+c+Math.max(12,l):2+l,f=Math.max(0,e-d-2-h),m=Math.max(0,n-s-4),p=m/i,g=Math.min(Math.max(0,p-a),u.clamp(.62*(p-a),4,t.bulletSize)),y=g+a,x=Math.max(12,.6*g),b=Math.min(p,Math.max(y,o)+x),k=Math.max(0,(o-g)/2),_=b*(i-1)+y,v=2+Math.max(k,(m-_)/2);return Array.from({length:i},(e,n)=>{const r=v+n*b,a={x:d,y:r,width:f,height:g},s=Math.min(r,r+g/2-o/2);return{band:a,label:{x:2+c,y:r+g/2,anchor:"end",maxWidth:c},axis:"row"===t.axis||"shared"===t.axis&&n===i-1,hit:{x:0,y:s,width:d+f,height:Math.max(r+y,r+g/2+o/2)-s}}})}(t):[]}function QB(t,e){const n=function(t,e=.36,n=.12){if(t<=0)return[];if(1===t)return[(e+n)/2];const i=(e-n)/(t-1);return Array.from({length:t},(t,n)=>e-n*i)}(t.length);return t.map((t,i)=>t.color?t:{...t,color:e(n[i])})}function ZB(t,e,n){if("function"!=typeof t)return NaN;const i=t(e,n);return null==i||""===i?NaN:Number(i)}function JB(t,e,n){return t._ids(e,n).join("-")}function tE(t,e,n){const i=t.schema.bands;return OB("function"==typeof i?i(e,n):i)}function eE(t,e,n){return[ZB(t.schema.value,e,n),ZB(t.schema.target,e,n),ZB(t.schema.forecast,e,n)]}function nE(t,e){const n=!!t.schema.sharedDomain,i=new Map;return e.forEach((e,o)=>{const r=n?"*":JB(t,e,o),a=WB(eE(t,e,o),tE(t,e,o),function(t,e,n){const i=t.schema.domain,o="function"==typeof i?i(e,n):i;return Array.isArray(o)?o:void 0}(t,e,o)),s=i.get(r);var c,l;i.set(r,s?(l=a,WB([...(c=s).extent,...l.extent],[],c.input)):a)}),i}const iE=(t,e,n,i=400)=>t?r.textWidth(t,{"font-family":e,"font-size":n,"font-weight":i}):0;function oE(t,e,n,i){const o=t.ctx.bulletFacet,r=t.schema.sharedDomain?"*":JB(t,n,i);return o?.get(r)??e.get(r)??{extent:[],input:void 0}}function rE(t,e){const n=t.some(t=>t.name),i=t.some(t=>t.subLabel);return{labelWidth:Math.max(0,...t.map(t=>iE(t.name,e,13,600)),...t.map(t=>iE(t.subLabel,e,11))),labelHeight:(n?13:0)+(i?11+(n?2:0):0)}}const aE=({viz:t})=>{const{width:n,height:i}=wt(t),o=t._filteredData??[],r="vertical"===t.schema.orient?"vertical":"horizontal",a=function(t,n,i){const o=(t.schema.axisConfig??{}).shapeConfig??{},r=o.labelConfig??{},a=Tc(t),c=e.colorContrast(a,t.schema.colorDefaults),l=k.interpolateRgb(a,c),h=Tg(r.fontColor,n,i)??c,u=Tg(r.fontFamily,n,i)??t.schema.fontFamily,d=Tg(r.fontSize,n,i),f=t.schema.tickFormat;return{background:a,mix:l,trackFill:Tg(o.fill,n,i)??l(.08),tickStroke:Tg(o.stroke,n,i)??l(.55),tickStrokeWidth:Tg(o.strokeWidth,n,i)??1,fontColor:h,mutedColor:k.interpolateRgb(a,h)(.68),fontFamily:s.fontFamilyStringify(u),tickFontSize:"number"==typeof d&&d>0?d:10,tickFormat:t=>`${f(t)}`}}(t,o[0]??{},0),c=a.fontFamily,l=function(t,e){const n=t.schema.subLabel,i=nE(t,e);return e.map((e,o)=>{const r="function"==typeof n?n(e,o):void 0,[a,s,c]=eE(t,e,o);return{d:e,i:o,value:a,target:s,forecast:c,name:RB(t,e,o)?`${t._drawLabel(e,o)??""}`:"",subLabel:null==r?"":`${r}`,extent:oE(t,i,e,o)}})}(t,o),h=t.schema.ticks,u=t=>iE(a.tickFormat(t),c,a.tickFontSize),d=l.map(t=>jB(t.extent,10)),f=XB({orient:r,width:n,height:i,count:l.length,bulletSize:Math.max(1,Number(t.schema.bulletSize)||1),...rE(l,c),axis:!1!==h&&(t.schema.sharedDomain?"shared":"row"),tickFontSize:a.tickFontSize,tickLabelWidth:Math.max(0,...d.flatMap(t=>zB(t,10,!1,10).major.map(u))),tickOverhang:[Math.max(0,...d.map(t=>u(t[0])/2)),Math.max(0,...d.map(t=>u(t[1])/2))]}),m="vertical"===r,p=f.map((e,n)=>{const i=l[n],o=IB(i.extent,h,m?e.band.height:e.band.width,m?()=>1.2*a.tickFontSize:u,m?45:70);return{__d3plus__:!0,data:i.d,i:i.i,key:JB(t,i.d,i.i),value:i.value,target:i.target,forecast:i.forecast,name:i.name,subLabel:i.subLabel,track:{orient:r,band:e.band,domain:o.domain},bands:DB(QB(tE(t,i.d,i.i),a.mix),o.domain,a.mix(.2)),ticks:e.axis?o.ticks:[],axis:e.axis,label:e.label,hit:e.hit}});return t.ctx.bullet={orient:r,style:a,nameFontSize:13,subFontSize:11},{shapeData:p}};function sE(t,e,n){return{type:"path",key:t,interactive:!1,d:a.arcPath(e),arc:e,paint:{fill:n}}}function cE(t,e,n,i,o=8,a=400){const s=(t,n)=>r.textWidth(t,{"font-family":e,"font-size":n,"font-weight":a});let c=s(t,n);c>i&&c>0&&(c=s(t,n=Math.max(o,n*i/c)));let l=t;for(;c>i&&l.length>1;)if(l=l.slice(0,-1),c=s(`${l.trimEnd()}…`,n),c<=i)return{text:`${l.trimEnd()}…`,size:n,width:c};return{text:l,size:n,width:c}}function lE(t,e,n,i,o){return{type:"text",key:t,interactive:!1,x:0,y:0,transform:{x:n,y:i},lines:[{text:e,x:0,y:0,width:o.width??r.textWidth(e,{"font-family":o.family,"font-size":o.size})}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:"middle",baseline:"middle"},paint:{fill:o.color}}}function hE(t,e,n){return t.map(t=>{const i=Math.sin(t),o=Math.cos(t);return`M${e*i},${-e*o}L${n*i},${-n*o}`}).join("")}function uE(t,e,n,i){const{domain:o,start:r,end:a,ticks:s,bands:c}=n,l=t=>CB(t,o,r,a),h=e.rings.map((e,n)=>sE(`${t}-track-${n}`,{innerRadius:e.inner,outerRadius:e.outer,startAngle:r,endAngle:a},i.trackFill));c.forEach((n,i)=>h.push(sE(`${t}-band-${i}`,{innerRadius:e.bandInner,outerRadius:e.bandOuter,startAngle:l(n.min),endAngle:l(n.max)},n.color)));const u={fill:"none",stroke:i.tickStroke,strokeLinecap:"round"};return s.minor.length&&h.push({type:"path",key:`${t}-minor-ticks`,interactive:!1,d:hE(s.minor.map(l),e.tickOuter,e.tickOuter-e.minorLength),paint:{...u,strokeWidth:i.tickStrokeWidth/2,strokeOpacity:.75}}),s.major.length&&h.push({type:"path",key:`${t}-major-ticks`,interactive:!1,d:hE(s.major.map(l),e.tickOuter,e.tickOuter-e.majorLength),paint:{...u,strokeWidth:i.tickStrokeWidth}}),e.tickLabelRadius>0&&s.major.forEach((n,o)=>{const r=l(n),a=e.tickLabelRadius;h.push(lE(`${t}-tick-${o}`,i.tickFormat(n),a*Math.sin(r),-a*Math.cos(r),{size:e.tickFontSize,family:i.fontFamily,color:i.fontColor}))}),h}function dE(t,e,n,i,o){const r=[];if(i){const o=cE(i,n.fontFamily,e.valueFontSize,e.valueMaxWidth,8,600);r.push(lE(`${t}-value`,o.text,0,e.valueY,{size:o.size,family:n.fontFamily,color:n.fontColor,weight:600,width:o.width}))}if(o&&e.nameFontSize){const i=cE(o,n.fontFamily,e.nameFontSize,e.nameMaxWidth);r.push(lE(`${t}-name`,i.text,0,e.nameY,{size:i.size,family:n.fontFamily,color:n.fontColor,width:i.width}))}return r}function fE(t,e,n,i,o){return{type:"text",key:t,x:0,y:0,transform:{x:n,y:i},lines:[{text:e,x:0,y:0,width:o.width}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:o.anchor,baseline:"middle"},paint:{fill:o.color}}}function mE(t,e,n){const{track:i}=t,[o,r]=i.domain,a=qB(i.domain),s=(t,e,n,o)=>{const r=VB(i,e,n,1);return((t,e,n,i)=>({type:"rect",key:t,interactive:!1,...e,enterRect:i,paint:{fill:n}}))(t,r,o,KB(i,a,r))},c=[s(`${e}-track`,o,r,n.trackFill)];if(t.bands.forEach((t,n)=>c.push(s(`${e}-band-${n}`,t.min,t.max,t.color))),!t.ticks.length)return c;const l="vertical"===i.orient,{band:h}=i,u=l?h.x:h.y+h.height,d=t.ticks.map(t=>{const e=GB(i,t);return l?`M${u-4},${e}L${u},${e}`:`M${e},${u}L${e},${u+4}`}).join("");c.push({type:"path",key:`${e}-ticks`,interactive:!1,d:d,paint:{fill:"none",stroke:n.tickStroke,strokeWidth:n.tickStrokeWidth}});return t.ticks.forEach((t,o)=>{const r=GB(i,t),a=cE(n.tickFormat(t),n.fontFamily,n.tickFontSize,1/0);c.push({...fE(`${e}-tick-${o}`,a.text,l?u-7:r,l?r:u+7+n.tickFontSize/2,{size:n.tickFontSize,family:n.fontFamily,color:n.fontColor,anchor:l?"end":"middle",width:a.width}),interactive:!1})}),c}function pE(t,e,n){const{style:i,nameFontSize:o,subFontSize:r}=n,{label:a}=t,s=[];if(t.name&&s.push({text:t.name,size:o,weight:600,color:i.fontColor,kind:"name"}),t.subLabel&&s.push({text:t.subLabel,size:r,weight:400,color:i.mutedColor,kind:"sub"}),!(s.length&&a.maxWidth>0))return[];const c=s.reduce((t,e)=>t+e.size,0)+2*(s.length-1);let l="vertical"===n.orient?a.y:a.y-c/2;return s.map(n=>{const o=cE(n.text,i.fontFamily,n.size,a.maxWidth,8,n.weight),r=fE(`${e}-${n.kind}`,o.text,a.x,l+n.size/2,{size:o.size,family:i.fontFamily,color:n.color,anchor:a.anchor,width:o.width,weight:n.weight});return l+=n.size+2,{...r,datum:t.data,index:t.i}})}function gE(t,e,n,i){const{track:o,data:r,i:a}=e,s=[],c=qB(o.domain),l=Hg(t,"Rect"),h=Wg(l,r,a),u=t.schema.valueFormat,d=[e.name,Number.isFinite(e.value)?u(e.value,r):""];Number.isFinite(e.target)&&d.push(`${t.schema.translate("Target")} ${u(e.target,r)}`);const f={datum:r,index:a,aria:{label:`${d.filter(Boolean).join(", ")}.`}},m=t.schema.forecastConfig??{};if(Number.isFinite(e.forecast)){const t=Tg(m.size,r,a)??.6,i=Tg(m.fill,r,a)??Tg(l.fill,r,a),h=VB(o,c,e.forecast,t),u={type:"rect",key:`${n}-forecast`,...h,enterRect:KB(o,c,h),shapeType:"Rect",paint:{fill:Og({...l,...m},r,a,i),opacity:Tg(m.opacity,r,a)??.35},...f};s.push(u);const d=WS(m,u,r,a);d&&s.push(d)}if(Number.isFinite(e.value)){const i=Number(t.schema.measureSize),u=VB(o,c,e.value,Number.isFinite(i)?i:.35),d={type:"rect",key:`${n}-measure`,...u,enterRect:KB(o,c,u),shapeType:"Rect",paint:h,...f};s.push(d);const m=WS(l,d,r,a);m&&s.push(m)}const p=t.schema.targetConfig??{};if(Number.isFinite(e.target)){const t=Tg(p.size,r,a)??.75;s.push({type:"line",key:`${n}-target`,points:YB(o,e.target,t),shapeType:"Line",paint:{fill:"none",stroke:Tg(p.stroke,r,a)??i.style.fontColor,strokeWidth:Tg(p.strokeWidth,r,a)??3},...f})}return s}function yE(t){return"function"==typeof t?t:"string"==typeof t?G(t):"number"==typeof t&&W(t)}const xE={name:"Bullet",layoutStage:aE,emit:({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.bullet;if(!n.length||!i)return[];const o=new Map;return n.map(e=>{const n=o.get(e.key)??0;o.set(e.key,n+1);const r=`bullet-${e.key}${n?`-${n}`:""}`,a={type:"rect",key:`${r}::hit`,...e.hit,datum:e.data,index:e.i,paint:{fill:"transparent"}};return{type:"group",key:r,children:[{type:"group",key:`${r}-static`,interactive:!1,aria:{hidden:!0},children:mE(e,r,i.style)},a,...pE(e,r,i),...gE(t,e,r,i)]}})},facet:{aspect:2,share:(t,e)=>nE(t,e.flat()),panel:(t,e)=>(e.shared&&e.scales instanceof Map&&(t.ctx.bulletFacet=e.scales),()=>{t.ctx.bulletFacet=void 0})},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"bulletSize",default:40},{key:"domain"},{key:"forecast",default:H("forecast"),coerce:yE},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=t._filteredData??[],r=new Set(o.map((e,n)=>JB(t,e,n)));return!(i.length>=r.size)&&e.call(t,n,i)}}},{key:"measureSize",default:.35},{key:"orient",default:"horizontal"},{key:"sharedDomain",default:!1},{key:"subLabel",default:!1,coerce:yE},{key:"target",default:H("target"),coerce:yE},{key:"tickFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"value",default:H("value"),coerce:t=>yE(t)||H("value")},{key:"valueFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1},{key:"forecastConfig",merge:!0,default:{opacity:.35,size:.6}},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Tc(t),strokeWidth:1})},{key:"targetConfig",merge:!0,default:{size:.75,strokeWidth:3}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>function(t,e,n){const i=t.schema.valueFormat,o=[];for(const[r,a]of[["value","Value"],["target","Target"],["forecast","Forecast"]]){const s=ZB(t.schema[r],e,n);Number.isFinite(s)&&o.push([t.schema.translate(a),`${i(s,e)}`])}return o}(t,e,n)})}]};var bE=fk(xE);const kE={name:"BumpChart",paintDriven:!0,setup:t=>{const e=t;e.y2((e,n)=>t._y(e,n)),e.yConfig({tickFormat:e=>{const n=t._formattedData??[],i=n[0].x instanceof Date?n[0].x.getTime():n[0].x,o=n.filter(t=>(t.x instanceof Date?t.x.getTime():t.x)===i),r=o.find(t=>t.y===e);return r?t._drawLabel(r,r.i):""}}),e.y2Config({tickFormat:e=>{const n=t._formattedData??[],i=n[n.length-1].x instanceof Date?n[n.length-1].x.getTime():n[n.length-1].x,o=n.filter(t=>(t.x instanceof Date?t.x.getTime():t.x)===i),r=o.find(t=>t.y===e);return r?t._drawLabel(r,r.i):""}}),e.ySort((e,n)=>t._y(n)-t._y(e)),e.y2Sort((e,n)=>t._y(n)-t._y(e))},facet:{axes:"all"},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"discrete",default:"x"},{key:"shape",default:W("Line"),coerce:"const"}]};var _E=fk(kE,XN);const vE=/^(\d{4})-(\d{2})-(\d{2})$/;function wE(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function ME(t){if(Array.isArray(t))return t.length?ME(t[0]):null;if(t instanceof Date)return isNaN(+t)?null:wE(t);if("number"==typeof t)return Number.isFinite(t)?wE(new Date(t)):null;if("string"!=typeof t||!t.trim())return null;const e=vE.exec(t.trim());if(e){const[t,n,i]=[+e[1],+e[2]-1,+e[3]],o=new Date(t,n,i);return o.setFullYear(t),o.getMonth()===n&&o.getDate()===i?o:null}const n=new Date(t);return isNaN(+n)?null:wE(n)}function SE(t){return`${`${t.getFullYear()}`.padStart(4,"0")}-${`${t.getMonth()+1}`.padStart(2,"0")}-${`${t.getDate()}`.padStart(2,"0")}`}function CE(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),i=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.round((i-n)/864e5)}function $E(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function AE(t,e){return((t.getDay()-e)%7+7)%7}function zE(t,e,n){return Math.floor((CE(e,t)+AE(e,n))/7)}const DE=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function LE(t,e){if("number"==typeof t&&Number.isFinite(t))return(Math.round(t)%7+7)%7;if("string"==typeof t&&t.length>=2){const e=t.toLowerCase(),n=DE.findIndex(t=>t.startsWith(e));if(n>=0)return n}return l.findWeekStart("string"==typeof e?e:"")}function FE(t){if(!t.length)return null;let e=t[0],n=t[0];for(const i of t)+i<+e&&(e=i),+i>+n&&(n=i);return[e,n]}function NE(t,e,n){const i=[];if(+e<+t)return i;if("month"===n){let n=t.getFullYear(),o=t.getMonth();const r=12*e.getFullYear()+e.getMonth();for(;12*n+o<=r;)i.push({key:`${SE(new Date(n,o,1)).slice(0,7)}`,start:new Date(n,o,1),end:new Date(n,o+1,0)}),o+=1,o>11&&([n,o]=[n+1,0]);return i}for(let n=t.getFullYear();n<=e.getFullYear();n++)i.push({key:`${n}`,start:new Date(n,0,1),end:new Date(n,11,31)});return i}function BE(t,e){return zE(t.end,t.start,e)+1}function EE(t,e){const n=CE(t.start,t.end)+1,i=AE(t.start,e),o=[];for(let e=0;e<n;e++){const n=$E(t.start,e);o.push({date:n,key:SE(n),week:Math.floor((e+i)/7),day:(e+i)%7})}return o}function RE(t){return NE(t.start,t.end,"month")}function PE(t){return"string"==typeof t&&l.locale[t]||l.locale["en-US"]}function TE(t,e,n){const i=void 0===t?n:t;if("function"==typeof i){const t=i;return e=>`${t(e)??""}`}return"string"==typeof i&&i?y.timeFormatLocale(e).format(i):null}function OE(t){const e=t.dateTime.replace(/[,.]?\s*%X/g,"").replace(/[\s,.]+$/,"").replace(/%e/g,"%-d").trim()||t.date;return/%[aA]/.test(e)?e:`%A, ${e}`}function WE(t,e){const[n=""]=Array.from(t.trim());try{return n.toLocaleUpperCase(e)}catch{return n.toUpperCase()}}function jE(t){const{count:e,gridColumns:n,gridRows:i,insetTop:o,insetLeft:r,gap:a,width:s,height:c}=t,l=Math.max(1,e),h=t.columns?[Math.min(l,Math.max(1,Math.round(t.columns)))]:Array.from({length:l},(t,e)=>e+1);let u;for(const t of h){const e=Math.ceil(l/t),h=(s-t*r-(t-1)*a)/(t*n),d=(c-e*o-(e-1)*a)/(e*i),f=Math.max(0,Math.min(h,d));(!u||f>u.cell+1e-9)&&(u={cell:f,columns:t,rows:e})}const{cell:d,columns:f,rows:m}=u,p=r+n*d,g=o+i*d;return{cell:d,columns:f,rows:m,blockWidth:p,blockHeight:g,width:f*p+(f-1)*a,height:m*g+(m-1)*a}}function HE(t,e,n){return"vertical"===n?[e,t]:[t,e]}function IE(t,e){return"vertical"===e?{columns:7,rows:t}:{columns:t,rows:7}}function GE(t,e,n,i){const{week:o,day:r}=t,{week:a,day:s}=e,c=t=>Math.round(100*t)/100;return`${[[o+1,r],[o,r],[o,7],[a,7],[a,s+1],[a+1,s+1],[a+1,0],[o+1,0]].map(([t,e],o)=>{const[r,a]=HE(t,e,i);return`${o?"L":"M"}${c(r*n)},${c(a*n)}`}).join("")}Z`}function qE(t){return 0===t.day?t.week:t.week+1}function VE(t,e){return t>=e?[0,1,2,3,4,5,6]:[1,3,5]}function KE(t,e){return t>0&&e>0?Math.min(t,e/3):0}const YE=new Date(2023,0,1);function UE(t){return Math.max(3,Math.round(.4*t))}function XE(t,e){return Array.from({length:7},(n,i)=>t($E(YE,(e+i)%7)))}function QE(t,e,n,i,o){const r=n.fontSize,a=UE(r),s=1.15*r+a,c=r+a,l=n.weekday?i+a:0;if("month"===t){return{top:(n.title.length?s:0)+("vertical"===e&&n.weekday?c:0),left:"horizontal"===e?l:0}}return"vertical"===e?{top:(n.year?s:0)+(n.weekday?c:0),left:n.month?o+a:0}:{top:n.month?c:0,left:l+(n.year?s:0)}}function ZE(t,e,n){const i=t=>Math.round(100*t)/100;return t.replace(/(-?[\d.]+),(-?[\d.]+)/g,(t,o,r)=>`${i(+o+e)},${i(+r+n)}`)}function JE(t){const{start:e,end:n,period:i,orient:o,weekStart:r,width:a,height:s,labels:c}=t,l=NE(e,n,i),h=Math.max(1,...l.map(t=>BE(t,r))),u=c.weekday?XE(c.weekday,r):[],d=c.month?Math.max(0,...Array.from({length:12},(t,e)=>c.measure(c.month(new Date(2023,e,1))))):0,f=Math.max(0,...u.map(c.measure)),m=QE(i,o,c,f,d),p=IE(h,o),g="month"===i?1.5*c.fontSize:c.fontSize,y=jE({count:l.length,gridColumns:p.columns,gridRows:p.rows,insetTop:m.top,insetLeft:m.left,gap:g,width:a,height:s,columns:"month"===i?void 0:"vertical"===o?l.length:1}),{cell:x}=y,b=Math.max(0,(a-y.width)/2),k=Math.max(0,(s-y.height)/2),_=[],v=[],w=[];return l.forEach((e,n)=>{const a=b+n%y.columns*(y.blockWidth+g),s=k+Math.floor(n/y.columns)*(y.blockHeight+g),l={block:e,left:a,top:s,x:a+m.left,y:s+m.top};for(const t of EE(e,r)){const[n,i]=HE(t.week,t.day,o);_.push({...t,block:e.key,x:l.x+n*x,y:l.y+i*x,size:x})}c.weekday&&v.push(...function(t,e,n,i){const{labels:o,orient:r}=n,a=o.fontSize,s=UE(a),c="vertical"===r;let l=e,h=VE(i,1.25*a);if(c){const t=(t,e)=>Math.max(...t.map(o.measure))<=e,n=e.map(o.narrow);t(e,i-2)?h=[0,1,2,3,4,5,6]:t(n,i)?[l,h]=[n,[0,1,2,3,4,5,6]]:t(n,2*i-2)?[l,h]=[n,[0,2,4,6]]:h=[]}return h.map(e=>({key:`${t.block.key}-weekday-${e}`,kind:"weekday",text:l[e],x:c?t.x+(e+.5)*i:t.x-s,y:c?t.y-s-a/2:t.y+(e+.5)*i,anchor:c?"middle":"end"}))}(l,u,t,x)),"year"===i&&c.month&&v.push(...function(t,e,n,i){const{labels:o,orient:r,weekStart:a}=e,s=o.month,c=o.fontSize,l=UE(c),h=[];let u=-1/0;for(const e of RE(t.block)){const d=qE({week:zE(e.start,t.block.start,a),day:AE(e.start,a)});if(d>=i)continue;const f=s(e.start),m=d*n,p="vertical"===r?c:o.measure(f);m<u||m+("vertical"===r?0:p)>i*n+l||(u=m+p+l,h.push({key:`${t.block.key}-month-${e.key}`,kind:"month",text:f,x:"vertical"===r?t.x-l:t.x+m,y:"vertical"===r?t.y+m+n/2:t.y-l-c/2,anchor:"vertical"===r?"end":"start"}))}return h}(l,t,x,BE(e,r)));const h=function(t,e,n,i){const{labels:o,orient:r,period:a}=e,s=o.fontSize,c=`${t.block.key}-${"month"===a?"title":"year"}`;if("month"===a){const e=o.title.map(e=>e(t.block.start)).find((t,e,i)=>e===i.length-1||1.1*o.measure(t)<=n.blockWidth);return void 0===e?null:{key:c,kind:"title",text:e,x:t.left,y:t.top+.6*s,anchor:"start"}}if(!o.year)return null;const l=o.year(t.block.start);return"vertical"===r?{key:c,kind:"year",text:l,x:t.x+i/2,y:t.top+.6*s,anchor:"middle"}:{key:c,kind:"year",text:l,x:t.left+.6*s,y:t.y+7*n.cell/2,anchor:"middle",rotate:-90}}(l,t,y,p.columns*x);h&&v.push(h),"year"===i&&w.push(...function(t,e,n,i){return RE(t.block).map(o=>{const r=n=>({week:zE(n,t.block.start,e),day:AE(n,e)}),a=GE(r(o.start),r(o.end),n,i);return{key:`${t.block.key}-outline-${o.key}`,d:ZE(a,t.x,t.y)}})}(l,r,x,o))}),{blocks:l,fit:y,cells:_,labels:v,outlines:w}}function tR(t,e,n){const i=t.schema.date;return ME("function"==typeof i?i(e,n):void 0)}function eR(t,e){const n=[];return e.forEach((e,i)=>{const o=tR(t,e,i);o&&n.push(o)}),FE(n)}function nR(t){return"month"===t.schema.period?"month":"year"}function iR(t){const e=t.schema.orient;return"horizontal"===e||"vertical"===e?e:"month"===nR(t)?"vertical":"horizontal"}function oR(t){const e=t.schema.calendarLabelConfig??{},n=e.fontFamily??t.schema.fontFamily;return{fontColor:"string"==typeof e.fontColor?e.fontColor:void 0,fontFamily:s.fontFamilyStringify(n),fontSize:"number"==typeof e.fontSize?e.fontSize:11,fontWeight:e.fontWeight??400}}function rR(t){const e=PE(t.schema.locale);return TE(OE(e),e,!1)}function aR(t,e,n){const i=PE(t.schema.locale),o=[];if("month"===e){const e=TE(t.schema.monthFormat,i,!1);if(e)o.push(e);else if(!1!==t.schema.monthFormat)for(const t of["%B %Y","%b %Y","%b"])o.push(TE(t,i,!1))}return{fontSize:n.fontSize,measure:t=>r.textWidth(t,{"font-family":n.fontFamily,"font-size":n.fontSize,"font-weight":n.fontWeight}),weekday:TE(t.schema.weekdayFormat,i,"%a"),month:"year"===e?TE(t.schema.monthFormat,i,"%b"):null,year:"year"===e?TE(t.schema.yearFormat,i,"%Y"):null,title:o,narrow:e=>WE(e,t.schema.locale)}}const sR=({viz:t})=>{const e=t._filteredData??[],n=new Map;e.forEach((e,i)=>{const o=tR(t,e,i);if(!o)return;const r=SE(o);n.has(r)||n.set(r,{datum:e,i:i})});const i=t.ctx.calendarSharedExtent??eR(t,e);if(t.ctx.calendarLayout=void 0,!i)return{shapeData:[]};const{width:o,height:r}=wt(t),a=nR(t),s=oR(t),c=JE({start:i[0],end:i[1],period:a,orient:iR(t),weekStart:LE(t.schema.weekStart,t.schema.locale),width:o,height:r,labels:aR(t,a,s)});t.ctx.calendarLayout=c,t.ctx.calendarDateFormat=rR(t),t.ctx.calendarLabelStyle=s;return{shapeData:c.cells.map(t=>{const e=n.get(t.key);return e?{...t,datum:e.datum,i:e.i}:t})}};function cR(t,e){const n=k.interpolateRgb(t,e);return{empty:n(.09),outline:n(.45),text:n(.75)}}function lR(t,e,n){const i=t.schema.colorScale;if("function"!=typeof i)return;const o=i(e,n);return null!=o&&""!==o&&"boolean"!=typeof o&&Number.isFinite(+o)?+o:void 0}function hR(t,e,n){return"function"!=typeof t.schema.colorScale||void 0!==lR(t,e,n)}function uR(t,e,n){if(!t.schema.monthOutline)return[];const i=t.schema.monthOutlineConfig??{},o=i.strokeDasharray;return e.outlines.map(t=>({type:"path",key:`calendar-${t.key}`,d:t.d,interactive:!1,paint:{fill:"none",stroke:i.stroke??n,strokeWidth:i.strokeWidth??1,...o?{strokeDasharray:o}:{}}}))}const dR=({viz:t,shapeData:n})=>{const i=n??[],o=t.ctx.calendarLayout;if(!i.length||!o)return[];const a=t.ctx.calendarLabelStyle,s=Tc(t),c=cR(s,e.colorContrast(s,t.schema.colorDefaults)),l=Hg(t,"Rect"),h=o.fit.cell,u=Math.min(Math.max(0,Number(t.schema.cellPadding)||0),h/2),d=Math.max(0,h-u),f={viz:t,sc:l,emptyFill:t.schema.emptyFill??t._theme?.colorScale.missing??c.empty,padding:u,side:d,radius:KE(Number(t.schema.cellRadius)||0,d),noData:t.schema.translate("No Data"),dateFormat:t.ctx.calendarDateFormat},m=i.map(t=>function(t,e){const{viz:n,sc:i,emptyFill:o,noData:r}=e,a={type:"rect",key:`calendar-${t.key}`,x:t.x+e.padding/2,y:t.y+e.padding/2,width:e.side,height:e.side,...e.radius?{rx:e.radius,ry:e.radius}:{}},{datum:s,i:c}=t;if(!s){const n=e.dateFormat?e.dateFormat(t.date):t.key;return{...a,interactive:!1,paint:{fill:o},aria:{label:`${n}, ${r}.`}}}const l=lR(n,s,c??0),h=hR(n,s,c??0),u=h?Tg(i.fill,s,c):o,d=Tg(i.ariaLabel,s,c)??t.key,f=h?l:r;return{...a,datum:s,index:c,shapeType:"Rect",paint:{fill:h?Og(i,s,c,u):u,stroke:Tg(i.stroke,s,c),strokeWidth:Tg(i.strokeWidth,s,c),opacity:Tg(i.opacity,s,c)??1},aria:{label:`${void 0===f?d:`${d}, ${f}`}.`}}}(t,f)),p=i.filter(t=>t.datum),g=m.filter(t=>t.datum),y=t=>r.textWidth(t,{"font-family":a.fontFamily,"font-size":a.fontSize,"font-weight":a.fontWeight}),x=o.labels.map(t=>function(t,e,n,i){const o="year"===t.kind||"title"===t.kind;return{type:"text",key:`calendar-label-${t.key}`,interactive:!1,x:0,y:0,transform:{x:t.x,y:t.y,...t.rotate?{rotate:t.rotate}:{}},lines:[{text:t.text,x:0,y:0,width:i(t.text)}],font:{family:e.fontFamily,size:e.fontSize,weight:o?600:e.fontWeight,anchor:t.anchor,baseline:"middle"},paint:{fill:n}}}(t,a,a.fontColor??c.text,y));return[...m,...jS(l,g,t=>[p[t].datum,p[t].i]),...uR(t,o,c.outline),...x]},fR=t=>void 0!==t.date?t.date:t.time,mR={name:"Calendar",layoutStage:sR,emit:dR,insetRegion:function(t){const{width:e,height:n}=wt(t);return{bounds:{x:t._margin.left,y:t._margin.top,width:e,height:n},obstacles:Xc(t._chartScene||[],t._chartTransform,void 0,!0)}},defaults:{hoverOutline:!0},facet:{aspect:3,share:(t,e)=>FE(e.flatMap(e=>eR(t,e)??[])),panel:(t,{shared:e,scales:n})=>(t.ctx.calendarSharedExtent=e&&n?n:void 0,()=>{t.ctx.calendarSharedExtent=void 0})},colorScaleTooltip:!1,ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellRadius",default:2},{key:"date",default:fR,coerce:t=>"function"==typeof t?t:G(t)},{key:"emptyFill"},{key:"monthFormat"},{key:"monthOutline",default:!0},{key:"orient"},{key:"period",default:"year"},{key:"weekStart"},{key:"weekdayFormat"},{key:"yearFormat"},{key:"zoom",default:!1},{key:"colorScale",default:H("value"),coerce:Rl},{key:"groupBy",factory:t=>[(e,n)=>{const i=tR(t,e,n);return i?SE(i):e.id}]},{key:"label",coerce:"const",factory:t=>(e,n)=>{const i=tR(t,e,n);return i?rR(t)(i):""}},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>!!t._legendCategories&&e.call(t,n,i)}},{key:"calendarLabelConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,default:{hoverOpacity:1}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[[()=>t.schema.translate("Value"),(e,n)=>{const i=lR(t,e,n);return void 0===i?"":p.formatAbbreviate(i,t.schema.locale)}]]})},{key:"monthOutlineConfig",merge:!0,default:{}}]};var pR=fk(mR);function gR(t){const e=(e,n)=>{const i=t._id(e,n);return Array.isArray(i)?i:[i]};return n=>{const i=new Set;(t._facetPanels?t._facetPanels.map(t=>t.scene):[t._chartScene||[]]).forEach(t=>De(t,t=>i.add(t)));const o=new Set;return n.forEach(t=>e(t,0).forEach(t=>o.add(t))),(t,r)=>!t.__d3plus__&&(i.has(t)?n.has(t):e(t,r).some(t=>o.has(t)))}}function yR(t){if(null==t||""===t||"boolean"==typeof t)return;const e="number"==typeof t?t:Number(t);return Number.isFinite(e)?e:void 0}function xR(t,e,n){const i=yR(n.close(t,e));if(void 0===i)return;const o=yR(n.open(t,e))??i,r=yR(n.high(t,e)),a=yR(n.low(t,e));return{open:o,high:Math.max(r??-1/0,o,i),low:Math.min(a??1/0,o,i),close:i}}function bR(t,e){return e>=t?"up":"down"}function kR(t,e){if(Number.isFinite(t)&&Number.isFinite(e)&&0!==t)return(e-t)/Math.abs(t)}function _R(t,e){let n=1/0,i=-1/0;for(const{d:o,i:r}of t){const t=xR(o,r,e);t&&(t.low<n&&(n=t.low),t.high>i&&(i=t.high))}return n<=i?[n,i]:void 0}function vR(t,e){const n=Array.from(new Set(t.filter(Number.isFinite))).sort((t,e)=>t-e);let i=1/0;for(let t=1;t<n.length;t++)i=Math.min(i,n[t]-n[t-1]);return Number.isFinite(i)&&i>0?i:e}function wR(t,e){const n=Number.isFinite(e)?Math.min(1,Math.max(0,e)):.7;return Math.max(1,t*n)}const MR=t=>Math.round(t-.5)+.5;function SR(t,e,n){const i=Math.min(n.open,n.close),o=Math.max(n.open,n.close),r=Math.min(n.high,i),a=Math.max(n.low,o),s=e/2;let c="";return r<i&&(c+=`M${t},${r}V${i}`),a>o&&(c+=`M${t},${o}V${a}`),c+=`M${t-s},${i}H${t+s}V${o}H${t-s}Z`,c}function CR(t,e,n){const i=e/2;return`M${t},${n.high}V${n.low}M${t-i},${n.open}H${t}M${t},${n.close}H${t+i}`}const $R=["open","high","low","close","volume"],AR=new WeakMap;function zR(t){if("function"==typeof t)return t;if("string"!=typeof t)return W(t);const e=G(t);return AR.set(e,t),e}function DR(t){const e=H(t);return AR.set(e,t),e}function LR(t){return"function"==typeof t?AR.get(t):void 0}const FR=(t,e)=>t.map(e).map(yR).filter(t=>void 0!==t),NR=(t,e)=>FR(t,e)[0],BR=(t,e)=>FR(t,e).at(-1),ER=(t,e)=>{const n=FR(t,e);return n.length?Math.max(...n):void 0},RR=(t,e)=>{const n=FR(t,e);return n.length?Math.min(...n):void 0},PR=(t,e)=>{const n=FR(t,e);return n.length?n.reduce((t,e)=>t+e,0):void 0},TR={open:NR,high:ER,low:RR,close:BR,volume:PR},OR=new Set(Object.values(TR)),WR=t=>OR.has(t);function jR(t,e){const n=new Map;for(const t of $R){const i=LR(e[t]);void 0!==i&&n.set(i,TR[t])}for(const e of Object.keys(t))WR(t[e])&&!n.has(e)&&delete t[e];n.forEach((e,n)=>{t[n]&&!WR(t[n])||(t[n]=e)})}function HR(t,e,n){let i;for(const o of $R){const r=e[o];if("function"!=typeof r||void 0!==LR(r))continue;const a=n[o],s="function"!=typeof a||WR(a)?TR[o]:a;(i??(i={}))[o]=s(t,e=>r(e,t.indexOf(e)))}return i}const IR=t=>Object.fromEntries($R.map(e=>[e,t.schema[e]])),GR=new WeakMap;function qR(t,e){return(n,i)=>{const o=GR.get(t)?.get(n);return o&&e in o?o[e]:t.schema[e](n,i)}}function VR(t){return{open:qR(t,"open"),high:qR(t,"high"),low:qR(t,"low"),close:qR(t,"close")}}function KR(t,e,n,i=4){let[o,r]=t;const a=n.invert,s=(t,e)=>{const i=n(t);if(!a||!Number.isFinite(i))return t;const o=Number(a(i+e));return Number.isFinite(o)?o:t},c=s(e[1],-i),l=s(e[0],i);return c>r&&(r=c),l<o&&(o=l),[o,r]}function YR({data:t,x:e,y:n,x2:i}){if(i)return[e,n];!function(t,e){if(t.padding)return void t.padding(1);const n=Array.from(new Set(e.filter(Number.isFinite))).sort((t,e)=>t-e);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,$o(t,n[e-1],n[e]));if(!Number.isFinite(i))return;const[o,r]=t.domain().map(Number);t.domain([Ao(t,o,-i),Ao(t,r,i)])}(e,t.map(t=>+t.x));const o=_R(t.map(t=>({d:t.data,i:t.i})),VR(this));if(!o)return[e,n];const r=KR(n.domain().slice().reverse(),o,n);return n.domain(r.slice().reverse()),[e,n]}const UR=["day","week","month","quarter","year"],XR=[2,5,10,20,50,100,200,500,1e3];function QR(t){if(t instanceof Date)return t;if("string"!=typeof t&&"number"!=typeof t)return t;const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:t}function ZR(t){const e=!t.getHours()&&!t.getMinutes()&&!t.getSeconds();return y.timeFormat(e?"%b %-d, %Y":"%b %-d, %Y %-I:%M %p")(t)}function JR(t,e){const n=t.getFullYear(),i=t.getMonth();switch(e){case"day":return 31*(12*n+i)+t.getDate();case"week":return+x.timeMonday.floor(t);case"month":return 12*n+i;case"quarter":return 4*n+Math.floor(i/3);default:return n}}function tP(t,e){if(!t.length)return[];const n=Math.max(1,Math.floor(e)),i=UR.map(e=>function(t,e){const n=[];for(let i=1;i<t.length;i++)JR(t[i],e)!==JR(t[i-1],e)&&n.push(t[i]);return n}(t,e)),o=i[i.length-1],r=i.concat(XR.map(t=>o.filter(e=>e.getFullYear()%t===0))).filter((t,e,n)=>{return t.length&&!(e&&(i=t,o=n[e-1],i.length===o.length&&i.every((t,e)=>+t===+o[e])));var i,o}),a=r.filter(t=>t.length<=n),s=a.length?a:r.slice(-1);return s.length?s.flatMap(e=>e.length>1?[[t[0],...e],e]:[[t[0],...e]]):[[t[0]]]}function eP(t){const e=new Map(t.map((t,e)=>[+t,e])),n=(n,i)=>{const o=e.get(+n);return Boolean(o)&&JR(t[o],i)!==JR(t[o-1],i)},i=new WeakMap;return function(t){if(!(t instanceof Date))return String(t);const e=this?Ho(this):void 0;if(!e?.length)return ZR(t);let o,r=i.get(e);r||i.set(e,r=function(t,e){return UR.slice().reverse().find(n=>t.slice(1).every(t=>e(t,n)))??"day"}(e,n));for(const n of e)+n<+t&&(o=n);return function(t,e,n){const i=!e||e.getFullYear()!==t.getFullYear();return"year"===n?y.timeFormat("%Y")(t):"day"===n||"week"===n?y.timeFormat(i?"%b %-d, %Y":"%b %-d")(t):e?y.timeFormat(i?"%Y":"%b")(t):y.timeFormat("%b %Y")(t)}(t,o,r)}}function nP(t){const e=function(t){const e=t._filteredData||[],n=new Map;return e.forEach((e,i)=>{const o=t._x?t._x(e,i):void 0;o instanceof Date&&!isNaN(+o)&&!n.has(+o)&&n.set(+o,o)}),Array.from(n.values()).sort((t,e)=>+t-+e)}(t);return{labels:tP(e,(t.schema.width-t._margin.left-t._margin.right-60)/72),tickFormat:eP(e)}}const iP={height:.2,gap:16,axisConfig:{},shapeConfig:{fillOpacity:.5}};function oP(t){return null==t||!1===t?void 0:zR(t)}const rP=t=>"function"==typeof t.schema.volume;function aP(t){const e=t.schema.volumeConfig??{};return{...iP,...e}}function sP(t,e,n){return rP(t)?yR(qR(t,"volume")(e,n)):void 0}function cP(t,e){if(!(e>0))return{height:0,gap:0};const n=Number(t.height),i=Number.isFinite(n)&&n>0?n:iP.height,o=Math.min(i<=1?i*e:i,.5*e),r=Math.max(0,Number.isFinite(Number(t.gap))?Number(t.gap):iP.gap);return{height:Math.round(o),gap:r}}function lP(t){const e=c.scaleLinear().domain([0,t>0?t:1]).nice(2);return{domain:e.domain(),ticks:e.ticks(2)}}function hP(t,e){return d.max(e,(e,n)=>sP(t,e,n))??0}const uP=new WeakMap;function dP(t){return"panel"===t._facetStep&&t._plotFacetScales?uP.get(t)??0:hP(t,t._filteredData||[])}function fP(t){const e=t._yConfig?.labels;return!(Array.isArray(e)&&!e.length)}function mP(t,e){return p.formatAbbreviate(e,t.schema.locale)}function pP(t,e){const{domain:n,ticks:i}=lP(dP(t)),o=fP(t);return(new Va).renderMode("compute").select(null).config(Dz(t,{locale:t.schema.locale,scale:"linear",domain:[n[1],n[0]],range:e,ticks:i,labels:o?i.filter(t=>t>0):[],tickFormat:e=>mP(t,e),gridSize:0,rounding:"none",title:!1,height:e[1],width:e[1]})).config(aP(t).axisConfig)}function gP(t){t._plotInsetBottom=e=>{if(!rP(t))return 0;const{height:n,gap:i}=cP(aP(t),e);return n?n+i:0},t._plotMinLeft=()=>rP(t)&&fP(t)?function(t){const e=t.outerBounds();return e.width?e.width+t.padding():0}(pP(t,[0,100]).measure()):0}function yP(t){const e=t.insetBottom??0;if(!(e>0))return;const n=t.yRange[1]-(t.x2Height??0),{gap:i}=aP(t.viz);return{top:n+Math.min(i,e),bottom:n+e,left:t.xRange[0],right:t.xRange[t.xRange.length-1]}}const xP=t=>"path"===t.type||String(t.key).endsWith("::hit");function bP(t,e,n,i,o){const{viz:r}=t,a=yP(t);if(!a||!e.size)return[];const{domain:s}=lP(dP(r)),c=a.bottom-a.top,l=new Map;e.forEach(({cx:t,width:e},n)=>{const i=sP(r,n.data,n.i);if(void 0===i||i<0)return;const o=Math.min(c,i/s[1]*c);l.set(n,{cx:t,width:e,top:a.bottom-o})});const h=aP(r),u=Pg("Path").renderMode("compute").config(Hg(r,i)).config(n).config(te.bind(r)(h.shapeConfig)).config({d:t=>{const{cx:e,width:n,top:i}=l.get(t),o=n/2;return`M${e-o},${i}H${e+o}V${a.bottom}H${e-o}Z`},hitArea:t=>{const{cx:e,width:n}=l.get(t),i=Math.max(n,6);return{x:e-i/2,y:a.top,width:i,height:c}},id:t=>`${t.id}_${t.discrete}_volume`,label:!1,x:0,y:0}),d=u.schema.fill,f=u.schema.texture;u.config({texture:(t,e)=>o(f(t,e),d(t,e))}).data(Array.from(l.keys())),r._wirePlotShapeEvents(u,i,t.events);const m=Gg(u).map(t=>{const n=t.datum,o=n&&xP(t)?{interactionPoints:e.get(n)?.interactionPoints}:{};return{...t,shapeType:i,...o}}),p=pP(r,[a.top,a.bottom]);p.render();const g=p.toScene();return[...m,_P({...g,key:"candlestick-volume-axis",transform:{x:a.left-kP(p,g),y:0}})]}function kP(t,e){const n=(e.children||[]).find(t=>"bar"===t.key&&"line"===t.type),i=n?.points?.[0]?.[0];if(Number.isFinite(i))return i;const o=t.outerBounds();return o.x+o.width}function _P(t){const e=t.children;return{...t,interactionGroup:"axis",...e?{children:e.map(_P)}:{}}}function vP(t,e){if(Math.abs(t)<1)return p.formatAbbreviate(t,e,".3~g");const n=p.formatAbbreviate(1.5,e,".1f").charAt(1),[i,o=""]=p.formatAbbreviate(t,e,",.2f").split(n);return`${i}${n}${o.padEnd(2,"0")}`}function wP(t,e){return`${t>0?"+":""}${p.formatAbbreviate(100*t,e,".2f")}%`}function MP(t,e,n){const i=t._x?t._x(e,n):void 0,o=t._xConfig?.tickFormat,r=QR(i);return"function"==typeof o?String(o(r)):r instanceof Date?ZR(r):String(i??"")}function SP(t,e,n){const i=xR(e,n,VR(t));if(!i)return[];const o=e=>t.schema.translate(e),r=function(t){const e=t._yConfig?.tickFormat;return"function"==typeof e?t=>String(e(t)):e=>vP(e,t.schema.locale)}(t),a=[[dz(t,"x"),MP(t,e,n)],[o("Open"),r(i.open)],[o("High"),r(i.high)],[o("Low"),r(i.low)],[o("Close"),r(i.close)]],s=kR(i.open,i.close);void 0!==s&&a.push([o("Change"),wP(s,t.schema.locale)]);const c=sP(t,e,n);return void 0!==c&&a.push([o("Volume"),mP(t,c)]),a}function CP(t,e,n){const[i,...o]=SP(t,e,n);return`${AP(t,e,n,i?.[1])}: ${o.map(([t,e])=>`${t} ${e}`).join(", ")}.`}function $P(t,e,n){const i=sP(t,e,n),o=void 0===i?"":` ${mP(t,i)}`;return`${AP(t,e,n,MP(t,e,n))}: ${t.schema.translate("Volume")}${o}.`}function AP(t,e,n,i){return[t._drawLabel(e,n),i].filter(t=>void 0!==t&&""!==t).join(", ")}const zP="Candlestick",DP=(t,e)=>"function"==typeof t?t(e.data,e.i):t;function LP(t,e,n,i,o){const r=VR(t),a=t.schema.variant,s=Math.min(Math.abs(o[o.length-1]-o[0]),40),c=e.map(t=>n(t.x)),l=wR(vR(c,s),Number(t.schema.bodyWidth)),h=l>=2?2*Math.round(l/2):l,u=new Map;return e.forEach((t,e)=>{const n=xR(t.data,t.i,r);if(!n||!Number.isFinite(c[e]))return;const o={open:MR(i(n.open)),high:MR(i(n.high)),low:MR(i(n.low)),close:MR(i(n.close))};if(![o.open,o.high,o.low,o.close].every(Number.isFinite))return;const s=MR(c[e]);u.set(t,{cx:s,width:h,px:o,direction:bR(n.open,n.close),d:"ohlc"===a?CR(s,h,o):SR(s,h,o)})}),u}function FP(t,e){if(!t)return t;const n="string"==typeof e?i.color(e):null;if(!n)return t;const o="object"==typeof t?{...t}:{texture:t};return o.stroke||(o.stroke=n.darker(1).formatHex()),o}const NP=t=>{const{viz:e,x:n,y:i,xRange:o}=t,r=t.values,a=LP(e,r,n,i,o);if(!a.size)return[];const s=t=>a.get(t),c=e.schema.shapeConfig[zP],l=Pg("Path").renderMode("compute").config(Hg(e,zP)).config(function(t,e){const n=n=>DP("up"===e(n).direction?t.schema.upColor:t.schema.downColor,n);return{fill:i=>{const{direction:o}=e(i);return"ohlc"===t.schema.variant||"up"===o&&t.schema.hollow?"none":n(i)},stroke:n,strokeWidth:1,strokeLinecap:"butt"}}(e,s)).config(c?te.bind(e)(c):{}).config({ariaLabel:t=>CP(e,t.data,t.i),d:t=>s(t).d,hitArea:t=>{const{cx:e,width:n,px:i}=s(t),o=Math.max(n,6);return{x:e-o/2,y:i.high-2,width:o,height:i.low-i.high+4}},id:t=>`${t.id}_${t.discrete}`,label:!1,x:0,y:0}),h=l.schema.fill,u=l.schema.backgroundImage,d=l.schema.texture;l.config({backgroundImage:(t,e)=>"none"!==h(t,e)&&u(t,e),texture:(t,e)=>FP(d(t,e),h(t,e))}).data(Array.from(a.keys())),e._wirePlotShapeEvents(l,zP,t.events);const f=(t,e)=>[{x:e.cx,y:e.px.close,datum:t,index:t.i}],m=Gg(l).map(t=>{const e=t.datum,n=e&&a.get(e),i=n&&xP(t)?{interactionPoints:f(e,n)}:{};return{...t,shapeType:zP,...i}});if(!rP(e)||!yP(t))return m;const p=new Map;a.forEach((t,e)=>p.set(e,{cx:t.cx,width:t.width,interactionPoints:f(e,t)}));const g=bP(t,p,function(t,e){return{ariaLabel:e=>$P(t,e.data,e.i),fill:n=>DP("up"===e(n).direction?t.schema.upColor:t.schema.downColor,n),stroke:"none",strokeWidth:0}}(e,s),zP,FP),y=t.yRange[0]-(t.x2Height??0);return[{type:"group",key:"candlestick-price",clip:{type:"rect",x:o[0],y:y,width:o[o.length-1]-o[0],height:t.yRange[1]-t.yRange[0]},children:m},...g]};const BP=t=>t.ctx.candlestick;function EP(t){const e=BP(t),n=qR(t,"close");Object.defineProperty(t,"_x",{configurable:!0,enumerable:!0,get:()=>t.schema.skipGaps?e.xDate:e.x,set:t=>{t!==e.xDate&&t!==e.x&&(e.x=t)}}),Object.defineProperty(t,"_y",{configurable:!0,enumerable:!0,get:()=>n,set:e=>{e!==n&&(t.schema.close=e)}}),Object.defineProperty(t,"_yKey",{configurable:!0,enumerable:!0,get:()=>e.yKey??t.schema.translate("Close"),set:n=>{e.yKey="y"===n?void 0:n,void 0!==e.yKey&&"function"==typeof t.schema.close&&function(t,e){AR.set(t,e)}(t.schema.close,n)}})}const RP={name:"Candlestick",paintDriven:!0,facet:{aspect:16/9},setup:t=>{const e=H("date");t.ctx.candlestick={x:e,xDate:(e,n)=>QR(BP(t).x(e,n))},t._xKey="date",EP(t),function(t){const e=new WeakMap;GR.set(t,e),t._mergeRows=i=>{const o=n.merge(i,t.schema.aggs);if(i.length>1){const n=HR(i,IR(t),t.schema.aggs);n&&e.set(o,n)}return o}}(t),gP(t),t._buffer={...t._buffer,[zP]:YR},t._plotShapeEmitters={[zP]:NP},t._plotColumnHighlight=gR(t),t._tooltipAxisRows=!1,t._yTitle=null;const i=t._preDraw.bind(t);t._preDraw=()=>{!function(t){const e=BP(t),n=t.schema.time;void 0!==n&&n!==e.time||(e.time=t.schema.skipGaps?void 0:(e,n)=>t._x(e,n),t.schema.time=e.time)}(t),function(t){jR(t.schema.aggs,IR(t))}(t),i()};const o=t._draw.bind(t);t._draw=e=>(t._plotAxisDefaults=t.schema.skipGaps?{x:nP(t)}:void 0,"chrome"===t._facetStep&&function(t){uP.set(t,hP(t,t._filteredData||[]))}(t),o(e))},ctx:{},fields:[{key:"open",coerce:zR,factory:()=>DR("open")},{key:"high",coerce:zR,factory:()=>DR("high")},{key:"low",coerce:zR,factory:()=>DR("low")},{key:"close",coerce:zR,factory:()=>DR("close")},{key:"volume",coerce:oP},{key:"volumeConfig",merge:!0,default:iP},{key:"variant",default:"candlestick"},{key:"upColor",default:"#2f9e44"},{key:"downColor",default:"#e03131"},{key:"hollow",default:!0},{key:"bodyWidth",default:.7},{key:"skipGaps",default:!0},{key:"discrete",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:W(zP),coerce:"const"},{key:"timeline",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>SP(t,e,n)})}]};var PP=fk(RP,XN);const TP={out:.06,in:.06};function OP(t){const e={},{fontFamily:n,fontWeight:i}=t;return("string"==typeof n||Array.isArray(n))&&(e.fontFamily=n),"number"!=typeof i&&"string"!=typeof i||(e.fontWeight=i),e}function WP(t,e){const n={"font-family":r.fontExists(e.fontFamily??s.fontFamily),"font-size":100,"font-weight":e.fontWeight??400},i=r.textWidth(t,n);return t=>i*t/100}const jP=t=>"text"===t.type&&t.lines.some(t=>t.text.replace(/(\.\.\.|…)$/,"").trim().length>0);function HP(t,e,n={}){if(!e.length)return[];const i=new Map(e.map(t=>[t.key,t.fit.fontSize]));return Ky(t,e.map(t=>({key:t.key,text:t.text,d:t.fit.d,color:t.color,anchor:"middle",datum:t.datum,index:t.index})),{fontWeight:400,...n,fontColor:t=>t.color,fontSize:t=>i.get(t.key)??10},{halo:!1}).filter(jP).map(t=>({...t,fadeSwap:TP}))}function IP(t,e=[]){const n=e.slice();return t.filter(t=>{const e=rM([t]);return!e.some(t=>n.some(e=>av(t,e)))&&(n.push(...e),!0)})}const GP=1e-6;function qP(t={}){return{fontMin:8,fontMax:24,padding:2,lineHeight:1.2,maxLines:3,...t}}function VP(t){const e=[];let n=!1;for(const i of s.textSplit(t))n?e[e.length-1]+=i.replace("",""):e.push(i.replace("","")),n=i.endsWith("");return e}function KP(t,e){const n=VP(t).map(t=>t.trim()).filter(Boolean);if(!n.length)return{words:[],space:0};const[i,...o]=e([" ",...n]);return{words:o,space:i}}function YP(t,e,n){return("function"==typeof t?t(e,0):t)??n}function UP(t,e,n){const i={"font-family":r.fontExists(YP(n.fontFamily,e,s.fontFamily)),"font-size":100,"font-weight":YP(n.fontWeight,e,400)};return KP(t,t=>r.textWidth(t,i).map(t=>t/100))}function XP(t,e,n){let i=1,o=0;for(const r of t.words){const a=r*e;if(a>n+GP)return 1/0;const s=o?o+t.space*e+a:a;s>n+GP?(i++,o=a):o=s}return i}function QP(t,e,n){if(!t(e))return null;let i=e,o=Math.max(e,n);for(;i<o;){const e=Math.ceil((i+o)/2);t(e)?i=e:o=e-1}return i}const ZP=2*Math.PI,JP=1e-6,tT=5;function eT(t,e){return Math.max(t,.3*e)}function nT(t,e){return[t*Math.sin(e),-t*Math.cos(e)]}function iT(t,e){const n=[nT(1,t),nT(1,e)];return jy(n)===n}function oT(t,e,n,i){const o=t=>Math.round(100*t)/100,[r,a]=i?[e,n]:[n,e],[s,c]=nT(t,r),[l,h]=nT(t,a),u=n-e>Math.PI?1:0,d=o(t);return`M${o(s)},${o(c)}A${d},${d} 0 ${u} ${i?1:0} ${o(l)},${o(h)}`}function rT(t,e,n,i){const o=t.innerRadius+n+e/2,r=t.outerRadius-n-e/2;return r<o-JP?null:"outer"===i?r:"inner"===i?o:(t.innerRadius+t.outerRadius)/2}function aT(t,e,n={}){const{fontMin:i=8,fontMax:o=24,padding:r=tT,endPadding:a=r,align:s="middle",minRadius:c=2.5,maxTurn:l=Math.PI,truncate:h=!0}=n,u=Math.min(t.startAngle,t.endAngle),d=Math.min(ZP,Math.abs(t.endAngle-t.startAngle));if(!(d>0&&t.outerRadius>t.innerRadius&&i>0))return null;if(t.innerRadius<=0&&d>=ZP-JP)return null;const f=u+d/2,m=iT(f-.01,f+.01),p=Math.sqrt(t.innerRadius**2+t.outerRadius**2),g=(t.padAngle??0)*p,y=e=>{const n=rT(t,e,r,s);if(null===n)return null;const i=n+(m?-.3:.3)*e;if(i<c*e)return null;const o=n-e/2;if(!(o>0))return null;const h=Math.min(l,d-(g+2*eT(a,e))/o,ZP-JP);return h>0?{radius:i,turn:h}:null};let x=QP(t=>{const n=y(t);return Boolean(n&&e(t)<=n.radius*n.turn+JP)},i,Math.max(i,o));const b=null===x;if(b){if(!h)return null;x=i}const k=y(x);if(!k)return null;const _=k.radius*k.turn;return b&&_<3*x?null:{d:oT(k.radius,f-k.turn/2,f+k.turn/2,m),fontSize:x,radius:k.radius,clockwise:m,length:_,truncated:b}}function sT(t,e,n,i={}){const{fontMin:o=8,fontMax:r=24,padding:a=tT,align:s="middle"}=i,c=Math.abs(t.endAngle-t.startAngle),l=Math.min(t.startAngle,t.endAngle)+c/2,h=iT(l-.01,l+.01)?1:-1,u=r=>{const c=Math.max(o,Math.round(.75*r)),l=r+1.3*c,u=rT(t,l,a,s);if(null===u)return null;const d=(e,n,o)=>aT({...t,innerRadius:e-n/2,outerRadius:e+n/2},o,{...i,fontMin:n,fontMax:n,padding:0,endPadding:i.endPadding??a,align:"middle",truncate:!1}),f=d(u+h*(l-r)/2,r,e),m=d(u-h*(l-c)/2,c,n);return f&&m?[f,m]:null},d=QP(t=>Boolean(u(t)),o,Math.max(o,r));return null===d?null:u(d)}function cT(t,e,n,i="straight"){if("inside"===t||"outside"===t)return e?"straight":null;if("along"===t)return n?"curved":null;return!n||n.truncated||e&&!e.truncated&&(o=n.fontSize,r=e.fontSize,!("curved"===i?o>=r:o>r))?e?"straight":n?"curved":null:"curved";var o,r}function lT(t,e,n){const i=t.schema.labelPosition;return"function"==typeof i?i(e,n):i}function hT(t,e){const n=t=>t.split(/\s+/).filter(Boolean),i=t.flatMap(n),o=n(e);return i.length!==o.length||i.some((t,e)=>t!==o[e])}function uT(t){const e=Ig(t,"Path").fontSize;return"number"==typeof e&&e>0?e:11}function dT(t,e,n){const i=uT(t),o=OP(Ig(t,"Path"));return e.map(e=>{const r=e.group;if(!r)return null;const a=lT(t,e.data,e.i);if("inside"===a||"outside"===a)return null;const s=`${t._drawLabel(e.data,e.i)??""}`;return s?aT({innerRadius:n,outerRadius:n+i+8,startAngle:r.startAngle,endAngle:r.endAngle},WP(s,o),{fontMin:i,fontMax:i,padding:4,align:"inner",minRadius:0,truncate:"along"===a}):null})}function fT(t,e,n){return e.every((e,i)=>!(e.group&&!n[i])||!`${t._drawLabel(e.data,e.i)??""}`)}function mT(t,e,n,i=11){const o=1.5*i;t.forEach(t=>{const i=t.group;if(!i)return;const r=(i.startAngle+i.endAngle)/2,a=r-Math.PI/2;t.labelX=Math.cos(a)*e,t.labelY=Math.sin(a)*e;let s=180*r/Math.PI-90;r>Math.PI?(s+=180,t.labelBounds={x:-(n+4),y:-o/2,width:n,height:o},t.labelAnchor="end"):(t.labelBounds={x:4,y:-o/2,width:n,height:o},t.labelAnchor="start"),t.labelRotate=s})}function pT(t,e,n,i){const o=Math.max(0,i),r=Math.min(t.schema.arcThickness,o),a=Math.max(0,o-r),s=null!=t.schema.padAngle?t.schema.padAngle:t.schema.padPixel/(o||1),c=(t.schema.directed?w.chordDirected():w.chord()).padAngle(s).sortSubgroups(d.descending)(n);c.groups.forEach(t=>{const n=e[t.index];n&&(n.group=t)});const l=b.arc().innerRadius(a).outerRadius(o),h=t.schema.arrows,u="function"==typeof h||!!h&&"source"!==h,f="number"==typeof t.schema.arrowSize?t.schema.arrowSize:void 0;let m;if(u){const t=w.ribbonArrow().radius(a).headRadius(f??Math.max(10,.75*r));m=e=>t(e)??""}else{const t=w.ribbon().radius(a);m=e=>t(e)??""}return{outer:o,chords:c,arcFn:t=>l(t)??"",ribbonFn:m}}const gT=({viz:t})=>{const e=t,{width:n,height:i}=wt(e),o=Array.isArray(e.schema.nodes)&&e.schema.nodes.length>0,r=Array.isArray(e.schema.links)&&e.schema.links.length>0;if(!o&&!r)return e.ctx.nodeLookup={},e.ctx.adjacency={},{viz:t};const a=(o?e.schema.nodes:function(t,e,n){const i=new Set,o=[];for(const r of t){const t=r[e];i.has(t)||(i.add(t),o.push(t));const a=r[n];i.has(a)||(i.add(a),o.push(a))}return o.map(t=>({id:t}))}(e.schema.links,e.schema.linksSource,e.schema.linksTarget)).map((t,n)=>({__d3plus__:!0,data:t,node:t,i:n,id:e.schema.nodeId(t,n),shape:"Path"})),s={};a.forEach((t,e)=>{s[String(t.id)]=e}),e.ctx.nodeLookup=s;const c=a.length,l=Array.from({length:c},()=>new Array(c).fill(0)),h={},u=(t,e)=>{var n,i;((n=h)[i=String(t)]??(n[i]=[])).push(e)};e.schema.links.forEach((t,n)=>{const i=s[String(t[e.schema.linksSource])],o=s[String(t[e.schema.linksTarget])];null!=i&&null!=o&&(l[i][o]+=e.schema.value(t,n)||0,u(a[i].id,a[o].id),u(a[o].id,a[i].id))}),e.ctx.adjacency=h;const d=Math.min(n,i)/2,f=Math.min(.28*d,90),m=uT(e)+8;let p=pT(e,a,l,d-m),g=dT(e,a,p.outer);fT(e,a,g)||(p=pT(e,a,l,d-f),g=dT(e,a,p.outer));const{chords:y,arcFn:x,ribbonFn:b}=p;return mT(a,p.outer,f,uT(e)),a.forEach((t,e)=>{t.labelCurve=g[e]??void 0}),e.ctx.chordCtx={nodes:a,chords:y,arcFn:x,ribbonFn:b},e.ctx.chordWidth=n,e.ctx.chordHeight=i,{shapeData:a}};const yT={name:"Chord",layoutStage:gT,emit:({viz:t})=>{const e=t.ctx.chordCtx;if(!e)return[];const n=[],i=Hg(t,"Path"),o=t.schema.chordOpacity??.6;n.push(...function(t,e,n,i){const o=[],r=[];for(let a=0;a<e.chords.length;a++){const s=e.chords[a],c=e.nodes[s.source.index],l=e.nodes[s.target.index];if(!c||!l)continue;const h=Tg(n.fill,c.data,c.i),u="string"==typeof h?h:void 0,d=Tg(n.opacity,c.data,c.i),f={type:"path",shapeType:"Chord",key:`chord-ribbon-${c.id}-${l.id}`,d:e.ribbonFn(s),datum:{source:{id:c.id},target:{id:l.id},value:s.source.value},index:a,paint:{fill:Og(n,c.data,c.i,h),fillOpacity:i,stroke:u,strokeOpacity:1,opacity:"number"==typeof d?d:1},aria:{label:`${t._drawLabel(c.data,c.i)} to ${t._drawLabel(l.data,l.i)}, ${s.source.value}.`}};o.push(f);const m=WS(n,{...f,paint:{...f.paint,opacity:(f.paint?.opacity??1)*i}},c.data,c.i);m&&r.push(m)}return[...o,...r]}(t,e,i,o));const r=[],a=e.nodes.filter(t=>Boolean(t.group));for(const n of a){const o=Wg(i,n.data,n.i);r.push({type:"path",key:`chord-arc-${n.id}`,d:e.arcFn(n.group),datum:n.data,index:n.i,paint:o,aria:{label:`${t._drawLabel(n.data,n.i)}, ${n.group.value}.`}})}return n.push(...r,...jS(i,r,t=>[a[t].data,a[t].i])),a.length&&n.push(...function(t,e){const n=Ig(t,"Path"),i=n.fontColor,o=Oc(t),r=t=>{const e=Tg(i,t.data,t.i);return"string"==typeof e?e:o},a=HP(t,e.filter(t=>t.labelCurve).map(e=>({key:`chord-label-curved-${e.id}`,text:`${t._drawLabel(e.data,e.i)}`,fit:e.labelCurve,color:r(e),datum:e.data,index:e.i})),OP(n)),s=e.filter(e=>!e.labelCurve&&"along"!==lT(t,e.data,e.i)),c=s.length?e_({data:s,label:e=>{const n=e;return t._drawLabel(n.data,n.i)},x:t=>t.labelX??0,y:t=>t.labelY??0,aes:()=>({}),rotate:t=>t.labelRotate??0,id:t=>`chord-label-${t.id}`,labelBounds:t=>t.labelBounds??!1,labelConfig:{fontColor:t=>r(t.data??t),...n,fontResize:!1,fontSize:uT(t),padding:0,textAnchor:t=>(t.data??t).labelAnchor??"start",verticalAlign:"middle"}}):[];return[...a,...IP(c,rM(a))]}(t,a)),n},chartTransform:t=>Mt(t,t.ctx.chordWidth,t.ctx.chordHeight),chartBodyRect:t=>{const e=t.ctx.chordWidth??0,n=t.ctx.chordHeight??0;return{x:-e/2,y:-n/2,width:e,height:n}},setup:t=>{const e=t;t.schema.color=(e,n)=>t.schema.groupBy[0](e,n)??t.schema.nodeId(e,n),t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{if(n(i,o,r,a),t._focus&&t._focus===i.id)return e.hover(!1),t.schema.on.mouseenter.bind(t)(i,o,r,a),void(t._focus=void 0);const s=i;if(s.source&&s.target){const n=s.source.id,i=s.target.id;return void e.hover((e,o)=>{if(e.source&&e.target)return e.source.id===n&&e.target.id===i;const r=t.schema.nodeId(e,o);return r===n||r===i})}const c=t.schema.nodeId(i,o),l=t.ctx.adjacency[String(c)]??[],h=[c,...l];e.hover((e,n)=>e.source&&e.target?e.source.id===c||e.target.id===c:h.includes(t.schema.nodeId(e,n)))},e.links=function(){return arguments.length?(_n(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(_n(this,"nodes",arguments),this):this.schema.nodes},e.nodeId=function(t){return arguments.length?(this.schema.nodeId="function"==typeof t?t:G(t),this):this.schema.nodeId},e.value=function(t){return arguments.length?(this.schema.value="function"==typeof t?t:G(t),this):this.schema.value},e.hover=mk},facet:{aspect:1},ctx:{},fields:[...Mn("links","nodes"),{key:"arcThickness",default:20},{key:"arrows",default:!1},{key:"arrowSize"},{key:"chordOpacity",default:.6},{key:"directed",default:!0},{key:"links",default:H("links")},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:H("nodes")},{key:"nodeId",default:H("id")},{key:"padAngle"},{key:"padPixel",default:2},{key:"value",default:W(1)},{key:"shape",default:W("Path"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>({Path:{label:!1}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:e=>e&&e.source&&e.target?`${e.source.id} → ${e.target.id}`:t._drawLabel(e,"number"==typeof e.i?e.i:0)})}]};var xT=fk(yT);const bT=2*Math.PI,kT=1e-9;function _T(t,e){const n=t=>"number"==typeof t&&Number.isFinite(t),i=n(t)?t*Math.PI/180:0,o=n(e)?e*Math.PI/180:i+bT;return{start:i,end:i+Math.max(-bT,Math.min(bT,o-i))}}function vT(t,e){return Math.abs(e-t)>=bT-kT}function wT(t,e){const n=e.end-e.start;if(!n)return 0;let i=(t-e.start)*Math.sign(n)%bT;return i<0&&(i+=bT),i/Math.abs(n)}const MT=t=>Math.abs(t)<kT?0:t;function ST(t,e,n=0){if(vT(t,e))return{x0:-1,x1:1,y0:-1,y1:1};const i=Math.min(t,e),o=Math.max(t,e),r=Math.max(0,Math.min(1,n)),a=[],s=[],c=(t,e)=>{a.push(MT(e*Math.sin(t))),s.push(MT(-e*Math.cos(t)))};c(i,1),c(o,1);const l=Math.PI/2;for(let t=Math.ceil(i/l-kT);t*l<=o+kT;t++)c(t*l,1);return c(i,r),c(o,r),{x0:Math.min(...a),x1:Math.max(...a),y0:Math.min(...s),y1:Math.max(...s)}}function CT(t,e,n,i){const o=ST(t,e,n>0?i/n:0);return{x0:o.x0*n,x1:o.x1*n,y0:o.y0*n,y1:o.y1*n}}function $T(t,e,n){const i=n.x1-n.x0,o=n.y1-n.y0;return Math.max(0,Math.min(i>0?t/i:1/0,o>0?e/o:1/0))}function AT(t,e,n,i,o=0,r=0){if(vT(n,i)){const n=Math.max(0,Math.min(t,e)/2-r);return{cx:t/2,cy:e/2,radius:n,box:{x0:-n,x1:n,y0:-n,y1:n}}}const a=Math.max(0,t-2*r),s=Math.max(0,e-2*r),c=Math.max(0,o);let l=$T(a,s,ST(n,i,0));if(c>0&&Number.isFinite(l)){let t=$T(a,s,ST(n,i,1));Number.isFinite(t)||(t=l);const e=t=>{const e=CT(n,i,t,c);return e.x1-e.x0<=a+kT&&e.y1-e.y0<=s+kT};for(let n=0;n<40&&t-l>1e-6;n++){const n=(l+t)/2;e(n)?l=n:t=n}}const h=Number.isFinite(l)?l:0,u=CT(n,i,h,c),d=u.x1-u.x0,f=u.y1-u.y0;return{cx:r+(a-d)/2-u.x0,cy:r+(s-f)/2-u.y0,radius:h,box:u}}function zT(t,e,n,i=0){const o=vT(e,n)?{x0:-1,x1:1,y0:-1,y1:1}:ST(e,n,0);return{width:t*(o.x1-o.x0)+2*i,height:t*(o.y1-o.y0)+2*i}}const DT=2*Math.PI,LT=1e-9,FT=t=>[Math.sin(t),-Math.cos(t)];function NT(t,e=0){let n=Math.min(t.startAngle,t.endAngle),i=Math.max(t.startAngle,t.endAngle);const o=t.innerRadius>0?t.innerRadius+e:0,r=t.outerRadius-e;if(!(i-n>LT&&r>o))return null;if(i-n>=DT-1e-6)return{mid:0,dir:FT(0),span:DT,inner:o,outer:r,sides:[]};const a=(t.padAngle??0)/2;let s=0;a>0&&t.innerRadius>0?s=Math.hypot(t.innerRadius,t.outerRadius)*Math.sin(a):a>0&&(n+=a,i-=a);const c=i-n;if(!(c>LT))return null;const l=(n+i)/2,h=s+e,u=[{normal:[Math.cos(n),Math.sin(n)],offset:h,ray:FT(n)},{normal:[-Math.cos(i),-Math.sin(i)],offset:h,ray:FT(i)}];return{mid:l,dir:FT(l),span:c,inner:o,outer:r,sides:u}}function BT(t,e,n,i){const[o,r]=t.normal,a=o*e[0]+r*e[1],s=t.offset+n*Math.abs(o)+i*Math.abs(r);return a>LT?s/a:1/0}function ET(t,e,n){const i=e/2,o=n/2,{dir:r,inner:a,outer:s,sides:c,span:l}=t,h=Math.abs(r[0]),u=Math.abs(r[1]),d=i*h+o*u,f=d*d-(i*i+o*o-s*s);if(i*i+o*o>s*s||f<0)return null;const m=-d+Math.sqrt(f);if(!(c.length||a>0))return{lo:-m,hi:m};let p=Math.max(0,function(t,e,n,i){if(!(i>0))return-1/0;const o=Math.abs(t[0]),r=Math.abs(t[1]),a=[];if(o>LT){const t=(e+i)/o;t*r<=n+LT&&a.push(t)}if(r>LT){const t=(n+i)/r;t*o<=e+LT&&a.push(t)}const s=e*o+n*r,c=s*s-(e*e+n*n-i*i);if(c>=0){const t=s+Math.sqrt(c);t*o>=e-LT&&t*r>=n-LT&&a.push(t)}return a.length?Math.min(...a):1/0}(r,i,o,a));return c.length&&(p=Math.max(p,l>Math.PI?function(t,e,n){const{dir:i,sides:o,span:r}=t;let a=Math.min(...o.map(t=>BT(t,i,e,n)));const s=o[0].offset/Math.sin(r/2),c=[[1,0],[-1,0],[0,1],[0,-1]];for(const t of c){const r=e=>t[0]*e[0]+t[1]*e[1];if(r(o[0].ray)<-1e-9||r(o[1].ray)<-1e-9)continue;const c=e*Math.abs(t[0])+n*Math.abs(t[1]),l=r(i),h=s*l;l<-1e-9?a=Math.min(a,(c-h)/-l):c<=h+LT&&(a=-1/0)}return a}(t,i,o):Math.max(...c.map(t=>BT(t,r,i,o))))),p<=m+LT?{lo:p,hi:Math.max(p,m)}:null}function RT(t,e,n,i){return{x:e*t.dir[0]-n/2,y:e*t.dir[1]-i/2,width:n,height:i}}function PT(t,e,n){const i=ET(t,e,n);return i?RT(t,(i.lo+i.hi)/2,e,n):null}function TT(t,e,n=40){const i=n=>null!==ET(t,...e(n));let o=0,r=2*t.outer;if(!i(o))return null;for(let t=0;t<n;t++){const t=(o+r)/2;i(t)?o=t:r=t}return o>0?PT(t,...e(o)):null}const OT={fontMin:10,fontMax:32,padding:5,lineHeight:1.2,shareRatio:.7,shareKeep:.75,shareFont:16,margin:.2,maxLines:4},WT=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0;function jT(t){const e=WT(t.fontSize),n=e??WT(t.fontMax)??OT.fontMax,i=Math.min(n,e??WT(t.fontMin)??OT.fontMin),o="number"==typeof t.padding&&t.padding>=0?t.padding:OT.padding;return{...OT,fontMin:i,fontMax:n,padding:o}}function HT(t,e,n){const i=t.split(/\s+/).filter(Boolean),o=i.length;if(!o)return[];const r=new Map,a=(t,n)=>{const o=`${t},${n}`;let a=r.get(o);return void 0===a&&(a=e(i.slice(t,n).join(" ")),r.set(o,a)),a};let s=Array.from({length:o+1},(t,e)=>e?a(0,e):0);const c=[s[o]];for(let t=2;t<=Math.min(n,o);t++){const e=s.map(()=>1/0);for(let n=t;n<=o;n++)for(let i=t-1;i<n;i++)e[n]=Math.min(e[n],Math.max(s[i],a(i,n)));s=e,c.push(s[o])}return c}function IT(t,e,n,i=OT){const{fontMin:o,fontMax:r,padding:a,lineHeight:s}=i;if(!e.length)return null;const c=(t,r,c)=>{const l=c?Math.max(o,Math.round(r*i.shareRatio)):null,h=t*s*r+1;return{width:1.02*Math.max(e[t-1]*r,l?n*l:0)+2,height:h+(l?a+s*l+1:0),nameHeight:h,shareSize:l,margin:Math.max(a,r*i.margin)}},l=e=>null!==ET(t,e.width+2*e.margin,e.height+2*e.margin),h=t=>{let n={lines:0,size:0};return e.forEach((e,i)=>{const a=((t,e)=>{let n=Math.ceil(o),i=Math.floor(r);if(i<n&&(i=n=o),!l(c(t,n,e)))return 0;for(;n<i;){const o=Math.ceil((n+i)/2);l(c(t,o,e))?n=o:i=o-1}return n})(i+1,t);a>n.size&&(n={lines:i+1,size:a})}),n},u=h(!1),d=null!==n?h(!0):{lines:0,size:0},f=Math.min(u.size*i.shareKeep,i.shareFont),m=d.size>0&&d.size>=f?{...d,share:!0}:{...u,share:!1};if(!m.size)return function(t,e){const{fontMin:n,padding:i,lineHeight:o}=e,r=o*n+2*i+1,a=TT(t,t=>[t,r]);return!a||a.width-2*i<2*n?null:{fontSize:n,lines:1,shareSize:null,name:a,share:null,center:[a.x+a.width/2,a.y+a.height/2],truncated:!0}}(t,i);const p=c(m.lines,m.size,m.share),g=PT(t,p.width+2*p.margin,p.height+2*p.margin),y=[g.x+g.width/2,g.y+g.height/2],x=y[0]-p.width/2-a,b=y[1]-p.height/2;return{fontSize:m.size,lines:m.lines,shareSize:p.shareSize,name:{x:x,y:b-a,width:p.width+2*a,height:p.nameHeight+2*a},share:p.shareSize?{x:x,y:b+p.nameHeight,width:p.width+2*a,height:s*p.shareSize+2*a+1}:null,center:y,truncated:!1}}function GT(t,e){const n=rM(t);if(!n.length)return;const i=e-(Math.min(...n.map(t=>t.y-t.height/2))+Math.max(...n.map(t=>t.y+t.height/2)))/2,o=new Set;for(const e of t){const t=e.transform;t&&!o.has(t)&&(o.add(t),t.y=(t.y??0)+i)}}const qT="center-label",VT=[1,2,3];function KT(t){return{fontColor:()=>Oc(t),fontMax:40,fontMin:10,padding:5}}function YT(t,e,n){const i=e_({data:[{text:t}],label:()=>t,x:()=>0,y:()=>0,aes:()=>({}),rotate:W(0),id:()=>qT,labelBounds:()=>({...e}),labelConfig:n}).filter(t=>"text"===t.type);return!i.length||i.some(t=>t.truncated)?null:i}const UT=t=>Math.max(...t.map(t=>t.font?.size??0));function XT(t,e,n){const i=t.schema.centerLabel;if(!i)return[];const o=function(t){const e=t.radius;if(!(e>0))return[];const{startAngle:n,endAngle:i}=t;if(void 0===n||void 0===i||vT(n,i))return[{x:-e,y:-e,width:2*e,height:2*e,shape:"circle"}];const o=NT({innerRadius:0,outerRadius:e,startAngle:n,endAngle:i});return o?VT.flatMap(t=>{const e=TT(o,e=>[e*t,e]);return e?[{...e,shape:"square"}]:[]}):[]}(e);if(!o.length)return[];const r=t._filteredData??[],a=function(t,e,n,i){if(!t)return"";if("function"==typeof t){const i=t(e,n);return i||0===i?String(i):""}return"string"==typeof t?t:p.formatAbbreviate(n,i)}(i,r,function(t,e){return t.reduce((t,n,i)=>{const o=Number(e(n,i));return Number.isFinite(o)?t+o:t},0)}(r,n),t.schema.locale);if(!a)return[];const s=function(t){const e=t.fontResize??void 0===t.fontSize;return{textAnchor:"middle",verticalAlign:"middle",...t,fontResize:e,pointerEvents:"none"}}(t.schema.centerLabelConfig??{});let c=null;for(const t of o){const e=YT(a,t,s);e&&(!c||UT(e)>UT(c.nodes))&&(c={nodes:e,box:t})}if(!c)return[];const l=c.nodes.map(t=>({...t,datum:void 0,index:void 0,interactive:!1}));return"middle"===s.verticalAlign&>(l,c.box.y+c.box.height/2),[{type:"group",key:qT,interactive:!1,children:l}]}function QT(t,e){return[()=>t.schema.translate("Share"),(n,i,o)=>{const r=e=>`${p.formatAbbreviate(100*e,t.schema.locale)}%`;if(o._isColorScaleBucket){const n=hh(t,o.color,t.schema[e]);return null==n?"":r(n)}const a=Ch(o);return Number.isFinite(a)?r(a):""}]}function ZT(t,e=()=>!0){const n=t.schema.legend;return(i,o)=>(o.length!==t._filteredData.length||!e(t))&&n.call(t,i,o)}function JT(t,e){return(n,i)=>{const o=t.schema[e];return o(i)-o(n)}}function tO(t){return{fontSize:t,lineHeight:Math.ceil(1.3*t),elbow:10,tail:8,gap:4}}function eO(t){return Math.sin(t)>=-1e-9?1:-1}function nO(t,e){return t+e.elbow+e.tail}function iO(t,e){const n={left:0,right:0},i=e.elbow+e.tail+e.gap;for(const{angle:e,width:o}of t){const t=1===eO(e)?"right":"left";n[t]=Math.max(n[t],o+i)}return n}function oO(t,e,n=()=>!0){const i=t.map(()=>null),o=Math.min(...e),r=Math.max(...e);let a=t.map((t,e)=>({...t,i:e})).filter(t=>t.size<=r-o).sort((t,e)=>t.y-e.y||t.i-e.i);for(;a.length;){const t=a[0].size/2,e=a[a.length-1].size/2,s=LD(a.map(t=>t.y),a.map(t=>t.size),[o+t,r-e]);if(s.every((t,e)=>t+a[e].size/2<=r+.5&&n(a[e].i,t))){a.forEach((t,e)=>i[t.i]=s[e]);break}const c=a.reduce((t,e)=>e.weight<t.weight||e.weight===t.weight&&e.i>t.i?e:t);a=a.filter(t=>t!==c)}return i}function rO(t,e){const n=e[0]-t[0],i=e[1]-t[1],o=n*n+i*i,r=o?Math.max(0,Math.min(1,-(t[0]*n+t[1]*i)/o)):0;return Math.hypot(t[0]+r*n,t[1]+r*i)}function aO(t,e,n,i){const o=eO(t),r=nO(e,i),a=Math.sin(t),s=Math.cos(t),c=[e*a,-e*s],l=[o*r,n],h=[o*(r-i.tail),n],u=[(e+i.elbow)*a,-(e+i.elbow)*s],d=[];rO(u,h)>=e+i.elbow/2-1e-9&&d.push([c,u,h,l]);let f=Math.abs(u[0]);const m=e*e-c[1]*n,p=Math.abs(c[0]);if(f*p<m&&(f=p<1e-9?1/0:m/p),f<=r-i.tail/2+1e-9){const t=[o*f,n];d.push([c,[(c[0]+t[0])/2,(c[1]+t[1])/2],t,l])}return d}function sO(t,e,n=2){for(let i=1;i<t.length;i++)for(let o=1;o<e.length;o++){const[r,a,s,c]=[t[i-1],t[i],e[o-1],e[o]],l=[a[0]-r[0],a[1]-r[1]],h=[c[0]-s[0],c[1]-s[1]],u=l[0]*h[1]-l[1]*h[0];if(Math.abs(u)<1e-12)continue;const d=[s[0]-r[0],s[1]-r[1]],f=(d[0]*h[1]-d[1]*h[0])/u,m=(d[0]*l[1]-d[1]*l[0])/u,p=Math.hypot(...l),g=Math.hypot(...h),y=(t,e)=>t*e>n&&(1-t)*e>n;if(y(f,p)&&y(m,g))return!0}return!1}function cO(t,e,n){return-(e+n.elbow)*Math.cos(t)}const lO=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0,hO=t=>t.datum?.data;function uO(t){const e=lO(t.fontSize),n=e??lO(t.fontMax)??24;return{fontMin:Math.min(n,e??lO(t.fontMin)??8),fontMax:n}}function dO(t,e){const n=t=>t.replace(/[\s\u00ad\u2010-]/g,""),i=n(e);return i.length>0&&n(t.join(""))===i}function fO(t){const{viz:n,slices:i,arcOf:o,nameOf:r,shareOf:a,fillOf:s,labelConfig:c}=t,l=new Map;for(const e of t.straight){const t=hO(e);if(!t)continue;const n=l.get(t);n?n.push(e):l.set(t,[e])}const h=OP(c),u=uO(c),d=[],f=[],m=new Set,p=new Map;i.forEach((t,i)=>{const g=t.i??i,y=r(t),x=l.get(t)??[],b=x[0],k=b?{fontSize:b.font?.size??0,truncated:hT(b.lines.map(t=>t.text),y)}:null,_=void 0!==b&&dO(b.lines.map(t=>t.text),y),v=o(t);if(!(v.innerRadius>0))return d.push(...x),void(_&&m.add(t));const w={...u,align:v.innerRadius>=.3*v.outerRadius?"middle":"outer"},M=WP(y,h),S=y?aT(v,M,w):null,C=cT(lT(n,t.data,g),k,S);if("straight"===C&&(d.push(...x),_&&m.add(t)),"curved"!==C||!S)return;const $=Tg(c.fontColor,t.data,g),A=s(t),z="string"==typeof $?$:e.colorContrast("string"==typeof A?A:"rgb(255, 255, 255)",n.schema.colorDefaults),D=a(t),L=S.truncated?null:sT(v,M,WP(D,h),w),F={color:z,datum:t.data,index:g},N=`pie-label-curved-${n._ids(t.data,g).join("-")}`;S.truncated||p.set(N,t),L?f.push({...F,key:N,text:y,fit:L[0]},{...F,key:`${N}-share`,text:D,fit:L[1]}):f.push({...F,key:N,text:y,fit:S})});const g=IP(HP(n,f,h),rM(d));for(const t of g){const e=p.get(String(t.key));e&&m.add(e)}return{straight:d,curved:g,whole:m}}const mO=t=>t.datum?.data;function pO(t){const{viz:n,slices:i,arcOf:o,sc:r,sharePct:a,labelConfig:s}=t,c=jT(s),l=OP(s),h=t=>WP(t,l)(1),u=new Map;i.forEach((t,e)=>{const i=n._drawLabel(t.data,t.i??e),r=i?NT(o(t)):null;if(!r)return;const s=IT(r,HT(String(i),h,c.maxLines),h(a(t)),c);s&&u.set(t,s)});const d=e_({data:i,label:(t,e)=>{const o=n._drawLabel(i[e].data,i[e].i??e);return u.get(i[e])?.share?[o,a(i[e])]:[o]},x:()=>0,y:()=>0,aes:()=>({}),rotate:W(0),id:(t,e)=>`pie-label-${e}`,labelBounds:(t,e)=>{const n=u.get(i[e]);if(!n)return!1;return(n.share?[n.name,n.share]:[n.name]).map(t=>({...t,angle:0}))},labelConfig:{fontColor:t=>{const i=t.data??t,o=Tg(r.fill,i.data,i.i??0);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",n.schema.colorDefaults)},textAnchor:"middle",verticalAlign:"middle",...s,fontResize:!1,fontSize:t=>{const e=t.data?u.get(t.data):void 0;return e?1===t.l&&e.shareSize?e.shareSize:e.fontSize:c.fontMin}}});if(void 0===s.verticalAlign){const t=new Map;for(const e of d){const n=mO(e);n&&t.set(n,[...t.get(n)??[],e])}t.forEach((t,e)=>{const n=u.get(e);n&>(t,n.center[1])})}return d}function gO(t,e){const n=t.split(/\s+/).filter(Boolean);let i=e(n.join(" "));for(let t=1;t<n.length;t++)i=Math.min(i,Math.max(e(n.slice(0,t).join(" ")),e(n.slice(t).join(" "))));return i}function yO(t){const e=t.schema.locale;return t=>`${p.formatAbbreviate(100*(t.share??0),e)}%`}function xO(t){const e=t.fontSize;return"number"==typeof e&&e>0?e:12}function bO(t,e){return"outside"===t||"inside"!==t&&"along"!==t&&!e}function kO(t,e){return e.some((e,n)=>{const i=lT(t,e.data,e.i??n);return"inside"!==i&&"along"!==i})}function _O(t,e){const n=t.ctx.arcData,i=t.ctx.pieLabelPlan;if(i&&i.arc===n&&i.slices===e)return i.plan;const o=n.innerRadius(),r=n.outerRadius(),a=Hg(t,"Path"),s=Ig(t,"Path"),c=yO(t),l=e=>t._drawLabel(e.data,e.i??0),h=t=>({innerRadius:o(t,t.i??0),outerRadius:r(t,t.i??0),startAngle:t.startAngle,endAngle:t.endAngle,padAngle:t.padAngle}),u=fO({viz:t,slices:e,arcOf:h,nameOf:l,shareOf:c,fillOf:t=>Tg(a.fill,t.data,t.i??0),straight:pO({viz:t,slices:e,arcOf:h,sc:a,sharePct:c,labelConfig:s}),labelConfig:s}),d=[];if(kO(t,e)){const n=OP(s),i=xO(s);e.forEach((e,o)=>{const r=e.i??o,a=l(e),s=lT(t,e.data,r);if(!a||!bO(s,u.whole.has(e)))return;const h=`${a} ${c(e)}`,f=t=>WP(t,n)(i);d.push({slice:e,index:r,angle:(e.startAngle+e.endAngle)/2,text:h,width:f(h),wrapWidth:gO(h,f),weight:e.value})})}const f={straight:u.straight,curved:u.curved,outside:d};return t.ctx.pieLabelPlan={arc:n,slices:e,plan:f},f}const vO={start:.5,end:1};function wO(t,e){const n=nO(t.radius,e)+e.gap;return{left:t.cx-n,right:t.width-t.cx-n}}function MO(t,e,n){const{radius:i,cy:o,height:r}=e,a=t.map(()=>null),s=(e,o)=>aO(t[e].angle,i,o,n);for(const e of[1,-1]){let c=t.map((t,n)=>eO(t.angle)===e?n:-1).filter(t=>t>=0);for(;c.length;){const e=oO(c.map(e=>({y:cO(t[e].angle,i,n),size:t[e].lines*n.lineHeight,weight:t[e].weight})),[-o,r-o],(t,e)=>s(c[t],e).length>0),l=c.map((t,n)=>({k:t,y:e[n]})).filter(t=>null!==t.y).sort((t,e)=>t.y-e.y),h=[];let u=!1;for(const{k:t,y:e}of l){const n=s(t,e).find(t=>h.every(e=>!sO(t,e.leader)));if(!n){u=!0;break}h.push({k:t,y:e,leader:n})}if(!u){for(const{k:t,y:e,leader:n}of h)a[t]={y:e,leader:n};break}const d=c.reduce((e,n)=>t[n].weight<t[e].weight?n:e);c=c.filter(t=>t!==d)}}return a}const SO=t=>t.match(/\S+\s*/g)??[],CO=t=>t.replace(/[\s\u00ad\u2010-]/g,"");function $O(t,e,n){const i=new Set,o=[],r=tO(xO(Ig(t,"Path"))),a=function(t,e,n,i){const o=Ig(t,"Path"),r=wO(n,i),a=nO(n.radius,i)+i.gap,s=t=>1===eO(t.angle),c=t=>s(t)?r.right:r.left,l=e.filter(t=>c(t)>=3*i.fontSize);if(!l.length)return[];const h=Oc(t),u=(new ei).renderMode("compute").locale(t.schema.locale).data(l.map((t,e)=>({id:`${e}`,c:t}))).config({fontWeight:400,...OP(o),fontSize:i.fontSize,lineHeight:1.2*i.fontSize,fontColor:({c:t})=>{const e=Tg(o.fontColor,t.slice.data,t.index);return"string"==typeof e?e:h},text:({c:t})=>t.text,split:SO,textAnchor:({c:t})=>s(t)?"start":"end",maxLines:2,ellipsis:t=>t,padding:0,x:({c:t})=>s(t)?a:-a-r.left,y:0,width:({c:t})=>c(t),height:2*i.lineHeight});return u.toScene().children.flatMap(e=>{const n=e.datum?.c;if(!n||"text"!==e.type||!e.lines.length)return[];const i=CO(t._drawLabel(n.slice.data,n.index)),o=c(n)+.5;return CO(e.lines.map(t=>t.text).join("")).startsWith(i)&&e.lines.every(t=>t.width<=o)?[{c:n,node:e}]:[]})}(t,e,n,r);if(!a.length)return{nodes:[],named:i,crowded:o};const s=MO(a.map(({c:t,node:e})=>({angle:t.angle,weight:t.weight,lines:e.lines.length})),n,r),c=Oc(t),l=1.2*r.fontSize,h=[],u=[];return a.forEach(({c:e,node:n},a)=>{const d=s[a];if(!d)return void o.push({angle:e.angle,size:n.lines.length*r.lineHeight});i.add(e.slice);const f=`pie-outside-${t._ids(e.slice.data,e.index).join("-")}`,m={interactive:!1,datum:e.slice.data,index:e.index,aria:{hidden:!0},enterWindow:vO},p=n.transform??{};h.push({...n,...m,key:f,transform:{...p,y:(p.y??0)+d.y-n.lines.length*l/2},paint:{...n.paint,opacity:1}}),u.push({type:"line",key:`${f}-leader`,...m,points:d.leader,curve:"linear",paint:{fill:"none",stroke:c,strokeWidth:1,strokeOpacity:.5,opacity:1}})}),{nodes:[...u,...h],named:i,crowded:o}}const AO=new WeakMap;function zO(t,e){const n=_O(t,e),i=AO.get(n);if(i)return i;const o=t.ctx.arcData,r=t.ctx.pieCenter,{width:a,height:s}=wt(t),c=e.length?$O(t,n.outside,{radius:o.outerRadius()(e[0],e[0].i??0),cx:r?.x??a/2,cy:r?.y??s/2,width:a,height:s}):{nodes:[],named:new Set,crowded:[]};return AO.set(n,c),c}const DO={left:0,right:0,top:0,bottom:0};function LO(t,e,n,i){const o=t+e,r=Math.max(0,n-i);if(o<=r)return[t,e];const a=o>0?r/o:0;return[t*a,e*a]}function FO(t,e,n){return t<=n?t:e<=n?e:0}function NO(t,e,n,i){if(!kO(t,e))return n;const{outside:o}=_O(t,e);if(!o.length)return n;const{width:r}=wt(t),a=tO(xO(Ig(t,"Path"))),s=.3*r,c=iO(o.map(t=>({angle:t.angle,width:FO(t.width,t.wrapWidth,s)})).filter(t=>t.width>0),a),[l,h]=LO(Math.max(n.left,Math.ceil(c.left)),Math.max(n.right,Math.ceil(c.right)),r,i);return{...n,left:l,right:h}}function BO(t,e,n,i){let o=t.top,r=t.bottom;for(const{angle:t,size:n}of e)Math.cos(t)>=0?o+=n:r+=n;return[o,r]=LO(o,r,n,i),{...t,top:o,bottom:r}}function EO(t,e){return{...t,left:e.left?t.left:0,right:e.right?t.right:0}}const RO=(t,e)=>t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom;function PO(t,e,n){let i=DO,o=e(i);for(let r=0;r<2;r++){const r=NO(t,o,i,n.width);if(RO(r,i))break;i=r,o=e(i)}if(!i.left&&!i.right)return o;const{crowded:r}=zO(t,o);if(r.length){const a=BO(i,r,wt(t).height,n.height);RO(a,i)||(i=a,o=e(i))}const a={left:!1,right:!1};for(const e of zO(t,o).named){a[1===eO((e.startAngle+e.endAngle)/2)?"right":"left"]=!0}const s=EO(i,a);return RO(s,i)?o:e(s)}function TO(t){return _T(t.schema.startAngle,t.schema.endAngle)}function OO(t){const{width:e,height:n}=wt(t),{start:i,end:o}=TO(t);return AT(e,n,i,o).radius}function WO(t){const{start:e,end:n}=TO(t),i=ST(e,n),o=i.y1-i.y0;return o>0?(i.x1-i.x0)/o:1}function jO(t){const e=t.schema.shapeConfig??{};return 3*("number"==typeof e.strokeWidth?e.strokeWidth:2)/2}function HO(t,e=DO){const{width:n,height:i}=wt(t),o=Math.max(0,n-e.left-e.right),r=Math.max(0,i-e.top-e.bottom),a=jO(t),s=TO(t),c=t.ctx.pie,l=t.schema.padAngle??0,h=t.schema.padPixel??0,u=t.schema.sort,d=t.schema.value,f=e=>c.startAngle(s.start).endAngle(s.end).padAngle(l||h/e).sort(u).value(d)(t._filteredData),m=AT(o,r,s.start,s.end,0,a),p=o<n||r<i?AT(n,i,s.start,s.end,0,a).radius:m.radius,g=p>0?m.radius/p:1,y=t.schema.innerRadius,x="function"==typeof y?y:()=>y,b=(t,e)=>x(t,e)*g;let k=f(m.radius);const _=k.reduce((t,e,n)=>Math.min(t,Number(b(e,n))||0),1/0),v=Number.isFinite(_)&&_>0?AT(o,r,s.start,s.end,_,a):m;v.radius!==m.radius&&(k=f(v.radius));const w=v.radius,M=k.reduce((t,e)=>t+e.value,0);return k.forEach((t,e)=>{t.__d3plus__=!0,t.i=e;const n=M?t.value/M:0;t.share=n,Mh(t.data,n)}),t.ctx.arcData=R.arc().innerRadius(b).outerRadius(w),t.ctx.pieData=k,t.ctx.pieSweep=s,t.ctx.pieCenter={x:e.left+v.cx,y:e.top+v.cy},t.ctx.pieBox=v.box,k}const IO=({viz:t})=>{const e=HO(t),n=TO(t),i=zT(.6*t.ctx.arcData.outerRadius()(e[0]),n.start,n.end,jO(t));return{shapeData:PO(t,e=>HO(t,e),i)}};const GO={name:"Pie",layoutStage:IO,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.arcData,o=i.innerRadius(),r=i.outerRadius(),s=Hg(t,"Path"),c=t._pendingEnterOrigin,l=c?.parentStartAngle,h=c?.parentEndAngle,u=void 0!==l&&void 0!==h?{start:l,span:h-l}:void 0,d=Boolean(t._pendingExitReunion),f=t.ctx.pieSweep??{start:0,end:a.FULL_TURN},m=t.schema.value,p=yO(t),g={viz:t,arcMaker:t=>i(t)??"",resolveInnerRadius:o,resolveOuterRadius:r,sc:s,value:m,sharePct:p,flipSource:u,isReunionDraw:d,sweep:f},y=n.map((t,e)=>function(t,e,n){const{viz:i,arcMaker:o,resolveInnerRadius:r,resolveOuterRadius:s,sc:c,value:l,sharePct:h,flipSource:u,isReunionDraw:d,sweep:f}=n,m=Tg(c.fill,t.data,t.i??0),p=Tg(c.stroke,t.data,t.i??0),g=Tg(c.strokeWidth,t.data,t.i??0),y={innerRadius:r(t,t.i??0),outerRadius:s(t,t.i??0),startAngle:t.startAngle,endAngle:t.endAngle,padAngle:t.padAngle},x=f.end-f.start||a.FULL_TURN,b=(t,e)=>e.start+(t-f.start)/x*e.span,k=u?{...y,startAngle:b(t.startAngle,u),endAngle:b(t.endAngle,u)}:void 0,_=d?{...y,startAngle:f.start,endAngle:f.end}:void 0;return{type:"path",key:`pie-${i._ids(t.data,t.i??0).join("-")}`,d:o(t),arc:y,flipFromArc:k,reunionFromArc:_,...(v=f,0===v.start&&v.end===a.FULL_TURN?{}:{sweep:{startAngle:f.start,endAngle:f.end}}),shapeType:"Pie",transform:{x:0,y:0},startAngle:t.startAngle,endAngle:t.endAngle,datum:t.data,paint:{fill:Og(c,t.data,t.i??0,m),stroke:p,strokeWidth:g,opacity:1},aria:{label:`${e+1}. ${i._drawLabel(t.data,t.i??0)}, ${l(t.data,t.i??0)}, ${h(t)}.`}};var v}(t,e,g)),x=_O(t,n),b=zO(t,n),k=new Set(Array.from(b.named,t=>t.data)),_=x.straight.filter(t=>{const e=t.datum?.data;return!e||!b.named.has(e)}),v=x.curved.filter(t=>!k.has(t.datum));!function(t,e,n){for(const i of t){const t=i;if(t.shapeType="Label",!e)continue;const o=t.transform??{},r=o.x??0,a=o.y??0,s=Math.hypot(r,a),c=Math.atan2(r,-a),l=e.start+wT(c,n)*e.span;t.flipFromTransform={x:s*Math.sin(l),y:-s*Math.cos(l)}}}(_,u,f);const w=jS(s,y,t=>[n[t].data,n[t].i??0]),M=n.reduce((t,e)=>Math.min(t,Number(o(e,e.i??0))||0),1/0);return[...y,...w,..._,...v,...b.nodes,...XT(t,{radius:M,startAngle:f.start,endAngle:f.end},m)]},insetRegion:Ay,chartTransform:t=>{const e=t.ctx.pieCenter;if(!e){const{width:e,height:n}=wt(t);return Mt(t,e,n)}return{x:t._margin.left+e.x,y:t._margin.top+e.y}},chartBodyRect:t=>{const e=t.ctx.pieBox;return e?{x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0}:{x:0,y:0,width:0,height:0}},facet:{aspect:WO},ctx:{pie:b.pie()},fields:[{key:"innerRadius",default:0},{key:"centerLabel",default:!1},{key:"centerLabelConfig",merge:!0,factory:KT},{key:"startAngle",default:0},{key:"endAngle"},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:G(t)},{key:"sort",factory:t=>{const e=t.schema.value;return(t,n)=>e(n)-e(t)}},{key:"legendSort",factory:t=>JT(t,"value")},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t.ctx.pieData;return i?`${++i[n].index}. ${t._drawLabel(e,n)}, ${t.schema.value(e,n)}.`:""},Path:{labelConfig:{fontResize:!0}},stroke:()=>Tc(t),strokeWidth:2})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[QT(t,"value")]})},{key:"legend",coerce:"const",factory:ZT}]};var qO=fk(GO);var VO=fk({name:"Donut",emit:GO.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:t=>()=>OO(t)/2}]},qO);const KO="::connector";function YO(t,e){const n="x"===e?"y":"x",i=new Map;for(const o of t){const t=`${o[e]}`;let r=i.get(t);r||i.set(t,r={});const a=o[n];u.finite(a)&&((!r.lo||a<r.lo[n])&&(r.lo=o),(!r.hi||a>r.hi[n])&&(r.hi=o))}const o=[];return i.forEach(({lo:t,hi:e},i)=>{t&&e&&t!==e&&t[n]!==e[n]&&o.push({category:i,lo:t,hi:e})}),o}function UO(t){const e={...t,interactive:!1};return delete e.datum,e}function XO(t){const{viz:e}=t,n="x"===e.schema.discrete?"x":"y",i=YO(t.values,n);if(!i.length)return[];const o=i.flatMap(({category:t,lo:e,hi:n})=>[{__d3plus__:!0,data:e,i:e.i,category:t},{__d3plus__:!0,data:n,i:n.i,category:t}]),r=e=>{const n=t.shapeConfig[e];return t=>n(t.data,t.data.i)},a=Pg("Line").renderMode("compute").config(t.shapeConfig).data(o),s=Hg(e,"Line");return void 0===e.schema.shapeConfig.duration&&delete s.duration,a.config(s).config({curve:"linear",hitArea:!1,id:t=>`${t.category}${KO}`,label:!1,x:r("x"),y:r("y")}),Gg(a).map(UO)}const QO=(t,e)=>{const n=Nt({...t.shapeConfig,id:t=>`${t.id}_${t.discrete}`});return[...XO(t),...FF.Circle({...t,shapeConfig:n},e)]};function ZO(t,e,n){const i=new Map;t.forEach((t,o)=>{const r=`${e(t,o)}`,a=n(t,o),s=i.get(r);u.finite(a)?s&&u.finite(s[0])?i.set(r,[Math.min(s[0],a),Math.max(s[1],a)]):i.set(r,[a,a]):s||i.set(r,[NaN,NaN])});const o=new Map;return i.forEach(([t,e],n)=>o.set(n,u.finite(t)?e-t:0)),o}function JO(t,e,n){const i=e=>t().get(`${n(e)}`)??0;return(t,n)=>"ascending"===e?i(t)-i(n):i(n)-i(t)}function tW(t,e){e.axis&&e.sort&&t.schema[`${e.axis}Sort`]===e.sort&&(t.schema[`${e.axis}Sort`]=void 0),e.axis=e.sort=void 0;const n=t.schema.gapSort;if("ascending"!==n&&"descending"!==n)return;const i="x"===t.schema.discrete?"x":"y";if(t.schema[`${i}Sort`])return;const o=t[`_${i}`],r=t["_"+("x"===i?"y":"x")],a=new WeakMap,s="y"===i?"ascending"===n?"descending":"ascending":n;e.axis=i,e.sort=t.schema[`${i}Sort`]=JO(()=>{const e=t._filteredData||[];let n=a.get(e);return n||a.set(e,n=ZO(e,o,r)),n},s,t=>o(t,0))}function eW(t){return e.colorContrast(Tc(t),t.schema.colorDefaults)===t.schema.colorDefaults.dark?e.colorGray[500]:e.colorGray[700]}const nW={name:"Dumbbell",paintDriven:!0,setup:t=>{const e={};t.ctx.dumbbell=e,t._plotShapeEmitters={Circle:QO},t._plotColumnHighlight=gR(t);const n=t._preDraw.bind(t);t._preDraw=()=>{tW(t,e),n()}},ctx:{},fields:[{key:"discrete",default:"y"},{key:"gapSort",default:!1},{key:"shapeConfig",merge:!0,factory:t=>({Circle:{label:!1,trail:!1},Line:{label:!1,stroke:()=>eW(t),strokeWidth:3}})}]};var iW=fk(nW,XN);var oW=fk({name:"LinePlot",paintDriven:!0,ctx:{},fields:[{key:"discrete",default:"x"},{key:"lineLabels",default:"along"},{key:"shape",default:W("Line"),coerce:"const"}]},XN);const rW={name:"FanChart",paintDriven:!0,ctx:{},fields:[{key:"forecast",default:"auto"}]};var aW=fk(rW,oW);function sW(t,e,n){if(t<=0||!(e>0))return[];const i=t>1?Math.min(.95,Math.max(0,n||0)):0,o=e/(t-i),r=o*(1-i);return Array.from({length:t},(t,e)=>({start:e*o,end:e*o+r}))}function cW(t){return Number.isFinite(t)&&t>0?t:0}function lW(t){return t.reduce((t,e)=>Math.max(t,cW(e)),0)}function hW(t,e,n=0){const i=Math.max(lW(t),cW(n));return t.map(t=>i>0?cW(t)/i*e:0)}function uW(t){const e=t.length;if(e<2)return t.map(()=>0);const n=[];for(let i=0;i<e-1;i++){const e=t[i+1].s-t[i].s;n.push(e>0?(t[i+1].w-t[i].w)/e:0)}const i=t.map((t,i)=>{if(0===i)return n[0];if(i===e-1)return n[e-2];const o=n[i-1],r=n[i];return o*r<=0?0:(o+r)/2});for(let t=0;t<e-1;t++){const e=n[t];if(0===e){i[t]=0,i[t+1]=0;continue}const o=i[t]/e,r=i[t+1]/e,a=o*o+r*r;if(a>9){const n=3/Math.sqrt(a);i[t]=n*o*e,i[t+1]=n*r*e}}return i}function dW(t,e,n){if(!t.length)return[];if(!n)return t.flatMap((t,n)=>[{s:t.start,w:e[n],m:0},{s:t.end,w:e[n],m:0}]);const i=t.length-1,o=t.map((t,n)=>({s:t.start,w:e[n]}));o.push({s:t[i].end,w:e[i]});const r=uW(o);return o.map((t,e)=>({...t,m:r[e]}))}function fW(t,e,n,i){const o=e.s-t.s;if(!(o>0))return t.w;const r=Math.min(1,Math.max(0,(n-t.s)/o));if("smooth"!==i)return t.w+(e.w-t.w)*r;const a=r*r,s=a*r;return(2*s-3*a+1)*t.w+(s-2*a+r)*o*t.m+(-2*s+3*a)*e.w+(s-a)*o*e.m}function mW(t,e){return t.w===e.w&&0===t.m&&0===e.m}function pW(t,e,n,i,o=12){const r=[];if(!(n>e))return r;for(let a=0;a<t.length-1;a++){const s=t[a],c=t[a+1],l=Math.max(e,s.s),h=Math.min(n,c.s);if(!(h>l&&c.s>s.s))continue;const u="smooth"!==i||mW(s,c)?1:Math.max(1,Math.ceil(o*(h-l)/(c.s-s.s)));for(let t=0;t<=u;t++){const e=l+(h-l)*t/u,n=fW(s,c,e,i),o=r[r.length-1];o&&o[0]===e&&o[1]===n||r.push([e,n])}}return r}const gW=t=>Math.round(100*t)/100;function yW(t,e,n){if(t.length<2)return"";const i=(t,e)=>"horizontal"===n?`${gW(t)},${gW(e)}`:`${gW(e)},${gW(t)}`,o=t.map(([t,n])=>i(t,e-n/2)),r=t.slice().reverse().map(([t,n])=>i(t,e+n/2));return`M${o.join("L")}L${r.join("L")}Z`}function xW(t){if(!t.length)return{min:0,max:0};const e=t.map(t=>t[1]);return{min:Math.min(...e),max:Math.max(...e)}}function bW(t){const e=(t,e)=>Number.isFinite(t)&&Number.isFinite(e)&&0!==e?t/e:NaN;return{first:t.map(n=>e(n,t[0])),previous:t.map((n,i)=>i?e(n,t[i-1]):NaN)}}function kW(t){var e;return(e=t.ctx).funnelRates??(e.funnelRates=new WeakMap)}function _W(t,e){const n=t.schema.sort;return"function"==typeof n?e.slice().sort(n):e}function vW(t){const e=Number(t.ctx.funnelScaleMax);return Number.isFinite(e)&&e>0?e:0}function wW(t){return"horizontal"===t.schema.orient?"horizontal":"vertical"}function MW(t){return"smooth"===t.schema.curve?"smooth":"linear"}function SW(t,e,{width:n,height:i},o){const r=wW(t),a=MW(t),s=t.schema.value,c=e.map((t,e)=>Number(s(t,e))),l="vertical"===r,h=Math.max(0,(l?i:n)-4),u=Math.max(0,(l?n:i)-4),d=sW(e.length,h,Number(t.schema.stagePadding)).map(t=>({start:t.start+2,end:t.end+2})),f=hW(c,u,o),m=dW(d,f,!!t.schema.taper),p=bW(c),g=e.map((t,e)=>{const n=d[e],i=pW(m,n.start,n.end,a),o=e?pW(m,d[e-1].end,n.start,a):[];return{__d3plus__:!0,data:t,i:e,value:c[e],first:p.first[e],previous:p.previous[e],start:n.start,end:n.end,points:i,neck:o,...xW(i)}});return{stages:g,shared:{orient:r,curve:a,center:(l?n:i)/2,breadth:u,offset:2}}}const CW=({viz:t})=>{const e=_W(t,t._filteredData??[]),{stages:n,shared:i}=SW(t,e,wt(t),vW(t)),o=kW(t);for(const t of n)o.set(t.data,{first:t.first,previous:t.previous});return t.ctx.funnel=i,{shapeData:n}};function $W(t){return!0===t||"both"===t?["first","previous"]:"first"===t||"previous"===t?[t]:Array.isArray(t)?["first","previous"].filter(e=>t.includes(e)):[]}function AW(t,e,n,i){const{fontMax:o,padding:r,lineHeight:a}=i,s=e.width-2*r,c=e.height-2*r;if(!(t.length&&s>0&&c>0))return 0;const l=Math.max(...t.map(t=>n(t,o))),h=c/(t.length*a),u=l>0?s/l*o:o,d=Math.min(o,h,u);return Math.floor(2*d)/2}function zW(t,e,n,i,o){for(let r=t.length;r>0;r--){const a=t.slice(0,r),s=AW(a,e,i,o),c=n?AW(a,n,i,o):0;if(s>=o.fontMin&&s>=.8*c)return{position:"inside",fontSize:s,lines:a};if(c>=o.fontMin)return{position:"outside",fontSize:c,lines:a}}return null}function DW(t,e,n,i=1/0){const o=t.map(t=>zW(t.lines,t.inside,t.outside,e,t.fixed?{...n,fontMin:t.fixed,fontMax:t.fixed}:n)),r=o.flatMap((e,n)=>e&&!t[n].fixed?[n]:[]);if(!r.length)return{plans:o,fontSize:0};const a=Math.min(i,...r.map(t=>o[t].fontSize));for(const i of r){const r=o[i],s="inside"===r.position||AW(r.lines,t[i].inside,e,n)>=a;o[i]={...r,position:s?"inside":"outside",fontSize:a}}return{plans:o,fontSize:a}}function LW(t,e,n,i){const o=e*n,r="top"===i?t.y:t.y+(t.height-o)/2;return Array.from({length:e},(e,i)=>({x:t.x,y:r+i*n,width:t.width,height:n}))}function FW(t,e){return`${p.formatAbbreviate(100*e,t.schema.locale)}%`}function NW(t,e){const n=t.schema.valueFormat,i=[t._drawLabel(e.data,e.i)];if(Number.isFinite(e.value)&&i.push(`${n(e.value,e.data)}`),!e.i)return i;const o=$W(t.schema.conversion);for(const n of o){const o="first"===n?e.first:e.previous;if(!Number.isFinite(o))continue;const r=t.schema.translate("first"===n?"of first":"of previous");i.push(`${FW(t,o)} ${r}`)}return i}function BW(t,e){const n=t.end-t.start,i=e.center+t.max/2+6,o=Math.max(0,(e.breadth-t.max)/2-6);return"horizontal"===e.orient?{inside:{x:t.start,y:e.center-t.min/2,width:n,height:t.min},outside:{x:t.start,y:i,width:n,height:o}}:{inside:{x:e.center-t.min/2,y:t.start,width:t.min,height:n},outside:{x:i,y:t.start,width:o,height:n}}}function EW(t,e){return{x:t.x+e,y:t.y+e,width:Math.max(0,t.width-2*e),height:Math.max(0,t.height-2*e)}}function RW(t,e,n){const i=(t,i)=>{const o=Tg(t,e,n);return"number"==typeof o&&o>0?o:i};return{fontMin:i(t.fontMin,10),fontMax:i(t.fontMax,16),padding:4,lineHeight:1.2}}function PW(t,e,n,i=1/0){const o=Ig(t,"Path"),a=e[0],c=a?RW(o,a.data,a.i):RW({},{},0),l=s.fontFamilyStringify((a?Tg(o.fontFamily,a.data,a.i):void 0)??t.schema.fontFamily),h=e.map(e=>{const{inside:i,outside:r}=BW(e,n),a=Tg(o.fontSize,e.data,e.i);return{lines:NW(t,e),inside:i,outside:r,fixed:"number"==typeof a&&a>0?a:void 0}}),{plans:u,fontSize:d}=DW(h,(t,e)=>Number(r.textWidth(t,{"font-family":l,"font-size":e,"font-weight":600}))||0,c,i),f=new Map;return u.forEach((t,n)=>{t&&f.set(e[n].data,t)}),{plans:f,fontSize:d,sizing:c,user:o}}function TW(t,e,n){return e.length?PW(t,e,n).fontSize:0}function OW(t){const e=Number(t.ctx.funnelLabelSize);return Number.isFinite(e)&&e>0?e:1/0}function WW(t,n,i){const o=Hg(t,"Path"),{plans:r,sizing:a,user:s}=PW(t,n,i,OW(t)),c="horizontal"===i.orient,l=new Map;for(const t of n){const e=r.get(t.data);if(!e)continue;const{inside:n,outside:o}=BW(t,i),a="inside"===e.position?n:o,s="outside"===e.position&&c?"top":"middle",h=LW(EW(a,4),e.lines.length,1.2*e.fontSize,s);l.set(t.data,{stage:t,plan:e,boxes:h})}const h=t=>l.get((t&&t.data)??t);return e_({data:n.map(t=>t.data),datum:t=>t,label:t=>l.get(t)?.plan.lines??!1,labelBounds:t=>{const e=l.get(t)?.boxes;return!!e&&e.map(t=>({...t,y:t.y-1,height:t.height+2}))},x:()=>0,y:()=>0,aes:()=>({}),rotate:W(0),id:(e,n)=>`funnel-label-${t._ids(e,n).join("-")}`,labelConfig:{fontResize:!1,padding:0,lineHeight:t=>1.2*(h(t)?.plan.fontSize??a.fontMin),fontWeight:t=>t&&0===t.l?600:400,textAnchor:t=>"outside"!==h(t)?.plan.position||c?"middle":"start",verticalAlign:"top",fontColor:n=>{const i=h(n);if(!i||"outside"===i.plan.position)return Oc(t);const r=Tg(o.fill,i.stage.data,i.stage.i);return"string"==typeof r?e.colorContrast(r,t.schema.colorDefaults):Oc(t)},...s,fontSize:t=>h(t)?.plan.fontSize??a.fontMin}})}function jW(t,e={}){return{...e,...t.schema.connectorConfig??{}}}function HW(t,e,n,i={}){const o=t.schema.connectorConfig??{},r=e.data,a=e.i,s=Tg(o.fill,r,a)??n;return{fill:Og(jW(t,i),r,a,s),opacity:Tg(o.opacity,r,a),stroke:Tg(o.stroke,r,a),strokeWidth:Tg(o.strokeWidth,r,a)}}function IW(t,e){const n=t.schema.valueFormat,i=Number.isFinite(e.value)?`, ${n(e.value,e.data)}`:"";return`${e.i+1}. ${t._drawLabel(e.data,e.i)}${i}.`}const GW=({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.funnel;if(!n.length||!i)return[];const o=Hg(t,"Path"),r=e=>`funnel-${t._ids(e.data,e.i).join("-")}`,a=[],s=[],c=[];for(const e of n){const n=Wg(o,e.data,e.i);a.push({type:"path",key:r(e),d:yW(e.points,i.center,i.orient),datum:e.data,index:e.i,shapeType:"Path",paint:n,aria:{label:IW(t,e)}});const l=yW(e.neck,i.center,i.orient);if(!1!==t.schema.connector&&l){const n=Tg(o.fill,e.data,e.i);s.push({type:"path",key:`${r(e)}-neck`,d:l,datum:e.data,index:e.i,interactive:!1,aria:{hidden:!0},paint:HW(t,e,"string"==typeof n?n:void 0,o)}),c.push(e)}}const l=jS(jW(t,o),s,t=>[c[t].data,c[t].i]),h=jS(o,a,t=>[n[t].data,n[t].i]),u=!1===(t.schema.shapeConfig??{}).label?[]:WW(t,n,i);return[...s,...l,...a,...h,...u]};function qW(t,e,n){if(!1===(t.schema.shapeConfig??{}).label)return 0;const i=wt(t),o=e.filter(t=>t.length).map(e=>{const{stages:o,shared:r}=SW(t,_W(t,e),i,n);return TW(t,o,r)}).filter(t=>t>0);return o.length?Math.min(...o):0}function VW(t,e){const n=t.schema.value,i=lW(e.flatMap(t=>t.map((t,e)=>Number(n(t,e)))));return{max:i,fontSize:qW(t,e,i)}}function KW(t,e){const n=t.ctx.funnelScaleMax,i=t.ctx.funnelLabelSize,o=e.shared?e.scales:void 0;return t.ctx.funnelScaleMax=o?o.max:void 0,t.ctx.funnelLabelSize=o&&o.fontSize?o.fontSize:void 0,()=>{t.ctx.funnelScaleMax=n,t.ctx.funnelLabelSize=i}}const YW={scales:"independent",share:VW,panel:KW};function UW(t,e,n){const i=Number(t.schema.value(e,n)),o=t.schema.valueFormat,r=[];Number.isFinite(i)&&r.push([t.schema.translate("Value"),`${o(i,e)}`]);const a=e?kW(t).get(e):void 0,s=a?a.first:NaN,c=a?a.previous:NaN;return Number.isFinite(c)&&(Number.isFinite(s)&&r.push([t.schema.translate("% of First Stage"),FW(t,s)]),r.push([t.schema.translate("% of Previous Stage"),FW(t,c)])),r}const XW={name:"Funnel",layoutStage:CW,emit:GW,insetRegion:Ay,facet:YW,ctx:{},fields:[{key:"connector",default:!0},{key:"conversion",default:!1},{key:"curve",default:"linear"},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=new Set(t._filteredData.map((e,n)=>t._ids(e,n).join("_")));return!(i.length>=o.size)&&e.call(t,n,i)}}},{key:"orient",default:"vertical"},{key:"sort"},{key:"stagePadding",default:.3},{key:"taper",default:!1},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:"string"==typeof t?G(t):W(t)},{key:"valueFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1},{key:"connectorConfig",merge:!0,default:{opacity:.35}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>UW(t,e,n)})}]};var QW=fk(XW);const ZW=t=>"function"==typeof t?t:G(t),JW=t=>(e,n)=>{const i="function"==typeof n?null:n;i&&!e.schema.aggs[i]&&(e.schema.aggs[i]=t)};function tj(){return[{key:"end",default:H("end"),coerce:ZW,onSet:JW(d.max)},{key:"start",default:H("start"),coerce:ZW,onSet:JW(d.min)}]}function ej(t){t.schema.aggs.start||(t.schema.aggs.start=d.min),t.schema.aggs.end||(t.schema.aggs.end=d.max)}function nj(t){const e=t.schema.axisConfig;return"time"===e?.scale}function ij(t,e){if(null==t||""===t)return null;if(e){const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:null}const n=Number(t);return Number.isFinite(n)?n:null}const oj=(t,e,n)=>e.config({domain:n.domain,height:n.height,width:n.width}).config(n.config??{}).config(t.schema.axisConfig);function rj(t,e){const n=t.ctx.axisTest;return oj(t,n,e).measure(),{height:n.outerBounds().height,padding:n.schema.padding}}function aj(t,e){const n=t.ctx.axis,i=t.ctx.axisTest.schema.height;Fi(oj(t,n,e),i).renderMode("compute").select(void 0).render();const o=n.toScene();var r;o&&((r=t)._chartScene||(r._chartScene=[])).push(Lr({type:"group",key:e.key,transform:e.transform,children:o.children??[]}));return n._d3Scale}function sj(t,e,n,i){return t.schema[e](n,i)}const cj=t=>Math.round(100*t)/100;function lj(t,e,n){return`M${cj(t)},${cj(e-n)}L${cj(t+n)},${cj(e)}L${cj(t)},${cj(e+n)}L${cj(t-n)},${cj(e)}Z`}function hj(t,e,n){const i=e*Math.max(0,Math.min(1,n));return{done:{x:t,width:i},rest:{x:t+i,width:e-i}}}function uj(t,e,n,i){const o=n-i/2,r=n+i/2,a=Math.min(i,Math.max(0,(e-t)/2));return`M${cj(t)},${cj(o)}H${cj(e)}V${cj(r+a)}L${cj(e-a)},${cj(r)}H${cj(t+a)}L${cj(t)},${cj(r+a)}Z`}function dj(t,e,n,i){const[o,r]=t,[a,s]=e;if(r===s&&a>=o)return[t,e];const c=o+n;if(a-o>=2*n)return[t,[c,r],[c,s],e];const l=r+(s>r?1:-1)*i/2,h=a-n;return[t,[c,r],[c,l],[h,l],[h,s],e]}function fj(t,e,n,i){if(!(t>0&&n>0))return 0;const o=n<=1?e*n:n;return Math.max(0,Math.min(Math.ceil(t+2*i),o))}function mj(t){const e=t.schema.taskLabelConfig??{},n=Tg(e.fontSize,{},0),i=Tg(e.fontFamily,{},0)??t.schema.fontFamily,o="number"==typeof n&&n>0?n:12;return{family:s.fontFamilyStringify(i),size:o,color:Tg(e.fontColor,{},0)??Oc(t),lineHeight:Math.round(1.2*o)}}function pj(t,e,n=400){return t?r.textWidth(t,{"font-family":e.family,"font-size":e.size,"font-weight":n}):0}function gj(t,e,n){let i=t.trimEnd();for(;i.length;){const t=`${i}…`;if(n(t)<=e)return t;i=i.slice(0,-1).trimEnd()}return""}function yj(t,e,n,i,o=400){const r=t=>pj(t,i,o);if(!t||e<=0||n<1)return{lines:[],widths:[]};const a=s.textWrap().fontFamily(i.family).fontSize(i.size).fontWeight(o).lineHeight(i.lineHeight).width(e).height(i.lineHeight*n).maxLines(n)(t),c=a.lines.filter(t=>""!==t),l=c.join(" ").replace(/\s+/g," ").trim(),h=t.replace(/\s+/g," ").trim();if(!c.length){const t=gj(h,e,r);return t?{lines:[t],widths:[r(t)]}:{lines:[],widths:[]}}if(a.truncated||l.length<h.length||r(c[c.length-1])>e){const t=c.length-1,n=h.slice(c.slice(0,t).join(" ").length+(t?1:0));c[t]=gj(n,e,r),c[t]||c.pop()}return{lines:c,widths:c.map(r)}}function xj(t,e,n){return null!=n&&""!==n?!!n:+t===+e}function bj(t){let e;if("number"==typeof t)e=t;else if("string"==typeof t&&t.trim().endsWith("%"))e=parseFloat(t)/100;else{if("string"!=typeof t||""===t.trim())return;e=Number(t)}if(Number.isFinite(e))return Math.max(0,Math.min(1,e))}function kj(t){const e=(Array.isArray(t)?t:"string"==typeof t?t.split(","):"number"==typeof t?[t]:[]).filter(t=>null!=t).map(t=>`${t}`.trim()).filter(t=>""!==t);return Array.from(new Set(e))}function _j(t,e){const n=(t,e)=>t.i-e.i;return"function"==typeof e?[...t].sort((t,i)=>e(t.data,i.data)||n(t,i)):"start"===e?[...t].sort((t,e)=>+t.start-+e.start||+t.end-+e.end||n(t,e)):[...t].sort(n)}function vj(t,e){const n=_j(t,e),i=(t,e)=>({kind:"task",key:`task-${t.id}`,task:t,indent:e});if(!n.some(t=>void 0!==t.group))return n.map(t=>i(t,!1));const o=new Map,r=[];for(const t of n){if(void 0===t.group){r.push(t);continue}const e=o.get(t.group);e?e.push(t):(o.set(t.group,[t]),r.push(t.group))}const a=[];for(const t of r){if("string"!=typeof t){a.push(i(t,!1));continue}const e=o.get(t);a.push({kind:"group",key:`group-${t}`,label:t,start:wj(e.map(t=>t.start)),end:Mj(e.map(t=>t.end)),tasks:e}),e.forEach(t=>a.push(i(t,!0)))}return a}const wj=t=>t.reduce((t,e)=>+e<+t?e:t),Mj=t=>t.reduce((t,e)=>+e>+t?e:t);function Sj(t,e){if(!nj(t))return e=>p.formatAbbreviate(Number(e),t.schema.locale);const n=Array.from(new Set(e.map(Number))).sort((t,e)=>t-e).map(t=>new Date(t)),i=y.timeFormatLocale(PE(t.schema.locale)),o=p.dateFullFormatter(n,i.format);return t=>o(t instanceof Date?t:new Date(t))}function Cj(t,e,n){const i=+n-+e;if(!nj(t))return p.formatAbbreviate(i,t.schema.locale);const o=function(t){const e=t.schema.axisConfig,n=po(e?.rangeBreaks);return n.some(t=>"object"==typeof t&&"hours"in t)?[]:n}(t),r=o.length?wo(o,+e,+n):i,a=Math.round(r/864e5*10)/10,s=t.schema.translate(`${o.length?"working ":""}${1===a?"day":"days"}`);return`${$j(a,t.schema.locale)} ${s}`}function $j(t,e){try{return new Intl.NumberFormat("string"==typeof e?e:"en-US",{maximumFractionDigits:1}).format(t)}catch{return`${t}`}}const Aj=t=>`${Math.round(100*t)}%`;function zj(t,e,n){const i=nj(t);let o=ij(sj(t,"start",e,n),i),r=ij(sj(t,"end",e,n),i);if(null===o&&null===r)return null;o??(o=r),r??(r=o),+r<+o&&([o,r]=[r,o]);const a=t.schema.milestone,s=t.schema.progress;return{start:o,end:r,milestone:xj(o,r,"function"==typeof a?a(e,n):void 0),progress:bj("function"==typeof s?s(e,n):void 0)}}function Dj(t,e){const n=t.ctx.gantt;return n?.format??Sj(t,e)}function Lj(t,e,n){const i=zj(t,e,n);if(!i)return[];const o=e=>t.schema.translate(e),r=Dj(t,[i.start,i.end]),a=i.milestone?[[o("Milestone"),r(i.end)]]:[[o("Start"),r(i.start)],[o("End"),r(i.end)],[o("Duration"),Cj(t,i.start,i.end)]];return void 0!==i.progress&&a.push([o("Progress"),Aj(i.progress)]),a}function Fj(t,e,n){const i=`${t._drawLabel(e,n)??""}`,o=zj(t,e,n);if(!o)return`${i}.`;const r=Dj(t,[o.start,o.end]);return`${i}, ${o.milestone?`${t.schema.translate("Milestone")} ${r(o.end)}`:`${r(o.start)} - ${r(o.end)}`}${void 0===o.progress?"":`, ${t.schema.translate("Progress")} ${Aj(o.progress)}`}.`}const Nj=(t,e,n)=>"function"==typeof t?t(e,n):void 0;function Bj(t,e){const n=[];return e.forEach((e,i)=>{const o=zj(t,e,i);if(!o)return;const r=Nj(t.schema.group,e,i);n.push({__d3plus__:!0,data:e,i:i,id:`${t._id(e,i)}`,label:`${t._drawLabel(e,i)??""}`,...o,dependencies:kj(Nj(t.schema.dependencies,e,i)),group:null==r||""===r?void 0:`${r}`})}),n}function Ej(t,e){if(!t.length)return[0,1];let n=Math.min(...t.map(t=>+t.start)),i=Math.max(...t.map(t=>+t.end));return n===i&&(e?(n=+x.timeDay.offset(new Date(n),-1),i=+x.timeDay.offset(new Date(i),1)):(n-=1,i+=1)),[n,i]}function Rj(t,e,n,i){const o=n>=2*i.lineHeight+2?2:1;return t.map(t=>{const n="task"===t.kind&&t.indent?12:0,r=e-16-n;return"group"===t.kind?yj(t.label,r,o,i,600):yj(t.task.label,r,o,i)})}const Pj=({viz:t})=>{const e=t,n=e._filteredData??[],i=nj(e),o=Bj(e,n),r=vj(o,e.schema.taskSort??"data"),a=mj(e),{width:s,height:l}=wt(e),h=function(t,e,n,i){return fj(Math.max(0,...e.map(t=>"group"===t.kind?pj(t.label,n,600):pj(t.task.label,n)+(t.indent?12:0))),i,Number(t.schema.labelWidth),8)}(e,r,a,s),u="bottom"!==(e.schema.axisConfig??{}).orient,d={domain:Ej(o,i),width:Math.max(0,s-h),height:l,config:{orient:u?"top":"bottom",align:u?"start":"end"}},f=rj(e,d),m=Math.max(0,l-f.height-2*f.padding),p=Math.min(m,40*r.length),g=u?f.height+f.padding:f.padding,y=aj(e,{...d,height:p+f.height+2*f.padding,transform:{x:h,y:0},key:"gantt-axis"}),x=t=>h+y(t),b=c.scaleBand().domain(r.map((t,e)=>e)).paddingInner(Number(e.schema.paddingInner)||0).paddingOuter(Number(e.schema.paddingOuter)||0).range([g,g+p]),k=b.bandwidth(),_=r.length>1?b.step():p,v=r.map((t,e)=>(b(e)??0)+k/2),w=[];r.forEach((t,e)=>{"task"===t.kind&&w.push({...t.task,row:e,cy:v[e],x0:x(t.task.start),x1:x(t.task.end)})});const M=y.range?.()??[0,d.width];return e.ctx.gantt={rows:r,labels:Rj(r,h,_,a),font:a,column:h,x:x,cy:v,step:_,band:k,plot:{x0:h+Math.min(...M),x1:h+Math.max(...M),y0:g,y1:g+p},time:i,format:Sj(e,o.flatMap(t=>[t.start,t.end]))},{shapeData:w}},Tj=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function Oj(t){const e=t.schema.dependencyConfig??{};return{stroke:e.stroke||Oc(t),strokeWidth:Tj(e.strokeWidth,1),strokeOpacity:Tj(e.strokeOpacity,.55),arrowSize:Math.max(2,Tj(e.arrowSize,6))}}function Wj(t,e){const{font:n}=t,i=new Map(e.map(t=>[t.row,t])),o=[];return t.rows.forEach((e,r)=>{const a=t.labels[r];if(!a||!a.lines.length)return;const s="group"===e.kind,c=!s&&e.indent?12:0,l=t.cy[r]-a.lines.length*n.lineHeight/2,h=i.get(r);o.push({type:"text",key:`gantt-label-${e.key}`,interactive:!1,...h?{datum:h.data,index:h.i}:{},x:0,y:0,transform:{x:8+c,y:l},lines:a.lines.map((t,e)=>({text:t,x:0,y:n.lineHeight*(e+.5),width:a.widths[e]})),font:{family:n.family,size:n.size,weight:s?600:400,anchor:"start",baseline:"middle"},paint:{fill:n.color}})}),o}function jj(t,e){const n=Oc(t),i=[];return e.rows.forEach((t,o)=>{if("group"!==t.kind)return;const r=e.x(t.start),a=Math.max(e.x(t.end),r+1);i.push({type:"path",key:`gantt-${t.key}`,interactive:!1,d:uj(r,a,e.cy[o],Math.max(2,.4*e.band)),paint:{fill:n,fillOpacity:.6}})}),i}function Hj(t,e){return[t.milestone?t.x1+e:t.x1,t.cy]}function Ij(t,e){return[t.milestone?t.x1-e:t.x0,t.cy]}function Gj(t,e,n,i){const o=Oj(t),r=new Map(n.map(t=>[t.id,t])),a=Math.max(8,o.arrowSize+4),s=[];for(const t of n)for(const n of t.dependencies){const c=r.get(n);if(!c||c===t)continue;const l=Hj(c,i),h=Ij(t,i),u=dj(l,h,a,e.step).slice();u[u.length-1]=[h[0]-.8*o.arrowSize,h[1]];const d=`gantt-dependency-${c.id}-${t.id}`,f=[{x:l[0],y:l[1],datum:c.data,index:c.i},{x:h[0],y:h[1],datum:t.data,index:t.i}];s.push({type:"line",key:d,interactive:!1,points:u,curve:"linear",interactionPoints:f,paint:{fill:"none",stroke:o.stroke,strokeWidth:o.strokeWidth,strokeOpacity:o.strokeOpacity}});const m=$v({key:`${d}-arrow`,datum:t.data,x:h[0],y:h[1],angle:0,size:o.arrowSize,fill:o.stroke});s.push({...m,datum:void 0,interactionPoints:f,paint:{...m.paint,fillOpacity:o.strokeOpacity}})}return s}function qj(t,e=()=>new Date){return!0===t?e():!1===t||null==t||""===t?null:t}function Vj(t,e){const n=qj(t.schema.today);if(null===n)return[];const i=t.schema.todayConfig??{},o={label:t.schema.translate("Today"),fontSize:11,labelPosition:"end",strokeOpacity:.85,strokeWidth:1.5,...i,shape:"ReferenceLine",x:n};return nA(t,o,{plot:e.plot,axes:{x:{scale:t=>e.x(t),time:e.time}}},"gantt-today")}function Kj(t,e){return k.interpolateRgb(t,e)(.6)}const Yj=t=>Math.max(3,.6*t);function Uj(t,e,n){const i=Tg(e.fill,n.data,n.i),o={fill:Og(e,n.data,n.i,i),stroke:Tg(e.stroke,n.data,n.i),strokeWidth:Tg(e.strokeWidth,n.data,n.i)},r=Tg(e.opacity,n.data,n.i);"number"==typeof r&&(o.opacity=r);const a="string"!=typeof o.fill||o.fill.startsWith("pattern:")?void 0:o.fill;return{paint:o,color:a}}function Xj(t,e,n,i){const{paint:o,color:r}=Uj(0,i,n),a=Yj(e.band),s=void 0!==n.progress&&n.progress<1&&!!r;return{type:"path",shapeType:"Path",key:`gantt-milestone-${n.id}`,d:lj(0,0,a),transform:{x:n.x1,y:n.cy},datum:n.data,index:n.i,paint:s?{...o,fill:Kj(r,Tc(t)),stroke:r,strokeWidth:1.5}:o,aria:{label:Fj(t,n.data,n.i)}}}const Qj=({viz:t,shapeData:e})=>{const n=t,i=n.ctx.gantt,o=e??[];if(!i||!o.length)return[];const r=Hg(n,"Rect"),a=Hg(n,"Path"),s=Yj(i.band),c=o.flatMap(t=>t.milestone?[Xj(n,i,t,a)]:function(t,e,n,i){const{paint:o,color:r}=Uj(0,i,n),a=Math.max(1,n.x1-n.x0),s=void 0!==n.progress&&void 0!==r,c=`gantt-task-${n.id}`,l={type:"rect",transform:{x:n.x0,y:n.cy},y:-e.band/2,height:e.band,datum:n.data,index:n.i},h={...l,shapeType:"Bar",key:c,x:0,width:a,paint:s?{...o,fill:Kj(r,Tc(t))}:o,aria:{label:Fj(t,n.data,n.i)}},u=[h],d=WS(i,h,n.data,n.i);if(d&&u.push(d),s){const{done:t}=hj(0,a,n.progress);t.width>0&&u.push({...l,key:`${c}-progress`,interactive:!1,x:t.x,width:t.width,paint:{fill:r,..."number"==typeof o.opacity?{opacity:o.opacity}:{}}})}return u}(n,i,t,r));return[...jj(n,i),...Gj(n,i,o,s),...c,...Wj(i,o),...Vj(n,i)]};function Zj(t){return"function"==typeof t?t:!("string"!=typeof t||!t)&&G(t)}function Jj(t,e){return d.mean(t.map(t=>bj(e(t))).filter(t=>void 0!==t))}const tH={name:"Gantt",layoutStage:Pj,emit:Qj,setup:t=>{ej(t),t.schema.aggs.progress||(t.schema.aggs.progress=Jj)},ctx:{axis:(new Ga).align("start").orient("top"),axisTest:(new Ga).align("start").gridSize(0).orient("top")},fields:[{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"dependencies",default:H("dependencies"),coerce:Zj},{key:"dependencyConfig",merge:!0,default:{}},...tj(),{key:"group",default:!1,coerce:Zj},{key:"labelWidth",default:.3},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=t._filteredData??[];return!(i.length>=o.length)&&e.call(t,n,i)}}},{key:"milestone",default:H("milestone"),coerce:Zj},{key:"paddingInner",default:.35},{key:"paddingOuter",default:.2},{key:"progress",default:H("progress"),coerce:Zj,onSet:(t,e)=>{const n="string"==typeof e?e:null;n&&!t.schema.aggs[n]&&(t.schema.aggs[n]=Jj)}},{key:"taskSort",default:"data"},{key:"taskLabelConfig",merge:!0,default:{}},{key:"today",default:!1},{key:"todayConfig",merge:!0,default:{}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>Lj(t,e,n)})},{key:"zoom",default:!1}]};var eH=fk(tH);function nH(t){const n=Tc(t),i=e.colorContrast(n,t.schema.colorDefaults),o=k.interpolateRgb(n,i);return{track:o(.12),tick:o(.6),text:i}}const iH={name:"Gauge",layoutStage:TB,emit:({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.gauge;if(!(n.length&&i&&i.radius>0))return[];const o=1===n.length,r=n[0],c=EB(i.radius,i.dial),l=function(t,e,n){const i=(t.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},r=nH(t),a=Tg(o.fontFamily,e,n)??t.schema.fontFamily,c=t.schema.tickFormat;return{trackFill:Tg(i.fill,e,n)??r.track,tickStroke:Tg(i.stroke,e,n)??r.tick,tickStrokeWidth:Tg(i.strokeWidth,e,n)??1,fontColor:Tg(o.fontColor,e,n)??r.text,fontFamily:s.fontFamilyStringify(a),tickFormat:t=>`${c(t)}`}}(t,r.data,r.i),h=t.schema.valueFormat,u=o&&Number.isFinite(r.value)?`${h(r.value,r.data)}`:"",d=i.dial.hasName?t._drawLabel(r.data,r.i):void 0,f={type:"group",key:"gauge-dial",interactive:!1,aria:{hidden:!0},children:[...uE("gauge",c,i,l),...dE("gauge",c,l,u,d)]},m={viz:t,layout:c,shared:i,single:o},p=[f,...n.flatMap(t=>function(t,e){const{viz:n,layout:i,shared:o,single:r}=e,s=`gauge-${n._ids(t.data,t.i).join("-")}`,c=Hg(n,"Path"),l=Wg(c,t.data,t.i),h=n.schema.valueFormat,u=`${[RB(n,t.data,t.i)?n._drawLabel(t.data,t.i):"",h(t.value,t.data)].filter(Boolean).join(", ")}.`,d={datum:t.data,index:t.i,shapeType:"Path",aria:{label:u}},f="progress"===o.dial.indicator,m=i.rings[f?t.i:0],p={startAngle:o.start,endAngle:o.end},g={rotate:SB(t.angle)},y={type:"path",key:`${s}-indicator::hit`,d:r?a.arcPath({innerRadius:0,outerRadius:i.outer,...p}):f?a.arcPath({innerRadius:m.inner,outerRadius:m.outer,...p}):BB(i.needleLength,3*i.needleHalfWidth,i.needleTail),transform:r||f?void 0:g,datum:t.data,index:t.i,paint:{fill:"transparent"}};if(!Number.isFinite(t.value))return[y];if(f){const e={innerRadius:m.inner,outerRadius:m.outer,startAngle:o.start,endAngle:t.angle},n={type:"path",key:`${s}-indicator`,d:a.arcPath(e),arc:e,paint:l,...d},i=WS(c,n,t.data,t.i);return i?[y,n,i]:[y,n]}const x={type:"path",key:`${s}-indicator`,d:BB(i.needleLength,i.needleHalfWidth,i.needleTail),transform:g,paint:l,...d};return r?[y,x,{type:"circle",key:`${s}-hub`,cx:0,cy:0,r:i.hubRadius,paint:l,...d}]:[y,x]}(t,m))];return o||"progress"===i.dial.indicator||p.push({type:"circle",key:"gauge-hub",interactive:!1,cx:0,cy:0,r:c.hubRadius,paint:{fill:l.fontColor,stroke:Tc(t),strokeWidth:1.5}}),[{type:"group",key:"gauge",transform:{x:i.cx,y:i.cy},children:p}]},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"domain"},{key:"endAngle",default:120},{key:"indicator",default:"needle"},{key:"minorTicks",default:!0},{key:"startAngle",default:-120},{key:"thickness",default:.2},{key:"tickFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Tc(t),strokeWidth:()=>"progress"===t.schema.indicator?0:1.5})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[[()=>t.schema.translate("Value"),(e,n)=>{const i=Number(t.schema.value(e,n));return Number.isFinite(i)?`${t.schema.valueFormat(i,e)}`:""}]]})},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:"string"==typeof t?G(t):W(t)},{key:"valueFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1}]};var oH=fk(iH);const rH=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["tile.openstreetmap.org"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["openstreetmap.fr/hot"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>"},{matches:["stadiamaps.com"],text:"© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["World_Light_Gray_Base","World_Dark_Gray_Base"],text:"Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}],aH={light:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",dark:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}"};function sH(t,e){return(t=>"object"==typeof t&&null!==t&&"light"in t&&"dark"in t)(t)?e?t.dark:t.light:t}function cH(t){const e=t.ctx.linkBundleCache;if(e)return e;const n=F_();return t.ctx.linkBundleCache=n,n}function lH(t,e){return R_(e,t.schema.linkBundleConfig??{},cH(t))}function hH(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&Number.isFinite(t[0])&&Number.isFinite(t[1])&&Math.abs(t[1])<=90}function uH(t){if(!Array.isArray(t)||t.length<2)return null;const e=[Number(t[0]),Number(t[1])];return hH(e)?e:null}function dH(t){const e=t?.geometry;if(!e)return null;let n=e;if("MultiPolygon"===e.type){const t=e.coordinates;let i=-1;for(const e of t){const t={type:"Polygon",coordinates:e},o=fH(t);o>i&&(i=o,n=t)}}let i=S.geoCentroid(n);return S.geoArea(n)>2*Math.PI&&(i=[i[0]>0?i[0]-180:i[0]+180,-i[1]]),hH(i)?i:null}function fH(t){const e=S.geoArea(t);return Math.min(e,4*Math.PI-e)}function mH(t,e,n){const i=S.geoInterpolate(t,e),o=Math.max(1,Math.round(n));return Array.from({length:o+1},(t,e)=>i(e/o))}function pH(t,e){if(!e||t.length<2)return t.slice();const[n,i]=t[0],[o,r]=t[t.length-1],a=Math.hypot(o-n,r-i);if(!a)return t.slice();const s=(r-i)/a,c=-(o-n)/a,l=t.length-1;return t.map(([t,n],i)=>{const o=i/l,r=4*o*(1-o)*e*a;return[t+s*r,n+c*r]})}function gH(t,e,n){if(1!==(t.match(/M/g)??[]).length)return!1;const i=function(t){return(t.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number)}(t);if(i.length<4)return!1;const o=(t,e,n)=>Math.abs(t-n[0])<=1&&Math.abs(e-n[1])<=1;return o(i[0],i[1],e)&&o(i[i.length-2],i[i.length-1],n)}function yH(t,e,n,i){const o=i({type:"LineString",coordinates:[t,e]}),r=kH(n(t)),a=kH(n(e));return!(o&&r&&a&&gH(o,r,a))}function xH(t,e,n=0){const i=Math.hypot(e[0]-t[0],e[1]-t[1]),o=Math.min(128,Math.max(16,Math.ceil(i/4))),r=pH(Array.from({length:o+1},(n,i)=>{const r=i/o;return[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r]}),n);return{d:jw(r),points:r}}function bH(t,e,n,i,o=0){if(!S.geoDistance(t,e))return null;const r=i({type:"LineString",coordinates:[t,e]});if(!r)return null;const a=kH(n(t)),s=kH(n(e)),c=!vH(n),l=t=>wH(i,t),h=()=>c&&a&&s&&l(t)&&l(e)?xH(a,s,o):null;if(!a||!s||!gH(r,a,s))return h()??{d:r,points:null};const u=Math.hypot(s[0]-a[0],s[1]-a[1]),d=Math.min(128,Math.max(16,Math.ceil(u/4))),f=[];for(const i of mH(t,e,d)){const t=kH(n(i));if(!t)return h()??{d:r,points:null};f.push(t)}const m=o?pH(f,o):f;return{d:o?jw(m):r,points:m}}function kH(t){return t&&Number.isFinite(t[0])&&Number.isFinite(t[1])?[t[0],t[1]]:null}function _H(t){const e=[];for(const[,n,i]of t.matchAll(/([ML])([^ML]*)/gi)){const t=(i.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number);"M"!==n.toUpperCase()&&e.length||e.push([]);const o=e[e.length-1];for(let e=0;e+1<t.length;e+=2)o.push([t[e],t[e+1]])}return e.filter(t=>t.length>1)}function vH(t){const e=t?.clipAngle;if("function"!=typeof e)return!1;const n=e.call(t);return"number"==typeof n&&Number.isFinite(n)&&n>0}function wH(t,e){return!!t({type:"Point",coordinates:e})}function MH(t){if(hH(t))return[t[0],t[1]];if("string"==typeof t)return t;if("number"==typeof t&&Number.isFinite(t))return`${t}`;if(t&&"object"==typeof t&&"id"in t){const e=t.id;if("string"==typeof e||"number"==typeof e)return`${e}`}return null}function SH(t,e){let n;try{const t=new Intl.NumberFormat(e||void 0,{maximumFractionDigits:2});n=e=>t.format(e)}catch{n=t=>""+Math.round(100*t)/100}return`${n(t[0])}, ${n(t[1])}`}function CH(t,e){const n=new Map;e.pointData.forEach((i,o)=>{const r=uH(t.schema.point(i,o));if(!r)return;const a=`${t._id(i,o)}`;if(n.has(a))return;const s=e.pointR(i,o);n.set(a,{data:i,i:o,id:a,coord:r,shape:"Circle",r:Number.isFinite(s)?s:0})});const i=new Map;e.topoData.forEach((t,e)=>{const n=`${t.id}`;i.has(n)||i.set(n,{row:t,i:e})});const o=new Map,r=new Map,a=t.schema.locale;return t=>{const e=MH(t);if(null===e)return null;if("string"!=typeof e){const t=e.join(",");return r.has(t)||r.set(t,{data:{point:e},i:0,id:t,label:SH(e,a),coord:e,r:0}),r.get(t)}const s=n.get(e);if(s)return s;if(!o.has(e)){const t=i.get(e),n=t?dH(t.row.feature):null;o.set(e,t&&n?{data:t.row.data??t.row,i:t.i,id:e,coord:n,shape:"Path",r:0}:null)}return o.get(e)}}function $H(t){if(!Array.isArray(t))return[];const e=[];for(const n of t)if(n&&"object"==typeof n)for(const t of[n.source,n.target])hH(t)&&e.push([t[0],t[1]]);return e}function AH(t,{scale:e,min:n,max:i}){const o=t.map(t=>"number"==typeof t&&Number.isFinite(t)?t:void 0),[r,a]=d.extent(o.filter(t=>void 0!==t));if(void 0===r||void 0===a||r===a)return o.map(t=>t??n);const s=`${e||"sqrt"}`,c=(E[`scale${s.charAt(0).toUpperCase()}${s.slice(1)}`]??E.scaleSqrt)().domain([r,a]).range([n,Math.max(n,i)]);return o.map(t=>void 0===t?n:c(t))}function zH(t){const e=(t.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number),n=[];for(let t=0;t+1<e.length;t+=2)n.push([e[t],e[t+1]]);return n.length?Vw(n):[[0,0],[0,0]]}function DH(t,e,n,i){if(!t.schema.linkBundle||vH(n))return;const o=e.filter(t=>t.points&&t.sourceAt&&t.targetAt&&!yH(t.source.coord,t.target.coord,n,i));if(!o.length)return;const r=lH(t,o.map(t=>[t.points[0],t.points[t.points.length-1]]));o.forEach((t,e)=>{t.points=r[e],t.d=jw(r[e]),t.box=Vw(r[e])})}function LH(t,e){"panel"!==t._facetStep&&aw(t);const n=Array.isArray(t.schema.links)?t.schema.links:[],i=CH(t,e),o=t.schema.projection,r=t=>{const n=wH(e.path,t)?o(t):null;return n&&Number.isFinite(n[0])&&Number.isFinite(n[1])?n:null},a=vH(o)?0:Number(t.schema.linkCurve)||0,s=[];n.forEach((t,n)=>{if(!t||"object"!=typeof t)return;const c=i(t.source),l=i(t.target);if(!c||!l)return;const h=bH(c.coord,l.coord,o,e.path,a);h&&s.push({datum:iw(t,c,l,n),index:n,source:c,target:l,...h,sourceAt:r(c.coord),targetAt:r(l.coord),box:h.points?Vw(h.points):zH(h.d)})}),DH(t,s,o,e.path);const c=t.schema.linkSize,l=AH(s.map(t=>ow(t.datum,c(t.datum,t.index))),{scale:t.schema.linkSizeScale,min:Number(t.schema.linkSizeMin)||0,max:Number(t.schema.linkSizeMax)||0}),h=s.map((t,e)=>({...t,size:l[e]})),u=new Map;for(const t of h)for(const e of[t.source,t.target])e.shape&&u.set(e.id,e);return rw(t,h.map(t=>t.datum),[...u.values()]),h}const FH=new WeakMap;function NH(t,e){const n=t.objects,i=e&&n[e]?e:Object.keys(n)[0];let o=FH.get(t);o||FH.set(t,o=new Map);let r=o.get(i);return r||(r=C.feature(t,i),o.set(i,r)),Array.isArray(r.features)?{...r,features:r.features.map(t=>({...t}))}:{...r}}const BH=["scale","translate","rotate","center","angle","reflectX","reflectY","parallels","clipAngle","clipExtent","precision","preclip","postclip"],EH=[[0,0],[-98,39],[-150,61],[-157,21],[-66,18],[12,50],[116,40],[151,-34],[-58,-34],[28,-26]],RH=new WeakMap;let PH=0;function TH(t){if("function"==typeof t){let e=RH.get(t);return void 0===e&&RH.set(t,e=PH++),`f${e}`}return"number"==typeof t?Object.is(t,-0)?"-0":String(t):Array.isArray(t)?`[${t.map(TH).join(",")}]`:null==t?String(t):"boolean"==typeof t||"string"==typeof t?JSON.stringify(t):"?"}function OH(t){try{const e=[];for(const n of BH){const i=t[n];"function"==typeof i&&e.push(`${n}=${TH(i.call(t))}`)}for(const n of EH)e.push(TH(t(n)));return e.join(";")}catch{return null}}function WH(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!WH(t[n],e[n]))return!1;return!0}if(!t||!e||"object"!=typeof t||"object"!=typeof e||Array.isArray(e)||Object.getPrototypeOf(t)!==Object.prototype||Object.getPrototypeOf(e)!==Object.prototype)return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&WH(t[n],e[n]))}const jH=new WeakMap;const HH=new WeakMap;const IH=Math.PI/180,GH=180/Math.PI,qH=t=>Math.max(-1,Math.min(1,t));function VH([t,e,n]){const i=t*IH/2,o=e*IH/2,r=(n??0)*IH/2,a=Math.sin(i),s=Math.cos(i),c=Math.sin(o),l=Math.cos(o),h=Math.sin(r),u=Math.cos(r);return[s*l*u+a*c*h,a*l*u-s*c*h,s*c*u+a*l*h,s*l*h-a*c*u]}function KH(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]**2+t[2]**2))*GH,Math.asin(qH(2*(t[0]*t[2]-t[3]*t[1])))*GH,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]**2+t[3]**2))*GH]}function YH([t,e]){const n=t*IH,i=e*IH,o=Math.cos(i);return[o*Math.cos(n),o*Math.sin(n),Math.sin(i)]}function UH(t,e){const n=[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],i=Math.hypot(...n);if(!i)return[1,0,0,0];const o=Math.acos(qH(t[0]*e[0]+t[1]*e[1]+t[2]*e[2]))/2,r=Math.sin(o);return[Math.cos(o),n[2]/i*r,-n[1]/i*r,n[0]/i*r]}function XH(t,e){return[t[0]*e[0]-t[1]*e[1]-t[2]*e[2]-t[3]*e[3],t[1]*e[0]+t[0]*e[1]+t[2]*e[3]-t[3]*e[2],t[0]*e[2]-t[1]*e[3]+t[2]*e[0]+t[3]*e[1],t[0]*e[3]+t[1]*e[2]-t[2]*e[1]+t[3]*e[0]]}const QH=t=>t&&Number.isFinite(t[0])&&Number.isFinite(t[1])?t:null;function ZH(t,e){const n=QH(t.invert?.(e));if(!n)return null;const i=t(n);return i&&Math.hypot(i[0]-e[0],i[1]-e[1])<.5?n:null}function JH(t,e,n,i){const o=t.rotate();t.rotate(e);const r=ZH(t,n),a=r?ZH(t,i)??QH(t.invert?.(i)):null;t.rotate(o);const[s,c,l=0]=e;if(r&&a)return KH(XH(VH(e),UH(YH(r),YH(a))));const h=GH/(t.scale()||1);return[s+(i[0]-n[0])*h,Math.max(-90,Math.min(90,c-(i[1]-n[1])*h)),l]}function tI(t,e){const n=t.touches,i=n&&n.length?n[0]:void 0!==t.clientX?t:null;if(!i)return null;const o=e.getBoundingClientRect();return[i.clientX-o.left-(e.clientLeft||0),i.clientY-o.top-(e.clientTop||0)]}function eI(t,e,n={}){return[(t[0]-e.x)/e.k-(n.x??0),(t[1]-e.y)/e.k-(n.y??0)]}function nI(t){return vH(t.schema.projection)&&!!t.schema.zoom&&!t._ssr&&!t._facetPanels&&!t._facetStep}function iI(t){const e=t.schema.projectionRotate;if(Array.isArray(e))return e;const n=t._globeHome;return n&&n.projection===t.schema.projection?n.rotate:void 0}function oI(t,e){let n=null;const i=()=>(t._zoomEventTarget||t._container)?.node()??null,o=()=>{if(!n||!n.to)return;n.frame=void 0;const i=t.schema.projection;i.rotate(JH(i,n.r0,n.p0,n.to)),e(),t._drawSceneToTarget?.(0)},r=()=>{n&&(void 0!==n.frame&&cancelAnimationFrame(n.frame),o(),n=null,t._globeDragging=!1)},a={start(e){n=null;const o=i();if(!o||!nI(t)||!(t=>!!t&&("mousedown"===t.type||"pointerdown"===t.type||"touchstart"===t.type&&1===(t.touches?.length??0)))(e.sourceEvent))return;const r=tI(e.sourceEvent,o);if(!r)return;const a=t.schema.projection;iI(t)||(t._globeHome={projection:a,rotate:a.rotate()}),n={t0:e.transform,r0:a.rotate(),p0:eI(r,e.transform,t._chartTransform)}},zoom(e){if(!n)return!1;const a=e.sourceEvent,s=i();if(!a||!s||"wheel"===a.type||(a.touches?.length??0)>1)return r(),!1;(t._zoomEventTarget||t._container).property("__zoom",n.t0);const c=tI(a,s);return!c||(t._globeDragging=!0,n.to=eI(c,n.t0,t._chartTransform),"function"!=typeof requestAnimationFrame?o():void 0===n.frame&&(n.frame=requestAnimationFrame(o)),!0)},end(){r()},reset(){if(!nI(t))return;const n=iI(t);n&&(t.schema.projection.rotate(n),e())}};t._zoomGesture=a}function rI(t){return t._filteredData.filter((e,n)=>t.schema.point(e,n)instanceof Array)}function aI(t,e){const n=`scale${t.schema.pointSizeScale.charAt(0).toUpperCase()}${t.schema.pointSizeScale.slice(1)}`;return E[n]().domain(d.extent(e,(e,n)=>t.schema.pointSize(e,n))).range([t.schema.pointSizeMin,t.schema.pointSizeMax])}function sI(t,e,n){return e.filter((e,i)=>{const o=uH(t.schema.point(e,i));return null!==o&&wH(n,o)})}function cI(t,e,n,i,o,r){e.effectivePadding=void 0;const a=t.schema.fitObject?NH(t.schema.fitObject,t.schema.fitKey):n;e.extentBounds={type:"FeatureCollection",features:t.schema.fitFilter?a.features.filter(t.schema.fitFilter):a.features.slice()},e.extentBounds.features=function(t,e){return t.reduce((t,n)=>{const i=n;if(!i.geometry)return t;const o={type:i.type,id:i.id,geometry:{coordinates:i.geometry.coordinates,type:i.geometry.type}};if("MultiPolygon"===i.geometry.type&&i.geometry.coordinates.length>1){const t=[],n=[];i.geometry.coordinates.forEach(n=>{o.geometry.coordinates=[n],t.push(e.area(o))}),o.geometry.coordinates=[i.geometry.coordinates[t.indexOf(d.max(t))]];const r=e.centroid(o);i.geometry.coordinates.forEach(t=>{o.geometry.coordinates=[t],n.push(u.pointDistance(e.centroid(o),r))});const a=d.quantile(t.reduce((e,i,o)=>(n[o]&&e.push(t[o]/n[o]),e),[]),.9);o.geometry.coordinates=i.geometry.coordinates.filter((e,i)=>{const o=n[i];return 0===o||t[i]/o>=a})}return t.push(o),t},[])}(e.extentBounds.features,i);const s=$H(t.schema.links);e.extentBounds.features.length||!o.length&&!s.length||function(t,e,n,i,o){const r=[[void 0,void 0],[void 0,void 0]];n.map((e,n)=>t.schema.point(e,n)).concat(o).forEach(e=>{const n=t.schema.projection(e);n&&((void 0===r[0][0]||n[0]<r[0][0])&&(r[0][0]=n[0]),(void 0===r[1][0]||n[0]>r[1][0])&&(r[1][0]=n[0]),(void 0===r[0][1]||n[1]<r[0][1])&&(r[0][1]=n[1]),(void 0===r[1][1]||n[1]>r[1][1])&&(r[1][1]=n[1]))}),e.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:r.map(e=>t.schema.projection.invert(e))}}]};const a=d.max(n,(e,n)=>i(t.schema.pointSize(e,n)))??0;e.effectivePadding={top:t.schema.projectionPadding.top+a,right:t.schema.projectionPadding.right+a,bottom:t.schema.projectionPadding.bottom+a,left:t.schema.projectionPadding.left+a}}(t,e,o,r,s)}function lI(t,e,n,i){const o=e.effectivePadding||t.schema.projectionPadding,r=vH(t.schema.projection)?iI(t):void 0,a=r?t.schema.projection.rotate():void 0;r&&t.schema.projection.rotate(r),function(t,e,n){const i=jH.get(t);i&&null!==i.state&&WH(i.extent,e)&&i.state===OH(t)&&WH(i.object,n)||(t.fitExtent(e,n),jH.set(t,{extent:[[...e[0]],[...e[1]]],object:n,state:OH(t)}))}(t.schema.projection,e.extentBounds.features.length?[[o.left,o.top],[n-o.right,i-o.bottom]]:[[0,0],[n,i]],e.extentBounds.features.length?e.extentBounds:{type:"Sphere"}),a&&t.schema.projection.rotate(a)}const hI=({viz:t})=>{const e=t,n=t.ctx,{width:i,height:o}=wt(e),r=e.schema.topojson?NH(e.schema.topojson,e.schema.topojsonKey):{type:"FeatureCollection",features:[]};n.coordData=r,e.schema.topojsonFilter&&(r.features=r.features.filter(e.schema.topojsonFilter));const a=P.geoPath().projection(e.schema.projection);n.path=a;const s=rI(e),c=e._filteredData.filter((t,n)=>!(e.schema.point(t,n)instanceof Array)).reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{}),l=r.features.reduce((t,n)=>{const i=e.schema.topojsonId(n);return t.push({__d3plus__:!0,data:c[i],feature:n,id:i}),t},[]),h=aI(e,s);e._sizeLegendFinal=s.length?h:null,e._zoomSet&&n.extentBounds||cI(e,n,r,a,s,h),e._globeDragging||lI(e,n,i,o),n.geomapWidth=i,n.geomapHeight=o;const u=function(t,e){const n=OH(t);if(null===n)return e;let i=HH.get(t);i?.state!==n&&HH.set(t,i={state:n,byGeometry:new WeakMap});const{byGeometry:o}=i;return t=>{const n=t?.geometry;if(!n||"object"!=typeof n)return e(t);if(o.has(n))return o.get(n);const i=e(t);return o.set(n,i),i}}(e.schema.projection,a),d=(t,n)=>h(e.schema.pointSize(t,n));return n.geomapCtx={flowLinks:LH(e,{pointData:s,topoData:l,pointR:d,path:a}),topoData:l,pathFn:t=>u(t.feature),pointData:sI(e,s,a),pointR:d,pointSort:(t,n)=>e.schema.pointSize(n)-e.schema.pointSize(t),pointX:(t,n)=>e.schema.projection(e.schema.point(t,n))[0],pointY:(t,n)=>e.schema.projection(e.schema.point(t,n))[1]},{shapeData:l}},uI={geoAlbers:S.geoAlbers,geoAlbersUsa:T.geoAlbersUsa??S.geoAlbersUsa,...T.geoAlbersUsaTerritories&&{geoAlbersUsaTerritories:T.geoAlbersUsaTerritories},geoAzimuthalEqualArea:S.geoAzimuthalEqualArea,geoAzimuthalEquidistant:S.geoAzimuthalEquidistant,geoConicConformal:S.geoConicConformal,geoConicEqualArea:S.geoConicEqualArea,geoConicEquidistant:S.geoConicEquidistant,geoEqualEarth:S.geoEqualEarth,geoEquirectangular:S.geoEquirectangular,geoGnomonic:S.geoGnomonic,geoMercator:S.geoMercator,geoMiller:$.geoMiller,geoNaturalEarth1:S.geoNaturalEarth1,geoOrthographic:S.geoOrthographic,geoRobinson:$.geoRobinson,geoStereographic:S.geoStereographic,geoTransverseMercator:S.geoTransverseMercator,geoWinkel3:$.geoWinkel3};function dI(t,e,n,i){const o=e.label;if(!1!==o)return void 0!==o?Tg(o,n,i):t._drawLabel(n,i)}function fI(t,n,i){const o={...i.labelConfig??{},...Ig(t,"Circle")},r=n.points.map((e,r)=>{const a=n.pointR(e,r);return{key:e,datum:e,index:r,x:n.pointX(e,r),y:n.pointY(e,r),r:a,text:dI(t,i,e,r),inside:{width:2*a,height:2*a,shape:"circle",padding:Tg(o.padding,e,r)??t_.padding,font:{family:Tg(o.fontFamily,e,r),weight:Tg(o.fontWeight,e,r)}}}}),{width:a,height:s}=wt(t),c=Ew(t,r,{x:0,y:0,width:a,height:s});if(!c.size)return[];const l=new Map(n.points.map((t,e)=>[t,e])),h=e=>`geomap-label-${t._id(e,l.get(e)??0)}`,u=e_({data:n.points,label:t=>"inside"===c.get(t)?.position&&c.get(t).text,x:(t,e)=>n.pointX(t,e),y:(t,e)=>n.pointY(t,e),aes:(t,e)=>({r:n.pointR(t,e)}),rotate:W(0),id:h,labelBounds:(t,e,n)=>{const i=n.r;return{width:2*i,height:2*i,x:-i,y:-i,shape:"circle"}},labelConfig:{fontColor:n=>{const o=n.data,r=Tg(i.fill,o,l.get(o)??0);return e.colorContrast("string"==typeof r?r:"rgb(255, 255, 255)",t.schema.colorDefaults)},textAnchor:"middle",verticalAlign:"middle",...o,fontMin:(e,n)=>Ow(t,c.get(e.data),Tg(o.fontMin,e,n)??t_.fontMin)}}),d=Tw(c,t=>({id:h(t),datum:t}));return[...u,...Pw(t,d)]}const mI=t=>`geomap-link-${t.source.id}-${t.target.id}-${t.index}`;function pI(t){return k.interpolateRgb(Tc(t),Oc(t))(.5)}function gI(t,e,n,i){return{fill:"none",stroke:n(e.datum,e)??i,strokeWidth:e.size,strokeOpacity:.85,strokeLinecap:"round"}}const yI=(t,e)=>!!t&&!!e&&Math.hypot(t[0][0]-e[0],t[0][1]-e[1])<=1;function xI(t,e,n,i=1){const o=kv({arrows:t.schema.arrows,arrowSize:yv(t.schema.arrowSize,i),strokeWidth:xv(e.size,i),datum:e.datum,i:e.index});if(!o.ends.source&&!o.ends.target)return{d:e.d,arrows:[]};const r=_H(e.d),a=r[r.length-1],s=t=>t?t+1:0,c={source:o.ends.source&&yI(r[0],e.sourceAt),target:o.ends.target&&yI(a?[...a].reverse():void 0,e.targetAt)},{d:l,source:h,target:u}=xM(r,{...o,ends:c},{source:s(e.source.r),target:s(e.target.r)});return{d:l,arrows:_M({ends:{source:h,target:u},size:o.size,datum:e.datum,keyPrefix:`${mI(e)}-arrow`,fill:n})}}function bI(t,e){if(!e.length)return[];const n=zw(t),i=pI(t),o=[],r=[],a=[],s=[...e].sort((t,e)=>e.size-t.size||t.index-e.index);for(const e of s){const s=gI(0,e,n,i),c=mI(e),l="string"==typeof s.stroke?s.stroke:void 0,h=bv(n=>xI(t,e,l,n));h.arrows.length&&(s.strokeLinecap="butt"),o.push({type:"path",key:c,d:h.d,...h.emphasis?{emphasis:h.emphasis}:{},datum:e.datum,index:e.index,paint:s,aria:{label:pw(t,e.datum)}}),r.push(Sw(c,e.d,e.datum,e.size)),a.push(...h.arrows)}return[...o,...r,...a]}function kI(t,e,n){return aM(t,e.map((t,e)=>({key:mI(t),link:t.datum,i:e,anchor:t.points?qw(t.points):null,path:t.points,priority:t.size})),{circles:n})}function _I(t){return`link:${ew(t)?.index}`}function vI(t,e){const n=ew(e),i=t.ctx.nodeLookup;if(!n||!i)return null;const o=[n.source.id,n.target.id].map(t=>i[t]),r=[];for(const t of o){if(!t||"number"!=typeof t.x||"number"!=typeof t.y)return null;const e="number"==typeof t.r?t.r:0;r.push([[t.x-e,t.y-e],[t.x+e,t.y+e]])}return[[Math.min(r[0][0][0],r[1][0][0]),Math.min(r[0][0][1],r[1][0][1])],[Math.max(r[0][1][0],r[1][1][0]),Math.max(r[0][1][1],r[1][1][1])]]}function wI(t){return void 0!==t._focus&&(t.active?.(!1),t._focus=void 0,t._zoomToBounds?.(null),!0)}const MI=new WeakSet;function SI(t){const e=t._select?.node?.();e&&"function"==typeof e.addEventListener&&(MI.has(e)||(MI.add(e),e.addEventListener("click",n=>{if(n.target!==e)return;const i=_u(t),{clientX:o,clientY:r}=n;t._backgroundClick?.([o-i.left,r-i.top])})))}function CI(t,e,{nodeKey:n,box:i}={}){t._tooltipClass?.data([]).render();const o=_I(e);t._focus!==o?(t.hover?.(!1),t.active?.(gw(t,e,n)),t._focus=o,SI(t),i&&t._zoomToBounds&&VM(t,[i[0][0],i[1][0]],[i[0][1],i[1][1]])):wI(t)}function $I(t){t._backgroundClick=([e,n])=>{const{width:i,height:o}=wt(t),{left:r,top:a}=t._margin;e>=r&&e<=r+i&&n>=a&&n<=a+o&&wI(t)}}function AI(t,e){const n=ew(e)?.index,i=(t.ctx.geomapCtx?.flowLinks??[]).find(t=>t.index===n);return i?i.box:null}function zI(t,e){const n=(e,n)=>`${t._id(e,n)}`;return nw(e)?gw(t,e,n):bw(t,e,n)}function DI(t){t.links=function(){return arguments.length?(_n(this,"links",arguments),this):this.schema.links},$I(t);const e=t.schema.on;let n=!1;const i=e["mousemove.shape"];e["mousemove.shape"]=(e,o,r,a)=>{i?.(e,o,r,a);const s=zI(t,e);s&&(n=!0,mk.call(t,s))};const o=e["mouseleave.shape"];e["mouseleave.shape"]=(e,i,r,a)=>{o?.(e,i,r,a),n&&(n=!1,mk.call(t,!1))};const r=e["click.shape"];e["click.shape"]=(e,n,i,o)=>nw(e)?(o?.stopPropagation?.(),void CI(t,e,{nodeKey:(e,n)=>`${t._id(e,n)}`,box:AI(t,e)})):wI(t)?void 0:r?.(e,n,i,o);const a=t._draw.bind(t);t._draw=function(e){const n=a(e);return t._container?.select("rect.d3plus-geomap-ocean").on("click.linkFocus",()=>wI(t)),n}}const LI="Shift+ArrowLeft Shift+ArrowRight Shift+ArrowUp Shift+ArrowDown",FI="Hold Shift and use the arrow keys to rotate the globe.",NI={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]},BI=t=>((t+180)%360+360)%360-180;function EI(t,e,n){const[i=0,o=0,r=0]=t;return[BI(i-e),Math.max(-90,Math.min(90,o-n)),r]}function RI(t,e,n){const[i=0,o=0,r=0]=t,[a=0,s=0,c=0]=e;return[BI(i+BI(a-i)*n),o+(s-o)*n,r+(c-r)*n]}function PI(t){if(!t.shiftKey||t.altKey||t.ctrlKey||t.metaKey)return null;const e=NI[t.key];return e?[10*e[0],10*e[1]]:null}const TI=(t,e)=>t.every((t,n)=>Math.abs(t-(e[n]??0))<1e-6);function OI(t,e){let n=null;const i=()=>t.schema.projection,o=n=>(i().rotate(n),e(),t._drawSceneToTarget?.(0),i().rotate()),r=()=>{void 0!==n?.frame&&cancelAnimationFrame(n.frame),n=null},a=t=>{if(!n)return;if(n.frame=void 0,!TI(i().rotate(),n.last))return r();const e=Math.max(0,Math.min(1,(t-n.start)/n.duration));n.last=o(e<1?RI(n.from,n.to,(t=>1-(1-t)**3)(e)):n.to),e<1?n.frame=requestAnimationFrame(a):n=null},s={keydown(e){const s=PI(e);if(!s||!nI(t))return!1;const c=i();iI(t)||(t._globeHome={projection:c,rotate:c.rotate()});const l=c.rotate(),h=EI(n&&TI(l,n.last)?n.to:l,...s),u=Math.min(200,Jt(t));return r(),u&&"function"==typeof requestAnimationFrame?(n={from:l,to:h,start:performance.now(),duration:u,last:l},n.frame=requestAnimationFrame(a),!0):(o(h),!0)},keys:()=>nI(t)?{shortcuts:LI,instructions:t.schema.translate(FI)}:null};t._keyboardGesture=s}function WI(){return[{key:"arrows",default:!1},{key:"arrowSize"},...cM(),...hM(),{key:"links",default:[]},{key:"linkCurve",default:.2},{key:"linkSize",default:W(2),coerce:t=>"function"==typeof t?t:W(t)},lM(10),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"nodeTooltipLinks"},{key:"tooltipConfig",merge:!0,factory:t=>Mw(t)}]}function jI(t){const{width:e,height:n}=wt(t);return[[0,0],[e,n]]}function HI(t){return sH(t.schema.tileUrl,Boolean(t._basemapDark))}function II(t){const e=!!t.schema.tiles&&function(t){const e=rH.find(e=>e.matches.some(e=>t.includes(e)));return!!e&&e.text}(HI(t)),n=t.schema.attribution;n&&n!==t._tileAttribution||(t.schema.attribution=e||""),t._tileAttribution=e}function GI(t){!function(t){const e=t;e.fitFilter=function(t){if(arguments.length){if(this._zoomSet=!1,"function"==typeof t)return this.schema.fitFilter=t,this;const e=t instanceof Array?t:[t];return this.schema.fitFilter=t=>e.includes(t.id),this}return this.schema.fitFilter},e.fitKey=function(t){return arguments.length?(this.schema.fitKey=t,this._zoomSet=!1,this):this.schema.fitKey},e.fitObject=function(t,e){return arguments.length?(n.addToQueue.bind(this)(t,e,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},e.point=function(t){return arguments.length?(this.schema.point="function"==typeof t?t:W(t),this):this.schema.point},e.pointSize=function(t){return arguments.length?(this.schema.pointSize="function"==typeof t?t:W(t),this):this.schema.pointSize}}(t),function(t){const e=t;e.projection=function(t){return arguments.length&&"geoMercator"!==t&&e.tiles(!1),arguments.length?(this.schema.projection="string"==typeof t?(n=t,Object.hasOwn(uI,n)?uI[n]():(Rt(`Geomap received unknown projection "${n}"; using geoMercator. Pass the projection itself to use one not built in, e.g. .projection(${n}()).`),S.geoMercator())):t,this):this.schema.projection;var n},e.projectionPadding=function(t){return arguments.length?(this.schema.projectionPadding=r.parseSides(t),this):this.schema.projectionPadding},e.projectionRotate=function(t){return arguments.length?(this.schema.projectionRotate=t,this.schema.projection.rotate(t),e.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}(t),function(t){const e=t;e.tiles=function(t){return arguments.length?(this.schema.tiles=t,II(this),this):this.schema.tiles},e.tileUrl=function(t){return arguments.length?(this.schema.tileUrl=t,II(this),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}(t),function(t){const e=t;e.topojson=function(){return arguments.length?(_n(this,"topojson",arguments),this._zoomSet=!1,this):this.schema.topojson},e.topojsonFill=function(t){return arguments.length?(this.schema.topojsonFill="function"==typeof t?t:W(t),this):this.schema.topojsonFill},e.topojsonFilter=function(t){if(arguments.length){if(this._zoomSet=!1,"function"==typeof t)return this.schema.topojsonFilter=t,this;const e=t instanceof Array?t:[t];return this.schema.topojsonFilter=t=>e.includes(t.id),this}return this.schema.topojsonFilter},e.topojsonKey=function(t){return arguments.length?(this.schema.topojsonKey=t,this._zoomSet=!1,this):this.schema.topojsonKey},e.topojsonId=function(t){return arguments.length?(this.schema.topojsonId="function"==typeof t?t:H(t),this):this.schema.topojsonId}}(t)}const qI={name:"Geomap",layoutStage:hI,sizeLegendScale:t=>{const e=rI(t);return e.length?aI(t,e):null},emit:({viz:t})=>{const e=t.ctx.geomapCtx;if(!e)return[];const n=function(t){const e=[],n="panel"===t._facetStep;if(t._ssr||n){const n=sH(t.schema.ocean,Boolean(t._basemapDark));if(n&&"transparent"!==n){const{width:i,height:o}=wt(t);e.push({type:"rect",key:"geomap-ocean",x:0,y:0,width:i,height:o,paint:{fill:n}})}}const i=t._ssrTiles;if((i&&i.size||n&&!t._ssr)&&"function"==typeof t._computeTileList)for(const n of t._computeTileList()){const t=i&&i.size?i.get(n.key):n.url;t&&e.push({type:"image",key:`geomap-tile-${n.key}`,x:n.x,y:n.y,width:n.size,height:n.size,href:t,preserveAspectRatio:"none",interactive:!1})}return e}(t);if(e.topoData&&e.topoData.length){const i=Hg(t,"Path"),o=t.schema.colorScale,r=n.length;for(let r=0;r<e.topoData.length;r++){const a=e.topoData[r],s=a.data??a,c=Wg(i,s,r),l=o?`, ${o(s,r)}`:"";n.push({type:"path",key:`geomap-path-${a.id}`,d:e.pathFn(a),datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${t._drawLabel(s,r)}${l}.`}})}n.push(...jS(i,n.slice(r),t=>{const n=e.topoData[t];return[n.data??n,t]}))}const i=e.flowLinks??[];n.push(...bI(t,i));const o=[];if(e.pointData&&e.pointData.length){const i=Hg(t,"Circle"),r=e.pointSort?[...e.pointData].sort(e.pointSort):e.pointData,a=n.length;for(let a=0;a<r.length;a++){const s=r[a],c=Wg(i,s,a);o.push({x:e.pointX(s,a),y:e.pointY(s,a),r:e.pointR(s,a)}),n.push({type:"circle",key:`geomap-point-${t._id(s,a)}`,cx:0,cy:0,r:e.pointR(s,a),transform:{x:e.pointX(s,a),y:e.pointY(s,a)},datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${t._drawLabel(s,a)}, ${t.schema.pointSize(s,a)}.`},...i.trail?{trail:!0}:{},...i.trailPersist?{trailPersist:i.trailPersist}:{}})}n.push(...jS(i,n.slice(a),t=>[r[t],t])),n.push(...fI(t,{points:r,pointR:e.pointR,pointX:e.pointX,pointY:e.pointY},i))}return n.push(...kI(t,i,o)),n},insetRegion:Ay,colorScaleShape:(t,e,n)=>t.schema.point(e,n)instanceof Array?t.schema.shape(e,n):"Path",pointMark:(t,e)=>mu(e),chartClip:St,setup:t=>{const e=t;t._zoomSet=!1,t.schema.tiles=!0,t._tileGen=M.tile(),function(t){t._renderTiles=function(t=nf(this),e=0){if(this._ssr)return;if(this._facetPanels||this._facetStep)return void this._tileGroup?.selectAll("image.d3plus-geomap-tile").remove();let n=[];this.schema.tiles&&(n=this._tileGen.extent(jI(this)).scale(this.schema.projection.scale()*(2*Math.PI)*t.k).translate(t.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(e).attr("transform",t));const i=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(n,([t,e,n])=>`${t}-${e}-${n}`);i.exit().transition().duration(e).attr("opacity",0).remove();const o=n.scale/t.k,r=i.enter().append("image").attr("class","d3plus-geomap-tile");r.attr("opacity",0).transition().duration(e).attr("opacity",1),i.interrupt(),i.merge(r).attr("width",o).attr("height",o).attr("xlink:href",([t,e,n])=>HI(this).replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${n}`).replace("{x}",`${t}`).replace("{y}",`${e}`)).attr("x",([e])=>e*o+n.translate[0]*o-t.x/t.k).attr("y",([,e])=>e*o+n.translate[1]*o-t.y/t.k)},t._computeTileList=function(){if(!this.schema.tiles)return[];const t=this._tileGen.extent(jI(this)).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),e=t.scale;return t.map(([n,i,o])=>({key:`${n}-${i}-${o}`,url:HI(this).replace("{s}","a").replace("{z}",`${o}`).replace("{x}",`${n}`).replace("{y}",`${i}`),x:n*e+t.translate[0]*e,y:i*e+t.translate[1]*e,size:e}))}}(t),function(t){const e=t._draw.bind(t);t._draw=function(n){t._basemapDark=t._theme?t._theme.dark:rp(t),II(t);const i=e(n),{width:o,height:r}=wt(t);return An(t,{kind:"geomap",width:o,height:r,duration:Jt(t),ocean:t._facetStep?"transparent":sH(t.schema.ocean,Boolean(t._basemapDark))}),t._zoomSet=!0,i}}(t),GI(t),DI(t);const n=()=>Ct(t,qI,hI);oI(t,n),OI(t,n),e.tileUrl(aH),t.schema.topojsonFill=()=>t._theme?.colorScale.missing??(t._basemapDark?"#3d3e44":"#f5f5f3")},ctx:{},fields:[...Mn("topojson","links"),{key:"fitObject",default:!1},...WI(),{key:"noDataMessage",default:!1},{key:"ocean",default:{light:"#d0cfd4",dark:"#222327"}},{key:"point",default:H("point")},{key:"pointSize",default:W(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:S.geoMercator()},{key:"projectionPadding",default:r.parseSides(20)},{key:"shape",default:W("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:W("#f5f5f3")},{key:"topojsonFilter",default:t=>!["010"].includes(t.id)},{key:"topojsonId",default:H("id")},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>`${t._drawLabel(e,n)}, ${t.schema.pointSize(e,n)}`,hoverOpacity:1,Path:{ariaLabel:(e,n)=>{const i=t.schema.colorScale,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},fill:(e,n)=>{const i=t.ctx.coordData?.features??[],o=t.schema.colorScale;if(o&&!i.includes(e)){const n=o(e);if(null!=n){if(t._colorScaleClass._colorScale)return t._colorScaleClass._colorScale(n);let e=t._colorScaleClass.color();return e instanceof Array&&(e=e[e.length-1]),e}}return t.schema.topojsonFill(e,n)},on:{mouseenter:(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on.mouseenter.bind(t)(e,n,i,o),"mousemove.shape":(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on["mousemove.shape"].bind(t)(e,n,i,o),mouseleave:(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on.mouseleave.bind(t)(e,n,i,o)},stroke:(e,n)=>{const o=t.schema.shapeConfig.Path,r="function"==typeof o.fill?o.fill(e,n):o.fill,a=i.color(r);return a?a.darker().toString():r},strokeWidth:1},Circle:{trail:!0}})}]};var VI=fk(qI);const KI=Math.sqrt(3),YI=t=>Number.isFinite(t.x)&&Number.isFinite(t.y);function UI(t,e){const{shape:n,size:i}=e,[o,r]=e.origin??[0,0],a=t.filter(YI);if(!(i>0&&a.length))return[];if("square"===n){const t=new Map;for(const e of a){const n=Math.floor((e.x-o)/i),a=Math.floor((e.y-r)/i),s=`s${n}_${a}`;let c=t.get(s);c||(c={key:s,cx:o+(n+.5)*i,cy:r+(a+.5)*i,points:[]},t.set(s,c)),c.points.push(e)}return Array.from(t.values())}const s=i*KI,c=1.5*i;return z.hexbin().radius(i).x(t=>t.x-o).y(t=>t.y-r)(a).map(t=>({key:`h${Math.round(2*t.x/s)}_${Math.round(t.y/c)}`,cx:o+t.x,cy:r+t.y,points:Array.from(t)}))}function XI(t,e,n){const i="square"===e?n/2:n*KI/2,o="square"===e?n/2:n;return{x0:t.cx-i,x1:t.cx+i,y0:t.cy-o,y1:t.cy+o}}function QI(t,e,n){const i=t=>Math.round(100*t)/100;if("square"===e){const{x0:o,x1:r,y0:a,y1:s}=XI(t,e,n);return`M${i(o)},${i(a)}H${i(r)}V${i(s)}H${i(o)}Z`}return`M${[0,1,2,3,4,5].map(e=>{const o=e*Math.PI/3;return`${i(t.cx+Math.sin(o)*n)},${i(t.cy-Math.cos(o)*n)}`}).join("L")}Z`}function ZI(t,e){return"square"===t?e*e:3*KI/2*e*e}function JI(t,e){if("count"===e)return t.length;let n=0,i=0;for(const e of t)"number"==typeof e.weight&&Number.isFinite(e.weight)&&(n+=e.weight,i++);return"sum"===e?n:i?n/i:NaN}function tG(t,e){return Array.isArray(e)?e.filter(t=>Number.isFinite(t)&&t>0).sort((t,e)=>t-e):t>0&&e>0?d.ticks(0,t,e).filter(e=>e>0&&e<t):[]}function eG(t,[e,n]=[0,0]){const i=t=>Math.round(100*t)/100;return t.flatMap(t=>t.map(t=>`M${t.map(([t,o])=>`${i(t+e)},${i(o+n)}`).join("L")}Z`)).join("")}function nG(t,e){const{left:n,top:i,width:o,height:r,bandwidth:a,unit:s}=e,c=t.filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y));if(!(c.length&&o>0&&r>0&&s>0))return[];const l=D.contourDensity().x(t=>t.x-n).y(t=>t.y-i).weight(t=>"number"==typeof t.weight&&Number.isFinite(t.weight)?t.weight:1).size([Math.ceil(o),Math.ceil(r)]).bandwidth(Math.max(a,.5)).contours(c);return tG(l.max*s,e.thresholds).map(t=>({level:t,path:eG(l(t/s).coordinates,[n,i])})).filter(t=>t.path.length)}const iG="Hexbin",oG="__d3plusHexbin",rG={bandwidth:20,thresholds:8,strokeWidth:1.5,fillOpacity:.8,labels:!0,labelConfig:{},labelSpacing:"auto",labelStep:"auto"},aG={r:1.5,fillOpacity:.35};function sG(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function cG(t){const e=t?sG(t):void 0;return e?e[oG]:void 0}function lG(t){const e=cG(t);return e?"bin"===e.kind?e.value:e.level:void 0}function hG(t,e){return{id:t,[oG]:e}}function uG(t,e){if(!t||"count"===t||"object"!=typeof t)return{agg:"count",measure:e("Count")};const{value:n,agg:i,label:o}=t,r="function"==typeof n?n:"string"==typeof n?G(n):void 0;if(!r)return{agg:"count",measure:e("Count")};const a="mean"===i?"mean":"sum",s="string"==typeof n?n:q(r)??void 0,c=e("mean"===a?"Mean":"Total");return{agg:a,weight:r,measure:o??(s?`${c} ${s}`:c)}}function dG(t){const e=t.schema,n="square"===e.binShape?"square":!1!==e.binShape&&"hex",i=Number(e.binSize),o="filled"===e.contours?"filled":(!0===e.contours||"lines"===e.contours)&&"lines";return{shape:n,size:i>0?i:12,...uG(e.binValue,t=>e.translate(t)),contours:o,contourConfig:{...rG,...e.contourConfig},points:Boolean(e.points),pointConfig:{...aG,...e.pointConfig}}}function fG(t){return t.ctx.hexbin}const mG=t=>"number"==typeof t&&Number.isFinite(t);function pG(t){const{xRange:e,yRange:n}=t;return{left:e[0],top:n[0]-(t.x2Height??0),width:e[e.length-1]-e[0],height:n[n.length-1]-n[0]}}function gG(t,e,n){const i=e.shape||"hex",o=[];for(const r of t){const t=JI(r.points,e.agg);if(!Number.isFinite(t))continue;const a=XI(r,i,e.size),[s,c]=[n.x(a.x0),n.x(a.x1)].sort((t,e)=>t-e),[l,h]=[n.y(a.y0),n.y(a.y1)].sort((t,e)=>t-e);o.push(hG(`bin-${r.key}`,{kind:"bin",count:r.points.length,value:t,x0:s,x1:c,y0:l,y1:h,path:QI(r,i,e.size),rows:r.points.map(t=>t.row)}))}return o}function yG(t,e,n){const{bandwidth:i,thresholds:o}=n.contourConfig,r=nG("sum"===n.agg?t:t.map(t=>({...t,weight:1})),{...e,bandwidth:i,thresholds:o,unit:ZI(n.shape||"hex",n.size)});return r.map((t,e)=>hG(`contour-${e}`,{kind:"contour",level:t.level,next:r[e+1]?.level,index:e,levels:r.length,path:t.path}))}function xG(t,e,n){const i=n.shape||"hex";return t.filter(t=>{const o=XI(t,i,n.size);return o.x1>e.left&&o.x0<e.left+e.width&&o.y1>e.top&&o.y0<e.top+e.height})}function bG(t,e){const n=t=>Math.round(10*t)/10;let i="";for(const o of t)mG(o.x)&&mG(o.y)&&(i+=`M${n(o.x-e)},${n(o.y)}a${e},${e} 0 1,0 ${2*e},0a${e},${e} 0 1,0 ${-2*e},0`);return i}function kG(t,e,n,i){const o={x:()=>NaN,y:()=>NaN};return i.shape?gG(xG(UI(t,{shape:i.shape,size:i.size,origin:n}),e,i),i,o):i.contours?yG(t,e,i):[]}function _G(t,e,n,i,o){const{weight:r}=o;return e.map((e,o)=>({x:n(Number(t._x(e,o))),y:i(Number(t._y(e,o))),row:e,weight:r?Number(r(e,o)):void 0}))}function vG(t,e){if(!de(t))return[e];const n=t.schema.facet;return d.groups(e,(t,e)=>xg(bg(n(t,e)))).map(([,t])=>t)}function wG(t){const e=fG(t);e.colorRows=void 0;const n=t._filteredData??[],i=n.map((e,n)=>Number(t._x(e,n))).filter(mG),o=n.map((e,n)=>Number(t._y(e,n))).filter(mG),[r]=d.extent(i),[a]=d.extent(o);e.anchor=void 0!==r&&void 0!==a?[r,a]:void 0,e.panels=de(t)?vG(t,n):void 0}function MG(t,e,n,i,o){const{viz:r}=t,a=fG(r).panels;return"panel"===r._facetStep&&a?a.flatMap(e=>kG(_G(r,e,e=>t.x(e),e=>t.y(e),o),n,i,o)):e}function SG(t){return fG(t).colorRows??$G(t,dG(t))}const CG={width:.8,height:.7};function $G(t,e){const n=t._filteredData??[],i=n.map((e,n)=>Number(t._x(e,n))).filter(mG),o=n.map((e,n)=>Number(t._y(e,n))).filter(mG);if(!i.length||!o.length)return[];const r=vG(t,n),a={left:0,top:0,width:t.schema.width*CG.width/Math.sqrt(r.length),height:t.schema.height*CG.height/Math.sqrt(r.length)},s=c.scaleLinear().domain(d.extent(i)).range([a.left,a.left+a.width]),l=c.scaleLinear().domain(d.extent(o)).range([a.top+a.height,a.top]),h=[a.left,a.top+a.height];return r.flatMap(n=>kG(_G(t,n,s,l,e),a,h,e))}function AG(t,e){fG(t).colorRows=e;const n=t._colorScaleClass;n&&t.schema.colorScale&&n.data(e).render()}function zG(t,e,n,i,o){if(!t.invert)return;const[r,a]=d.extent(n.filter(mG));if(void 0===r||void 0===a)return;let s=t.domain().slice();s=hC(t,e,r,i,s,0,o),hC(t,e,a,i,s,1,o)}function DG({data:t,x:e,y:n,x2:i,y2:o,xScale:r,yScale:a}){if(i||o)return[e,n];const{size:s}=dG(this);return e=e.copy(),n=n.copy(),zG(e,r??"linear",t.map(t=>t.x),s,!1),zG(n,a??"linear",t.map(t=>t.y),s,!0),[e,n]}const LG=(t,e)=>Number.isFinite(e)?p.formatAbbreviate(e,t.schema.locale):"",FG=(t,e,n)=>`${LG(t,e)} – ${LG(t,n)}`;function NG(t,e){const n=t[`_${e}Key`];return"string"==typeof n?n:e}function BG(t,e){const n=t.schema.levelFormat;return"function"==typeof n?`${n(e)}`:LG(t,e)}function EG(t,e,n){const i=e=>BG(t,e);return void 0===n?`≥ ${i(e)}`:`${i(e)} – ${i(n)}`}function RG(t,e){const n=cG(e);if(!n)return"";return"contour"===n.kind?(i="Density",t.schema.translate(i)):`${dG(t).measure}: ${LG(t,n.value)}`;var i}function PG(t,e){const n=cG(e);if(!n)return[];const i=e=>t.schema.translate(e);if("contour"===n.kind)return[[i("Range"),EG(t,n.level,n.next)]];const o=[[NG(t,"x"),FG(t,n.x0,n.x1)],[NG(t,"y"),FG(t,n.y0,n.y1)]];return"count"!==dG(t).agg&&o.push([i("Count"),LG(t,n.count)]),o}function TG(t,e){const n=cG(e);return n?[RG(t,e),`${NG(t,"x")} ${FG(t,n.x0,n.x1)}`,`${NG(t,"y")} ${FG(t,n.y0,n.y1)}`].join(", "):""}function OG(t,e){const n=cG(e);if(!n||"contour"!==n.kind)return"";return`${i="Density",t.schema.translate(i)}: ${EG(t,n.level,n.next)}`;var i}const WG=Math.PI/3;function jG(t){return(t.match(/M[^MZ]*/g)??[]).map(t=>t.slice(1).split("L").map(t=>t.split(",").map(Number)).filter(([t,e])=>Number.isFinite(t)&&Number.isFinite(e))).filter(t=>t.length>2).map(t=>[...t,t[0]])}function HG(t,e){return"number"==typeof t&&Number.isFinite(t)?Math.max(1,Math.round(t)):e>5?2:1}function IG(t,e=HG("auto",t.length)){if(e<=1)return t.map(()=>!0);const n=t[1]-t[0];return n>0&&t.every((e,i)=>!i||Math.abs(e-t[i-1]-n)<1e-9)&&Math.abs(t[0]/n-Math.round(t[0]/n))<1e-9?t.map(t=>Math.round(t/n)%e===0):t.map((t,n)=>(n+1)%e===0)}function GG(t,e,n){return"number"==typeof t&&t>0&&Number.isFinite(t)?t:Math.max(20*e,(n.width+n.height)/4)}function qG(t,e,n){const i=Math.abs(((t-e)%n+n)%n);return Math.min(i,n-i)}function VG(t,e){const n=e.fontSize/2;return[-n,0,n].flatMap(n=>Px(t,{...e,lift:e.lift+n}))}function KG(t,e,n,i){const o=Wy(t);if(!(o>2*e))return[];const r=Math.max(i,e),a=Iy([...t,...t.slice(1)],0,o+e),s=Math.max(1,Math.floor(o/r)),c=[],l=[];for(;l.length<s;){const t=jx([a],e,n,t=>t<o&&c.every(n=>qG(t+e/2,n,o)>=r));if(!t)break;c.push(t.from+e/2),l.push(t.points),n.grid.add(VG(t.points,n))}return l}function YG(t,e,n,i,o,a=[]){const{labels:c,labelConfig:l,labelSpacing:h,labelStep:u,strokeWidth:d}=o.contourConfig;if(!c||!e.length)return[];const f=e.map(t=>cG(t)).filter(t=>"contour"===t?.kind),m=f.map(t=>jG(t.path)),p="number"==typeof l.fontSize?l.fontSize:10,g={"font-family":r.fontExists(l.fontFamily??s.fontFamily),"font-size":p,"font-weight":l.fontWeight??600},y={x0:i.left,y0:i.top,x1:i.left+i.width,y1:i.top+i.height},x=new Bx(p);for(const t of a)x.add(Ex(t,2));let b=0;const k=m.map(t=>t.map(t=>(x.add(Ex(t,2),b),b++))),_={grid:x,rect:y,fontSize:p,lift:-.3*p,maxTurn:WG,minClearance:Math.max(2,.3*p)},v=GG(h,p,i),w=function(t){const e=new Map;for(const n of t){const t=cG(n.datum);if("contour"!==t?.kind)continue;const i=n.paint??{},o=(i.strokeWidth??0)>0?i.stroke:i.fill;o&&e.set(t.index,o)}return e}(n),M="lines"===o.contours&&d>0,S=IG(f.map(t=>t.level),HG(u,f.length)),C=[],$=[];return f.forEach((e,n)=>{if(!S[n])return;const i=BG(t,e.level);if(!i)return;const o=r.textWidth(i,g)+.8*p;m[n].forEach((r,a)=>{_.ignore=k[n][a],KG(r,o,_,v).forEach((n,o)=>{const r=`contour-label-${e.index}-${a}-${o}`;M&&C.push({type:"path",key:`${r}-pad`,d:qy(n),interactive:!1,aria:{hidden:!0},paint:{fill:"none",stroke:Tc(t),strokeWidth:d+2,strokeLinecap:"butt"}}),$.push({key:r,text:i,d:qy(Hy(n,_.lift)),color:w.get(e.index)??Oc(t),anchor:"middle"})})})}),[...C,...Ky(t,$,{fontSize:p,...l})]}function UG(t,e,n){const i=("x"===e?t._xAxis:t._yAxis)?._d3Scale;return t=>i&&i.invert?Number(i.invert(t+n)):NaN}function XG(t,e){const n=t.values,{weight:i}=e;return n.map(e=>({x:t.x(e.x),y:t.y(e.y),row:e.data,weight:i?Number(i(e.data,e.i)):void 0}))}function QG(t,e,n,i){if(!e.length)return[];const{viz:o}=t,r=Hg(o,iG),a=Pg("Path").renderMode("compute").config(r).config(n(r)).config({ariaLabel:t=>"contour"===cG(t)?.kind?OG(o,t):TG(o,t),d:t=>cG(t)?.path??"",id:t=>t.id,label:!1,x:0,y:0}).data(e);return i&&o._wirePlotShapeEvents(a,iG,t.events),Gg(a).map(t=>({...t,shapeType:iG,...i?{}:{interactive:!1}}))}function ZG(t,e,n){const i=bG(e,n.pointConfig.r);return i?[{type:"path",key:"hexbin-points",d:i,interactive:!1,aria:{hidden:!0},paint:{fill:n.pointConfig.fill??Oc(t),fillOpacity:n.pointConfig.fillOpacity}}]:[]}function JG(t){return(t.viz._trendFits??[]).map(e=>e.samples.map(e=>[t.x(e.x),t.y(e.y)]).filter(([t,e])=>Number.isFinite(t)&&Number.isFinite(e)))}const tq=t=>{const{viz:e}=t,n=dG(e),i=pG(t),o=XG(t,n),r={x:UG(e,"x",0),y:UG(e,"y",t.x2Height??0)},a=function(t,e){const n=fG(t.viz).anchor,i=n?t.x(n[0]):NaN,o=n?t.y(n[1]):NaN;return[Number.isFinite(i)?i:e.left,Number.isFinite(o)?o:e.top+e.height]}(t,i),s=n.shape?UI(o,{shape:n.shape,size:n.size,origin:a}):[],c=gG(s,n,r),l=n.contours?yG(o,i,n):[],h=new Set(xG(s,i,n).map(t=>`bin-${t.key}`));AG(e,MG(t,n.shape?c.filter(t=>h.has(String(t.id))):l,i,a,n));const u=QG(t,l,t=>function(t,e,n){const{strokeWidth:i,fillOpacity:o}=e.contourConfig,r=Boolean(e.shape);return"filled"===e.contours?{fillOpacity:t=>{const e=cG(t);return e&&"contour"===e.kind?o*(e.index+1)/e.levels:o},stroke:n,strokeWidth:0}:{fillOpacity:0,stroke:r?()=>Oc(t):n,strokeWidth:i}}(e,n,(t=>{const e=t.fill;return(t,n)=>"function"==typeof e?e(t,n):e})(t)),!n.shape);return[...n.points?ZG(e,o,n):[],...QG(t,c,()=>({}),!0),...u,...YG(e,l,u,i,n,JG(t))]};function eq(t){const e=fG(t);t._data!==e.rows&&(e.raw=t._data),t._sourceData=e.raw;const n=e.raw.filter((e,n)=>mG(t._x(e,n))&&mG(t._y(e,n)));e.rows=t._data=n.length===e.raw.length?e.raw:n}const nq={name:"Hexbin",paintDriven:!0,setup:t=>{t.ctx.hexbin={raw:[],rows:[]},t._buffer={...t._buffer,[iG]:DG},t._plotShapeEmitters={[iG]:tq},t._unmergedShapes=[iG],t._colorScaleRows=()=>SG(t),t._tooltipAxisRows=!1,t._sharedHover=()=>{},function(t){const e=t.schema.on.mouseenter;t.schema.on.mouseenter=(n,i,...o)=>{if(!cG(n)||1===t.schema.shapeConfig.hoverOpacity)return e(n,i,...o);const r=sG(n);t._hoverBucket=!1,t.hover(t=>sG(t)===r)}}(t);const e=t._preDraw.bind(t);t._preDraw=()=>{eq(t),e()};const n=t._draw.bind(t);t._draw=e=>("panel"!==t._facetStep&&wG(t),n(e))},colorScaleTooltip:!1,ctx:{},fields:[{key:"binShape",default:"hex"},{key:"binSize",default:12},{key:"binValue",default:"count"},{key:"contours",default:!1},{key:"contourConfig",merge:!0,default:rG},{key:"levelFormat"},{key:"points",default:!1},{key:"pointConfig",merge:!0,default:aG},{key:"colorScale",coerce:Rl,default:lG},{key:"colorScaleConfig",merge:!0,default:{scale:"linear"}},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:W(iG),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({[iG]:{stroke:()=>Tc(t),strokeWidth:W(.5)}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:e=>RG(t,e),tbody:e=>PG(t,e)})}]};var iq=fk(nq,XN);const oq=new WeakMap;function rq(t){const e=H(t);return oq.set(e,t),e}function aq(t){return"function"==typeof t?oq.get(t)??q(t):void 0}function sq(t,e,n){!t||void 0!==t.title&&t.title!==e||(t.title=n)}function cq(t="count",e=!1){return e&&"density"===t?"relative":t}function lq(t,e){if(!e)return t.slice();const n="reverse"===e,i=new Array(t.length);let o=0;for(let e=0;e<t.length;e++){const r=n?t.length-1-e:e;i[r]=o+=t[r]}return i}function hq(t,e){let[n,i]=e.domain??d.extent(t),o=Boolean(e.domain);if(n===i&&([n,i]=[n-.5,i+.5],o=!0),e.width&&e.width>0)return function(t,e,n){const i=Math.floor(t/n)*n,o=Math.max(Math.ceil(e/n)*n,i+n);return d.range(0,Math.round((o-i)/n)+1).map(t=>i+t*n)}(n,i,e.width);let r=d.bin();o&&(r=r.domain([n,i]));const a=e.thresholds??d.thresholdSturges,s=r.thresholds(a)(t);return[s[0].x0,...s.map(t=>t.x1)]}function uq(t,e){const{value:n,panel:i=()=>""}=e,o=t.map((t,e)=>({d:t,i:e,v:Number(n(t,e))})).filter(t=>t.d&&Number.isFinite(t.v));if(!o.length)return[];const r=e.sharedEdges?hq(o.map(t=>t.v),e):void 0;return d.groups(o,t=>i(t.d,t.i)).flatMap(([,t])=>function(t,e,n){const{group:i=()=>"",cumulative:o=!1}=n,r=cq(n.normalize,o),a=d.bin().domain([e[0],e[e.length-1]]).thresholds(e.slice(1,-1)),s=t.length,c=[];for(const[,e]of d.groups(t,t=>i(t.d,t.i))){const t=a(e.map(t=>t.v)),n=e[0].d,i=lq(t.map(t=>t.length),o);t.forEach((t,e)=>{const a=t.x0,l=t.x1,h=t.length,u=i[e],d="density"===r?u/(s*(l-a)):"relative"===r?u/s:u;c.push({...n,x0:a,x1:l,x:(a+l)/2,count:h,...o?{cumulativeCount:u}:{},y:d})})}return c}(t,r??hq(t.map(t=>t.v),e),e))}const dq={count:"Count",density:"Density",relative:"Relative Frequency"},fq={count:"Cumulative Count",density:"Cumulative Relative Frequency",relative:"Cumulative Relative Frequency"};function mq(t="count",e=!1){const n=cq(dq[t]?t:"count",e);return(e?fq:dq)[n]}function pq(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}const gq=t=>Array.isArray(t.x);function yq(t){const e=t.ctx.histogram;t._data!==e.bins&&(e.raw=t._data),t._sourceData=e.raw;const n=function(t,e){if(t.schema.timeFilter)return t.schema.timeFilter;const n=t._data;t._data=e;try{return sg(t)}finally{t._data=n}}(t,e.raw),i=t.schema.filter,o=n?e.raw.filter(n):e.raw,r=i?o.filter(i):o,a=de(t)?t.schema.facet:void 0,s=t.schema.groupBy,c=aq(t.schema.value),l=uq(r,{value:t.schema.value,group:(t,e)=>s.map(n=>`${n(t,e)}`).join("_"),panel:a?(t,e)=>xg(bg(a(t,e))):void 0,sharedEdges:"independent"!==ae(t.schema.facetConfig).scales,thresholds:t.schema.binThresholds,domain:t.schema.binDomain,width:t.schema.binWidth,normalize:t.schema.binNormalize,cumulative:t.schema.cumulative}),h=l.every((t,e)=>s.every(n=>void 0===n(t,e)));l.forEach(e=>{c&&delete e[c],h&&(e.id=c??t.schema.translate("Value"))});const u=n?e.raw.filter((t,e)=>!n(t,e)):[];e.bins=t._data=u.length?[...l,...u]:l,e.binned=new Set(l);const d=t.schema.translate(mq(t.schema.binNormalize,t.schema.cumulative));sq(t._yConfig,e.yTitle,d),e.yTitle=d,sq(t._xConfig,e.xTitle,c),e.xTitle=c}const xq={name:"Histogram",paintDriven:!0,thresholdFunction:(t,e)=>e,defaults:{groupPadding:1},setup:t=>{const e={raw:[],bins:[],binned:new Set};t.ctx.histogram=e,t._filterApplied=t=>e.binned.has(t),t.stackOrder("key"),t.schema.shapeConfig.Bar={...t.schema.shapeConfig.Bar,label:!1},t._discreteExtent=t=>[t.x0,t.x1];const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(e,i,o,r)=>{if(n(e,i,o,r),1===t.schema.shapeConfig.hoverOpacity)return;const a=pq(e),s=`${t._id(a,i)}`;t.hover((e,n)=>{const i=pq(e);return`${t._id(i,n)}`===s&&(gq(i)||i.x0===a.x0)})};const i=t._preDraw.bind(t);t._preDraw=()=>{yq(t),i()}},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"binThresholds"},{key:"binDomain"},{key:"binWidth"},{key:"binNormalize",default:"count"},{key:"cumulative",default:!1},{key:"discrete",default:"x"},{key:"shape",default:W("Bar"),coerce:"const"},{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:t=>{const e=e=>p.formatAbbreviate(e,t.schema.locale),n=t=>{const n=pq(t);return`${e(n.x0)} – ${e(n.x1)}`},i=(e,n)=>t.schema.groupBy.some(t=>void 0!==t(pq(e),n));return{title:(e,o)=>i(e,o)?t._drawLabel(pq(e),o):n(e),tbody:(o,r)=>{const a=pq(o),s=t.schema.translate,c=[];if(gq(a))return[[s("Count"),e(a.count)]];i(o,r)&&c.push([s("Range"),n(o)]),c.push([s("Count"),e(a.count)]);const l=t.schema.cumulative;l&&c.push([s("Cumulative Count"),e(Number(a.cumulativeCount))]);const h=t.schema.binNormalize;return"count"!==cq(h,l)&&c.push([s(mq(h,l)),e(a.y)]),c}}}},{key:"value",default:rq("value"),coerce:t=>"string"==typeof t?G(t):"function"==typeof t?t:W(t)}]};var bq=fk(xq,XN);function kq(t,e){const{aggs:i,drawDepth:o,groupBy:r,label:a,threshold:s,thresholdKey:c}=e,l=d.sum(t,c);if(!s||!c)return t;return function t(e,h){if(h<o)return[...d.group(e,r[h])].reduce((e,[,n])=>{const i=t(n,h+1)??[];return e.concat(i)},[]);if(h===o){const t=Math.min(1,Math.max(0,s(e)));if(!isFinite(t)||isNaN(t))return null;const o=[],u=[],d=t*l;for(let t=0;t<e.length;t++){const n=e[t];c(n)<d?o.push(n):u.push(n)}if(o.length<2)return e;const f=n.merge(o,i);return f._isAggregation=!0,f._threshold=t,f[Dh]=Lh(o,(t,e)=>e,a??(t=>r[h](t)),c),u.push(f),u}throw new Error("Depth is higher than the amount of grouping levels.")}(t,0)??t}function _q(t,e,n={}){const{level:i=0,path:o=[],index:r=()=>0}=n;if(!e.length)return{children:[],own:t};const[a,...s]=e,c=[],l=new Map;for(const e of t){const t=a(e,r(e));if(null==t){c.push(e);continue}const n=l.get(t);n?n.push(e):l.set(t,[e])}return{children:[...l].map(([t,e])=>{const n=[...o,t];if(!s.length)return{key:t,path:n,level:i,rows:e,own:e};const a=_q(e,s,{level:i+1,path:n,index:r});return{key:t,path:n,level:i,rows:e,own:a.own,children:a.children.length?a.children:void 0}}),own:c}}function vq(t){const{children:e,rows:n}=t.data;return!e&&1===n.length&&!0===n[0]._isAggregation}function wq(t){return(e,n)=>{const i=vq(e),o=vq(n);return i&&!o?1:!i&&o?-1:t(e,n)}}function Mq(t){if(!(_h in t))return t;const e={...t};return e.share===e[_h]&&delete e.share,delete e[_h],e}function Sq(t,e){const i=n.merge(t.map(Mq),e);return delete i._isAggregation,delete i._threshold,delete i[Dh],i}function Cq(t,e){const{data:n,keys:i,firstLevel:o,focusPath:r,sum:a,sort:s,aggs:c}=t;if(!n.length)return[];const l=t=>n.indexOf(t),h=_q(n,i,{level:o,path:r,index:l}),u={key:r[r.length-1],path:r,level:o-1,rows:n,own:h.own,children:h.children};let d=L.hierarchy(u,t=>t.children).sum(t=>t.own.reduce((t,e)=>t+(Number(a(e))||0),0));s&&(d=d.sort(s));const f=L.partition().size([t.breadth??1,i.length+1])(d),m=f.value??0,p=[],g=new Map;for(const t of f.descendants()){if(0===t.depth&&!r.length)continue;const n=t.value??0;if(!(n>0)||t.x1-t.x0<=0)continue;const i=t.data,o=!i.children&&1===i.rows.length,a=o?i.rows[0]:Sq(i.rows,c),s=t.parent?t.parent.value??0:n,h={id:JSON.stringify(i.path),path:i.path,level:i.level,depth:t.depth,datum:a,i:o?l(a):void 0,value:n,share:m?n/m:0,parentShare:s?n/s:0,x0:t.x0,x1:t.x1,hasChildren:Boolean(t.children&&t.children.length)},u={...h,...e(h),parent:t.parent?g.get(t.parent.data):void 0};g.set(i,u),p.push(u)}return p}function $q(t){const e=[];for(let n=t;n;n=n.parent)e.push(n);return e}function Aq(t){const e=_e(t._history),n=t._filteredData??[],i=t.schema.groupBy;if(!e||void 0===e.groupDepth||!n.length)return{level:-1,path:[]};const o=Math.min(e.groupDepth,t._drawDepth-1);if(o<0)return{level:-1,path:[]};return{level:o,path:i.slice(0,o+1).map(t=>t(n[0],0))}}function zq(t,e,n){const i=t.ctx[e];if(i&&i.data===t._filteredData)return i.base;const o=n();return t.ctx[e]={data:t._filteredData,base:o},o}function Dq(t,e){const n=new Set(e.map(t=>t.id));return t.filter(t=>!n.has(t.id))}function Lq(t,e){const n=t.find(t=>0===t.depth);if(!n)return;return e.filter(t=>t.depth>0&&(t=>t.path.length<=n.path.length&&t.path.every((t,e)=>t===n.path[e]))(t)).sort((t,e)=>e.path.length-t.path.length)[0]}function Fq(t,e,n){const i=new Map,o=Lq(t,e);if(!o)return i;const r=new Set(t.map(t=>t.id));for(const t of e)r.has(t.id)||i.set(t.id,n(t,o));return i}function Nq(t,e,n){let i=e;for(;i&&i.__d3plus__&&i.data;)i=i.data;const o=t.ctx[`${n}Nodes`];return i&&o?o.get(i):void 0}function Bq(t,e){if(0===e.depth||e.datum._isAggregation)return!1;const n=t.schema.groupBy.length-1;return e.hasChildren||e.level===t._drawDepth&&e.level<n}function Eq(t){t.hover(!1),t._tooltipClass?.data([]).render()}function Rq(t,e){return`${p.formatAbbreviate(100*e,t.schema.locale)}%`}function Pq(t,e,n,i){const o=t._tooltipClass,r=t.schema.tooltipConfig;if(void 0===r.title){const n=t._drawLabel(e.datum,e.i??0,e.level);Xh(o.title(()=>n),Uh(t,t._lastScenePick))}if(void 0===r.footer){const n=!!i&&t.schema.translate(Bq(t,e)?"Click to Expand":"Click to Zoom Out");o.footer(n)}const a=function(t,e){if(e&&e.parent&&0!==e.parent.depth)return[t.schema.translate("Share of Parent"),Rq(t,e.parentShare)]}(t,e);a&&function(t,e){if(!Array.isArray(t)||1!==t.length||!Array.isArray(t[0]))return!1;const n=t[0];return n.length===e.length&&n.every((t,n)=>t===e[n])}(r.tbody,n)&&o.tbody([...r.tbody,a]),(void 0===r.title||void 0===r.footer||a)&&o.render()}function Tq(t,e,n){const{prefix:i}=n,o=t.schema.on,r=o.mouseenter,a=o["mousemove.shape"],s=e=>Nq(t,e,i),c=e=>{if(t.ctx[`${i}Hovered`]=e,1===t.schema.shapeConfig.hoverOpacity)return;const n=function(t){return new Set($q(t).map(t=>t.datum))}(e);var o;o=t=>n.has(t),t.hover(o)};return{mouseenter:(e,n,i,o)=>{const a=s(e);a?c(a):r.call(t,e,n,i,o)},"mousemove.shape":(n,o,r,l)=>{a.call(t,n,o,r,l);const h=s(n);if(!h)return;t.ctx[`${i}Hovered`]!==h&&c(h);const u=Jl(t,"click.shape")&&function(t,e){return 0===e.depth?void 0!==_e(t._history):Bq(t,e)}(t,h);Vl(t,u||th(t,"click.shape")?"pointer":"auto"),t._tooltipClass&&Yl(t,n,o)&&Pq(t,h,e,u)},"click.shape":(e,i,o,r)=>{r?.stopPropagation?.();const a=s(e);a&&(0===a.depth?function(t){const e=ve(t._history);if(!e)return;Eq(t);const n={depth:e.depth,filter:e.filter};t.config(n).render()}(t):Bq(t,a)&&function(t,e,n){var i;const o=t.schema.groupBy,r=Aq(t),a=t.schema.filter,s=o.slice(0,e.level+1),c=e.path;Eq(t);const l={depth:t.schema.depth,filter:a,groupId:c[e.level],groupDepth:e.level};((i=t)._history??(i._history=[])).push(l),t.ctx[`${n.prefix}ZoomOrigin`]=n.origin(e);const h={filter:(t,e)=>(!a||a(t,e))&&s.every((n,i)=>n(t,e)===c[i])};if(void 0!==t.schema.depth){const n=e.level-r.level;h.depth=Math.min(o.length-1,t._drawDepth+n)}t.config(h).render()}(t,a,n))}}}function Oq(t,e){return kq(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)})}const Wq=(t,e)=>(e.value??0)-(t.value??0);function jq(t,e){return wq(e)}function Hq(t){return"function"==typeof t?t:G(t)}function Iq(t,e){t.schema.thresholdKey=e}function Gq(t){return JT(t,"sum")}function qq(t){return(e,n)=>Nq(e,n,t.prefix)?.level}function Vq(t,e){const{prefix:n}=e;t.ctx[`${n}DefaultColor`]=t.schema.color,t.ctx[`${n}DefaultFill`]=t.schema.shapeConfig.fill;const i=Tq(t,(t.schema.tooltipConfig.tbody??[])[0]??[],e);Object.assign(t.schema.on,i),Zl(t,"click.shape",i["click.shape"])}const Kq={step:.22,max:.6};function Yq(t,e={}){const{step:n,max:i}={...Kq,...e};return t<=0?0:Math.max(0,Math.min(i,n*t))}function Uq(t,n,o,r){const a=function(t,e,n="Path"){const i=t.shapeConfig??{},o=i[n]??{};return!1!==t.shade&&!t.colorScale&&!t.colorOrdinal&&t.color===e.color&&i.fill===e.fill&&void 0===o.fill}(t,o,r),s=t.shadeConfig??{};return t=>{const o=Tg(n.fill,t.datum,t.i??0);if("string"==typeof o)return a?function(t,n){return t&&n>0&&i.color(t)?e.colorLighter(t,n):t}(o,Yq(t.level,s)):o}}function Xq(t){const{width:e,height:n,orient:i}=t,o=Math.max(0,e),r=Math.max(0,n);return"vertical"===i?{depth:r,breadth:o}:{depth:o,breadth:r}}function Qq(t,e,n){const i=Math.max(0,t),o=Math.max(0,e)+(n?1:0);if(o<1)return[[0,0]];const r=i/o,a=n?[]:[[0,0]];for(let t=0;t<o;t++)a.push([t*r,(t+1)*r]);return a}function Zq(t,e,n){const{breadth:i}=Xq(n),o=t.x0*i,r=t.x1*i,[a,s]=e;return"vertical"===n.orient?{x:o,y:a,width:r-o,height:s-a}:{x:a,y:o,width:s-a,height:r-o}}function Jq(t,e,n,i,o){const r=n.x1-n.x0||1,a=t=>Math.min(1,Math.max(0,(t-n.x0)/r)),s=e-n.depth,c=i[i.length-1]?.[1]??0,l=s<0?[0,0]:i[s]??[c,c];return Zq({x0:a(t.x0),x1:a(t.x1)},l,o)}function tV(t,e){return"vertical"===e?{x:t.x+t.width/2,y:t.y,width:0,height:0}:{x:t.x,y:t.y+t.height/2,width:0,height:0}}function eV(t,e,n){const i=new Map;for(const n of t){if(!e.has(n.id))continue;const t=n.parent;i.set(n.id,t?(i.get(t.id)??-1)+1:0)}const o=Math.max(0,...i.values())+1,r=new Map,s=new Map;for(const e of t){const t=i.get(e.id);void 0!==t&&(r.set(e.id,tV(e,n)),s.set(e.id,{start:a.cubicInOut(t/o),end:a.cubicInOut((t+1)/o)}))}return{rects:r,windows:s}}function nV(t){const{bands:e,frame:n,...i}=t;return Cq({...i,breadth:1},t=>Zq(t,e[t.depth]??[0,0],n))}function iV(t){return"vertical"===t?"vertical":"horizontal"}const oV=({viz:t})=>{const{width:e,height:n}=wt(t),i={width:Math.max(0,e),height:Math.max(0,n),orient:iV(t.schema.orient)};t.ctx.icicleWidth=i.width,t.ctx.icicleHeight=i.height,t.ctx.icicleNodes=new Map,t.ctx.icicleGhosts=[];const o=function(t){return zq(t,"iciclePass",()=>{const e={laid:t.ctx.icicleLaid,bands:t.ctx.icicleBands,frame:t.ctx.icicleFrame,origin:t.ctx.icicleZoomOrigin};return t.ctx.icicleZoomOrigin=void 0,e})}(t),r=t._filteredData??[];if(!r.length)return t.ctx.icicleLaid=[],t.ctx.icicleBands=void 0,t.ctx.icicleFrame=i,t.ctx.icicleEnterRects=new Map,t.ctx.icicleEnterWindows=new Map,{shapeData:[]};const a=Aq(t),s=t.schema.groupBy.slice(a.level+1,t._drawDepth+1),c=Qq(Xq(i).depth,s.length,a.path.length>0),l=nV({data:r,keys:s,firstLevel:a.level+1,focusPath:a.path,sum:t.schema.sum,sort:t.schema.sort,aggs:t.schema.aggs,bands:c,frame:i}),{laid:h,bands:u,origin:d}=o;t.ctx.icicleGhosts=d&&h?function(t,e,n,i,o){return Dq(t,e).map(t=>({id:t.id,datum:t.datum,i:t.i,level:t.level,rect:Jq(t,t.depth,n,i,o)}))}(h,l,d,c,i):[];const f=h&&u&&o.frame?function(t,e,n,i){return Fq(t,e,(t,e)=>Jq(t,t.depth,{x0:e.x0,x1:e.x1,depth:e.depth},n,i))}(h,l,u,o.frame):new Map,m=Boolean(d)||Boolean(h&&Lq(h,l)),p=new Set((h??[]).map(t=>t.id)),g=m?{rects:f,windows:new Map}:eV(l,new Set(l.filter(t=>!p.has(t.id)).map(t=>t.id)),i.orient);t.ctx.icicleEnterRects=g.rects,t.ctx.icicleEnterWindows=g.windows,t.ctx.icicleLaid=l,t.ctx.icicleBands=c,t.ctx.icicleFrame=i;const y=t.ctx.icicleNodes;for(const t of l)Mh(t.datum,t.share),y.set(t.datum,t);return{shapeData:l}};function rV(t,e,n={}){const{width:i,height:o}=t;if(!(e.words.length&&i>0&&o>0))return null;const r=qP(n),a=(t,n)=>QP(i=>function(t,e,n,i,o={}){const{padding:r,lineHeight:a,maxLines:s}=qP(o),c=n-2*r;if(c<=0)return!1;for(let n=1;n<=s;n++){if(n*a*e+2*r>i)return!1;if(XP(t,e,c)<=n)return!0}return!1}(e,i,t,n,r),r.fontMin,r.fontMax),s=a(i,o),c=o>i?a(o,i):null,l=t.x+i/2,h=t.y+o/2;return null!==s&&(null===c||s>=c)?{orientation:"upright",x:l,y:h,width:i,height:o,rotate:0,fontSize:s}:null===c?null:{orientation:"rotated",x:l,y:h,width:o,height:i,rotate:-90,fontSize:c}}function aV(t,e){return t._drawLabel(e.datum,e.i??0,e.level)}function sV(t,e){return(t.ctx.icicleGhosts??[]).map(t=>({type:"rect",key:`icicle-${t.id}`,...t.rect,paint:{fill:e(t),opacity:1}}))}const cV={out:.06,in:.06};function lV(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}const hV={prefix:"icicle",origin:function(t){return{x0:t.x0,x1:t.x1,depth:t.depth}}},uV={name:"Icicle",layoutStage:oV,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=Hg(t,"Rect"),r=t.schema.sum,a=t.schema.locale,s=function(t,e){return Uq(t.schema,e,{color:t.ctx.icicleDefaultColor,fill:t.ctx.icicleDefaultFill},"Rect")}(t,o),c=t.ctx.icicleEnterRects??new Map,l=t.ctx.icicleEnterWindows??new Map,h=i.map(e=>{const n=e.i??0;return{type:"rect",key:`icicle-${e.id}`,x:e.x,y:e.y,width:e.width,height:e.height,enterRect:c.get(e.id),enterWindow:l.get(e.id),datum:e.datum,paint:{fill:Og(o,e.datum,n,s(e)),stroke:Tg(o.stroke,e.datum,n),strokeWidth:Tg(o.strokeWidth,e.datum,n),opacity:Tg(o.opacity,e.datum,n)??1},aria:{label:`${aV(t,e)}, ${r(e.datum)}, ${p.formatAbbreviate(100*e.share,a)}%`}}}),u=jS(o,h,t=>[i[t].datum,i[t].i??0]),d=Ig(t,"Rect")??{},f="number"==typeof d.fontMin?d.fontMin:8,m="number"==typeof d.fontMax?d.fontMax:24,g=function(t,e,n,i){const o=new Map;for(const r of e){const e=rV(r,UP(aV(t,r),r.datum,n),i);e&&o.set(r,e)}return o}(t,i,d,{fontMin:f,fontMax:m}),y=i.filter(t=>g.has(t)),x=t=>g.get(t),b=t.ctx.icicleNodes,k=e_({data:y,label:e=>aV(t,e),x:t=>x(t).x,y:t=>x(t).y,rotate:t=>x(t).rotate,aes:()=>({}),id:t=>`icicle-${t.id}`,datum:t=>t.datum,labelBounds:t=>{const{width:e,height:n}=x(t);return{x:-e/2,y:-n/2,width:e,height:n}},labelConfig:{fontMax:m,fontMin:f,split:VP,fontResize:!0,padding:2,textAnchor:"middle",verticalAlign:"middle",fontColor:n=>{const i=b.get(lV(n)),o=i?s(i):void 0;return e.colorContrast(o??"rgb(255, 255, 255)",t.schema.colorDefaults)},...d}});for(const t of k)t.fadeSwap=cV;const _=new Map(i.map(t=>[t.datum,l.get(t.id)]));for(const t of[...u,...k])t.datum&&(t.enterWindow=_.get(lV(t.datum)));return[...sV(t,s),...h,...u,...k]},thresholdFunction:Oq,setup:t=>Vq(t,hV),shapeDepth:qq(hV),ctx:{},fields:[{key:"orient",default:"horizontal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...Kq})},{key:"sort",default:Wq,decorate:jq},{key:"sum",default:H("value"),coerce:Hq,onSet:Iq},{key:"shapeConfig",merge:!0,factory:t=>({Rect:{labelConfig:{fontResize:!0}},stroke:()=>Tc(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[QT(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:Gq},{key:"legend",coerce:"const",factory:ZT}]};var dV=fk(uV);const fV="::stem";function mV(t,e,n){const i=(t.transform?.x??0)+t.x,o=(t.transform?.y??0)+t.y,r=i+t.width,a=o+t.height;if("x"===e){const e=i+t.width/2;return!u.finite(n)||Math.abs(o-n)<=Math.abs(a-n)?{x:e,y:o,x0:e,y0:a}:{x:e,y:a,x0:e,y0:o}}const s=o+t.height/2;return!u.finite(n)||Math.abs(r-n)<=Math.abs(i-n)?{x:r,y:s,x0:i,y0:s}:{x:i,y:s,x0:r,y0:s}}function pV(t){const e=[];for(const n of t)e.push({__d3plus__:!0,data:n,i:n.i,end:!1}),e.push({__d3plus__:!0,data:n,i:n.i,end:!0});return e}function gV(t,e){let n=0;for(const i of t){const t="function"==typeof e?e(i.data,i.i):e;u.finite(t)&&t>n&&(n=t)}return n}function yV(t){const e=this.schema.shapeConfig.Circle,n=gV(t.data,e?.r);return aC.call(this,{...t,buffer:n+2})}function xV(t){const e=t.datum,n={...t,datum:e?.data??t.datum,shapeType:"Circle"};return delete n.interactionPoints,n}function bV(t,e,n){const{viz:i}=t,o=t=>n.get(t.data),r=Pg("Line").renderMode("compute").config(t.shapeConfig).data(pV(e));i._wirePlotShapeEvents(r,"Circle",t.events);const a=Hg(i,"Line");return void 0===i.schema.shapeConfig.duration&&delete a.duration,r.config(a).config({curve:"linear",id:t=>`${t.data.id}${fV}`,label:!1,x:t=>t.end?o(t).x:o(t).x0,y:t=>t.end?o(t).y:o(t).y0}),Gg(r).map(xV)}function kV(t,e,n){const i=Nt({...t.shapeConfig,x:t=>n.get(t).x,y:t=>n.get(t).y});return FF.Circle({...t,shapeConfig:i,values:e},"Circle")}const _V=(t,e)=>{const n=FF.Bar(t),i=function(t,e){const{viz:n}=t,i="y"===n.schema.discrete?"y":"x",o="x"===i?"y":"x",r="x"===i?t.y:t.x,a=new Map;for(const t of e){if("rect"!==t.type||"Bar"!==t.shapeType||`${t.key}`.endsWith("::hit"))continue;const e=t.datum;if(!e||a.has(e))continue;const n=void 0!==e[`${o}2`],s=n?e[`${o}2`]:e[o];a.set(e,mV(t,i,r(s,n?`${o}2`:void 0)))}return a}(t,n),o=t.values.filter(t=>i.has(t)),r=n.filter(t=>`${t.key}`.endsWith(gA));return[...bV(t,o,i),...r,...kV(t,o,i)]},vV=JN.fields.find(t=>"legend"===t.key),wV=t=>(e,n)=>{const i=t.schema.shapeConfig.fill;return"function"==typeof i?i(e,n):i},MV={name:"Lollipop",paintDriven:!0,setup:t=>{t._buffer={...t._buffer,Bar:yV},t._plotShapeEmitters={Bar:_V},t._plotCircleShapes=["Bar"],t._plotColumnHighlight=gR(t)},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},vV,{key:"shape",default:W("Bar"),coerce:"const"},{key:"legendConfig",merge:!0,default:{shape:"Circle"}},{key:"shapeConfig",merge:!0,factory:t=>({Bar:{label:!1},Circle:{label:!1,trail:!1},Line:{label:!1,stroke:wV(t)}})}]};var SV=fk(MV,XN);function CV(t){const e=e=>{const n=e.map(e=>{const n=function(t){for(let e=0;e<t.length;e++){const n=(t[e].data||[]).find(e=>e.id===t.key);if(n)return n}}(e);return n&&n.data?t(n.data,n.i??0):`${e.key}`}),i=new Map;n.forEach((t,n)=>i.set(t,(i.get(t)??0)+function(t){let e=0;for(let n=0;n<t.length;n++)e+=Math.abs(+t[n][1]||0);return e}(e[n])));const o=Array.from(i.keys()).sort((t,e)=>i.get(e)-i.get(t)),r=new Map(o.map((t,e)=>[t,e]));return e.map((t,e)=>e).sort((t,e)=>r.get(n[t])-r.get(n[e])||t-e)};return e.__d3plusStackOrder=!0,e}function $V(t){return t._stackOffset===PA("expand")}function AV(t,e){return`${p.formatAbbreviate(100*t,e)}%`}function zV(t){return t.schema.stacked&&$V(t)?{[ux(t)]:{rounding:"none",tickFormat:e=>AV(e,t.schema.locale)}}:{}}function DV(t){return"y"===ux(t)?{x:"all",y:"outer"}:{x:"outer",y:"all"}}function LV(t){return t.schema.stacked&&$V(t)?{[ux(t)]:!0}:{}}const FV={name:"Marimekko",paintDriven:!0,defaults:{groupPadding:1},facet:{axes:DV,fixedAxes:LV},setup:t=>{t._stackOffset=PA("expand"),t._stackOrder=CV((e,n)=>t._ids(e,n).slice(0,t._drawDepth+1).join("_"));const e=t._preDraw.bind(t);t._preDraw=()=>{t._plotAxisDefaults=zV(t),e()}},ctx:{},fields:[{key:"barWidth",coerce:Qy,factory:function(t){return Zy((e,n)=>{const i="y"===t.schema.discrete?t._x:t._y;return i?i(e,n??0):void 0},"Bar Total")}},{key:"barWidthShare",default:"opposite"},{key:"stacked",default:!0},{key:"tooltipShared",default:!1}]};var NV=fk(FV,tB);function BV(t){const e=this._filteredData,i=(this.schema.rowList||n.unique(e.map(this.schema.row))).sort(this.schema.rowSort),o=(this.schema.columnList||n.unique(e.map(this.schema.column))).sort(this.schema.columnSort);if(!i.length||!o.length)return{rowValues:[],columnValues:[],shapeData:[]};var r,a;return{rowValues:i,columnValues:o,shapeData:(r=i,a=o,[].concat(...r.map(t=>a.map(e=>[t,e])))).map(([t,n])=>{const i={__d3plusTooltip__:!0,__d3plus__:!0,column:n,row:t},o=e.findIndex((e,i)=>this.schema.row(e,i)===t&&this.schema.column(e,i)===n);return o>=0?(i.i=o,i.data=e[o]):i.data={row:t,column:n},i})}}const EV=({viz:t})=>{const e=BV.bind(t)(t._filteredData),{rowValues:n,columnValues:i,shapeData:o}=e;if(!n.length||!i.length)return{shapeData:[]};const{width:r,height:a}=wt(t),s=r/i.length<120||void 0;t._padding={top:0,right:0,bottom:0,left:0};const c=t.ctx.rowAxis,l=t.ctx.columnAxis,h=t.schema.rowConfig,u=t.schema.columnConfig;c.domain(n).height(a-t._padding.bottom-t._padding.top).maxSize(r/4).width(r).config(h),Ni(c,h).measure();const d=c.outerBounds().width;t._padding.left+=d,l.domain(i).range([t._margin.left+t._padding.left,t._margin.left+r-t._padding.right]).height(a).maxSize(a/4).width(r).labelRotation(s).config(u),Ni(l,u).measure();const f=l.outerBounds().height;t._padding.top+=f,c.renderMode("compute").select(void 0).height(a-t._padding.bottom).maxSize(d).range([f+l.padding(),void 0]).render();const m=c.toScene();if(m){var p;const e={type:"group",key:"matrix-row-axis",transform:{x:t._margin.left,y:0},children:m.children??[]};wf(e,"row"),((p=t)._chartScene||(p._chartScene=[])).push(Lr(e))}l.renderMode("compute").select(void 0).range([t._margin.left+t._padding.left+c.padding(),t._margin.left+r-t._padding.right]).maxSize(f).render();const g=l.toScene();if(g){var y;const e={type:"group",key:"matrix-column-axis",transform:{x:0,y:0},children:g.children??[]};wf(e,"column"),((y=t)._chartScene||(y._chartScene=[])).push(Lr(e))}const x=c._getPosition.bind(c),b=l._getPosition.bind(l),k=n.length>1?x(n[1])-x(n[0]):c.height(),_=i.length>1?b(i[1])-b(i[0]):l.width();return t.ctx.columnScale=b,t.ctx.rowScale=x,t.ctx.cellWidth=_,t.ctx.cellHeight=k,{shapeData:o}},RV={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},PV=(t,e)=>`${t}`.localeCompare(`${e}`),TV={name:"Matrix",layoutStage:EV,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.columnScale,o=t.ctx.rowScale,r=t.ctx.cellWidth,a=t.ctx.cellHeight,s=t.schema.cellPadding??0,c=Hg(t,"Rect"),l=t.schema.colorScale,h=n.map((t,e)=>{const n=Tg(c.fill,t,e),h=Tg(c.stroke,t,e),u=Tg(c.strokeWidth,t,e),d=r-s,f=a-s,m=i(t.column)+r/2-d/2,p=o(t.row)+a/2-f/2,g=l?`, ${l(t.data??t,e)}`:"";return{type:"rect",key:`matrix-${e}`,x:m,y:p,width:d,height:f,datum:t,paint:{fill:Og(c,t,e,n),stroke:h,strokeWidth:u},aria:{label:`${t.row}, ${t.column}${g}.`}}});return[...h,...jS(c,h,t=>[n[t],t])]},chartTransform:t=>({x:0,y:t._margin.top}),setup:t=>{const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),uh(o)||uh(n))return;const a=ee.bind(t)("row",n,i),s=ee.bind(t)("column",n,i),c=t.schema.colorScale,l=(e,n)=>(ee.bind(t)("row",e,n)===a||ee.bind(t)("column",e,n)===s)&&((t,e)=>{if("function"!=typeof c)return!0;const n=c(t,e);return"number"==typeof n||Array.isArray(n)})(e,n);t._hoverFocus={hover:l,rows:[{row:a,column:s}]},t.hover(l)}},facet:{aspect:1},ctx:{rowAxis:new Ga,columnAxis:new Ga},fields:[{key:"cellPadding",default:2},{key:"column",default:H("column"),coerce:t=>"function"==typeof t?t:G(t)},{key:"row",default:H("row"),coerce:t=>"function"==typeof t?t:G(t)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:PV},{key:"rowSort",default:PV},{key:"rowConfig",merge:!0,default:{orient:"left",...RV}},{key:"columnConfig",merge:!0,default:{orient:"top",...RV}},{key:"label",coerce:"const",factory:t=>(e,n)=>`${ee.bind(t)("row",e,n)} / ${ee.bind(t)("column",e,n)}`}]};var OV=fk(TV);const WV=t=>{const e="number"==typeof t?t:NaN;return Number.isFinite(e)&&e>=0?e:void 0};function jV(t,e,n){const i=WV(t)??1,o=WV(e);if(void 0!==o)return[Math.min(i,o),o];const r=Number.isFinite(n)?.5*Math.max(0,n):0;return[i,Math.max(i,r)]}function HV(t,e){if(!t.schema.linkBundle)return;const n=e.filter(t=>t.source&&t.target&&!t.loop&&!vM(t)&&Number.isFinite(t.source.x)&&Number.isFinite(t.source.y)&&Number.isFinite(t.target.x)&&Number.isFinite(t.target.y));if(!n.length)return;const i=lH(t,n.map(t=>[[t.source.x,t.source.y],[t.target.x,t.target.y]]));n.forEach((t,e)=>{t.points=i[e]})}function IV(t,e=0,n=0){return{source:Kw(t,e+1),target:Kw([...t].reverse(),n+1)}}function GV(t,e,n){const i=function(t,e,n,i,o){return kv({arrows:t.schema.arrows,arrowSize:o,strokeWidth:"number"==typeof i?i:void 0,datum:e,i:n})}(t,n.datum,n.i,n.strokeWidth,"arrowSize"in n?n.arrowSize:t.schema.arrowSize),o=IV(e.points,e.source?.r??0,e.target?.r??0),{d:r,source:a,target:s}=xM(e.points,i,o);return{d:r,arrows:_M({ends:{source:a,target:s},size:i.size,datum:n.datum,keyPrefix:n.keyPrefix,fill:n.fill})}}function qV(t){const{source:e,target:n}=IV(t.points,(t.source?.r??0)-1,(t.target?.r??0)-1);return Hw(t.points,e,n)}function VV(t){return qw(qV(t))}function KV(t){const e=[];let n=!1;for(const i of t){const t=[i.x??0,i.y??0];Number.isFinite(t[0])&&Number.isFinite(t[1])?e.push({node:i,p:t}):Number.isNaN(t[0])||Number.isNaN(t[1])||(n=!0)}e.sort((t,e)=>t.p[0]-e.p[0]);let i=1/0,o=!1;for(let t=0;t<e.length;t++){const n=e[t];for(let r=t+1;r<e.length;r++){const t=e[r];if(u.pointDistanceSquared([n.p[0],0],[t.p[0],0])>i)break;if(n.node===t.node)continue;const a=u.pointDistanceSquared(n.p,t.p);(!o||a<i)&&(i=a,o=!0)}}return o?Math.sqrt(i):n?function(t){const e=[];for(const n of t)for(const i of t)n!==i&&e.push(u.pointDistance([n.x??0,n.y??0],[i.x??0,i.y??0]));return d.min(e)}(t):void 0}const YV=t=>GM(t),UV=qM;function XV(t,e){if(!e.length)return;const n=t.map(e=>Math.min(...t.filter(t=>t!==e).map(t=>Math.hypot(t.fx-e.fx,t.fy-e.fy)))).filter(t=>t>0&&Number.isFinite(t)).sort((t,e)=>t-e),i=n.length?n[Math.floor(n.length/2)]:1,o=t.map(t=>t.fx),r=t.map(t=>t.fy),a=o.length?Math.min(...o):0,s=o.length?Math.max(...o):0,c=r.length?Math.max(...r):-i,l=Math.max(Math.ceil(Math.sqrt(e.length)),Math.floor((s-a)/i)+1),h=(a+s)/2;e.forEach((t,n)=>{const o=Math.floor(n/l),r=Math.min(l,e.length-o*l);t.fx=h+(n%l-(r-1)/2)*i,t.fy=c+(o+1)*i})}function QV(t,e,n){if(!e.some(t=>void 0===t.fx||void 0===t.fy))return;const i=n.filter(t=>t.source&&t.target&&!vM(t)),o=`${e.map(t=>t.id).join("\0")}|${i.map(t=>`${t.source.id}>${t.target.id}:${t.size}`).join("\0")}`,r=t.ctx.networkForceCache;if(r&&r.key===o)return void e.forEach((t,e)=>{t.fx=r.positions[e][0],t.fy=r.positions[e][1]});const a=new Set(i.flatMap(t=>[t.source,t.target])),s=e.filter(t=>a.has(t));s.length&&function(t,e){const n=E.scaleLinear().domain(d.extent(e,t=>t.size)).range([.1,.5]),i=F.forceSimulation().force("link",F.forceLink(e).id(t=>t.id).distance(1).strength(t=>n(t.size)).iterations(4)).force("charge",F.forceManyBody().strength(-1)).stop(),o=1-Math.pow(.001,.01);i.velocityDecay(0),i.alphaMin(.001),i.alphaDecay(o),i.alphaDecay(0),i.nodes(t),i.tick(100).stop();const r=t.map(t=>[t.vx??0,t.vy??0]);let a=0,s=0,c=0;if(2===r.length)a=100;else if(r.length>2){const t=N.polygonHull(r)||[],e=u.largestRect(t,{verbose:!0});a=e.angle,s=e.cx,c=e.cy}t.forEach(t=>{const e=u.pointRotate([t.vx??0,t.vy??0],Math.PI/180*a*-1,[s,c]);t.fx=e[0],t.fy=e[1]})}(s,i),XV(s,e.filter(t=>!a.has(t))),t.ctx.networkForceCache={key:o,positions:e.map(t=>[t.fx,t.fy])}}function ZV(t,e,n){const i=d.extent(e,t=>t.size);return i[0]===i[1]?null:E[`scale${t.schema.linkSizeScale.charAt(0).toUpperCase()}${t.schema.linkSizeScale.slice(1)}`]().domain(i).range(jV(t.schema.linkSizeMin,t.schema.linkSizeMax,n))}function JV(t,e,n,i,o=[]){const r=d.extent(e.map(t=>t.fx)),a=d.extent(e.map(t=>t.fy)),s=E.scaleLinear().domain(r).range([0,n]),c=E.scaleLinear().domain(a).range([0,i]),l=(r[1]-r[0])/(a[1]-a[0])||1,h=n/i;if(l>h){const t=i*h/l;c.range([(i-t)/2,i-(i-t)/2])}else{const t=n*l/h;s.range([(n-t)/2,n-(n-t)/2])}e.forEach(t=>{t.x=s(t.fx),t.y=c(t.fy)});const u=d.extent(e.map(t=>t.r));let f=t.schema.sizeMax||d.max([1,KV(e)/2]);const m=E[`scale${t.schema.sizeScale.charAt(0).toUpperCase()}${t.schema.sizeScale.slice(1)}`]().domain(u).range([u[0]===u[1]?f:d.min([f/2,t.schema.sizeMin]),f]),p=s.domain(),g=c.domain(),y=p[1]-p[0],x=g[1]-g[0];for(const[[n,i],[r,a]]of function(t,e,n,i){const o=new Map(e.map(t=>[t.id,{id:t.id,x:t.x??0,y:t.y??0,r:i(t.r)}])),r=[...o.values()].map(t=>[[t.x-t.r,t.y-t.r],[t.x+t.r,t.y+t.r]]),a=ZV(t,n,i.range()[0]),s=tK(e,n,t=>o.get(t.id),t=>a?a(t.size):t.size);for(const{box:t}of s.values())r.push(t);return r}(t,e,o,m))p[0]=Math.min(p[0],s.invert(n-3)),p[1]=Math.max(p[1],s.invert(r+3)),g[0]=Math.min(g[0],c.invert(i-3)),g[1]=Math.max(g[1],c.invert(a+3));const b=p[1]-p[0],k=g[1]-g[0];f*=d.min([y/b,x/k]),m.range([u[0]===u[1]?f:d.min([f/2,t.schema.sizeMin]),f]),s.domain(p),c.domain(g);const _=(l>h?n:i)/2;return e.forEach(t=>{t.x=s(t.fx),t.fx=t.x,t.y=c(t.fy),t.fy=t.y,t.r=m(t.r)||_,t.width=2*t.r,t.height=2*t.r}),m}function tK(t,e,n,i){const o=e.filter(t=>t.datum&&vM(t));if(!o.length)return new Map;const r=new Map;for(const t of e)if(t.source&&t.target&&!vM(t))for(const[e,i]of[[t.source,t.target],[t.target,t.source]]){r.has(e.id)||r.set(e.id,[]);const t=n(i);r.get(e.id).push([t.x,t.y])}const a=t.map(n),s=[a.reduce((t,e)=>t+e.x,0)/a.length,a.reduce((t,e)=>t+e.y,0)/a.length];return PM(o,{node:t=>n(t.source),angle:t=>EM([t.x,t.y],r.get(t.id)??[],RM([t.x,t.y],s)),reach:t=>SM(n(t.source).r),strokeWidth:i})}const eK=({viz:t})=>{const e=t,{width:n,height:i}=wt(e);Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]);const o=YV(e),r=UV(e,o);rw(e,r.flatMap(t=>t.datum?[t.datum]:[]),o.map(jM)),QV(e,o,r);const a=JV(e,o,n,i,r);e._sizeLegendFinal=e._size?a:null,function(t,e,n){const i=ZV(t,e,n.range()[0]);i&&e.forEach(t=>{t.size=i(t.size)})}(e,r,a),function(t,e){const n=tK(t,e,t=>({id:t.id,x:t.x??NaN,y:t.y??NaN,r:t.r??0}),t=>t.size);for(const[t,e]of n)t.loop=e}(o,r),HV(e,r);const s=Hg(e,"Path",e.schema.shapeConfig,"edge");delete s.on;const c={label:t=>!!(o.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i)},l=Array.from(d.groups(o,t=>t.shape));return e.ctx.networkCtx={links:r,linkConfig:s,linkD:t=>t.loop?t.loop.d:t.points?jw(t.points):`M${t.source.x},${t.source.y} ${t.target.x},${t.target.y}`,nodeGroups:l,nodeShapeConfig:c},{shapeData:o}};function nK(t,e){let n=!1;for(const i of t)e<i&&(n=!n);return n}function iK(t){const e=new Map,n=n=>{let i=e.get(n);return i||e.set(n,i=(e=>{const n=[],i=t.length;let[o,r]=t[i-1];for(let a=0;a<i;++a){const[i,s]=t[a];s>e!=r>e&&n.push((o-i)*(e-s)/(r-s)+i),o=i,r=s}return n})(n)),i};return{contains:([t,e])=>nK(n(e),t),row:n}}const oK={fontMax:16,fontMin:10,padding:4};function rK(t){const e=(t.schema.clusterConfig??{}).labelConfig;if(!1===e)return null;const{fontMax:n,fontMin:i,padding:o,...r}=e??{},a=(t,e)=>"number"==typeof t&&Number.isFinite(t)&&t>=0?t:e,s=a(n,oK.fontMax);return{fontMax:s,fontMin:Math.min(s,a(i,oK.fontMin)),padding:a(o,oK.padding),text:r}}function aK(t,e){const n=e.x-Math.max(t.x,Math.min(e.x,t.x+t.width)),i=e.y-Math.max(t.y,Math.min(e.y,t.y+t.height));return n*n+i*i<e.r*e.r}function sK(t,e){return t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height}function cK(){const t=new Map;let e=0;return{get size(){return e},get:(e,n)=>t.get(e)?.get(n),add(n,i,o){let r=t.get(n);r||t.set(n,r=new Map);const a=r.get(i);a?a.push(o):(r.set(i,[o]),e++)}}}function lK(t,e,n=32){const i=cK(),o=t=>{const e=(t=>"r"in t?{x:t.x-t.r,y:t.y-t.r,width:2*t.r,height:2*t.r}:t)(t);[e.x,e.y,e.width,e.height].every(Number.isFinite)&&((t,e)=>{for(let i=Math.floor(t.x/n);i<=Math.floor((t.x+t.width)/n);i++)for(let o=Math.floor(t.y/n);o<=Math.floor((t.y+t.height)/n);o++)e(i,o)})(e,(e,n)=>i.add(e,n,t))};t.forEach(o),e.forEach(o);return{hits:t=>{const e=Math.floor((t.x+t.width)/n),o=Math.floor((t.y+t.height)/n);for(let r=Math.floor(t.x/n);r<=e;r++)for(let e=Math.floor(t.y/n);e<=o;e++)for(const n of i.get(r,e)??[])if("r"in n?aK(t,n):sK(t,n))return!0;return!1},add:o}}function hK(t,e=32){const n=cK();let i=1/0,o=-1/0,r=1/0,a=-1/0;for(const s of t){if(!Number.isFinite(s.x)||!Number.isFinite(s.y))continue;const t=Math.floor(s.x/e),c=Math.floor(s.y/e);[i,o,r,a]=[Math.min(i,t),Math.max(o,t),Math.min(r,c),Math.max(a,c)],n.add(t,c,s)}return(t,s)=>{if(!n.size)return;const c=Math.floor(t/e),l=Math.floor(s/e),h=Math.max(Math.abs(c-i),Math.abs(c-o),Math.abs(l-r),Math.abs(l-a));let u,d=1/0;for(let i=0;i<=h&&!(u&&(i-1)*e>Math.sqrt(d));i++)for(let e=c-i;e<=c+i;e++)for(let o=l-i;o<=l+i;o++)if(Math.max(Math.abs(e-c),Math.abs(o-l))===i)for(const i of n.get(e,o)??[]){const e=(i.x-t)**2+(i.y-s)**2;e<d&&([u,d]=[i,e])}return u}}const uK=new WeakMap;function dK(t){let e=uK.get(t);return e||uK.set(t,e=iK(t)),e}const fK=new WeakMap;function mK(t,e,n,i,o=0,r=4){const{width:a,height:s}=e,{row:c}=dK(t),{spots:l,rows:h}=function(t,e,n){const i=`${e}|${n}`,o=fK.get(t);if(o?.key===i)return o;const{contains:r}=dK(t),a=t.map(t=>t[0]),s=t.map(t=>t[1]),[c,l]=[Math.min(...a),Math.max(...a)],[h,u]=[Math.min(...s),Math.max(...s)],d=Math.min(120,Math.ceil((l-c)/n)+1),f=Math.min(120,Math.ceil((u-h)/n)+1),m=[],p=[];for(let t=0;t<d;t++)for(let e=0;e<f;e++){const n=[c+(d>1?(l-c)*t/(d-1):0),h+(f>1?(u-h)*e/(f-1):0)];r(n)&&(m.push(n),p.push(e))}const g=m.map(([t,n])=>(t-e[0])**2+(n-e[1])**2),y=m.map((t,e)=>e).sort((t,e)=>g[t]-g[e]),x={key:i,spots:y.map(t=>m[t]),rows:y.map(t=>p[t])};return fK.set(t,x),x}(t,n,r),u=[],d=[];for(let t=0;t<l.length;t++){var f,m,p,g;const[e,n]=l[t],r=e-a/2,y=n-s/2,x=(f=u)[m=h[t]]??(f[m]=c(y));if(!nK(x,r)||!nK(x,r+a))continue;const b=(p=d)[g=h[t]]??(p[g]=c(y+s));if(!nK(b,r+a)||!nK(b,r))continue;if(!i({x:r-o,y:y-o,width:a+2*o,height:s+2*o}))return{x:r,y:y,width:a,height:s}}return null}function pK(t,e){const n=t.flatMap(({x:t,y:n,r:i})=>{const o=i+e;return[[t-o,n],[t+o,n],[t,n-o],[t,n+o],[t-o*Math.SQRT1_2,n-o*Math.SQRT1_2],[t+o*Math.SQRT1_2,n-o*Math.SQRT1_2],[t+o*Math.SQRT1_2,n+o*Math.SQRT1_2],[t-o*Math.SQRT1_2,n+o*Math.SQRT1_2]]}),i=N.polygonHull(n);return!i||t.length<3?null:{hull:i,target:[t.reduce((t,e)=>t+e.x,0)/t.length,t.reduce((t,e)=>t+e.y,0)/t.length]}}function gK(t,e,n){const i=t.ctx.clusterState,o=rK(t);if(!(i?.active&&o&&o.fontMax>0))return[];const r=e.filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y)),a=new Map(r.map(t=>[t.id,t])),s=function(t,e){const n=t=>"Rect"===t.shape;return lK(t.filter(t=>!n(t)).map(t=>({x:t.x,y:t.y,r:t.r})),t.filter(n).map(t=>{const e=t.width??2*t.r,n=t.height??2*t.r;return{x:t.x-e/2,y:t.y-n/2,width:e,height:n}}).concat(e))}(r,n),c=hK(r),{padding:l,fontMax:h,fontMin:u}=o,d=t=>({family:o.text.fontFamily,size:t,weight:o.text.fontWeight??600}),f=[];for(const t of i.clusters){const e=new Set(t.ids),n=pK(t.ids.flatMap(t=>a.get(t)??[]),h);if(!n)continue;const i=t=>[t.x+l,t.x+t.width/2,t.x+t.width-l].every(n=>e.has(c(n,t.y+t.height/2)?.id??"")),o=t=>s.hits(t)||!i(t);for(let e=h;e>=u;e--){const i=mK(n.hull,Fw(t.name,d(e)),n.target,o,l);if(!i)continue;const r=t.name;f.push({key:`network-cluster-label-${t.index}`,text:r,fontSize:e,box:i}),s.add({x:i.x-l,y:i.y-l,width:i.width+2*l,height:i.height+2*l});break}}return f}function yK(t,e){const n=rK(t);if(!e.length||!n)return[];const i=new Map(e.map(t=>[`${t.key}_0`,t])),o=t=>i.get(`${t.id}`)?.fontSize??10,r=e_({data:e,label:t=>t.text,labelBounds:t=>{const{width:e,height:n}=t.box;return{x:-e/2,y:-n/2,width:e,height:n}},x:t=>{const{box:e}=t;return e.x+e.width/2},y:t=>{const{box:e}=t;return e.y+e.height/2},aes:W({}),rotate:W(0),id:t=>t.key,labelConfig:{fontColor:()=>Oc(t),fontWeight:600,...n.text,fontResize:!1,fontSize:o,lineHeight:t=>1.2*o(t),padding:0,pointerEvents:"none",textAnchor:"middle",verticalAlign:"middle"}}).map(t=>{const{datum:e,...n}=t;return{...n,interactive:!1}}),a=Math.max(...e.map(t=>t.fontSize));return Vy(r,Tc(t),Math.max(2,a/4))}function xK(t,e,n){const i=gK(t,e,[...n.values()].flatMap(t=>"outside"===t.position&&t.box?[t.box]:[]));return{scene:yK(t,i),boxes:i.map(t=>t.box)}}function bK(t,e,n,i,o,r,a,s){const c={arrows:t.schema.arrows,arrowSize:yv(t.schema.arrowSize,s),strokeWidth:xv("number"==typeof r.strokeWidth?r.strokeWidth:void 0,s),datum:n,i:i,keyPrefix:a,fill:"string"==typeof r.stroke?r.stroke:void 0},l=kv(c);if(!l.source&&!l.target)return{d:o,arrows:[]};if(e.loop)return{d:LM(e.loop,l),arrows:OM({...c,loop:e.loop})};if(e.points)return GV(t,{...e,points:e.points},c);const h={source:e.source,target:e.target};return{d:Sv(h.source,h.target,l),arrows:Cv({...c,...h})}}const kK=(t,e)=>`network-link-${t.source.id??""}-${t.target.id??""}-${e}`;function _K(t,e,n,i,o){const r=`network-${t}-${e.id}`;if("Circle"===t)return{type:"circle",key:r,cx:e.x,cy:e.y,r:e.r,...i};if("Rect"===t){const t=Number(e.width??Tg(n.width,i.datum,o)??0),a=Number(e.height??Tg(n.height,i.datum,o)??0);return{type:"rect",key:r,x:e.x-t/2,y:e.y-a/2,width:t,height:a,...i}}return null}function vK(t,n,i,o,r,a){const s=n.nodeShapeConfig.label;if(!s)return[];const c="Circle"===i,l=r.labelConfig??{fontResize:!0},h=Ig(t,i),u=h.fontMin??l.fontMin,d=e_({data:o,label:(t,e)=>!!(t=>{const e=a.get(t);return!e||"inside"===e.position})(t)&&s(t,e),x:t=>t.x,y:t=>t.y,aes:t=>{const e=t;return c?{r:e.r,width:2*e.r,height:2*e.r}:{width:e.width??0,height:e.height??0}},rotate:W(0),id:t=>`network-label-${t.id}`,labelBounds:(t,e,n)=>{const i=n;if(c){const t=i.r??0;return{width:1.5*t,height:1.5*t,x:.75*-t,y:.75*-t}}const o=i.width??0,r=i.height??0;return{width:o,height:r,x:-o/2,y:-r/2}},labelConfig:{...l,fontColor:n=>{const i=n.data??n,o=Tg(r.fill,i.data??i,i.i??0);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",t.schema.colorDefaults)},...h,fontMin:(e,n)=>Ow(t,a.get(e.data),Tg(u,e,n)??t_.fontMin)}});if(!c)return d;const f=Tw(new Map(o.filter(t=>a.has(t)).map(t=>[t,a.get(t)])),t=>({id:`network-label-${t.id}`,datum:t}));return[...d,...Pw(t,f)]}const wK=HM,MK=t=>t.ctx.networkCtx?.links??[];function SK(t,e){const n=vI(t,e),i=MK(t).find(t=>t.datum===e);return n&&i?.loop?TM(n,i.loop.box):n&&i?.points?TM(n,Vw(i.points)):n}function CK(t,e){t.schema.on["click.shape"]=(n,i,o,r)=>{if(t._tooltipClass.data([]).render(),nw(n))CI(t,n,{nodeKey:(e,n)=>`${t._ids(e,n)[t._drawDepth]}`,box:SK(t,n)});else if(t._drawDepth>=t.schema.groupBy.length-1){const a=wK(t,n,i);if(t._focus&&t._focus===a)e.active(!1),t.schema.on.mouseenter.bind(t)(n,i,o,r),t._focus=void 0,t._zoomToBounds(null);else{e.hover(!1);const n=t.ctx.linkLookup[a]??[],i=t.ctx.nodeLookup[a];if(!i)return;const o=[a],r=[i.x-i.r,i.x+i.r],s=[i.y-i.r,i.y+i.r];n.forEach(t=>{o.push(t.id),t.x-t.r<r[0]&&(r[0]=t.x-t.r),t.x+t.r>r[1]&&(r[1]=t.x+t.r),t.y-t.r<s[0]&&(s[0]=t.y-t.r),t.y+t.r>s[1]&&(s[1]=t.y+t.r)}),function(t,e,n,i){for(const o of MK(t)){if(!o.loop||o.source?.id!==e)continue;const[[t,r],[a,s]]=o.loop.box;n[0]=Math.min(n[0],t),n[1]=Math.max(n[1],a),i[0]=Math.min(i[0],r),i[1]=Math.max(i[1],s)}}(t,a,r,s),e.active((e,n)=>{const i=ew(e);return i?i.source.id===a||i.target.id===a:o.includes(wK(t,e,n))}),t._focus=a,VM(t,r,s)}}}}function $K(t,e){$I(t),CK(t,e),function(t,e){t.schema.on["click.legend"]=(n,i,o,r)=>{const a=t._ids(n,i),s=a[a.length-1],c=t._id(n,i);if(t._drawDepth>=t.schema.groupBy.length-1){if(t._focus&&t._focus===c)e.active(!1),t._focus=void 0,t._zoomToBounds(null);else{e.hover(!1);const n=(Array.isArray(c)?c:[c]).map(e=>t.ctx.nodeLookup[String(e)]),i=[`${s}`],o=[n[0].x-n[0].r,n[0].x+n[0].r],r=[n[0].y-n[0].r,n[0].y+n[0].r];n.forEach(t=>{i.push(t.id),t.x-t.r<o[0]&&(o[0]=t.x-t.r),t.x+t.r>o[1]&&(o[1]=t.x+t.r),t.y-t.r<r[0]&&(r[0]=t.y-t.r),t.y+t.r>r[1]&&(r[1]=t.y+t.r)}),e.active((e,n)=>{const o=ew(e);if(o)return i.includes(o.source.id)&&i.includes(o.target.id);const r=t._ids(e,n);return i.includes(`${r[r.length-1]}`)}),t._focus=c,VM(t,o,r)}t.schema.on.mouseenter.bind(t)(n,i,o,r),t.schema.on["mousemove.legend"].bind(t)(n,i,o,r)}}}(t,e),function(t,e){t.schema.on.mouseenter=()=>{},t.schema.on["mouseenter.legend"]=(n,i)=>{e.hover(yw(t,n,i))},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=(e,n)=>`${t._ids(e,n)[t._drawDepth]}`;if(nw(i))return void e.hover(gw(t,i,s));const c=wK(t,i,o),l=t.ctx.linkLookup[c]??[],h=t.ctx.nodeLookup[c];if(!h)return;const u=[c],d=[h.x-h.r,h.x+h.r],f=[h.y-h.r,h.y+h.r];l.forEach(t=>{u.push(t.id),t.x-t.r<d[0]&&(d[0]=t.x-t.r),t.x+t.r>d[1]&&(d[1]=t.x+t.r),t.y-t.r<f[0]&&(f[0]=t.y-t.r),t.y+t.r>f[1]&&(f[1]=t.y+t.r)}),e.hover((t,e)=>{const n=ew(t);return n?n.source.id===c||n.target.id===c:u.includes(s(t,e))})}}(t,e)}const AK={name:"Network",layoutStage:eK,sizeLegendScale:(t,{width:e,height:n})=>function(t,e,n){if(!t._size)return null;if(!Array.isArray(t._filteredData)||!Array.isArray(t.schema.nodes)||!Array.isArray(t.schema.links))return null;const i=YV(t);if(!i.length)return null;const{nodeLookup:o,linkLookup:r}=t.ctx,a=UV(t,i);return t.ctx.nodeLookup=o,t.ctx.linkLookup=r,QV(t,i,a),JV(t,i,e,n,a)}(t,e,n),emit:({viz:t})=>{const e=t.ctx.networkCtx;if(!e)return[];const n=[],i=e.nodeGroups?.length?function(t,e){const n=e.nodeShapeConfig.label,i=[];for(const[o,r]of e.nodeGroups){const a="Circle"===o,s={...Hg(t,o),...e.nodeShapeConfig}.labelConfig??{};r.forEach((t,e)=>{const o=t.data??t,r=t.i??e,c=a?t.r:Math.hypot(t.width??0,t.height??0)/2||t.r;i.push({key:t,datum:o,index:r,x:t.x,y:t.y,r:c,text:a&&n?n(t,e):void 0,inside:{width:1.5*t.r,height:1.5*t.r,padding:Tg(s.padding,o,r)??t_.padding,font:{family:Tg(s.fontFamily,o,r),weight:Tg(s.fontWeight,o,r)}}})})}const{width:o,height:r}=wt(t);return Ew(t,i,{x:0,y:0,width:o,height:r})}(t,e):new Map;e.links&&e.links.length&&n.push(...function(t,e){const n=[],i=zw(t);for(const o of e.links){const r=o.datum;if(!r)continue;const a=ew(r).index,s=Wg(e.linkConfig,r,a);"number"==typeof o.size&&(s.strokeWidth=o.size);const c=i(r,o);c&&(s.stroke=c);const l=o.source.id??"",h=o.target.id??"",u=kK(o,a),d=e.linkD(o),f=bv(e=>bK(t,o,r,a,d,s,`network-arrow-${l}-${h}-${a}`,e));n.push({type:"path",key:u,d:f.d,...f.emphasis?{emphasis:f.emphasis}:{},datum:r,index:a,paint:s,aria:{label:pw(t,r)}}),n.push(Sw(u,d,r,s.strokeWidth)),n.push(...f.arrows)}return n}(t,e));const o=xK(t,(e.nodeGroups??[]).flatMap(([,t])=>t),i);if(n.push(...o.scene),n.push(...function(t,e,n,i=[]){if(!e.links?.length)return[];const o=[...n.values()].flatMap(t=>"outside"===t.position?[t.box]:[]),r=e.nodeGroups.flatMap(([,t])=>t);return aM(t,e.links.flatMap(t=>{if(!t.datum)return[];const e=ew(t.datum).index;return[{key:kK(t,e),link:t,i:e,anchor:t.loop?t.loop.apex:t.points?VV({...t,points:t.points}):t.source&&t.target?Z_([t.source.x,t.source.y],[t.target.x,t.target.y],t.source.r??0,t.target.r??0):null,path:t.loop?Uw(t.loop.d):t.points?qV({...t,points:t.points}):null,priority:t.size}]}),{circles:r.filter(t=>"Rect"!==t.shape).map(t=>({x:t.x,y:t.y,r:t.r})),boxes:r.filter(t=>"Rect"===t.shape).map(t=>{const e=t.width??2*t.r,n=t.height??2*t.r;return{x:t.x-e/2,y:t.y-n/2,width:e,height:n}}).concat(o,i)})}(t,e,i,o.boxes)),e.nodeGroups&&e.nodeGroups.length)for(const[o,r]of e.nodeGroups){if(!r.length)continue;const a={...Hg(t,o),...e.nodeShapeConfig},s=[];for(let e=0;e<r.length;e++){const i=r[e],c=i.data??i,l=Wg(a,c,i.i??e);void 0===l.vectorEffect&&(l.vectorEffect="non-scaling-stroke");const h=t._size,u=h?`, ${h(c,i.i??e)}`:"",d=_K(o,i,a,{datum:c,paint:l,aria:{label:`${jg(t,i,e)}${u}.`}},i.i??e);if(!d)continue;n.push(d);const f=WS(a,d,c,i.i??e);f&&s.push(f)}n.push(...s),n.push(...vK(t,e,o,r,a,i))}return n},insetRegion:Ay,setup:t=>{const e=t;$K(t,e),function(t){WM(t),t.x=function(t){if(!arguments.length)return this._x;if("function"==typeof t)this._x=t;else{const e=t;this._x=G(e),this.schema.aggs[e]||(this.schema.aggs[e]=d.mean)}return this},t.y=function(t){if(!arguments.length)return this._y;if("function"==typeof t)this._y=t;else{const e=t;this._y=G(e),this.schema.aggs[e]||(this.schema.aggs[e]=d.mean)}return this}}(e),rS(t),t._x=H("x"),t._y=H("y");const n=e._draw.bind(t);e._draw=function(e){const i=n(e),{width:o,height:r}=wt(t);return An(t,{kind:"network",width:o,height:r,duration:Jt(t)}),i}},facet:{aspect:1},pointMark:(t,e)=>mu(e)||wM(e),ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}},...cM(),...hM(),...Mn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:W(1),coerce:t=>"function"==typeof t?t:W(t)},lM(),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[H("id")]},{key:"nodeTooltipLinks"},{key:"nodeTooltipStats",default:!0},{key:"nodeTooltipStatsConfig",merge:!0,default:{}},{key:"tooltipConfig",merge:!0,factory:t=>Mw(t)},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:W("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t._size,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:()=>Z(t._theme,t=>t.link,"#adb5bd")}})}]};var zK=fk(AK);function DK(t){return t.groupRow??t.data}function LK(t,e){return!t.parent||e&&!!t.children}function FK(t,e){return e?t.data:DK(t)}const NK=({viz:t})=>{const e=t._filteredData;if(!e||!e.length)return{shapeData:[]};const i=t.schema.height-t._margin.top-t._margin.bottom,o=t.schema.width-t._margin.left-t._margin.right,r=Math.min(i,o),a=n.nestGroups(e,t.schema.groupBy.slice(0,t._drawDepth+1)),s=t.schema.packOpacity,c=t.ctx.pack.padding(t.schema.layoutPadding).size([r,r])(L.hierarchy({key:a.key,values:a},t=>t.values).sum(t.schema.sum).sort(t.schema.sort));!function(t,e){t.eachAfter(t=>{const i=t;if(!i.children)return;const o=n.merge(i.leaves().map(t=>t.data),e);delete o._isAggregation,delete o._threshold,delete o[Dh],o[fe]=i.depth-1,Object.defineProperties(o,{key:{value:i.data.key,configurable:!0},values:{value:i.children.map(t=>DK(t)),configurable:!0}}),i.groupRow=o})}(c,t.schema.aggs);const l=c.descendants().filter((t,e)=>{const n=t;n.__d3plus__=!0,n.i=e,n.id=n.parent?n.parent.data.key:"root";const i=n,o=n.height?s(FK(i,!n.parent),e):1;for(const t of new Set([n.data,DK(i)]))t.__d3plusOpacity__=o,t.__d3plusTooltip__=!!n.parent;return!n.children||n.children.length>1});return t.ctx.packDiameter=r,t.ctx.packOffsetX=(o-r)/2,t.ctx.packOffsetY=(i-r)/2,{shapeData:l}};function BK(t){const e=[];for(let n=t;n&&n.parent;n=n.parent)e.unshift(`${n.data.key}`);return e.join("/")}function EK(t){const e=t.parent;if(!e)return"pack-root-0";if(t.children)return`pack-group-${BK(t)}`;const n=`pack-leaf-${BK(e)}`,i=e.children??[];return i.length>1?`${n}#${i.indexOf(t)}`:n}function RK(t,e){let n;return n=e.parent?e.children?t._drawLabel(e.leaves()[0].data,0,e.depth-1):t._drawLabel(e.data,e.i):t.schema.translate("Total"),`${n}, ${e.value}.`}function PK(t,e=[]){return t.values?t.values.forEach(t=>{e.push(t),PK(t,e)}):e.push(t),e}const TK=t=>Array.isArray(t)?t:[t],OK={name:"Pack",layoutStage:NK,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=Hg(t,"Circle"),o=!!t.schema.colorScale,r=function(t){const e=jc(t),n=t.schema.shapeConfig??{};return void 0===(n.Circle??{}).stroke&&Bc(n.stroke)?{fill:e,stroke:`${Su(e)}`}:{fill:e}}(t),a=(t.schema.shapeConfig.Circle??{}).label,s=n.map((e,n)=>{const a=LK(e,o),s=FK(e,a),c=a?r.fill:Tg(i.fill,s,n),l=a&&void 0!==r.stroke?r.stroke:Tg(i.stroke,s,n),h=Tg(i.strokeWidth,s,n);return{type:"circle",key:EK(e),cx:e.x,cy:e.y,r:e.r,shapeType:"Pack",datum:DK(e),paint:{fill:Og(i,s,n,c),stroke:l,opacity:s.__d3plusOpacity__,strokeWidth:h},aria:{label:RK(t,e)}}}),c=e_({data:n,label:(t,e)=>{const n=t;return!n.children&&(a?a(n.data,e):!!n.parent&&(n.data.id??!1))},x:t=>t.x,y:t=>t.y,datum:t=>t.data,aes:t=>{const e=t.r;return{r:e,width:2*e,height:2*e}},rotate:W(0),id:t=>EK(t),labelBounds:(t,e,n)=>{const i=n.r;return{width:1.6*i,height:.8*i,x:.8*-i,y:.4*-i}},labelConfig:{fontResize:!0,...Ig(t,"Circle")}}),l=jS(i,s,t=>[FK(n[t],LK(n[t],o)),t]);return[...s,...l,...c]},insetRegion:Ay,chartTransform:t=>({x:t._margin.left+(t.ctx.packOffsetX??0),y:t._margin.top+(t.ctx.packOffsetY??0)}),chartBodyRect:t=>{const e=t.ctx.packDiameter??0;return{x:0,y:0,width:e,height:e}},setup:t=>{const e=t.hover.bind(t);t.hover=n=>(e(n),t.schema.legend&&t._legendClass.hover(n),t)},facet:{aspect:1},ctx:{pack:L.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(t,e)=>(e.value??0)-(t.value??0)},{key:"sum",default:H("value"),coerce:t=>"function"==typeof t?t:G(t)},{key:"packOpacity",default:W(.25),coerce:t=>"function"==typeof t?t:W(t)},{key:"shape",default:W("Circle"),coerce:t=>"function"==typeof t?t:W(t)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:t=>{const e=t;return!(!e.parent||e.children)&&e.id},labelConfig:{fontResize:!0},opacity:t=>t.__d3plusOpacity__}})},{key:"legendSort",factory:t=>JT(t,"sum")},{key:"legend",coerce:"const",factory:ZT},{key:"on",merge:!0,factory:t=>{const e=t.schema.on["mousemove.legend"],n=t.schema.on["mousemove.shape"],i=e=>t.hover(e);return{mouseenter:()=>{},"mousemove.legend":(n,o,r,a)=>{e(n,o,r,a);const s=t._ids(n,o),c=PK(n);i(t=>(Object.keys(t).filter(t=>"value"!==t&&!t.startsWith("__d3plus")).every(e=>null!=n[e]&&TK(t[e]).every(t=>TK(n[e]).includes(t)))?c.push(t):s.includes(t.key)&&c.push(...PK(t,[t])),c.includes(t)))},"mousemove.shape":(t,e,o,r)=>{t.__d3plusTooltip__&&n(t,e,o,r);const a=PK(t,[t]);i(t=>a.includes(t))}}}}]};var WK=fk(OK);function jK(t){return"number"==typeof t&&Number.isFinite(t)}function HK(t){return null==t||""===t||"number"==typeof t&&!Number.isFinite(t)}function IK(t,e=[]){const n=new Set(e),i=[],o=new Map;for(const e of t)for(const t of Object.keys(e)){if(n.has(t)||t.startsWith("_"))continue;const r=e[t];o.has(t)||(o.set(t,!0),i.push(t)),HK(r)||jK(r)||o.set(t,!1)}return i.filter(e=>o.get(e)&&t.some(t=>jK(t[e])))}function GK(t){const e=t.filter(t=>!HK(t));return e.length&&e.every(jK)?"numeric":"categorical"}function qK(t,e,n={}){const i=Array.isArray(n.domain)?n.domain:void 0;if("numeric"===e){const[e,n]=d.extent(t.filter(jK));return[i&&jK(i[0])?i[0]:e??0,i&&jK(i[i.length-1])?i[i.length-1]:n??0]}if(i)return i.map(String);return Array.from(new Set(t.filter(t=>!HK(t)).map(String))).sort((t,e)=>t.localeCompare(e,void 0,{numeric:!0}))}function VK(t,e,n={},i){return t.map(t=>{const o=n[t]??{},r=e.map(e=>e[t]),a="point"===o.scale||"band"===o.scale?"categorical":GK(r),s=i?.[t]??qK(r,a,o);return{key:t,title:"string"==typeof o.title?o.title:t,type:a,domain:s,reverse:Boolean(o.reverse)}})}function KK(t,e,n={}){const i={};for(const o of VK(t,e,n))i[o.key]=o.domain;return i}function YK(t){return t<=50?1:Math.max(.1,Math.round(100*Math.sqrt(50/t))/100)}function UK(t,e,n){if(t<=0)return[];if(1===t)return[(e+n)/2];const i=(n-e)/(t-1);return Array.from({length:t},(t,n)=>e+i*n)}function XK(t,e){const n=t.domain.slice();return("numeric"===t.type?"horizontal"===e!==t.reverse:t.reverse)?n.reverse():n}function QK(t){if(!t)return{};const e={...t};return delete e.domain,delete e.reverse,delete e.title,e}function ZK(t,e){const n=t.schema.axisConfig??{};return{fontColor:Oc(t),fontSize:12,textAnchor:"horizontal"===e?"middle":"end",verticalAlign:"horizontal"===e?"bottom":"middle",...n.titleConfig??{}}}function JK(t,e,n,i){const o=t.schema.dimensionConfig??{},r=(new Ga).orient("horizontal"===n?"left":"bottom").align("start");r.renderMode("compute").select(null).maxSize(i);const a=QK(o[e.key]);r.config(Dz(t,{})).config(t.schema.axisConfig??{}).config(a),Ni(r,t.schema.axisConfig,a),r.gridSize(0).title(!1);const s=r.scale();return"categorical"===e.type&&"point"!==s&&"band"!==s&&r.scale("point"),"numeric"!==e.type||"point"!==s&&"band"!==s||r.scale("linear"),r.domain(XK(e,n)),r._domainEndFirst="categorical"===e.type&&e.reverse,r}function tY(t,e){let n=0,i=e;for(const o of t){const t=o._d3Scale?.range()??[0,e];n=Math.max(n,Math.min(...t)),i=Math.min(i,Math.max(...t))}return i>n?[n,i]:[0,e]}function eY(t,e,n){return Pk({type:"group",key:`pc-axis-${e}`,transform:n,children:t.toScene().children})}function nY(t,e){return new Map(t.map((t,n)=>[t.key,e[n].schema.titleTooltip]))}function iY(t,e,n,i,o){const r=t._d3Scale,a="numeric"===e.type&&r&&"function"==typeof r.invert?t=>Number(r.invert(t-i)):void 0;return{dim:e,offset:n,start:i+o[0],end:i+o[1],position:n=>{const o=t._getPosition((t=>"categorical"===e.type?String(t):t)(n));return"number"==typeof o&&Number.isFinite(o)?i+o:NaN},invert:a}}function oY(t,e,n,i,o){return!e.length||n<=0||i<=0?{axes:[],nodes:[]}:"vertical"===o?function(t,e,n,i){const o=e.length,r=ZK(t,"vertical"),a=t.schema.locale,s=Wk(e.map(t=>t.title),r,a),c=Math.min(Math.max(0,...s)+4,.25*n),l=c?c+8:0,h=Math.max(0,n-l),u=Math.max(20,i/o*.5),d=e.map(e=>JK(t,e,"vertical",u).width(h).height(u));d.forEach(t=>t.measure());const f=d.map(t=>t.outerBounds().height||0),m=jk(e.slice(0,1).map(t=>({key:t.key,text:"M",x:0,y:0,width:c||1,height:0})),r,a),p=UK(o,Math.max(4,m/2),i-Math.max(4,f[o-1])),g=o>1?p[1]-p[0]:i,y=tY(d,h),x=[],b=d.map((t,n)=>{t.range(y).render();const i=Nr(t),o=i?i.points[0][1]:0;return x.push(eY(t,e[n].key,{x:l,y:p[n]-o})),iY(t,e[n],p[n],l,y)}),k=c?e.map((t,e)=>({key:t.key,text:t.title,x:0,y:p[e]-g/2,width:c,height:g})).filter(t=>t.text):[];return x.push(...Hk(k,r,a,nY(e,d))),{axes:b,nodes:x}}(t,e,n,i):function(t,e,n,i){const o=e.length,r=ZK(t,"horizontal"),a=t.schema.locale,s=Wk(e.map(t=>t.title),r,a),c=Math.max(30,n/o*.6),l=e.map(e=>JK(t,e,"horizontal",c).height(i).width(c));l.forEach(t=>t.measure());const h=l.map(t=>t.outerBounds().width||0);let u=o>1?n/o:n,d=[],f=0,m=0;for(let t=0;t<2;t++)d=s.map(t=>Math.min(t+4,Math.max(u-8,40))),f=Math.max(h[0],d[0]/2,4),m=Math.max(d[o-1]/2,4),u=o>1?(n-f-m)/(o-1):n-f-m;const p=UK(o,f,n-m),g=e.map((t,e)=>({key:t.key,text:t.title,x:p[e]-d[e]/2,y:0,width:d[e],height:0})).filter(t=>t.text),y=jk(g,r,a),x=y?y+8:0;g.forEach(t=>t.height=y);const b=Math.max(0,i-x);l.forEach(t=>t.height(b).measure());const k=tY(l,b),_=[],v=l.map((t,n)=>{t.range(k).render();const i=Nr(t),o=i?i.points[0][0]:h[n];return _.push(eY(t,e[n].key,{x:p[n]-o,y:x})),iY(t,e[n],p[n],x,k)});return _.push(...Hk(g,r,a,nY(e,l))),{axes:v,nodes:_}}(t,e,n,i)}function rY(t,e,n="horizontal"){return e.map(e=>{const i=t[e.key];if(HK(i))return null;const o=e.position(i);return"number"==typeof o&&Number.isFinite(o)?"horizontal"===n?[e.offset,o]:[o,e.offset]:null})}function aY(t,e="linear",n="horizontal"){const i="bump"===e?"horizontal"===n?b.curveBumpX:b.curveBumpY:b.curveLinear;return b.line().defined(t=>null!==t).x(t=>t[0]).y(t=>t[1]).curve(i)(t)??""}function sY(t){const e=t.schema.dimensions;if(Array.isArray(e))return e.map(String);const n=t._groupByRaw,i=(Array.isArray(n)?n:[n]).filter(t=>"string"==typeof t);return IK(t._data??[],["id",...i])}function cY(t){return"vertical"===t?"vertical":"horizontal"}function lY(t,e,n,i){const o=t.end-t.start,{dim:r}=t,a={id:`${n.left},${n.top}|${e}|${r.key}`,key:r.key,title:r.title,orient:e,type:r.type,domain:r.domain,position:t.position,invert:t.invert,alongStart:t.start};return"horizontal"===e?{...a,x:n.left+t.offset-i/2,y:n.top+t.start,width:i,height:o}:{...a,x:n.left+t.start,y:n.top+t.offset-i/2,width:o,height:i}}const hY=({viz:t})=>{var e;const n=(e=t.ctx).brushQueue??(e.brushQueue=[]),i=t._filteredData??[],o=sY(t);if(t.ctx.dimensions=[],t.ctx.axisNodes=[],!i.length||!o.length)return{shapeData:[]};const r=VK(o,i,t.schema.dimensionConfig??{},t.ctx.sharedDomains);t.ctx.dimensions=r;const a=cY(t.schema.orient),s="bump"===t.schema.curve?"bump":"linear",{width:c,height:l}=wt(t),h=oY(t,r,c,l,a);t.ctx.axisNodes=h.nodes;const u=t.schema.brushConfig??{},d="number"==typeof u.width?u.width:20;for(const e of h.axes)n.push(lY(e,a,t._margin,d));const f=h.axes.map(t=>({key:t.dim.key,offset:t.offset,position:t.position})),m=new Map;return{shapeData:i.map((e,n)=>{const i=`${t._id(e,n)}`,o=m.get(i)??0;return m.set(i,o+1),{data:e,i:n,id:o?`${i}-${o}`:i,d:aY(rY(e,f,a),s,a)}})}};function uY(t){return 2===t.length&&t.every(t=>jK(t))}function dY(t,e){if(uY(e)){if(!jK(t))return!1;const[n,i]=e[0]<=e[1]?e:[e[1],e[0]];return t>=n&&t<=i}return null!=t&&e.includes(String(t))}function fY(t,e){if(!e)return!0;for(const n of Object.keys(e))if(!dY(t[n],e[n]))return!1;return!0}function mY(t){return Boolean(t&&Object.keys(t).length)}function pY(t,e){const n=Math.min(t[0],t[1]),i=Math.max(t[0],t[1]);if("numeric"===e.type){if(!e.invert)return null;const t=e.invert(n),o=e.invert(i);return jK(t)&&jK(o)?t<=o?[t,o]:[o,t]:null}const o=e.domain.filter(t=>{const o=e.position(t);return o>=n&&o<=i}).map(String);return o.length?o:null}function gY(t,e,n=6){if(uY(t)){if("numeric"!==e.type)return null;const n=e.position(t[0]),i=e.position(t[1]);return jK(n)&&jK(i)?n<=i?[n,i]:[i,n]:null}const i=new Set(t.map(String)),o=e.domain.filter(t=>i.has(String(t))).map(t=>e.position(t)).filter(jK);return o.length?[Math.min(...o)-n,Math.max(...o)+n]:null}const yY="d3plus-parallel-brushes",xY="d3plus-parallel-brush",bY=new WeakMap;function kY(t){return"horizontal"===t.orient?t.height:t.width}function _Y(t,e){if(!t)return null;const n=gY(t,e);if(!n)return null;const i=kY(e),o=Math.max(0,Math.min(i,n[0]-e.alongStart)),r=Math.max(0,Math.min(i,n[1]-e.alongStart));return r>o?[o,r]:null}function vY(t,e){const n=bY.get(t)?.clearLabel,i=o.select(t).attr("tabindex",e?0:null);i.selectAll(":scope > title").remove(),e&&n&&i.insert("title",":first-child").text(n)}function wY(t,e,n,i){const r=bY.get(e);if(!r)return;const a=r.target.key,s={...t.schema.brushes??{}};n?s[a]=n:delete s[a],t.schema.brushes=s;const c=e.parentNode;c&&o.select(c).selectAll(`g.${xY}`).each(function(t){const r=bY.get(this);r&&t.key===a&&(vY(this,Boolean(n)),(this!==e||i)&&o.select(this).call(r.brush.move,_Y(n??void 0,r.target)))});const l=t.schema.on?.brush;"function"==typeof l&&l.call(t,s),t._scheduleSceneRepaint()}function MY(t,e){const n=bY.get(e),i=t.schema.brushes??{};return!(!n||!(n.target.key in i))&&(n.active=!1,wY(t,e,null,!0),!0)}function SY(t,e,n){const i=t._select&&"function"==typeof t._select.node?t._select.node():null;if(!i||"function"!=typeof i.querySelector)return;const r=!1!==t.schema.brushing&&!t._ssr&&e.length>0,a=o.select(i).selectAll(`:scope > g.${yY}`).data(r?[0]:[]);if(a.exit().remove(),!r)return;const s=a.enter().append("g").attr("class",`d3plus-viz-brush ${yY}`).merge(a),c=Array.from(new Map(e.map(t=>[t.id,t])).values()),l=s.selectAll(`g.${xY}`).data(c,t=>t.id);l.exit().remove();const h=t.schema.brushes??{},u=e=>t.schema.translate(e);l.enter().append("g").attr("class",xY).merge(l).each(function(e){const i=o.select(this);let r=bY.get(this);if(!r){const n="horizontal"===e.orient?f.brushY():f.brushX();r={brush:n,target:e,signature:"",active:!1,clearLabel:""},bY.set(this,r);const o=this;n.on("start brush end",e=>function(t,e,n){const i=bY.get(e);if(!i||!n.sourceEvent)return;const o=i.target;i.active="end"!==n.type;const r=n.selection;wY(t,e,r&&Math.abs(r[1]-r[0])>=1?pY([r[0]+o.alongStart,r[1]+o.alongStart],o):null,"end"===n.type&&"categorical"===o.type)}(t,o,e)),i.on("dblclick.clear",e=>{e.preventDefault(),e.stopPropagation(),MY(t,o)}).on("keydown.clear",e=>{"Escape"===e.key&&MY(t,o)&&(e.preventDefault(),e.stopPropagation())})}if(r.target=e,r.clearLabel=`${e.title}: ${u("Double-click or Escape to Clear")}`,i.attr("transform",`translate(${e.x},${e.y})`),r.active)return;const a=`${e.width}x${e.height}`;r.signature!==a&&(r.brush.extent([[0,0],[e.width,e.height]]),i.call(r.brush),r.signature=a),function(t,e,n){const i=t.selectAll("rect.selection"),o=[["fill",e.fill],["fill-opacity",e.fillOpacity],["stroke",e.stroke],["stroke-width",e.strokeWidth]];for(const[t,e]of o)null!=e&&i.attr(t,`${e}`);t.selectAll("rect.overlay").attr("aria-label",n)}(i,n,`${e.title}: ${u("Drag to Filter")}`),i.call(r.brush.move,_Y(h[e.key],e)),vY(this,e.key in h)})}function CY(t,e,n){if(HK(n))return"";const i=t.schema.dimensionConfig??{},o=i[e]?.tickFormat;return"function"==typeof o?`${o(n)}`:jK(n)?p.formatAbbreviate(n,t.schema.locale):String(n)}function $Y(t,e){return(t.ctx.dimensions??[]).map(n=>[n.title,CY(t,n.key,e[n.key])])}const AY="pc-line-",zY="::hit";function DY(t,e){return"number"==typeof t&&Number.isFinite(t)?Math.min(1,Math.max(0,t)):YK(e)}function LY(t,e,n,i){const o=i.map(n=>`${n.title} ${CY(t,n.key,e[n.key])}`).join(", ");return`${t._drawLabel(e,n)}${o?`: ${o}`:""}.`}const FY=({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.axisNodes??[];if(!n.length)return i;const o=t.ctx.dimensions??[],r=Hg(t,"Line"),a=DY(t.schema.lineOpacity,n.length),s=[];return n.forEach(e=>{if(!e.d)return;const{data:n,i:i}=e,c=`${AY}${e.id}`,l=Tg(r.strokeOpacity,n,i);s.push({type:"path",shapeType:"Line",key:c,d:e.d,datum:n,index:i,paint:{fill:"none",stroke:Tg(r.stroke,n,i),strokeWidth:Tg(r.strokeWidth,n,i),strokeOpacity:"number"==typeof l?l:a,strokeDasharray:Tg(r.strokeDasharray,n,i),opacity:Tg(r.opacity,n,i)},aria:{label:LY(t,n,i,o)}}),s.push({type:"path",shapeType:"Line",key:`${c}${zY}`,d:e.d,datum:n,index:i,paint:{fill:"none",stroke:"transparent",strokeWidth:8},aria:{hidden:!0}})}),[...s,...i]},NY=t=>"string"==typeof t.key&&t.key.includes(AY),BY=t=>"string"==typeof t.key&&t.key.endsWith(zY),EY=t=>"number"==typeof t.z&&t.z>0;function RY(t,e){if(NY(t))return e(t);const n=t.children;return n&&n.length?{...t,children:n.map(t=>RY(t,e))}:t}function PY(t){if(NY(t))return!BY(t)&&EY(t)?1:0;const e=t.children;return e?e.reduce((t,e)=>t+PY(e),0):0}function TY(t,n){const i=mY(n.brushes),o=1===PY(t);return i||o?RY(t,t=>{const r={...t.paint??{}};if(i&&!fY(t.datum,n.brushes)){if(!BY(t)){const t="number"==typeof r.strokeOpacity?r.strokeOpacity:1;r.strokeOpacity=n.inactiveOpacity??.3*t,"string"==typeof r.stroke&&(r.stroke=e.colorGrayscale(r.stroke))}const i={...t,paint:r,interactive:!1};return delete i.z,i}return o&&EY(t)&&!BY(t)?(r.strokeOpacity=1,{...t,paint:r}):t}):t}function OY(t){const e={};for(const[n,i]of Object.entries(t))e[n]="function"==typeof i?i():i;return e}const WY={name:"ParallelCoordinates",layoutStage:hY,emit:FY,decorateScene:function(t,e){const n=OY(t.schema.brushConfig??{}),i=t.ctx.brushQueue;i&&(t.ctx.brushQueue=void 0,SY(t,i,n));const o=TY(e.root,{brushes:t.schema.brushes,inactiveOpacity:"number"==typeof n.inactiveOpacity?n.inactiveOpacity:void 0});return o===e.root?e:{...e,root:o}},facet:{aspect:1.5,axes:"all",share:(t,e)=>KK(sY(t),e.flat(),t.schema.dimensionConfig??{}),panel:(t,e)=>{const n=t.ctx.sharedDomains;return t.ctx.sharedDomains=e.shared?e.scales:void 0,()=>{t.ctx.sharedDomains=n}}},ctx:{},fields:[{key:"brushes",default:{}},{key:"brushing",default:!0},{key:"curve",default:"linear"},{key:"dataCutoff",default:2e3},{key:"dimensions"},{key:"lineOpacity",default:"auto"},{key:"orient",default:"horizontal"},{key:"zoom",default:!1},{key:"axisConfig",merge:!0,default:{}},{key:"brushConfig",merge:!0,factory:t=>({fill:()=>Oc(t),fillOpacity:.12,stroke:()=>Oc(t),strokeWidth:1,width:20})},{key:"dimensionConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,factory:t=>({Line:{stroke:(e,n)=>{const i=t.schema.shapeConfig.fill;return"function"==typeof i?i(e,n):i},strokeWidth:1.5}})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:e=>$Y(t,e)})}]};var jY=fk(WY);function HY(t){return{barConfig:{stroke:()=>Oc(t),strokeWidth:1},gridConfig:{stroke:()=>Wc(t),strokeWidth:1},shapeConfig:{fill:W("none"),labelConfig:{fontColor:()=>Oc(t),fontResize:!1,padding:0,textAnchor:t=>t.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Oc(t),strokeWidth:W(1)}}}function IY(t){return[()=>t.schema.translate("Value"),(e,n)=>{const i=Number(t.schema.value(e,n));return Number.isFinite(i)?p.formatAbbreviate(i,t.schema.locale):""}]}function GY(t,e,n,i){const o=Hg(t,"Path"),r=e.filter(t=>t.arc.outerRadius>t.arc.innerRadius&&t.arc.endAngle>t.arc.startAngle),s=r.map(e=>{const r=Wg(o,e.data,e.i);return{type:"path",key:`${n}-${t._ids(e.data,e.i).join("-")}-${e.slot}`,d:a.arcPath(e.arc),arc:e.arc,datum:e.data,index:e.i,hoverKeys:{slot:e.slot},paint:{...r,opacity:r.opacity??1},aria:{label:i(e)}}}),c=jS(o,s,t=>[r[t].data,r[t].i]);return[...s,...c]}function qY(t,e,n){const i=e.flatMap(e=>n(t,e)).filter(Number.isFinite);return{extent:i.length?[Math.min(...i),Math.max(...i)]:[]}}function VY(t,e){const n=t.ctx.polarSharedExtent,i=e.scales;return t.ctx.polarSharedExtent=e.shared&&i?i.extent:void 0,()=>{t.ctx.polarSharedExtent=n}}function KY(t){const e=t.ctx.polarSharedExtent;return Array.isArray(e)?e:[]}function YY(t){return{aspect:1,scales:"independent",share:(e,n)=>qY(e,n,t),panel:VY}}const UY=1e-9;function XY(t,e,n,i,o,r=10){const a=Math.abs(Math.cos(t)),s=Math.abs(Math.sin(t));let c=1/0;return a>UY&&(c=Math.min(c,(i/2-n/2*s)/a-e-r)),s>UY&&(c=Math.min(c,(o/2-n/2*a)/s-e-r)),c}function QY(t){const{labels:e,width:n,height:i,measure:o,wrap:r}=t,a=t.padding??10,s=t.maxLines??2,c=Math.max(0,Math.min(n,i)/2),l=c*(t.minRadiusShare??.5),h=e.map(t=>o(t)),u=function(t,e,n,i=10){let o=Math.min(e,n)/2;for(const r of t){const t=Math.abs(Math.cos(r.angle)),a=Math.abs(Math.sin(r.angle));t>UY&&(o=Math.min(o,(e/2-r.height/2*a)/t-i-r.width)),a>UY&&(o=Math.min(o,(n/2-r.height/2*t)/a-i-r.width))}return Math.max(0,o)}(e.map((t,e)=>({angle:t.angle,width:h[e],height:t.lineHeight})),n,i,a);if(u>=l)return{radius:u,labels:e.map((t,e)=>({wrapWidth:h[e]+1,width:h[e],height:t.lineHeight,lines:1,truncated:!1}))};const d=t=>e.map((e,o)=>{if(h[o]<=XY(e.angle,t,e.lineHeight,n,i,a))return{wrapWidth:h[o]+1,width:h[o],height:e.lineHeight,lines:1,truncated:!1};const c=XY(e.angle,t,e.lineHeight*s,n,i,a),l=Math.max(0,c),u=r(e,l,s);return{wrapWidth:l,width:Math.max(0,...u.widths),height:Math.max(1,u.lines.length)*e.lineHeight,lines:u.lines.length,truncated:u.truncated}}),f=t=>t.every(t=>!t.truncated);let m=l,p=d(m);if(!f(p))return{radius:l,labels:p};let g=c;for(let t=0;t<16&&g-m>.5;t++){const t=(m+g)/2,e=d(t);f(e)?(m=t,p=e):g=t}return{radius:m,labels:p}}const ZY=t=>t.font.lineHeight??1.2*t.font.fontSize;function JY(t,e=1){return Math.max(0,...t.map(t=>t.font.fontSize))+(e-1)*Math.max(0,...t.map(ZY))+10}function tU(t,e,n,i){const o=(t.span??2*Math.PI/Math.max(1,i))/2,r=t.angle+Math.PI/2,a=e+n*ZY(t);return{innerRadius:a,outerRadius:a+t.font.fontSize+10,startAngle:r-o,endAngle:r+o}}function eU(t,e,n,i){const o=(e,o)=>aT(tU(t,n,o,i),WP(e,t.font),{fontMin:t.font.fontSize,fontMax:t.font.fontSize,padding:5,align:"inner",minRadius:0,truncate:!1}),r=o(e[0],0);if(!r)return null;const a=[];for(let t=0;t<e.length;t++){const n=r.clockwise?e.length-1-t:t,i=0===n?r:o(e[t],n);if(!i)return null;a.push({text:e[t],fit:i})}return a.length?{lines:a}:null}function nU(t,e,n,i){let o=t.width(n)(e).lines;if(i<2)return o;let r=n/2,a=n;for(let n=0;n<8&&a-r>1;n++){const n=(r+a)/2,s=t.width(n)(e);s.truncated||s.lines.length!==i?r=n:(a=n,o=s.lines)}return o}function iU(t,e,n,i=1){const o=e.length;return e.map((e,a)=>{const c=lT(t,e.data,a);if("inside"===c||"outside"===c||!e.text)return null;const l=eU(e,[e.text],n,o);if(l)return l;const h=i>1?function(t,e,n,i){const{fontSize:o}=t.font,a=ZY(t),c=tU(t,e,0,n),l=e+5;let h=(c.endAngle-c.startAngle)*l-2*eT(5,o);const u=s.textWrap().fontFamily(r.fontExists(t.font.fontFamily??s.fontFamily)).fontSize(o).fontWeight(t.font.fontWeight??400).lineHeight(a).height(a*i).maxLines(i);for(let i=0;i<6&&h>o;i++){const i=u.width(h)(t.text);if(i.truncated||!i.lines.length)return null;const o=eU(t,nU(u,t.text,h,i.lines.length),e,n);if(o)return o;h*=.9}return null}(e,n,o,i):null;if(h||"along"!==c)return h;const u=aT(tU(e,n,0,o),WP(e.text,e.font),{fontMin:e.font.fontSize,fontMax:e.font.fontSize,padding:5,align:"inner",minRadius:0});return u?{lines:[{text:e.text,fit:u}]}:null})}function oU(t,e){return t.every((t,n)=>e[n]||!t.text)}function rU(t,e,n,i){const o=function(t,e,n){for(let i=2;i>0;i--)if(e+JY(t,i)<=n)return i;return 0}(e,n,i);return o?iU(t,e,n,o):e.map(()=>null)}function aU(t,e,n){if(!e.length)return null;for(let i=1;i<=2;i++){const o=Math.max(0,n-JY(e,i)),r=iU(t,e,o,i);if(oU(e,r))return{radius:o,curves:r}}return null}function sU(t,e,n){const i=e=>{const i=Tg(n.fontColor,e.data,e.i);return"string"==typeof i?i:Oc(t)},o=new Map,r=HP(t,e.flatMap(t=>t.curve.lines.map((e,n)=>{const r=`${t.key}${n?`-${n}`:""}`;return o.set(r,t.hoverMatch),{key:r,text:e.text,fit:e.fit,color:i(t)}})),OP(n));for(const t of r){const e=o.get(`${t.key}`);e&&(t.hoverMatch=e)}return r}function cU(t,e){const n=Array.isArray(e)?e.filter(Number.isFinite):[],i=t.filter(Number.isFinite).concat(n),o=Math.min(0,...i),r=Math.max(0,...i);if(Array.isArray(e)){return{domain:[o,r],ticks:Array.from(new Set(n)).sort((t,e)=>t-e)}}const a=Math.max(1,Math.round(e)),s=c.scaleLinear().domain([o,r]).nice(a),[l,h]=s.domain();return{domain:[l,h],ticks:s.ticks(a)}}function lU(t,e,n){const i=e[1]-e[0];return i?(t-e[0])/i*n:0}const hU={"stroke-width":"strokeWidth","stroke-opacity":"strokeOpacity","stroke-dasharray":"strokeDasharray"};function uU(t,e){const n={...t};for(const[t,i]of Object.entries(e??{}))n[hU[t]??t]=i;return n}const dU=(t,e,n)=>"function"==typeof t?t(e,n):t;function fU(t,e,n){const i={fill:"none"},o=dU(t.stroke,e,n);"string"==typeof o&&(i.stroke=o);const r=Number(dU(t.strokeWidth,e,n));Number.isFinite(r)&&(i.strokeWidth=r);const a=Number(dU(t.strokeOpacity,e,n));Number.isFinite(a)&&(i.strokeOpacity=a);const s=Number(dU(t.opacity,e,n));Number.isFinite(s)&&(i.opacity=s);const c=dU(t.strokeDasharray,e,n),l=(Array.isArray(c)?c:"string"==typeof c?c.split(/[\s,]+/):[]).map(Number).filter(Number.isFinite);return l.length&&(i.strokeDasharray=l),i}const mU=2*Math.PI,pU=(t,e,n,i,o)=>{const a=t.schema.axisConfig,s=(new ei).config({...t_,...o??a.shapeConfig?.labelConfig??{}}).schema,c={data:n,i:i,text:e},l=Number(s.fontSize(c,i))||10;return{fontFamily:String(r.fontExists(s.fontFamily(c,i))||"sans-serif"),fontSize:l,fontWeight:s.fontWeight(c,i),lineHeight:Number(s.lineHeight(c,i))||1.2*l}};function gU(t,e){const n=t.schema.axisConfig,i=[],o=function(t,e){const n=t.schema.axisConfig,i=n.shapeConfig?.labelConfig??{},o=sU(t,e.flatMap(t=>t.labelCurve?[{key:`radar-axis-label-${t.id}`,data:t.data,i:t.i,curve:t.labelCurve,hoverMatch:{field:"metric",value:t.key}}]:[]),i),r=e_({data:e.filter(e=>!e.labelCurve&&"along"!==lT(t,e.data,e.i)),label:t=>t.id,x:t=>t.x,y:t=>t.y,aes:()=>({}),rotate:t=>t.angle||0,id:t=>t.id,labelBounds:t=>t.labelBounds,labelConfig:i});for(const t of r){const e=t.datum?.data?.key;void 0!==e&&(t.hoverMatch={field:"metric",value:e})}return[...o,...IP(r,rM(o))]}(t,e);o.length&&i.push({type:"group",key:"radar-axis-labels",children:o});const r=Hg(t,"Path",n.shapeConfig??{}),a=e.map((t,e)=>({type:"path",key:`radar-spoke-${t.id}`,interactive:!1,d:`M0,0 ${t.x},${t.y}`,paint:Wg(r,t,e)}));return a.length&&i.push({type:"group",key:"radar-axis-spokes",interactive:!1,children:a}),i}function yU(t,{domain:e,ticks:n},i,o=t=>lU(t,e,i),r="radar"){const a=t.schema.axisConfig,s=n.map(t=>({value:t,r:o(t)}));return function(t,e,n,i,o,r="radar"){if(!(e>0))return[];const a=t.filter(t=>t.r>0&&t.r<e),s=[...a,{value:n,r:e}].map((t,e)=>({type:"circle",key:e===a.length?`${r}-ring-outer`:`${r}-ring-${t.value}`,interactive:!1,cx:0,cy:0,r:t.r,paint:fU(e===a.length?o:i,t,e)}));return[{type:"group",key:`${r}-radial-circles`,interactive:!1,children:s}]}(s,i,e[1],uU({},a.gridConfig),uU({},a.barConfig),r)}function xU(t,{domain:e,ticks:n},i,o,a="radar"){if(!t.schema.levelLabels)return[];const c=t.schema.levelLabelConfig??{},l=c.fontSize??10,h=c.fontWeight??400,u=s.fontFamilyStringify(c.fontFamily??t.schema.fontFamily??s.fontFamily),d={"font-family":u,"font-size":l,"font-weight":h},f=t.schema.levelFormat,m=function(t){const{ticks:e,domain:n,radius:i,angle:o,format:r,measure:a,fontSize:s}=t,c=t.toRadius??(t=>lU(t,n,i)),l=o*Math.PI/180,h=Math.sin(l),u=-Math.cos(l),d=-u,f=h,m=d>1e-6?"start":d<-1e-6?"end":"middle",p=(t,e,n,i)=>(Math.abs(n)*t+Math.abs(i)*e)/2,g=e.filter(t=>t>=n[0]&&t<=n[1]).map(t=>{const e=c(t),n=r(t),i=a(n),o=s,l=3+p(i,o,d,f),g=e-2-p(i,o,h,u);return{value:t,text:n,r:e,x:g*h+l*d,y:g*u+l*f,width:i,height:o,anchor:m}}),y=Math.max(0,...g.map(t=>2*p(t.width,t.height,h,u)));let x=1/0;for(let t=1;t<g.length;t++)x=Math.min(x,g[t].r-g[t-1].r);const b=x>0?Math.max(1,Math.ceil((y+2)/x)):g.length;return g.filter((t,e)=>e%b===0)}({ticks:n,domain:e,radius:i,angle:Number(t.schema.levelLabelAngle)||0,format:e=>"function"==typeof f?String(f(e)):p.formatAbbreviate(e,t.schema.locale),measure:t=>r.textWidth(t,d),fontSize:l,toRadius:o});return function(t,e,n="radar"){if(!t.length)return[];const i=[];for(const o of t){const t="start"===o.anchor?-o.width/2:"end"===o.anchor?o.width/2:0;i.push({type:"text",key:`${n}-level-label-${o.value}`,interactive:!1,x:0,y:0,transform:{x:o.x+t,y:o.y},lines:[{text:o.text,x:0,y:.35*e.fontSize,width:o.width}],font:{family:e.fontFamily,size:e.fontSize,weight:e.fontWeight,anchor:o.anchor,baseline:"alphabetic"},paint:{fill:e.fontColor,opacity:e.fontOpacity}})}return[{type:"group",key:`${n}-level-labels`,interactive:!1,children:i}]}(m,{fontColor:c.fontColor??Oc(t),fontFamily:u,fontOpacity:c.fontOpacity??1,fontSize:l,fontWeight:h},a)}const bU=1e-9;function kU(t,e,n,i,o=6){const r=Math.sin(t),a=-Math.cos(t);return{x:(e+o)*r+r*n/2-n/2,y:(e+o)*a+a*i/2-i/2,width:n,height:i}}function _U(t,e,n,i=6){let o=Math.min(e,n)/2;for(const r of t){const t=Math.abs(Math.sin(r.angle)),a=Math.abs(Math.cos(r.angle));t>bU&&(o=Math.min(o,(e/2-r.width/2*(1+t))/t-i)),a>bU&&(o=Math.min(o,(n/2-r.height/2*(1+a))/a-i))}return Math.max(0,o)}function vU(t,e,n,i=6){const o=Math.abs(Math.sin(t));return o<=bU?n:Math.max(0,2*(n/2-(e+i)*o)/(1+o))}const wU=(t,e,n=2)=>t.x<e.x+e.width+n&&e.x<t.x+t.width+n&&t.y<e.y+e.height+n&&e.y<t.y+t.height+n;function MU(t,e,n=6,i=2){if(t.length<2)return!1;const o=t.map(t=>({angle:t.angle,p:kU(t.angle,e,t.width,t.height,n)})).sort((t,e)=>t.angle-e.angle);for(let t=0;t<o.length;t++){const e=o[(t+1)%o.length];if(e!==o[t]&&wU(o[t].p,e.p,i))return!0}return!1}function SU(t){const{angles:e,widths:n,lineHeight:i,width:o,height:r}=t,a=t.padding??6,s=Math.max(0,Math.min(o,r)/2)*(t.minRadiusShare??.5),c=_U(e.map((t,e)=>({angle:t,width:n[e],height:i})),o,r,a);return c>=s?{radius:c,labels:n.map(t=>({width:t,height:i,lines:1}))}:{radius:s,labels:e.map((t,e)=>{const r=vU(t,s,o,a);return n[e]<=r?{width:n[e],height:i,lines:1}:{width:r,height:2*i,lines:2}})}}function CU(t){const e=(180*(t-Math.PI/2)/Math.PI%360+360)%360;return Math.sin(t)<-1e-9?{rotate:e-180,anchor:"end"}:{rotate:e,anchor:"start"}}const $U=t=>t>.3?"start":t<-.3?"end":"middle",AU=t=>t<-.3?"bottom":t>.3?"top":"middle";function zU(t,e,n,i,o=!0){const a=Math.max(0,Math.min(n,i)/2);if(!o||!e.length)return{radius:a,labels:[],curves:[]};const c=e.map((e,n)=>pU(t,e.text,e.data,n)),l=e.map((t,e)=>({text:t.text,data:t.data,angle:t.angle-Math.PI/2,span:t.span,font:c[e]})),h=t=>e.flatMap((e,n)=>{const i=t[n];return i?[{key:e.key,data:e.data,i:n,curve:i}]:[]}),u=Math.max(0,a-2);if("number"!=typeof t.schema.outerPadding){const e=aU(t,l,u);if(e)return{radius:e.radius,labels:[],curves:h(e.curves)}}const d=function(t,e,n,i,o){const a=Math.max(0,Math.min(i,o)/2),c=t.schema.outerPadding,l=t=>({"font-family":n[t].fontFamily,"font-size":n[t].fontSize,"font-weight":n[t].fontWeight}),h=e.map((t,e)=>r.textWidth(t.text,l(e))),u=Math.max(...n.map(t=>t.lineHeight)),d=Math.max(0,i-4),f=Math.max(0,o-4),m="number"==typeof c?Math.max(0,a-c):void 0,p=t=>Math.max(t+2,12),g=SU({angles:e.map(t=>t.angle),widths:h.map(t=>p("number"==typeof c?Math.min(t,c):t)),lineHeight:u+2,width:d,height:f}),y=m??g.radius,x=e.map((t,e)=>({angle:t.angle,width:g.labels[e].width,height:g.labels[e].height}));if(!MU(x,y)){const t=e.map((t,e)=>{const n=x[e],i=kU(t.angle,y,n.width,n.height);return{__d3plus__:!0,data:t.data,id:t.key,text:t.text,x:0,y:0,rotate:0,textAnchor:$U(Math.sin(t.angle)),verticalAlign:AU(-Math.cos(t.angle)),labelBounds:i}});return{radius:y,labels:t}}return function(t,{fonts:e,widths:n,innerW:i,innerH:o,fixed:r,outerPadding:a}){const c=QY({labels:t.map((t,n)=>({text:t.text,angle:t.angle-Math.PI/2,lineHeight:e[n].lineHeight,i:n})),width:i,height:o,padding:6,measure:t=>n[t.i],wrap:(t,n,i)=>s.textWrap().fontFamily(e[t.i].fontFamily).fontSize(e[t.i].fontSize).fontWeight(e[t.i].fontWeight).lineHeight(e[t.i].lineHeight).width(n).height(e[t.i].lineHeight*i).maxLines(i)(t.text)}),l=r??c.radius,h=t.map((t,n)=>{const{rotate:i,anchor:o}=CU(t.angle),r=Math.max(12,"number"==typeof a?a:c.labels[n].wrapWidth),s=2*e[n].lineHeight,h="start"===o?6:-r-6;return{__d3plus__:!0,data:t.data,id:t.key,text:t.text,x:l*Math.sin(t.angle),y:-l*Math.cos(t.angle),rotate:i,textAnchor:o,verticalAlign:"middle",labelBounds:{x:h,y:-s/2,width:r,height:s},rotateAnchor:[-h,s/2]}});return{radius:l,labels:h}}(e,{fonts:n,widths:h,innerW:d,innerH:f,fixed:m,outerPadding:c})}(t,e,c,n,i),f=rU(t,l,d.radius,u);return{radius:d.radius,labels:d.labels.filter((e,n)=>!f[n]&&"along"!==lT(t,e.data,n)),curves:h(f)}}function DU(t,{labels:e,curves:n},i){if(!e.length&&!n.length)return[];const o=t.schema.axisConfig,r=o.shapeConfig?.labelConfig??{},a=sU(t,n.map(t=>({...t,key:`${i}-label-${t.key}`,hoverMatch:{field:"slot",value:t.key}})),r),s=e_({data:e,label:t=>t.text,x:t=>t.x,y:t=>t.y,aes:()=>({}),rotate:t=>t.rotate,id:t=>`${i}-label-${t.id}`,labelBounds:t=>t.labelBounds,labelConfig:{...r,verticalAlign:t=>t.data?.verticalAlign??"middle"}});for(const t of s){const e=t.datum?.data?.id;void 0!==e&&(t.hoverMatch={field:"slot",value:e})}const c=[...a,...IP(s,rM(a))];for(const t of c)t.interactive=!1;return c.length?[{type:"group",key:`${i}-labels`,interactive:!1,children:c}]:[]}function LU(t,e,n,i,o){return{rings:yU(t,e,n,i,o),labels:xU(t,e,n,i,o)}}function FU(t,e,n,i,o="sqrt"){const r=e[1]-e[0],a=Number.isFinite(t)&&r?(t-e[0])/r:0,s=Math.max(0,Math.min(1,a));return"linear"===o?n+s*(i-n):Math.sqrt(n*n+s*(i*i-n*n))}function NU(t,e=0,n=2*Math.PI){const i=Math.max(0,Math.floor(t)),o=i?n/i:0;return Array.from({length:i},(t,n)=>({startAngle:e+n*o,endAngle:e+(n+1)*o,angle:e+(n+.5)*o}))}function BU(t){const e=new Map;return t.map(({slot:t,value:n})=>{const i=e.get(t)??0,o=i+(Number.isFinite(n)&&n>0?n:0);return e.set(t,o),{slot:t,y0:i,y1:o}})}function EU(t,e,n){return t>0?t:e>0&&n>0?e/n:0}function RU(t,e,n=void 0){const i=cU(t,e),[o,r]=n??[],a="number"==typeof o&&Number.isFinite(o),s="number"==typeof r&&Number.isFinite(r);if(!a&&!s)return i;const l=a?o:i.domain[0],h=s?r:i.domain[1];if(!(h>l))return i;const u=Array.isArray(e)?i.ticks.filter(t=>t>=l&&t<=h):c.scaleLinear().domain([l,h]).ticks(Math.max(1,Math.round(e)));return{domain:[l,h],ticks:u}}function PU(t,e){const n=Number("function"==typeof t?t(e):t);return!Number.isFinite(n)||n<=0?0:Math.min(n,.95*e)}function TU(t,e,n,i){const o=Math.max(0,Math.min(.95,i.inset)),r=t.endAngle-t.startAngle;return{innerRadius:e,outerRadius:n,startAngle:t.startAngle+r*o/2,endAngle:t.endAngle-r*o/2,padAngle:EU(i.padAngle,i.padPixel,Math.hypot(e,n))}}function OU(t,e,n){const i=t.schema.value,o=d.groups(e.map((t,e)=>({d:t,i:e})),t=>n(t.d,t.i)),r=new Map(o.map(([t],e)=>[t,e])),a=e.map((t,e)=>Number(i(t,e))),s=BU(e.map((t,e)=>({slot:r.get(n(t,e)),value:a[e]}))),c=o.map((t,e)=>Math.max(0,...s.filter(t=>t.slot===e).map(t=>t.y1)));return{bySlot:o,values:a,stack:s,tops:c}}function WU(t,e,n){return OU(t,e,n).tops}function jU(t,e){const{width:i,height:o}=wt(t),r=e.rows??t._filteredData??[],s=t.schema.aggs,{bySlot:c,values:l,stack:h,tops:u}=OU(t,r,e.slotOf),d=RU(u.concat(KY(t)),t.schema.levels,t.schema.domain),f=(t=>(Number(t.schema.startAngle)||0)*Math.PI/180)(t),m=NU(c.length,f,e.sweep).map((t,e)=>({...t,key:c[e][0]})),p=zU(t,m.map((t,i)=>{const o=c[i][1].map(t=>t.d);return{key:t.key,text:e.slotLabel(t.key,o),angle:t.angle,span:t.endAngle-t.startAngle,data:1===o.length?o[0]:n.merge(o,s)}}),Math.max(0,i-4),Math.max(0,o-4)),g=Math.max(0,p.radius),y=PU(t.schema.innerRadius,g),x=t=>FU(t,d.domain,y,g,e.scale),b={inset:e.slotPadding,padAngle:Number(t.schema.padAngle)||0,padPixel:Number(t.schema.padPixel)||0},k=r.map((t,e)=>{const n=h[e],i=m[n.slot];return{__d3plus__:!0,data:t,i:e,slot:i.key,value:l[e],y0:n.y0,y1:n.y1,arc:TU(i,x(n.y0),x(n.y1),b)}}),_=m.map(t=>TU(t,y,g,b)),v=LU(t,d,g,x,e.key),w=Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[];e.trackPaint&&w.push(function(t,e,n,i){return{type:"group",key:`${t}-tracks`,interactive:!1,children:n.map((n,o)=>({type:"path",key:`${t}-track-${e[o].key}`,interactive:!1,d:a.arcPath(n),arc:n,paint:i}))}}(e.key,m,_,e.trackPaint)),w.push(...v.rings,...DU(t,p,e.key),...v.labels);const M={inner:y,outer:g,levels:d,scale:e.scale,slots:m,tracks:_};return t.ctx.polar=M,{wedges:k,frame:M}}function HU(t){const e=t.schema.metric;return"function"==typeof e?(t,n)=>`${e(t,n)}`:(e,n)=>t._ids(e,n).join("-")}const IU=(t,e)=>WU(t,e,HU(t)),GU=({viz:t})=>{const e=t.schema.metric,{wedges:n}=jU(t,{key:"polararea",slotOf:HU(t),slotLabel:(n,i)=>"function"!=typeof e&&i.length?t._drawLabel(i[0],0):n,scale:"linear"===t.schema.radialScale?"linear":"sqrt",slotPadding:0,sweep:2*Math.PI});return{shapeData:n}},qU=({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i="function"==typeof t.schema.metric;return GY(t,n,"polararea",e=>{const n=t._drawLabel(e.data,e.i),o=p.formatAbbreviate(e.value,t.schema.locale);return i?`${n}, ${e.slot}, ${o}.`:`${n}, ${o}.`})},VU={name:"PolarArea",layoutStage:GU,emit:qU,insetRegion:Ay,chartTransform:t=>{const{width:e,height:n}=wt(t);return Mt(t,e,n)},chartBodyRect:t=>{const e=t.ctx.polar?.outer??0;return{x:-e,y:-e,width:2*e,height:2*e}},facet:YY(IU),ctx:{},fields:[{key:"discrete",default:"metric"},{key:"domain"},{key:"innerRadius",default:0},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"metric",coerce:t=>"function"==typeof t?t:"string"==typeof t?G(t):void 0},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"radialScale",default:"sqrt"},{key:"startAngle",default:0},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:G(t)},{key:"legend",coerce:"const",factory:ZT},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:HY},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Tc(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>{const[e,n]=IY(t);return{tbody:[[(n,i)=>{const o=t.schema.metric;return"function"==typeof o?`${o(n,i)}`:e()},n]]}}},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})}]};var KU=fk(VU);const YU=({viz:t})=>{const e=t._filteredData;if(!e)return{shapeData:[]};const i=t.schema.start,o=t.schema.end,a=t._id,s=t.schema.axisConfig,c="time"===s?.scale,l=e.map((t,e)=>({__d3plus__:!0,data:t,end:c?r.date(o(t,e)):o(t,e),i:e,id:a(t,e),start:c?r.date(i(t,e)):i(t,e)})).filter(t=>Number(t.end)-Number(t.start)>0).sort((t,e)=>Number(t.start)-Number(e.start));let h;if(t.schema.groupBy.length>1&&t._drawDepth>0){const e=[];for(let n=0;n<t._drawDepth;n++)e.push(e=>t.schema.groupBy[n](e.data,e.i));h=n.nestGroups(l,e)}else h=[{values:l}];const u=(t=>{let e=0;return t.forEach(t=>{let n=[];t.values.forEach(t=>{n=n.map(e=>!(!1!==e&&e<=t.start)&&e);const i=n.indexOf(!1);i<0?(t.lane=e+n.length,n.push(t.end)):(n[i]=t.end,t.lane=e+i)}),e+=n.length}),e})(h);return((t,e,n)=>{const i={domain:[d.min(e,t=>Number(t.start))??0,d.max(e,t=>Number(t.end))??0],...wt(t)},o=rj(t,i),r=aj(t,{...i,transform:{x:0,y:0},key:"priestley-axis"}),a=E.scaleBand().domain(d.range(0,n,1).map(String)).paddingInner(t.schema.paddingInner).paddingOuter(t.schema.paddingOuter).rangeRound([i.height-o.height-o.padding,o.padding]);t.ctx.xScale=r,t.ctx.yScale=a,t.ctx.bandWidth=a.bandwidth()})(t,l,u),{shapeData:l}},UU={name:"Priestley",layoutStage:YU,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=t.ctx.xScale,r=t.ctx.yScale,a=t.ctx.bandWidth,s=Hg(t,"Rect"),c=i.map((e,n)=>{const i=Tg(s.fill,e.data,n),c=Tg(s.stroke,e.data,n),l=Tg(s.strokeWidth,e.data,n),h=`${t._drawLabel(e.data,n)}, ${e.start} - ${e.end}.`,u=Math.abs(o(e.end)-o(e.start)),d=u>2?u-2:u,f=o(e.start)+(o(e.end)-o(e.start))/2-d/2,m=(r(String(e.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${e.id}-${n}`,transform:{x:f,y:m},x:0,y:-a/2,width:d,height:a,datum:e.data,paint:{fill:Og(s,e.data,n,i),stroke:c,strokeWidth:l},aria:{label:h}}}),l=e_({data:i,label:(e,n)=>t._drawLabel(i[n].data,n),x:(t,e)=>{const n=i[e];return o(n.start)+(o(n.end)-o(n.start))/2},y:(t,e)=>(r(String(i[e].lane))??0)+a/2,aes:(t,e)=>{const n=i[e],r=Math.abs(o(n.end)-o(n.start));return{width:r>2?r-2:r,height:a}},rotate:W(0),id:(t,e)=>`priestley-label-${i[e].id}-${e}`,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;return{x:-i/2,y:-o/2,width:i,height:o}},labelConfig:{fontColor:n=>{const i=n.data??n,o=Tg(s.fill,i.data,i.i);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",t.schema.colorDefaults)},fontResize:!1,textAnchor:"start",verticalAlign:"top",...Ig(t,"Rect")}}),h=jS(s,c,t=>[i[t].data,t]);return[...c,...h,...l]},setup:ej,ctx:{axis:(new Ga).align("end").orient("bottom"),axisTest:(new Ga).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},...tj(),{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t.schema.start(e,n),o=t.schema.end(e,n);return`${t._drawLabel(e,n)}, ${i} - ${o}.`}})}]};var XU=fk(UU);function QU(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function ZU(t,e,n){const i=Array.isArray(n)?n.map(String):[];return t.forEach((t,n)=>{const o=`${e(t,n)}`;i.includes(o)||i.push(o)}),i}function JU(t,e){return t.length>0&&`${e}`===t[0]?-1:1}function tX(t,e){return t.reduce((t,n,i)=>t+(QU(e(n,i))??0),0)}function eX(t,e,n){const i=new Map;return t.forEach((t,o)=>{const r=`${n(t,o)}`;i.set(r,(i.get(r)??0)+(QU(e(t,o))??0))}),i}function nX(t,e){const{category:n,side:i,value:o,comparison:r,frame:a}=e,s=new Map,c=new Map;return t.forEach((t,e)=>{const l=`${a?a(t,e):""}\0${n(t,e)}\0${i(t,e)}`;s.set(l,(s.get(l)??0)+Math.abs(QU(o(t,e))??0)),r&&c.set(l,(c.get(l)??0)+Math.abs(QU(r(t,e))??0))}),Math.max(0,...s.values(),...c.values())}function iX(t){return t>0?[-t,t]:[-1,1]}function oX(t,e=0){const n=Math.abs(t);return n<=2*e?0:n}function rX(t,e=()=>0){return n=>t("number"==typeof n?oX(n,e()):n)}function aX(t,e,n){const i=t.slice().sort((t,e)=>t.y-e.y);if(!i.length)return[];const o=n/2,r=[[e,i[0].y-o]];for(const t of i)r.push([t.x,t.y-o],[t.x,t.y+o]);return r.push([e,i[i.length-1].y+o]),r}function sX(t,e){const n=Array.from(new Set(t)).sort((t,e)=>t-e);let i=1/0;for(let t=1;t<n.length;t++)i=Math.min(i,n[t]-n[t-1]);return Number.isFinite(i)?i:e}function cX(t){return Array.isArray(t)?t.map(Number):"string"==typeof t&&t.trim()?t.trim().split(/[\s,]+/).map(Number):"number"==typeof t?[t]:void 0}function lX(t,e,n){return"function"==typeof t?t(e,n):t}function hX(t,e){const{left:n,right:i,top:o,height:r}=e,a=[[n,u.clamp(e.inner[0],n,i)],[u.clamp(e.inner[1],n,i),i]];return t.slice(0,2).map((t,e)=>({text:t,x:a[e][0],y:o,width:Math.max(0,a[e][1]-a[e][0]),height:r}))}function uX(t,e,n){const i=t.slice(),o=i.findIndex(t=>t.key===ZF);if(o>=0&&e.length){const t=i[o];"group"===t.type&&(i[o]={...t,children:[...t.children,...e]})}else i.push(...e);return i.push(...n),i}function dX(t,e){const n=t._xFunc,i=t._yFunc,o=t._plotArea;if(!(n&&i&&o&&t._filteredData?.length))return{outlines:[],overlays:[]};const r=e.comparison?function(t){const{sides:e,categories:n,data:i,category:o,side:r,comparison:a,divisor:s,x:c,y:l,fallbackStep:h,config:u}=t,d=t.inset??0,f=sX(n.map(t=>l(t)),h);return e.flatMap((t,h)=>{const m=new Map;if(i.forEach((e,n)=>{if(`${r(e,n)}`!==t)return;const i=QU(a(e,n));if(void 0===i)return;const c=`${o(e,n)}`;m.set(c,(m.get(c)??0)+Math.abs(i)/(s||1))}),!m.size)return[];const p=JU(e,t),g=c(p*d),y=n.map(t=>({y:l(t),x:c(p*((m.get(`${t}`)??0)+d))})),x={fill:"none",stroke:lX(u.stroke,t,h),strokeWidth:lX(u.strokeWidth,t,h),strokeOpacity:lX(u.strokeOpacity,t,h)},b=cX(lX(u.strokeDasharray,t,h));return b&&(x.strokeDasharray=b),[{type:"line",key:`pyramid-comparison-${h}`,points:aX(y,g,f),curve:"linear",paint:x,interactive:!1,interactionGroup:"axis"}]})}({sides:e.sides,categories:t._yAxis?.domain()??[],data:t._filteredData,category:t._y,side:e.side,comparison:e.comparison,divisor:e.divisor,x:n,y:i,fallbackStep:o.height,config:t.schema.comparisonConfig,inset:e.inset}):[],a=[n(-e.inset),n(e.inset)],s=t._plotInsetTop??0,c=e.showTitles&&s>0?function(t,e,n){return t.renderMode("compute").select(void 0).data(e.map((t,e)=>({...t,id:`pyramid-side-${e}`}))).config(n).render(),[Lr({type:"group",key:"pyramid-side-titles",children:t.toScene().children??[]})]}(e.titleBox,hX(e.labels,{left:o.x,right:o.x+o.width,inner:a,top:t._margin.top-(t._chartTransform?.y??t._margin.top),height:s}),{...t.schema.fontFamily?{fontFamily:t.schema.fontFamily}:{},...t.schema.sideTitleConfig}):[];return{outlines:r,overlays:[...e.gutter?e.gutter(a):[],...c]}}function fX(t,e,n){const{outlines:i,overlays:o}=dX(t,n);return function(t,e,n){if(!e.length&&!n.length)return t;const i=t.root.children.find(t=>"viz-chart-cells"===t.key),o=i&&"children"in i?i.children.find(t=>"viz-zoom"===t.key):void 0,r=o&&"children"in o?o.children.find(t=>"viz-chart-body"===t.key):void 0;return r&&"group"===r.type?(r.children=uX(r.children,e,n),t):t}(e,i,o)}function mX(t){return 1e-9*(t>0?t:1)}function pX(t){return(e,n)=>{BA(e,n);const i=t();if(i)for(const t of e)for(const e of t){const t=e[0]<0?-i:i;e[0]+=t,e[1]+=t}}}function gX(t,e,n){const i=i=>{const o=t[i];return"function"==typeof o?o(e,n):o},o=i("fontFamily")??s.fontFamily;return{family:s.fontFamilyStringify(o),size:Number(i("fontSize"))||12,weight:i("fontWeight")??400,padding:Number(i("padding"))||0}}function yX(t,e,n=r.textWidth){let i=0,o=0;return t.forEach((t,r)=>{const a=e[r],s=n(t,{"font-family":a.family,"font-size":a.size,"font-weight":a.weight});i=Math.max(i,s),o=Math.max(o,a.padding)}),Math.ceil(i+2*o)}function xX(t,e){const n=t.map(()=>!1);let i;t.forEach((t,o)=>{(void 0===i||Math.abs(t-i)>=e)&&(n[o]=!0,i=t)});const o=t.length-1;if(o>0&&!n[o]){n[o]=!0;for(let i=o-1;i>=0&&Math.abs(t[o]-t[i])<e;i--)n[i]=!1}return n}function bX(t){return{...t._yAxis?.shapeConfig()?.labelConfig??{},...t._yConfig?.shapeConfig?.labelConfig??{}}}function kX(t,e){const n=t._yConfig?.tickFormat;return"function"==typeof n?`${n(e)}`:`${e}`}const _X=t=>1.2*t.size+2*t.padding;function vX(t,e,n){const i=t._yFunc,[o,r]=n;if(!(i&&t._yAxis&&r>o))return[];const a=t._yAxis.domain()??[],s=bX(t),c=a.map(t=>i(t)),l=a.map((t,e)=>gX(s,t,e)),h=xX(c,Math.max(0,...l.map(_X))),u=sX(c,t._plotArea?.height??0),d=a.flatMap((e,n)=>{if(!h[n])return[];const i=Math.max(u,1.5*l[n].size),a=kX(t,e),{padding:s}=l[n];return[{id:`pyramid-category-${n}`,text:a,x:o+s,y:c[n]-i/2,width:Math.max(0,r-o-2*s),height:i,font:l[n],data:{id:e,text:a,tick:!0}}]});return function(t,e,n,i,o){t.renderMode("compute").select(void 0).data(e).config({fontColor:n,fontFamily:t=>t.font.family,fontSize:t=>t.font.size,fontWeight:t=>t.font.weight,textAnchor:"middle",verticalAlign:"middle",truncateWord:!0}).render();const r=t.toScene().children??[];return zr(r,i,o),[Lr({type:"group",key:"pyramid-categories",children:r})]}(e,d,"string"==typeof s.fontColor?s.fontColor:Oc(t),t._yAxis.schema.tickTooltip,Ar(t._yAxis))}function wX(t,e,n,i,o,r=n){if("center"!==t)return{x:{...o.x},y:{...o.y}};return{x:{break:[[-e,e],...Array.isArray(i)?Array.isArray(i[0])?i:[i]:[]],breakConfig:{gap:n,lines:!1,mask:!1,size:0,space:n,spaceMin:r,stroke:"transparent"}},y:{barConfig:{stroke:"transparent"},tickSize:0,ticks:[]}}}const MX=new WeakMap,SX=t=>t.ctx.pyramid,CX=t=>t.schema.groupBy[0],$X=(t,e)=>`${p.formatAbbreviate(100*e,t.schema.locale)}%`;function AX(t){const e=SX(t),n=function(t){return(e,n)=>{const i=SX(t),o=i.value(e,n),r=QU(o);if(void 0===r)return o;const a=t.schema.percent?i.total?Math.abs(r)/i.total:0:Math.abs(r);return JU(i.sides,CX(t)(e,n))*a}}(t);e.value=t._x,Object.defineProperty(t,"_x",{configurable:!0,enumerable:!0,get:()=>n,set:t=>{t!==n&&(e.value=t)}})}function zX(t,e){const n=t._xConfig,i=n.tickFormat;void 0===i||i===e.tickFormat?(n.tickFormat=e.tickFormat=rX(function(t){return t.schema.percent?e=>$X(t,e):e=>p.formatAbbreviate(e,t.schema.locale)}(t),()=>e.inset),e.wrapped.add(n.tickFormat)):"function"!=typeof i||e.wrapped.has(i)||(n.tickFormat=rX(i,()=>e.inset),e.wrapped.add(n.tickFormat))}function DX(t,e,n){const i=t._xConfig,o=void 0!==i.domain&&(r=i.domain,a=e.domain,Array.isArray(r)&&Array.isArray(a)&&r.length===a.length&&r.every((t,e)=>t===a[e]));var r,a;if(void 0!==i.domain&&!o)return;if(!t.schema.symmetric||gx(t,"x"))return o&&delete i.domain,void(e.domain=void 0);i.domain=e.domain=iX(n+e.inset);const s=t._plotAxisDefaults??{};t._plotAxisDefaults={...s,x:{...s.x,rounding:"outside"}}}function LX(t,e,n,i=t.schema.categoryPosition){var o;(o=e).restore??(o.restore=function(t){return{y:{barConfig:{...t._yAxis.barConfig()},tickSize:t._yAxis.tickSize()},x:{breakConfig:{spaceMin:void 0,...t._xAxis.breakConfig()}}}}(t));const r="center"===i;e.inset=r?mX(n):0;let a=0,s=0;if(r){const e=function(t){const e=t._y;return Array.from(new Set(t._data.map((t,n)=>e(t,n))))}(t),n=bX(t),i=e.map((t,e)=>gX(n,t,e));a=yX(e.map(e=>kX(t,e)),i),s=function(t,e){if(!e.length)return t;const n=Math.max(...e.map(t=>t.size)),i=Math.max(...e.map(t=>t.padding));return Math.min(t,Math.ceil(5*n+2*i))}(a,i)}const c=wX(i,e.inset,a,t.schema.xBreak,e.restore,s);t._plotAxisDefaults=c,e.gutter=r?{width:a,min:s,breaks:c.x.break.length}:void 0}function FX(t,e){return n=>{const i=SX(t),o={margin:{...t._margin},padding:{...t._padding}};e(n),function(t,e){const{gutter:n}=e;if(!n||"chrome"===t._facetStep||!t._filteredData?.length)return!1;const i=t._xAxis?._getRange()??[];return!(i.length<2||!i.every(Number.isFinite))&&null===ro(Math.abs(i[i.length-1]-i[0]),n.breaks,n.width,n.min)}(t,i)&&(LX(t,i,i.extent,"left"),DX(t,i,i.extent),t._margin=o.margin,t._padding=o.padding,e(n))}}function NX(t){const e=SX(t);e.sides=ZU(t._data,CX(t),t.schema.sides);const n=t._legendData||t._filteredData||[];e.total=tX(n,e.value);const i=t.schema.comparison;e.comparisonTotal=i?tX(n,i):0,zX(t,e);const o=e.extent=function(t,e){const n=!!t._axisPersist,i=n?t._data:t._filteredData,o=n&&t.schema.time?t.schema.time:void 0,r=(e,n)=>{if(!t.schema.percent)return e;const r=o?eX(i,e,o):void 0;return(t,i)=>{const a=r?r.get(`${o(t,i)}`)??0:n,s=QU(e(t,i));return void 0!==s&&a?s/a:0}},a=t.schema.comparison;return nX(i,{category:t._y,side:CX(t),value:r(e.value,e.total),comparison:a?r(a,e.comparisonTotal):void 0,frame:o})}(t,e);LX(t,e,o),DX(t,e,o),function(t,e){const n=t._xConfig,i=t._xTitle;t.schema.percent?void 0!==n.title&&n.title!==i&&n.title!==e.title||(n.title=e.title=t.schema.translate("Percent of Total")):void 0!==e.title&&(n.title===e.title&&(n.title=i),e.title=void 0)}(t,e),t._plotInsetTop=function(t){if(!t.schema.sideTitles)return 0;const e=t.schema.sideTitleConfig,n="number"==typeof e.fontSize?e.fontSize:14,i="number"==typeof e.padding?e.padding:0;return Math.ceil(1.2*n+2*i)}(t)}function BX(t,e){const n=CX(t);return e.map(e=>{const i=t._data.findIndex((t,i)=>`${n(t,i)}`===e);return i>=0?t._drawLabel(t._data[i],i,0):e})}function EX(t){const e=SX(t);return{sides:e.sides,labels:BX(t,e.sides),side:CX(t),comparison:t.schema.comparison,divisor:t.schema.percent?e.comparisonTotal:1,titleBox:e.titleBox,showTitles:!!t.schema.sideTitles,inset:e.inset,gutter:e.inset?n=>vX(t,e.labelBox,n):void 0}}const RX={name:"Pyramid",paintDriven:!0,thresholdFunction:(t,e)=>e,defaults:{groupPadding:1},setup:t=>{t.ctx.pyramid={value:t._x,sides:[],total:0,comparisonTotal:0,wrapped:new WeakSet,titleBox:new ei,inset:0,extent:0,labelBox:new ei},AX(t),t._stackOffset=pX(()=>SX(t).inset),t._stackGroup=()=>"group",t._stackOrder=CV((e,n)=>t._ids(e,n).slice(1,t._drawDepth+1).join("_")),t.schema.color=(e,n)=>{const i=t.schema.groupBy;return i[Math.max(0,Math.min(t._drawDepth??0,i.length-1))](e,n)},t.schema.shapeConfig.Bar={...t.schema.shapeConfig.Bar,label:!1},t.schema.shapeConfig.ariaLabel=(e,n)=>{const i=t._xConfig.tickFormat;return`${t._drawLabel(e,n)}, ${t._y(e,n)}: ${i(t._x(e,n))}.`};const e=t._preDraw.bind(t);t._preDraw=()=>{e(),NX(t)},t._draw=FX(t,t._draw.bind(t))},decorateScene:(t,e)=>t._facetPanels?e:fX(t,e,EX(t)),facet:{scene:(t,e)=>function(t,e,n){const{outlines:i,overlays:o}=dX(t,n);return i.length||o.length?uX(e,i,o):e}(t,e,EX(t))},ctx:{},fields:[{key:"baselineBreak",default:!1},{key:"categoryPosition",default:"center"},{key:"comparison",coerce:t=>{if("string"!=typeof t)return t||void 0;const e=G(t);return MX.set(e,t),e}},{key:"comparisonConfig",merge:!0,factory:t=>({stroke:()=>Oc(t),strokeDasharray:"4 3",strokeOpacity:1,strokeWidth:1.5})},{key:"discrete",default:"y"},{key:"percent",default:!1},{key:"sideTitles",default:!0},{key:"sideTitleConfig",merge:!0,factory:t=>({fontColor:()=>Oc(t),fontSize:14,fontWeight:600,padding:2,textAnchor:"middle",verticalAlign:"middle"})},{key:"sides"},{key:"stacked",default:!0},{key:"symmetric",default:!0},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>function(t,e,n){const i=SX(t),o=QU(i.value(e,n));if(void 0===o)return[];const r=[],a=!!t.schema.percent;if(a){const e=t._xKey;r.push(["string"==typeof e?e:t.schema.translate("Value"),p.formatAbbreviate(Math.abs(o),t.schema.locale)])}else i.total&&r.push([t.schema.translate("Percent of Total"),$X(t,Math.abs(o)/i.total)]);const s=t.schema.comparison,c=s?QU(s(e,n)):void 0;if(s&&void 0!==c){const e=MX.get(s)??t.schema.translate("Comparison");r.push([e,a?$X(t,i.comparisonTotal?Math.abs(c)/i.comparisonTotal:0):p.formatAbbreviate(Math.abs(c),t.schema.locale)])}return r}(t,e,n)})}]};var PX=fk(RX,tB);const TX=new WeakMap;function OX(t){return t&&"object"==typeof t?TX.get(t):void 0}function WX(t,e){const n=t.schema.levelFormat;return"function"==typeof n?`${n(e)}`:p.formatAbbreviate(e,t.schema.locale)}function jX(t,e,n,i){const o=[];return e.points.forEach((r,a)=>{const s=e.arr[a],c=Number(Tg(i.r,s,n));if(!(c>0))return;const l=e.metrics[a];o.push({type:"circle",key:`radar-point-${e.id}-${l}`,cx:0,cy:0,r:c,transform:{x:r.x,y:r.y},datum:s,hoverKeys:{metric:[l]},paint:Wg(i,s,n),aria:{label:`${t._drawLabel(s,n)}, ${l}: ${WX(t,e.values[a])}.`}})}),o}const HX=2*Math.PI,IX=({viz:t})=>{const{width:e,height:i}=wt(t),o=t.schema.metric,a=t.schema.value,c=t._filteredData,l=d.groups(c,o),h=d.groups(c,t._id,o),u=h.flatMap(([,t])=>t.map(([,t])=>d.sum(t,(t,e)=>a(t,e)))),f=cU(u,t.schema.levels),{domain:m}=f;if(!u.length||m[0]===m[1])return t.ctx.groupData=[],t.ctx.pathConfig={},{shapeData:[]};const{radius:p,polarAxis:g}=function(t,e,i,o){const a=e.length,c=t.schema.aggs,l=t.schema.outerPadding,h=e.map(([e,i],o)=>{const r=n.merge(i,c),s=pU(t,String(e),r,o);return{key:e,data:r,font:s,text:String(e),angle:mU/a*o,lineHeight:s.lineHeight}}),u=Math.min(i,o)/2-2;let d,f=0,m=h.map(()=>({wrapWidth:0}));const p="auto"===l?aU(t,h,u):null;if(p&&({radius:f,curves:d}=p),"number"==typeof l)f=Math.max(0,Math.min(i,o)/2-l),m=h.map(()=>({wrapWidth:l}));else if(!d){const t=QY({labels:h,width:i-4,height:o-4,measure:({text:t,font:e})=>r.textWidth(t,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":e.fontWeight}),wrap:({text:t,font:e},n,i)=>s.textWrap().fontFamily(e.fontFamily).fontSize(e.fontSize).fontWeight(e.fontWeight).lineHeight(e.lineHeight).width(n).height(e.lineHeight*i).maxLines(i)(t)});f=t.radius,m=t.labels}d??(d=rU(t,h,f,u));const g=h.map(({key:t,data:e,font:n,angle:i},o)=>{const r=2*n.lineHeight,s=m[o].wrapWidth,c=parseInt(String(360-360/a*o/90),10)%4+1;let l=360/a*o,h="start",u=10;return 2!==c&&3!==c||(u=-s-10,h="end",l+=180),{__d3plus__:!0,data:e,i:o,id:t,key:t,angle:l,textAnchor:h,labelBounds:{x:u,y:-r/2,width:s,height:r},rotateAnchor:[-u,r/2],x:f*Math.cos(i),y:f*Math.sin(i),labelCurve:d[o]??void 0}}).sort((t,e)=>Number(t.key)-Number(e.key));return{radius:f,polarAxis:g}}(t,l,e,i);(Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[]).push(...yU(t,f,p),...gU(t,g),...xU(t,f,p));const y=l.length,x=new Map(l.map(([t],e)=>[t,e])),b=h.map(([e,i])=>{const o=i.slice().sort((t,e)=>x.get(t[0])-x.get(e[0])),r=o.map(([,t])=>d.sum(t,(t,e)=>a(t,e))),s=o.map(([t],e)=>{const n=lU(r[e],m,p),i=HX/y*x.get(t);return{x:n*Math.cos(i),y:n*Math.sin(i)}}),c=`M ${s[0].x} ${s[0].y} ${s.map(t=>`L ${t.x} ${t.y}`).join(" ")} L ${s[0].x} ${s[0].y}`,l=t.schema.aggs,h=o.map(([t])=>t),u=o.map(([,t],e)=>{const i=n.merge(t,l);return function(t,e){TX.set(t,e)}(i,{metric:h[e],value:r[e]}),i});return{__d3plus__:!0,arr:u,id:e,metrics:h,values:r,points:s,d:c,data:n.merge(u,l)}});return t.ctx.groupData=b,t.ctx.pathConfig=Hg(t,"Path"),{shapeData:b}},GX={name:"Radar",layoutStage:IX,emit:({viz:t})=>{const e=t.ctx.groupData,n=t.ctx.pathConfig;if(!e||!n||!e.length)return[];const i=Hg(t,"Circle"),o=[];for(let r=0;r<e.length;r++){const a=e[r],s=a.data??a,c=Tg(n.fillOpacity,s,r),l={...Wg(n,s,r),..."number"==typeof c?{fillOpacity:c}:{}},h=jX(t,a,r,i),u={type:"path",key:`radar-${a.id}`,d:a.d,datum:s,hoverKeys:{metric:a.metrics??[]},paint:l,interactive:!h.length,aria:{label:`${t._drawLabel(s,r)}.`}};o.push(u);const d=n.backgroundImage?WS(n,u,s,r):null;d&&o.push(d),o.push(...h)}return o},chartTransform:t=>{const{width:e,height:n}=wt(t);return Mt(t,e,n)},chartBodyRect:t=>{const{width:e,height:n}=wt(t);return{x:-e/2,y:-n/2,width:e,height:n}},pointMark:(t,e)=>mu(e),setup:function(t){const e=t.schema.on.mouseenter;t.schema.on.mouseenter=(n,i,o,r)=>{e&&e.call(t,n,i,o,r);const a=OX(n),s=t._hover;a&&"function"==typeof s&&(t._hoverFocus={hover:s,rows:[{metric:a.metric}]})}},facet:{aspect:1},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabelConfig",default:{},merge:!0},{key:"levelLabels",default:!0},{key:"levels",default:6},{key:"metric",default:H("metric"),coerce:t=>"function"==typeof t?t:G(t)},{key:"outerPadding",default:"auto"},{key:"shape",default:W("Path"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({Path:{fillOpacity:.25,stroke:(e,n)=>{const i=t.schema.shapeConfig,o=i.Path?.fill??i.fill;return"function"==typeof o?o(e,n):o},strokeWidth:2},Circle:{r:3}})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:e=>function(t,e){const n=OX(e);return n?[[`${n.metric}`,WX(t,n.value)]]:[]}(t,e)})},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:G(t)},{key:"axisConfig",merge:!0,factory:t=>({barConfig:{stroke:()=>Oc(t),strokeWidth:1},gridConfig:{stroke:()=>Wc(t),strokeWidth:1},shapeConfig:{fill:W("none"),labelConfig:{fontColor:()=>Oc(t),fontResize:!1,padding:0,textAnchor:t=>t.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Oc(t),strokeWidth:W(1)}})}]};var qX=fk(GX);function VX(t,e,n,i){const o=Math.max(0,Math.floor(t));if(!(o&&n>e))return[];const r=(n-e)/o,a=Math.max(0,Math.min(.95,i));return Array.from({length:o},(t,e)=>{const i=n-e*r;return{inner:i-r*(1-a),outer:i}})}function KX(t,e,n,i=0){if(!(t>0&&e>0))return 0;let o=e;return n<Math.PI/2&&(o=Math.min(o,t*Math.tan(Math.max(0,n)))),Math.max(0,o-i)}function YX(t,e,n){const i=Math.sin(t),o=-Math.cos(t),r=i-n*Math.cos(t),a=o-n*Math.sin(t);return FB(LB(t,e),{x0:Math.min(i,r),x1:Math.max(i,r),y0:Math.min(o,a),y1:Math.max(o,a)})}const UX=(t,e)=>Tg((t.schema.axisConfig.shapeConfig?.labelConfig??{}).fontColor,e,0)??Oc(t);function XX(t){const e=Number(t.schema.maxAngle??270)||270;return Math.max(1,Math.min(360,e))*Math.PI/180}const QX=Math.PI/6;function ZX(t){return 2*Math.PI-XX(t)>=QX-1e-9}function JX(t,e){const n=ZX(t);return e.map((e,i)=>{const o=lT(t,e,i);return"along"===o||"inside"!==o&&"outside"!==o&&!n})}function tQ(t){if("angle"===t.schema.discrete)return!1;const e=t._filteredData??[];return e.length>1&&JX(t,e).every(Boolean)}function eQ(t,e){const n=t.schema.axisConfig.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?Math.min(n,.9*e):Math.max(8,Math.min(14,.6*e))}function nQ(t,e,n){const i=eQ(t,n);return e.map((e,n)=>{const o=t._drawLabel(e,n),a=pU(t,o,e,n),s=r.textWidth(o,{"font-family":a.fontFamily,"font-size":i,"font-weight":a.fontWeight});return{d:e,i:n,text:o,font:a,size:i,width:s}})}function iQ(t,e){const{width:n,height:i}=wt(t),o=t.schema.value,s=e.map((t,e)=>Number(o(t,e))),c=(Number(t.schema.startAngle)||0)*Math.PI/180,l=c+XX(t),h=ZX(t),u=JX(t,e),d=t.schema.ticks,f="number"==typeof d?d:AB(c,l),m=$B(s.concat(KY(t)),[],t.schema.domain,f),p=zB(m,d,!1,f).major,g=t=>CB(t,m,c,l),y=function(t,e,n){const i=t.schema.tickFormat,o={},a=e.map((e,a)=>{const s=`${i(e)}`,c=pU(t,s,o,a),l={"font-family":c.fontFamily,"font-size":c.fontSize,"font-weight":c.fontWeight};return{t:e,text:s,font:c,angle:n(e),width:r.textWidth(s,l)}}),s=UX(t,o);return{margin:a.length?Math.max(...a.map(t=>Math.max(t.width,t.font.fontSize)))+6:0,nodes:t=>{const e=a.map(e=>kU(e.angle,t,e.width,e.font.fontSize)),n=e.length,i=n>1&&wU(e[0],e[n-1])?n-1:n;return a.slice(0,i).map((t,n)=>{const i=e[n];return{type:"text",key:`radialbar-tick-${n}`,interactive:!1,x:0,y:0,transform:{x:i.x+i.width/2,y:i.y+i.height/2},lines:[{text:t.text,x:0,y:0,width:t.width}],font:{family:t.font.fontFamily,size:t.font.fontSize,weight:t.font.fontWeight,anchor:"middle",baseline:"middle"},paint:{fill:s}}})}}}(t,p,g),{outer:x,cx:b,cy:k}=function(t,e,n,i){const{width:o,height:r,margin:a,start:s,end:c}=i,l=Math.max(0,o-2*a),h=Math.max(0,r-2*a),u=Number(t.schema.trackPadding)||0,d=t=>NB(l,h,YX(s,c,t));let f=d(0);const m=e.some((t,e)=>!n[e]);for(let i=0;i<2&&m&&f.radius>0;i++){const i=PU(t.schema.innerRadius,f.radius),o=VX(e.length,i,f.radius,u)[0];f=d((Math.max(0,...nQ(t,e,o.outer-o.inner).filter((t,e)=>!n[e]).map(t=>t.width))+6)/f.radius)}return{outer:f.radius,cx:f.cx-l/2,cy:f.cy-h/2}}(t,h?e:[],u,{width:Math.max(0,n-4),height:Math.max(0,i-4),margin:y.margin,start:c,end:l}),_=PU(t.schema.innerRadius,x),v={inner:_,outer:x,domain:m,start:c,end:l,ticks:p,cx:b,cy:k},w=VX(e.length,_,x,Number(t.schema.trackPadding)||0),M=g(Math.max(m[0],Math.min(m[1],0))),S=e.map((e,n)=>{const i=g(s[n]);return{__d3plus__:!0,data:e,i:n,slot:t._ids(e,n).join("-"),value:s[n],y0:0,y1:s[n],arc:{innerRadius:w[n].inner,outerRadius:w[n].outer,startAngle:Math.min(M,i),endAngle:Math.max(M,i)}}}),C=Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[];return!1!==t.schema.track&&C.push(function(t,e,n,i){const o=t.schema.trackConfig??{};return{type:"group",key:"radialbar-tracks",interactive:!1,children:e.map((e,r)=>{const s={innerRadius:n[r].inner,outerRadius:n[r].outer,startAngle:i.start,endAngle:i.end};return{type:"path",key:`radialbar-track-${t._ids(e,r).join("-")}`,interactive:!1,d:a.arcPath(s),arc:s,paint:Wg(o,e,r)}})}}(t,e,w,v)),C.push(...function(t,e,n){const i=uU({},t.schema.axisConfig.gridConfig),o=e.ticks.map((t,o)=>{const r=n(t),[a,s]=[Math.sin(r),-Math.cos(r)];return{type:"path",key:`radialbar-grid-${o}`,interactive:!1,d:`M${e.inner*a},${e.inner*s}L${e.outer*a},${e.outer*s}`,paint:fU(i,{value:t,r:e.outer},o)}});return o.length?[{type:"group",key:"radialbar-grid",interactive:!1,children:o}]:[]}(t,v,g)),p.length&&C.push({type:"group",key:"radialbar-ticks",interactive:!1,children:y.nodes(x)}),h&&C.push(...function(t,e,n,i,o){const r=2*Math.PI-(n.end-n.start),a=i.length?i[0].outer-i[0].inner:0,s=[];if(nQ(t,e,a).forEach(({d:e,i:a,text:c,font:l,size:h})=>{if(o[a])return;const u=i[a],d=(u.inner+u.outer)/2,f=KX(d,n.outer,r,6);if(h<6||f<2*h)return;const m=cE(c,l.fontFamily,h,f,6,l.fontWeight);s.push({type:"text",key:`radialbar-label-${t._ids(e,a).join("-")}`,interactive:!1,x:0,y:0,transform:{x:-6,y:-d},lines:[{text:m.text,x:0,y:0,width:m.width}],font:{family:l.fontFamily,size:m.size,weight:l.fontWeight,anchor:"end",baseline:"middle"},paint:{fill:UX(t,e)}})}),!s.length)return[];const c=180*n.start/Math.PI;return[{type:"group",key:"radialbar-labels",interactive:!1,transform:c?{rotate:c}:void 0,children:s}]}(t,e,v,w,u)),t.ctx.polar=v,{wedges:S,frame:v}}function oQ(t){const e=(t._filteredData??[]).slice(),n=t.schema.sort;return"function"==typeof n?e.sort(n):e}const rQ=t=>(e,n)=>t._ids(e,n).join("-"),aQ=(t,e)=>{if("angle"===t.schema.discrete)return WU(t,e,rQ(t));const n=t.schema.value;return e.map((t,e)=>Number(n(t,e)))},sQ=({viz:t})=>{const e=oQ(t);if("angle"===t.schema.discrete){const n=Number(t.schema.maxAngle??360)||360,i=t.schema.trackConfig??{},{wedges:o}=jU(t,{key:"radialbar",rows:e,slotOf:rQ(t),slotLabel:(e,n)=>n.length?t._drawLabel(n[0],0):"",scale:"linear",slotPadding:Number(t.schema.trackPadding)||0,sweep:Math.max(1,Math.min(360,n))*Math.PI/180,trackPaint:!1!==t.schema.track&&e.length?Wg(i,e[0],0):void 0});return{shapeData:o}}const{wedges:n}=iQ(t,e);return{shapeData:n}};function cQ(t,e,n,i){const o=t.outerRadius-t.innerRadius,r=Math.min(3,(o-i)/2);if(r<0)return null;const a=(t.innerRadius+t.outerRadius)/2-i/2;if(!(a>0))return null;const s=(n(i)+2*eT(r,i))/a+1e-6,c=e=>aT({...t,startAngle:e,endAngle:e+s},n,{fontMin:i,fontMax:i,padding:r,minRadius:0,truncate:!1});if(t.endAngle-t.startAngle>=s){const e=c(t.startAngle);if(e)return{fit:e,inBar:!0}}if(t.endAngle+s<=e+1e-9){const e=c(t.endAngle);if(e)return{fit:e,inBar:!1}}return null}function lQ(t,n,i){const o=n.map(t=>t.data),r=JX(t,o),a=t._alongStats;if(a&&(a.series+=n.length,a.requested+=r.filter(Boolean).length),!r.some(Boolean))return[];const s=n.length?n[0].arc.outerRadius-n[0].arc.innerRadius:0,c=nQ(t,o,s),l=Hg(t,"Path"),h=t.schema.trackConfig??{},u=Ig(t,"Path").fontColor,d=[];n.forEach((n,o)=>{const a=c[o];if(!r[o]||!a.text)return;const s={fontFamily:a.font.fontFamily,fontWeight:a.font.fontWeight},f=cQ(n.arc,i.end,WP(a.text,s),a.size);if(!f)return;const m=f.inBar?Wg(l,n.data,n.i).fill:!1===t.schema.track?void 0:Wg(h,n.data,n.i).fill,p=Tg(u,n.data,n.i),g="string"==typeof p?p:"string"==typeof m?e.colorContrast(m,t.schema.colorDefaults):Oc(t);d.push({key:`radialbar-label-curved-${t._ids(n.data,n.i).join("-")}`,text:a.text,fit:f.fit,color:g,datum:n.data,index:n.i})});const f=c[0]?.font,m=HP(t,d,f?{fontFamily:f.fontFamily,fontWeight:f.fontWeight}:{});return a&&(a.placed+=m.length),m}const hQ=({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i="angle"===t.schema.discrete,o=t.ctx.polar;return[...n.map((e,n)=>{const r=i?{...o.tracks[n],padAngle:0}:{innerRadius:e.arc.innerRadius,outerRadius:e.arc.outerRadius,startAngle:o.start,endAngle:o.end};return{type:"path",key:`radialbar-${t._ids(e.data,e.i).join("-")}-${e.slot}::hit`,d:a.arcPath(r),datum:e.data,index:e.i,paint:{fill:"transparent"}}}),...GY(t,n,"radialbar",e=>`${t._drawLabel(e.data,e.i)}, ${p.formatAbbreviate(e.value,t.schema.locale)}.`),...i?[]:lQ(t,n,o),...XT(t,{radius:o.inner},t.schema.value)]},uQ={name:"RadialBar",layoutStage:sQ,emit:hQ,insetRegion:Ay,setup:t=>{t._defaultLegend=t.schema.legend,t._alongLabelsPossible=tQ},chartTransform:t=>{const{width:e,height:n}=wt(t),i=Mt(t,e,n),o=t.ctx.polar;return{x:(i.x??0)+(o?.cx??0),y:(i.y??0)+(o?.cy??0)}},chartBodyRect:t=>{const e=t.ctx.polar?.outer??0;return{x:-e,y:-e,width:2*e,height:2*e}},facet:YY(aQ),ctx:{},fields:[{key:"centerLabel",default:!1},{key:"centerLabelConfig",merge:!0,factory:KT},{key:"discrete",default:"radius"},{key:"domain"},{key:"innerRadius",default:t=>t/4},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"maxAngle"},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"sort",factory:t=>(e,n)=>{const i=t.schema.value;return i(n)-i(e)}},{key:"startAngle",default:0},{key:"tickFormat",factory:t=>e=>p.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"track",default:!0},{key:"trackPadding",default:.25},{key:"value",default:H("value"),coerce:t=>"function"==typeof t?t:G(t)},{key:"legend",coerce:"const",factory:t=>ZT(t,t=>"angle"===t.schema.discrete||ZX(t))},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:t=>st(HY(t),{gridConfig:{stroke:()=>!1===t.schema.track?Wc(t):Tc(t)}})},{key:"trackConfig",merge:!0,factory:t=>({fill:()=>nH(t).track})},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Tc(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[IY(t)]})}]};var dQ=fk(uQ);const fQ=2*Math.PI,mQ=(t,e,n,i,o)=>{var r;const a=t.schema.columnConfig,s=a.shapeConfig?.labelConfig??{},c=t=>!(a.labels instanceof Array)||a.labels.includes(t),l=new Map;for(const t of n)l.has(t.column)||l.set(t.column,t.data??t);const h=e.map(t=>({key:t,data:l.get(t)??{column:t}})),{radius:u,curves:f}=((t,e,n,i,o,r)=>{const a=e.map(({key:o,data:r},a)=>{const s=n(o)?`${o}`:"";return{text:s,data:r,angle:a/e.length*fQ-Math.PI/2,font:pU(t,s,r,a,i)}});return aU(t,a,o)??{radius:r,curves:rU(t,a,r,o)}})(t,h,c,s,Math.max(0,Math.min(i,o)/2-2),Math.max(0,d.min([o-100,i-200])??0)/2),m=((t,e)=>{const n=t.slice().reverse();n.unshift(n.pop());const i=n.length;return n.map((t,n)=>{const o=n/i*fQ,r=Math.round(180*o/Math.PI),a=Math.floor((r+90)/90%4+1),s=[0,180].includes(r)?-50:[2,3].includes(a)?-100:0,c=[90,270].includes(r)?-25:[2,1].includes(a)?-50:0;return{key:t,angle:r,quadrant:a,radians:o,x:e*Math.sin(o+Math.PI)+s,y:e*Math.cos(o+Math.PI)+c}})})(e,u),p=sU(t,h.flatMap(({key:t,data:e},n)=>{const i=f[n];return i?[{key:`radialmatrix-column-${t}`,data:e,i:n,curve:i,hoverMatch:{field:"column",value:t}}]:[]}),s),g=new Set(h.filter(({key:e,data:n},i)=>c(e)&&!f[i]&&"along"!==lT(t,n,i)).map(t=>t.key)),y=((t,e,n,i,o)=>{if(!e.length)return[];const r=t.ctx.columnLabels;r.renderMode("compute").select(void 0).data(e).x(t=>t.x).y(t=>t.y).text(t=>t.key).width(n).height(i).config(o).render();const a=r.toScene()?.children??[];for(const t of a){const e=t.datum?.key;void 0!==e&&(t.hoverMatch={field:"column",value:e})}return a})(t,m.filter(t=>g.has(t.key)),100,50,s),x=[...p,...IP(y,rM(p))];return x.length&&((r=t)._chartScene||(r._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:x}),{radius:u,labelData:m}},pQ=({viz:t})=>{const{rowValues:e,columnValues:n,shapeData:i}=BV.bind(t)(t._filteredData),{width:o,height:r}=wt(t);if(!e.length||!n.length)return t.ctx.radialMatrixWidth=o,t.ctx.radialMatrixHeight=r,{shapeData:[]};t.ctx.radialMatrixWidth=o,t.ctx.radialMatrixHeight=r;const{radius:a,labelData:s}=mQ(t,n,i,o,r),c=(0,t.schema.innerRadius)(a),l=(a-c)/e.length,h=s.length>1?s[1].radians-s[0].radians:fQ,u=e.slice().reverse(),d=new Map;u.forEach((t,e)=>d.set(t,e));const f=new Map;n.forEach((t,e)=>f.set(t,e));const m=t.schema.cellPadding,p=R.arc().padAngle(m/a).innerRadius(t=>c+(d.get(t.row)??0)*l+m/2).outerRadius(t=>c+((d.get(t.row)??0)+1)*l-m/2).startAngle(t=>s[f.get(t.column)??0].radians-h/2).endAngle(t=>s[f.get(t.column)??0].radians+h/2);return t.ctx.arcData=p,{shapeData:i}},gQ=(t,e)=>`${t}`.localeCompare(`${e}`),yQ={name:"RadialMatrix",layoutStage:pQ,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.arcData,o=Hg(t,"Path"),r=t.schema.colorScale,a=n.map((e,n)=>{const a=Tg(o.fill,e,n),s=Tg(o.stroke,e,n),c=Tg(o.strokeWidth,e,n),l=r?`, ${r(e.data??e,n)}`:"";return{type:"path",key:`rm-${t._ids(e,n).join("-")}`,d:i(e),datum:e,paint:{fill:Og(o,e,n,a),stroke:s,strokeWidth:c},aria:{label:`${e.row}, ${e.column}${l}.`}}});return[...a,...jS(o,a,t=>[n[t],t])]},chartTransform:t=>Mt(t,t.ctx.radialMatrixWidth,t.ctx.radialMatrixHeight),chartBodyRect:t=>{const e=t.ctx.radialMatrixWidth??0,n=t.ctx.radialMatrixHeight??0;return{x:-e/2,y:-n/2,width:e,height:n}},setup:t=>{const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),uh(o)||uh(n))return;const a=ee.bind(t)("row",n,i),s=ee.bind(t)("column",n,i),c=(e,n)=>ee.bind(t)("row",e,n)===a||ee.bind(t)("column",e,n)===s;t._hoverFocus={hover:c,rows:[{row:a,column:s}]},t.hover(c)}},facet:{aspect:1},ctx:{columnLabels:new ei},fields:[{key:"cellPadding",default:2},{key:"column",default:H("column"),coerce:t=>"function"==typeof t?t:G(t)},{key:"row",default:H("row"),coerce:t=>"function"==typeof t?t:G(t)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:gQ},{key:"rowSort",default:gQ},{key:"innerRadius",default:t=>t/5,coerce:t=>"function"==typeof t?t:W(t)},{key:"columnConfig",merge:!0,factory:t=>({shapeConfig:{labelConfig:{fontColor:()=>Oc(t),padding:5,textAnchor:t=>[0,180].includes(t.angle)?"middle":[2,3].includes(t.quadrant)?"end":"start",verticalAlign:t=>[90,270].includes(t.angle)?"middle":[2,1].includes(t.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:t=>(e,n)=>`${ee.bind(t)("row",e,n)} / ${ee.bind(t)("column",e,n)}`}]};var xQ=fk(yQ);function bQ(t,e={}){const n=t.filter(t=>Number.isFinite(t)).sort((t,e)=>t-e);if(!n.length)return null;const i=u.kernelDensity(n,e);return{values:n,n:n.length,min:n[0],q1:d.quantileSorted(n,.25),median:d.quantileSorted(n,.5),q3:d.quantileSorted(n,.75),max:n[n.length-1],mean:d.mean(n),curve:i,peak:i.reduce((t,e)=>Math.max(t,e[1]),0)}}function kQ(t,e){const n=new Map;t.forEach((t,i)=>{if(!t)return;const o=e.value(t,i),r=null==o||""===o?NaN:Number(o);if(!Number.isFinite(r))return;const a=e.key(t,i);let s=n.get(a);s||n.set(a,s={first:t,rows:[],values:[]}),s.rows.push(t),s.values.push(r)});const i=[];return n.forEach((t,n)=>{const o=bQ(t.values,e.density);o&&i.push({key:n,first:t.first,summary:{...o,rows:t.rows,observed:t.values}})}),i}function _Q(t,e="area"){if("width"===e)return t=>t.peak>0?1/t.peak:0;if("count"===e){const e=t.reduce((t,e)=>Math.max(t,e.peak*e.n),0);return t=>e>0?t.n/e:0}const n=t.reduce((t,e)=>Math.max(t,e.peak),0);return()=>n>0?1/n:0}function vQ(t,e){const n=t.slice();if("ascending"!==e&&"descending"!==e)return n;const i="ascending"===e?1:-1;return n.map((t,e)=>({g:t,i:e})).sort((t,e)=>i*(t.g.summary.median-e.g.summary.median)||t.i-e.i).map(({g:t})=>t)}function wQ(t,e){if(!t.length||e<t[0][0]||e>t[t.length-1][0])return 0;let n=0,i=t.length-1;for(;i-n>1;){const o=n+i>>1;t[o][0]<=e?n=o:i=o}const[o,r]=t[n],[a,s]=t[i];return a===o?Math.max(r,s):r+(s-r)*(e-o)/(a-o)}const MQ="__d3plusDensity";function SQ(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function CQ(t){const e=SQ(t);return e?e[MQ]:void 0}function $Q(t){return`density-${t.id}`}function AQ(t){const e=t.schema.groupBy,n=[t.schema.facet,t.schema.time].filter(Boolean);return(t,i)=>[...e,...n].map(e=>`${e(t,i)}`).join("\0")}function zQ(t){const e=t.ctx.density;t._data!==e.rows&&(e.raw=t._data),t._sourceData=e.raw;const n=e.layout.valueAxis(t),i="x"===n?"y":"x",o=t.schema.groupBy,r=aq(t.schema.value),a=kQ(e.raw,{value:t.schema.value,key:AQ(t),density:t.schema.densityConfig}),s=vQ(a,t.schema.medianSort),c=_Q(a.map(t=>t.summary),t.schema.densityScale),l=a.every(t=>o.every(e=>void 0===e(t.first,0))),h=r??t.schema.translate("Value");e.categories=new Map,e.rows=t._data=s.map((t,a)=>{const s={...t.first};r&&delete s[r],l&&(s.id=h);const u=l?h:`${o[0](t.first,0)}`;return e.categories.has(u)||e.categories.set(u,e.categories.size),s[i]=u,s[n]=t.summary.median,s[MQ]={summary:t.summary,order:a,scale:c(t.summary)},s});const u={x:t._xConfig,y:t._yConfig};e.titleAxis&&e.titleAxis!==n&&sq(u[e.titleAxis],e.title,void 0),sq(u[n],e.titleAxis===n?e.title:void 0,r),e.title=r,e.titleAxis=n}function DQ({data:t,x:e,y:n,x2:i,y2:o}){if(i||o)return[e,n];const r=this.ctx.density,a=r.layout.valueAxis(this),s="x"===a?e:n,c="x"===a?n:e,l=s.domain().slice(),h=l[0]>l[1];h&&l.reverse(),t.forEach(t=>{const e=CQ(t)?.summary.curve;e&&e.length&&(l[0]=Math.min(l[0],e[0][0]),l[1]=Math.max(l[1],e[e.length-1][0]))}),h&&l.reverse(),s.domain(l);const[u,d]=r.layout.categoryPadding(this);return c.padding&&c.padding(u),c.align&&c.align(d),[e,n]}function LQ(t,e){t.ctx.density={raw:[],rows:[],layout:e,categories:new Map},t._buffer={...t._buffer,Area:DQ},t._plotShapeEmitters={...t._plotShapeEmitters,Area:e.emit},t._sharedHover=()=>{};const n=function(t){return(e,n)=>{const i=t.ctx.density,o="x"===i.layout.valueAxis(t)?"y":"x",r=t=>i.categories.get(`${SQ(t)?.[o]}`)??0;return i.layout.reverse?r(n)-r(e):r(e)-r(n)}}(t),i=t._preDraw.bind(t);t._preDraw=()=>{zQ(t);const o="x"===e.valueAxis(t)?"y":"x",r="x"===o?"y":"x";t.schema[`${r}Sort`]===n&&(t.schema[`${r}Sort`]=void 0),t.schema[`${o}Sort`]||(t.schema[`${o}Sort`]=n),i()}}function FQ(t,e,n){const i=e=>p.formatAbbreviate(e,t.schema.locale),o=e=>t.schema.translate(e),r=CQ(e);if(!r){const r=Number(t.schema.value(SQ(e),n));return Number.isFinite(r)?[[aq(t.schema.value)??o("Value"),i(r)]]:[]}const a=r.summary;return[[o("Observations"),i(a.n)],[o("Maximum"),i(a.max)],[o("Upper Quartile"),i(a.q3)],[o("Median"),i(a.median)],[o("Lower Quartile"),i(a.q1)],[o("Minimum"),i(a.min)]]}function NQ(){return[{key:"densityScale",default:"area"},{key:"medianSort",default:!1},{key:"shape",default:W("Area"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"value",default:rq("value"),coerce:t=>"string"==typeof t?G(t):"function"==typeof t?t:W(t)}]}function BQ(t){return[{key:"densityConfig",merge:!0,default:{kernel:"gaussian",points:80,cut:t}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>FQ(t,e,n)})}]}function EQ(t,e,n){return Math.abs(t)/Math.max(1,e-1+2*n)}function RQ(t,e){const{position:n,step:i,gap:o,split:r}=e,a=Math.max(1,i>o?i-o:i),s=new Map;t.forEach((t,e)=>{s.has(t)||s.set(t,[]),s.get(t).push(e)});const c=new Array(t.length);return s.forEach((t,e)=>{const i=n(e),o=t.length;if(r&&2===o)return c[t[0]]={center:i,half:a/2,side:"start"},void(c[t[1]]={center:i,half:a/2,side:"end"});const s=a/o,l=o>1?Math.min(2,s/4):0;t.forEach((t,e)=>{c[t]={center:i-a/2+s*(e+.5),half:Math.max(.5,(s-l)/2),side:"both"}})}),c}function PQ(t,e,n){return t.map(([t,i])=>({value:t,extent:i*e*n}))}function TQ(t,e){const{center:n,side:i}=t;return["end"===i?n:n-e,"start"===i?n:n+e]}function OQ(t){const e=Number(t.schema.overlap);return Number.isFinite(e)&&e>0?e:0}function WQ(t){return t>0?[t/2,1]:[0,.5]}const jQ=(t,e)=>{const{viz:n,values:i,x:o,y:r,yRange:a,yDomain:s}=t,c=OQ(n),l=s,h=l.map(t=>r(t,"y")).sort((t,e)=>t-e);let u=EQ(a[a.length-1]-a[0],l.length,WQ(c)[0]);for(let t=1;t<h.length;t++)u=Math.min(u,h[t]-h[t-1]);const d=c*u,f=i.filter(t=>CQ(t)).map(t=>({row:t,base:r(t.y,"y")})).sort((t,e)=>t.base-e.base),m=[];f.forEach(({row:t,base:e})=>{const n=CQ(t);n.summary.curve.forEach(([i,r])=>{m.push({...t,id:$Q(t),__pos:o(i),__base:e,__top:e-r*n.scale*d})})});const p=t=>t.__pos,g=t=>t.__base,y={x:p,x0:p,x1:null,y:g,y0:g,y1:t=>t.__top},x=zF({...t,values:m,shapeConfig:{...t.shapeConfig,...y}},e);return uF(x,"y",new Map(f.map(({row:t,base:e})=>[$Q(t),e]))),x},HQ={name:"Ridgeline",paintDriven:!0,setup:t=>LQ(t,{valueAxis:()=>"x",categoryPadding:t=>WQ(OQ(t)),reverse:!0,emit:jQ}),ctx:{},fields:[{key:"discrete",default:"y"},{key:"overlap",default:1.5},...NQ(),...BQ(3),{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var IQ=fk(HQ,XN);function GQ(t){const e=Number(t);return null!=t&&Number.isFinite(e)?Math.max(1,Math.floor(e)):2}function qQ(t,e,n=2){const i=(d.min([e,t])||0)/2,o=i/(n+1),r=1===n?i/3:o,a=Array.from({length:n},(t,e)=>o+o*e);return{width:t,height:e,ringWidth:o,primaryRing:o,baseRing:r,rings:a}}function VQ(t,e){const n=[];for(let i=1;i<=e;i++){const e=t/2**i,o=1===i?8:4;let r=e/2-4;r<o&&(r=d.min([e/2,o])||0),i>1&&r>t/10&&(r=t/10),n.push(r)}for(let t=1;t<e;t++)n[t]>n[t-1]&&n[t]>10&&(n[t]=.75*n[t-1]);for(let t=e-2;t>=0;t--)n[t]>1.5*n[t+1]&&(n[t]=1.5*n[t+1]);return n.map(t=>Math.floor(t))}function KQ(t){const[e,n]=VQ(t.baseRing,2);return t.rings.map((t,i)=>i?n:e)}function YQ(t,e){const n=t.schema.sizeMin,i=t.schema.sizeMax;return Math.min(i??1/0,Math.max(n??0,e))}function UQ(t,e,n,i,o){if(o.forEach((t,e)=>t.forEach(t=>t.ring=e+1)),t._size){const r=[e,...o.flat()];r.forEach(e=>e.size=Number(t._size(e.data,e.i)));const a=r.map(t=>t.size).filter(t=>Number.isFinite(t));if(a.length){const e=function(t,e,n,i){const{baseRing:o,rings:r}=e,a=Math.sin(Math.PI/Math.max(n,2)),s=Math.max(1,Math.floor(d.min([o/4,...r.map(t=>t*a-1)]))),c=Math.min(t.schema.sizeMax??1/0,s),l=Math.min(c/2,t.schema.sizeMin??3),h=d.extent(i),u=`scale${t.schema.sizeScale.charAt(0).toUpperCase()}${t.schema.sizeScale.slice(1)}`;return E[u]().domain(h).range([h[0]===h[1]?c:l,c])}(t,n,i,a);return r.forEach(n=>n.r=Number.isFinite(n.size)?e(n.size):YQ(t,0)),e}}const r=KQ(n);return o.forEach((e,n)=>e.forEach(e=>e.r=YQ(t,r[n]))),null}const XQ=t=>({data:t.data,i:t.i,id:t.id});function QQ(t,e,n){if("object"==typeof n)return e[n.id];const i=e[n];if(i)return i;if(!isNaN(n)){const t=e[parseFloat(n)];if(t)return t}if("number"==typeof n){const i=t.schema.nodes&&t.schema.nodes[n];if(null==i)return;return"object"==typeof i&&e[i.id]||e[i]}}const ZQ=t=>!!t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.r;function JQ(t,e,n,i,o){const r=new Map(e.filter(ZQ).map(t=>[t.id,t])),a=t.filter(t=>vM(t)&&r.has(t.source.id));if(!a.length)return[];const s=new Map,c=(t,e)=>{s.has(t)||s.set(t,[]),s.get(t).push(e)};for(const t of n){const e=r.get(t.source.id),n=r.get(t.target.id);e&&n&&e!==n&&(c(e.id,[n.x,n.y]),c(n.id,[e.x,e.y]))}for(const t of r.values())t.id!==i.id&&"number"==typeof t.radians&&c(t.id,[t.x+Math.cos(t.radians)*(t.r+10),t.y+Math.sin(t.radians)*(t.r+10)]);const l=Math.max(8,.6*(o.primaryRing-(i.r??0))),h=Math.max(0,...a.filter(t=>t.source.id===i.id).map(t=>t.size??1)),u=Math.max(0,l-1.5*h),d=PM(a,{node:t=>r.get(t.source.id),angle:t=>EM([t.x,t.y],s.get(t.id)??[],-Math.PI/2),strokeWidth:t=>t.size??1,reach:t=>{const e=r.get(t.source.id),n=SM(e.r);return e.id===i.id?Math.min(n,u):n}});return a.flatMap(t=>{const e=d.get(t),n=r.get(t.source.id);return e?[{...t,source:n,target:n,loop:e}]:[]})}const tZ=4/3*Math.tan(Math.PI/8),eZ=(t,e)=>t.primaryRing+t.ringWidth*(e-1),nZ=(t,e)=>eZ(t,e)+.5*(eZ(t,e+1)-eZ(t,e)),iZ=(t,e,n)=>Math.max(eZ(t,e)+.28*(eZ(t,e+1)-eZ(t,e)),eZ(t,e)+Math.max(...n.map(t=>t.r??0))+2),oZ=t=>[Math.cos(t),Math.sin(t)],rZ=(t,e,n)=>[t[0]+e[0]*n,t[1]+e[1]*n];function aZ(t,e,n,i){const o=Math.max(1,Math.ceil(Math.abs(i)/(Math.PI/2)-1e-9)),r=i/o,a=4/3*Math.tan(r/4)*e;return Array.from({length:o},(i,o)=>{const s=n+r*o,c=s+r,l=rZ(t,oZ(s),e),h=rZ(t,oZ(c),e);return[l,rZ(l,oZ(s+Math.PI/2),a),rZ(h,oZ(c+Math.PI/2),-a),h]})}function sZ(t,e,n,i){const o=t.radians,r=e.radians,a=Math.atan2(Math.sin(r-o),Math.cos(r-o)),s=a<0?-1:1,c=(t,e)=>{const o=rZ([t.x,t.y],oZ(e),t.r??0),r=Math.max(1,i-Math.hypot(o[0]-n[0],o[1]-n[1])),s=Math.min(r/i,Math.abs(a)/2);return{start:o,rise:r,delta:s,side:i*s}},l=c(t,o),h=c(e,r),u=o+s*l.delta,d=rZ(n,oZ(u),i),f=r-s*h.delta,m=[[l.start,rZ(l.start,oZ(o),tZ*l.rise),rZ(d,oZ(u+Math.PI/2),-s*tZ*l.side),d]],p=a-s*(l.delta+h.delta);Math.abs(p)>1e-6&&m.push(...aZ(n,i,u,p));const g=m[m.length-1][3];return m.push([g,rZ(g,oZ(f+Math.PI/2),s*tZ*h.side),rZ(h.start,oZ(r),tZ*h.rise),h.start]),m}function cZ(t){const{cx:e,cy:n,radius:i}=t.arc,o=sZ(t.source,t.target,[e,n],i),r=o[0],a=o[o.length-1];t.segments=o,t.spline=!0,[t.sourceX,t.sourceY]=r[0],[t.sourceBisectX,t.sourceBisectY]=r[1],[t.targetBisectX,t.targetBisectY]=a[2],[t.targetX,t.targetY]=a[3]}function lZ(t,e){const{width:n,height:i}=e,o=Math.min(t.source.ring,t.target.ring);if(t.source.ring===t.target.ring){const r=iZ(e,o,[t.source,t.target]);return t.arc={cx:n/2,cy:i/2,radius:r},void cZ(t)}const r=nZ(e,o);t.spline=!0;["source","target"].forEach(e=>{const a=t[e],s=a.radians,c=a.ring>o?s+Math.PI:s,l=a.r;t[`${e}X`]=a.x+Math.cos(c)*l,t[`${e}Y`]=a.y+Math.sin(c)*l,t[`${e}BisectX`]=n/2+r*Math.cos(s),t[`${e}BisectY`]=i/2+r*Math.sin(s)})}const hZ=(t,e)=>t.source.id===e?t.target:t.source;function uZ(t,e){const n=new Set;return t.filter(t=>{const i=hZ(t,e).id;return!n.has(i)&&(n.add(i),!0)})}const dZ=(t,e,n)=>t.filter(t=>hZ(t,e).id===n),fZ=(t,e)=>Array.from({length:t},(n,i)=>(i-(t-1)/2)*e);function mZ(t,e,n,i){const o=e[0]-t.x,r=e[1]-t.y,a=Math.hypot(o,r);if(!a)return e;const s=[n[1],-n[0]],c=.9*a,l=Math.max(-c,Math.min(c,o*n[0]+r*n[1]+i)),h=(o*s[0]+r*s[1]<0?-1:1)*Math.sqrt(a*a-l*l);return[t.x+n[0]*l+s[0]*h,t.y+n[1]*l+s[1]*h]}const pZ=(t,e,n)=>(t[0]-e[0])*n[0]+(t[1]-e[1])*n[1];function gZ(t,e,n,i){const o=Math.hypot(e.x-t.x,e.y-t.y)||1,r=(e.x-t.x)/o,a=(e.y-t.y)/o,s=t.r??0,c=e.r??0,l=.75*i,h=[t.x+r*s,t.y+a*s],u=[e.x-r*c,e.y-a*c],[d,f]=mZ(t,h,n,l),[m,p]=mZ(e,u,n,l),g=(i-(pZ([d,f],h,n)+pZ([m,p],u,n))/2)/.75,y=m-d,x=p-f;return{sourceX:d,sourceY:f,sourceBisectX:d+y/3+n[0]*g,sourceBisectY:f+x/3+n[1]*g,targetBisectX:d+2*y/3+n[0]*g,targetBisectY:f+2*x/3+n[1]*g,targetX:m,targetY:p}}function yZ(t,e,n){const i=.75*n,o=[t.sourceX,t.sourceY],r=[t.targetX,t.targetY];[t.sourceX,t.sourceY]=mZ(t.source,o,e,i),[t.targetX,t.targetY]=mZ(t.target,r,e,i);const a=(n-(pZ([t.sourceX,t.sourceY],o,e)+pZ([t.targetX,t.targetY],r,e))/8)/.75;t.sourceBisectX+=e[0]*a,t.sourceBisectY+=e[1]*a,t.targetBisectX+=e[0]*a,t.targetBisectY+=e[1]*a}function xZ(t,e){const n=t.arc,i=t=>Math.hypot((t.x??0)-n.cx,(t.y??0)-n.cy)+(t.r??0),o=Math.max(i(t.source),i(t.target))+2;t.arc={...n,radius:Math.max(o,n.radius+e)},cZ(t)}const bZ=t=>"number"==typeof t.x&&"number"==typeof t.y;function kZ(t){const e=new Map;for(const n of t){if(n.loop||n.source.id===n.target.id)continue;const t=[String(n.source.id),String(n.target.id)].sort(),i=JSON.stringify(t);e.has(i)||e.set(i,[]),e.get(i).push(n)}for(const t of e.values()){if(t.length<2)continue;const e=t[0],[n,i]=String(e.source.id)<String(e.target.id)?[e.source,e.target]:[e.target,e.source];if(!bZ(n)||!bZ(i))continue;const o=Math.hypot(i.x-n.x,i.y-n.y);if(!o)continue;const r=[-(i.y-n.y)/o,(i.x-n.x)/o],a=Math.max(...t.map(t=>t.size??1)),s=Math.max(8,a+4)+4;fZ(t.length,s).forEach((e,n)=>{const i=t[n];i.arc?xZ(i,e):i.spline&&null!=i.sourceX&&null!=i.targetX?yZ(i,r,e):(Object.assign(i,gZ(i.source,i.target,r,e)),i.spline=!0)})}}const _Z=(t,e)=>t.source.id===e?t.target:t.source;function vZ(t,e,n){const i=new Set([e]),o=new Map,r=[];(t[e.id]||[]).forEach(t=>{const n=_Z(t,e.id);i.has(n)||(i.add(n),r.push(n))}),r.sort((e,n)=>(t[e.id]||[]).length-(t[n.id]||[]).length);const a=[r];for(;a.length<n;){const e=a[a.length-1],n=[];e.forEach(e=>{const r=uZ((t[e.id]||[]).filter(t=>!i.has(_Z(t,e.id))),e.id).map(t=>_Z(t,e.id));r.forEach(t=>i.add(t)),o.set(e,r),n.push(...r)}),a.push(n)}return{rings:a,children:o}}function wZ(t){const e=new Map;for(let n=t.rings.length-1;n>=0;n--)t.rings[n].forEach(n=>{const i=(t.children.get(n)??[]).reduce((t,n)=>t+e.get(n),0);e.set(n,i||1)});return e}function MZ(t,e){const{width:n,height:i,rings:o}=e,r=wZ(t),a=t.rings[0].reduce((t,e)=>t+r.get(e),0),s=2*Math.PI,c=s/a,l=(e,a,s)=>{e.radians=a,e.x=n/2+o[s]*Math.cos(a),e.y=i/2+o[s]*Math.sin(a);const h=t.children.get(e)??[],u=r.get(e);let d=0;h.forEach(t=>{const e=r.get(t);l(t,a-c*u/2+c*e/2+c*d,s+1),d+=e})};let h=0;return t.rings[0].forEach((t,e)=>{const n=s/a*r.get(t);0===e&&(h-=n/2),l(t,h+n/2-s/4,0),h+=n}),a}function SZ(t,e,n,i){const{width:o,height:r,baseRing:a}=i;n.x=o/2,n.y=r/2,n.r=t.schema.sizeMin?d.max([t.schema.sizeMin,.65*a]):t.schema.sizeMax?d.min([t.schema.sizeMax,.65*a]):.65*a;const s=vZ(e,n,i.rings.length),c=UQ(t,n,i,MZ(s,i),s.rings);return{nodes:[n,...s.rings.flat()],rings:s.rings,radius:c}}function CZ(t,e,n,i,o=!1){const r=[],a=new Set(t.flat().map(t=>t.id));return t.forEach((s,c)=>{s.forEach(s=>{0===c&&dZ(e[s.id],s.id,n.id).forEach(t=>{r.includes(t)||r.push(t)});const l=c===t.length-1;l&&!o||e[s.id].forEach(t=>{const e=_Z(t,s.id);e.id!==n.id&&a.has(e.id)&&(l&&e.ring!==s.ring||(lZ(t,i),r.includes(t)||r.push(t)))})})}),r}function $Z(t,e,n){const{ringWidth:i}=n;e.forEach(e=>{if(e.id===t.schema.center){const{bounds:i,inside:o}=function(t,e,n,i,o){const{baseRing:a}=n;if(!t._size)return{bounds:{x:-a/2,y:-a/2,width:a,height:a},inside:!0};const c=e.r??0,l=c*Math.SQRT2;return l>=Math.max(0,...String(i??"").split(/\s+/).map(t=>r.textWidth(t,{"font-family":s.fontFamilyStringify(o),"font-size":9})))&&l>=12.6?{bounds:{x:-l/2,y:-l/2,width:l,height:l},inside:!0}:{bounds:{x:-a/2,y:c+3,width:a,height:a/2},inside:!1}}(t,e,n,t._drawLabel(e.data||e.node,e.i),t.schema.fontFamily);return e.labelBounds=i,void(e.labelInside=o)}const o=t.schema.shapeConfig.labelConfig,a=1.4*(o?.fontSize&&o.fontSize(e)||11),c=2*a,l=i-e.r;let h=e.radians*(180/Math.PI),u=e.r+5,d="start";(h<-90||h>90)&&(u=-e.r-l-5,d="end",h+=180),e.labelBounds={x:u,y:-a/2,width:l,height:c},e.rotate=h,e.textAnchor=d})}function AZ(t,n,i,o,r){t.ctx.linkLookup=o.reduce((t,e)=>(e.source===e.target||(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e.target),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e.source)),t),{}),function(t,e,n){const i=d.extent(n,t=>t.size);if(i[0]!==i[1]){const o=d.min(e,t=>t.r),r=E[`scale${t.schema.linkSizeScale.charAt(0).toUpperCase()}${t.schema.linkSizeScale.slice(1)}`]().domain(i).range(jV(t.schema.linkSizeMin,t.schema.linkSizeMax,o));n.forEach(t=>{t.size=r(t.size)})}}(t,n,o);const a=Hg(t,"Path",t.schema.shapeConfig,"edge");delete a.on;const s=e=>e.id===t.schema.center&&!1!==i[e.id]?.labelInside,c={label:e=>!!(n.length<=t.schema.dataCutoff||t._hover&&t._hover(e)||t._active&&t._active(e))&&t._drawLabel(e.data||e.node,e.i),labelBounds:t=>t.labelBounds,labelConfig:{fontColor:n=>{const o=n.data??n;if(o.id===t.schema.center&&!1!==i[o.id]?.labelInside){const n=Tg(Hg(t,o.key??o.shape).fill,o.data??o,o.i);return e.colorContrast("string"==typeof n?n:"rgb(255, 255, 255)",t.schema.colorDefaults)}return Oc(t)},fontResize:t=>s(t.data??t),padding:0,textAnchor:e=>{const n=e.data??e;return n.id!==t.schema.center||s(n)?i[n.id]?.textAnchor||Hg(t,n.key??n.shape).labelConfig.textAnchor:"middle"},verticalAlign:t=>s(t.data??t)?"middle":"top"},rotate:t=>i[t.id].rotate||0},l=Array.from(d.groups(n,t=>t.shape));t.ctx.ringsCtx={edges:r,nodeGroups:l,linkConfig:a,linkD:t=>t.loop?t.loop.d:t.segments?t.segments.map(([t,e,n,i],o)=>`${o?"":`M${t[0]},${t[1]}`}C${e[0]},${e[1]} ${n[0]},${n[1]} ${i[0]},${i[1]}`).join(""):t.spline?`M${t.sourceX},${t.sourceY}C${t.sourceBisectX},${t.sourceBisectY} ${t.targetBisectX},${t.targetBisectY} ${t.targetX},${t.targetY}`:`M${t.source.x},${t.source.y} ${t.target.x},${t.target.y}`,nodeShapeConfig:c}}function zZ(t){if(Array.isArray(t._filteredData)||(t._filteredData=[]),Array.isArray(t.schema.nodes)||(t.schema.nodes=[]),Array.isArray(t.schema.links)||(t.schema.links=[]),!t._filteredData.length&&!t.schema.nodes.length&&!t.schema.links.length)return null;const e=t._filteredData.reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),n=function(t,e){let n=t.schema.nodes;!n.length&&t.schema.links.length&&(n=Array.from(new Set(t.schema.links.reduce((t,e)=>t.concat([e.source,e.target]),[]))).map(t=>"object"==typeof t?t:{id:t}));const i=n.reduce((e,n,i)=>(e[t.schema.nodeGroupBy?t.schema.nodeGroupBy[t._drawDepth](n,i):t._id(n,i)]=n,e),{}),o=Array.from(new Set(Object.keys(e).concat(Object.keys(i)))).map((n,o)=>{const r=e[n],a=i[n];return void 0!==a&&{__d3plus__:!0,data:r||a,i:o,id:n,node:a,shape:void 0!==r&&void 0!==t.schema.shape(r)?t.schema.shape(r):t.schema.shape(a)}}).filter(t=>!!t),r=o.reduce((t,e)=>(t[e.id]=e,t),{});t.ctx.nodeLookup=r;const a=t.schema.links.flatMap((e,n)=>{const i=QQ(t,r,e.source),o=QQ(t,r,e.target);if(!i||!o)return[];const a=iw(e,XQ(i),XQ(o),n);return[{source:i,target:o,size:ow(a,t.schema.linkSize(a,n)),datum:a}]}),s=a.reduce((t,e)=>(e.source===e.target||(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e)),t),{});return{nodes:o,nodeLookup:r,links:a,linkMap:s}}(t,e);let i=n.nodeLookup[t.schema.center];return i||null==t.schema.center||isNaN(t.schema.center)||(i=n.nodeLookup[parseFloat(t.schema.center)]),i&&(t.schema.center=i.id),{data:e,graph:n,center:i}}const DZ=({viz:t})=>{const e=t;e._sizeLegendFinal=null;const n=zZ(e);if(!n)return e.ctx.nodeLookup={},e.ctx.linkLookup={},e.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:t};const{graph:{nodes:i,nodeLookup:o,links:r,linkMap:a},center:s}=n;if(rw(e,r.map(t=>t.datum),i.map(XQ)),!s)return e.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:t};const{width:c,height:l}=wt(e),h=qQ(c,l,GQ(e.schema.hops)),{nodes:u,rings:d,radius:f}=SZ(e,a,s,h);e._sizeLegendFinal=f;const m=CZ(d,a,s,h,!!e.schema.ringLinks);return $Z(e,u,h),AZ(e,u,o,r,m),kZ(m),m.push(...JQ(r,u,m,s,h)),{shapeData:u}};function LZ(t){const e=new Set,n=new Map;return t.map(t=>{let i=n.get(t)??0,o=i?`${t}-${i}`:t;for(;e.has(o);)o=`${t}-${++i}`;return n.set(t,i+1),e.add(o),o})}function FZ(t,e,n,i,o,r,a=1){const s=t.schema.arrows,c=yv(t.schema.arrowSize,a),l=xv(o,a),h=`${e.source.id}-${e.target.id}-${r}`,u="string"==typeof i?i:void 0;if(e.loop)return OM({arrows:s,arrowSize:c,strokeWidth:l,datum:n,i:r,keyPrefix:`rings-arrow-${h}`,fill:u,loop:e.loop});if(!e.spline)return Cv({arrows:s,arrowSize:c,strokeWidth:l,datum:n,i:r,keyPrefix:`rings-arrow-${h}`,fill:u,source:e.source,target:e.target});const d=NZ(e);if(!d)return[];const f=BZ(t,e,r,o,a);return f.ends.source||f.ends.target?_M({ends:yM(d,f),size:f.size,datum:n,keyPrefix:"rings-arrow",keys:{source:`rings-arrow-s-${h}`,target:`rings-arrow-t-${h}`},fill:u}):[]}function NZ(t){return t.segments?.length?t.segments:t.spline&&null!=t.sourceX&&null!=t.targetX?[[[t.sourceX,t.sourceY],[t.sourceBisectX,t.sourceBisectY],[t.targetBisectX,t.targetBisectY],[t.targetX,t.targetY]]]:null}const BZ=(t,e,n,i,o=1)=>kv({arrows:t.schema.arrows,arrowSize:yv(t.schema.arrowSize,o),strokeWidth:xv("number"==typeof i?i:void 0,o),datum:e.datum,i:n});function EZ(t,e,n,i,o,r=1){const a=BZ(t,e,n,i,r);if(!a.source&&!a.target)return o;if(e.loop)return LM(e.loop,a);const s=NZ(e);return s?yM(s,a).d:Sv(e.source,e.target,a)}const RZ=t=>`rings-link-${t.source.id}-${t.target.id}${t.loop?`-${ew(t.datum)?.index??0}`:""}`,PZ=t=>LZ(t.map(RZ));function TZ(t){if(t.loop)return t.loop.apex;if(t.segments?.length)return qw(function(t){const e=NZ(t);return e?e.flatMap((t,e)=>dM(t).slice(e?1:0)):null}(t));if(t.spline&&null!=t.sourceX&&null!=t.targetX)return ev([t.sourceX,t.sourceY],[t.sourceBisectX,t.sourceBisectY],[t.targetBisectX,t.targetBisectY],[t.targetX,t.targetY]);const e=t=>"number"==typeof t.r?t.r:0;return Z_([t.source.x,t.source.y],[t.target.x,t.target.y],e(t.source),e(t.target))}function OZ(t){if(t.loop)return Uw(t.loop.d);const e=NZ(t);return e?Uw(gM(e)):null}function WZ(t,e,n,i){const o=e.nodeShapeConfig;if(!i.length||!o.label||!o.labelBounds)return[];const r=o.label,a=o.labelBounds,s=e_({data:i,label:(t,e)=>r(t,e),x:t=>t.x,y:t=>t.y,aes:t=>({r:t.r}),rotate:t=>o.rotate?o.rotate(t):0,id:t=>`rings-label-${t.id}`,labelBounds:(t,e)=>a(t),labelConfig:{...Ig(t,n),...o.labelConfig}}),c=i.find(e=>e.id===t.schema.center&&!1!==e.labelInside),l=c?`rings-label-${c.id}_`:void 0,h=t=>void 0!==l&&String(t.key).startsWith(l)&&/^\d+$/.test(String(t.key).slice(l.length)),u=Vy(s.filter(t=>!h(t)),Tc(t),t=>Math.max(2,Math.round((t.font.size??10)/4)));return[...u,...s.filter(h)]}function jZ(t,e,n,i,o){const r=`rings-${t}-${e.id}`;if("Circle"===t)return{type:"circle",key:r,cx:0,cy:0,r:e.r,...i};if("Rect"===t){const t=Number(Tg(n.width,i.datum,o)??2*e.r),a=Number(Tg(n.height,i.datum,o)??2*e.r);return{type:"rect",key:r,x:-t/2,y:-a/2,width:t,height:a,...i}}return null}const HZ={name:"Rings",layoutStage:DZ,sizeLegendScale:(t,{width:e,height:n})=>function(t,e,n){if(!t._size)return null;const{nodeLookup:i}=t.ctx,o=zZ(t);if(t.ctx.nodeLookup=i,!o||!o.center)return null;const{graph:r,center:a}=o;return SZ(t,r.linkMap,a,qQ(e,n,GQ(t.schema.hops))).radius}(t,e,n),emit:({viz:t})=>{const e=t.ctx.ringsCtx;if(!e)return[];const n=[],i=new Map((e.nodeGroups??[]).map(([n,i])=>[n,WZ(t,e,n,i)]));if(e.edges&&e.edges.length){const o=zw(t),r=PZ(e.edges);for(const[i,a]of e.edges.entries()){const s=a.datum,c=ew(s)?.index??0,l=Wg(e.linkConfig,s,c);"number"==typeof a.size&&(l.strokeWidth=a.size);const h=o(s,a);h&&(l.stroke=h);const u=r[i],d=e.linkD(a),f="number"==typeof l.strokeWidth?l.strokeWidth:void 0,m=bv(e=>({d:EZ(t,a,c,f,d,e),arrows:FZ(t,a,s,l.stroke,f,c,e)}));n.push({type:"path",key:u,d:m.d,...m.emphasis?{emphasis:m.emphasis}:{},datum:s,index:c,paint:l,aria:{label:pw(t,s)}}),n.push(Sw(u,d,s,l.strokeWidth)),n.push(...m.arrows)}n.push(...function(t,e,n,i){return aM(t,e.edges.map((t,e)=>({key:i[e],link:t,i:e,anchor:TZ(t),path:OZ(t),priority:t.size})),{circles:e.nodeGroups.flatMap(([,t])=>t.map(t=>({x:t.x,y:t.y,r:t.r}))),labels:rM(n)})}(t,e,[...i.values()].flat(),r))}if(e.nodeGroups&&e.nodeGroups.length){const o=e.nodeShapeConfig;for(const[r,a]of e.nodeGroups){if(!a.length)continue;const s={...Hg(t,r),...e.nodeShapeConfig},c=[];for(let e=0;e<a.length;e++){const i=a[e],l=i.data??i,h=Wg(s,l,i.i??e);void 0===h.vectorEffect&&(h.vectorEffect="non-scaling-stroke");const u=o.rotate?o.rotate(i):0,d=u?{x:i.x,y:i.y,rotate:u}:{x:i.x,y:i.y},f=t._size,m=f?`, ${f(l,i.i??e)}`:"",p=jZ(r,i,s,{datum:l,paint:h,transform:d,aria:{label:`${jg(t,i,e)}${m}.`}},i.i??e);if(!p)continue;n.push(p);const g=WS(s,p,l,i.i??e);g&&c.push(g)}n.push(...c),n.push(...i.get(r)??[])}}return n},insetRegion:Ay,setup:t=>{!function(t){const e=t;e.links=function(){return arguments.length?(_n(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(_n(this,"nodes",arguments),this):this.schema.nodes},e.linkSize=function(t){return arguments.length?(this.schema.linkSize="function"==typeof t?t:W(t),this):this.schema.linkSize},e.nodeGroupBy=function(t){if(!arguments.length)return this.schema.nodeGroupBy;const e=t instanceof Array?t:[t];return this.schema.nodeGroupBy=e.map(t=>"function"==typeof t?t:(this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),G(t))),this},e.size=function(t){return arguments.length?(this._size="function"!=typeof t&&t?G(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size},e.hover=mk}(t);const e=t;t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=(e,n)=>`${t._ids(e,n)[t._drawDepth]}`;if(nw(i))return void e.hover(gw(t,i,s));if(t._focus&&t._focus===i.id)return e.hover(!1),t.schema.on.mouseenter.bind(t)(i,o,r,a),void(t._focus=void 0);const c=t.schema.nodeGroupBy&&t.schema.nodeGroupBy[t._drawDepth](i,o)?t.schema.nodeGroupBy[t._drawDepth](i,o):t._id(i,o),l=t.ctx.linkLookup[c]??[],h=t.ctx.nodeLookup[c];if(!h)return;const u=[h.id],d=[h.x-h.r,h.x+h.r],f=[h.y-h.r,h.y+h.r];l.forEach(t=>{u.push(t.id),t.x-t.r<d[0]&&(d[0]=t.x-t.r),t.x+t.r>d[1]&&(d[1]=t.x+t.r),t.y-t.r<f[0]&&(f[0]=t.y-t.r),t.y+t.r>f[1]&&(f[1]=t.y+t.r)}),e.hover((t,e)=>{const n=ew(t);return n?n.source.id===h.id||n.target.id===h.id:u.includes(s(t,e))})},$I(t),t.schema.on["click.shape"]=e=>{nw(e)?CI(t,e,{nodeKey:(e,n)=>`${t._ids(e,n)[t._drawDepth]}`}):(wI(t),t.hover?.(!1),t._tooltipClass?.data([]).render(),t.schema.center=e.id,t._margin={bottom:0,left:0,right:0,top:0},t._padding={bottom:0,left:0,right:0,top:0},Lb(t),Tb(t),t._sceneRenderer&&t._drawSceneToTarget(Jt(t)))}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"center"},{key:"hops",default:2},{key:"tooltipConfig",merge:!0,factory:t=>Mw(t)},...cM(),...Mn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:W(1)},lM(),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"ringLinks",default:!1},{key:"nodes",default:[]},{key:"nodeTooltipLinks"},{key:"nodeTooltipStats",default:!0},{key:"nodeTooltipStatsConfig",merge:!0,default:{}},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:W("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t._size,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:()=>Z(t._theme,t=>t.link,"#adb5bd"),strokeWidth:1}})}]};var IZ=fk(HZ);const GZ=(t,e)=>t.sourceLinks.length||!t.targetLinks.length?t.depth:e-1,qZ=(t,e)=>t.y0-e.y0,VZ=(t,e)=>qZ(t.source,e.source)||t.index-e.index,KZ=(t,e)=>qZ(t.target,e.target)||t.index-e.index,YZ=t=>t.value;function UZ(t,e){const n=t.length;let i=new Set(t),o=new Set,r=0;for(;i.size;){for(const t of i)if(t[e]=r,"depth"===e)for(const{target:e}of t.sourceLinks)o.add(e);else for(const{source:e}of t.targetLinks)o.add(e);if(++r>n)throw new Error("circular link");i=o,o=new Set}}function XZ(t,e,n,i){for(let o=1,r=e.length;o<r;++o){const r=e[o];for(const e of r){let i=0,o=0;for(const{source:n,value:r}of e.targetLinks){const a=r*(e.layer-n.layer);i+=iJ(t,n,e)*a,o+=a}if(!(o>0))continue;const r=(i/o-e.y0)*n;e.y0+=r,e.y1+=r,eJ(t,e)}void 0===t.sort&&r.sort(qZ),ZZ(t,r,i)}}function QZ(t,e,n,i){for(let o=e.length-2;o>=0;--o){const r=e[o];for(const e of r){let i=0,o=0;for(const{target:n,value:r}of e.sourceLinks){const a=r*(n.layer-e.layer);i+=oJ(t,e,n)*a,o+=a}if(!(o>0))continue;const r=(i/o-e.y0)*n;e.y0+=r,e.y1+=r,eJ(t,e)}void 0===t.sort&&r.sort(qZ),ZZ(t,r,i)}}function ZZ(t,e,n){const i=e.length>>1,o=e[i];tJ(t,e,o.y0-t.py,i-1,n),JZ(t,e,o.y1+t.py,i+1,n),tJ(t,e,t.y1,e.length-1,n),JZ(t,e,t.y0,0,n)}function JZ(t,e,n,i,o){for(;i<e.length;++i){const r=e[i],a=(n-r.y0)*o;a>1e-6&&(r.y0+=a,r.y1+=a),n=r.y1+t.py}}function tJ(t,e,n,i,o){for(;i>=0;--i){const r=e[i],a=(r.y1-n)*o;a>1e-6&&(r.y0-=a,r.y1-=a),n=r.y0-t.py}}function eJ(t,{sourceLinks:e,targetLinks:n}){if(void 0===t.linkSort){for(const{source:t}of n)t.sourceLinks.sort(KZ);for(const{target:t}of e)t.targetLinks.sort(VZ)}}function nJ(t,e){if(void 0===t.linkSort)for(const{sourceLinks:t,targetLinks:n}of e)t.sort(KZ),n.sort(VZ)}function iJ(t,e,n){let i=e.y0-(e.sourceLinks.length-1)*t.py/2;for(const{target:o,width:r}of e.sourceLinks){if(o===n)break;i+=r+t.py}for(const{source:t,width:o}of n.targetLinks){if(t===e)break;i-=o}return i}function oJ(t,e,n){let i=n.y0-(n.targetLinks.length-1)*t.py/2;for(const{source:o,width:r}of n.targetLinks){if(o===e)break;i+=r+t.py}for(const{target:t,width:o}of e.sourceLinks){if(t===n)break;i-=o}return i}const rJ=t=>Math.round(100*t)/100,aJ=t=>`${rJ(t[0])},${rJ(t[1])}`;function sJ(t){return t.map(t=>t.c1&&t.c2?`C${aJ(t.c1)} ${aJ(t.c2)} ${aJ(t.to)}`:`L${aJ(t.to)}`).join("")}function cJ(t){return`M${aJ(t.start)}${sJ(t.steps)}`}function lJ(t){const e=[t.start,...t.steps.map(t=>t.to)],n=[];for(let i=t.steps.length-1;i>=0;i--){const o=t.steps[i];n.push(o.c1&&o.c2?{to:e[i],c1:o.c2,c2:o.c1}:{to:e[i]})}return{start:e[e.length-1],steps:n}}function hJ(t,e){const n=t=>[t[0],t[1]+e];return{start:n(t.start),steps:t.steps.map(t=>({to:n(t.to),...t.c1&&t.c2?{c1:n(t.c1),c2:n(t.c2)}:{}}))}}function uJ(t,e){const n=lJ(e);return`${cJ(t)}L${aJ(n.start)}${sJ(n.steps)}Z`}function dJ(t,e,n,i,o){const r=(t+n)/2,a={start:[t,e],steps:[{c1:[r,e],c2:[r,i],to:[n,i]}]};return uJ(hJ(a,-o),hJ(a,o))}function fJ(t,e,n){const{source:i,target:o}=t;return(i.y0+i.y1+o.y0+o.y1)/4<=(e+n)/2?"top":"bottom"}const mJ=t=>Math.abs(t.source.layer-t.target.layer);function pJ(t,e){const n="top"===e?1:-1,i=t=>"top"===e?t.y0:t.y1;return t.slice().sort((t,e)=>mJ(t)-mJ(e)||n*(i(t.source)-i(e.source))||n*(i(t.target)-i(e.target))||e.value-t.value||t.index-e.index)}function gJ(t,e){const n={source:new Map,target:new Map},i=(t,e)=>{const i=e[t].layer,o=n[t].get(i)??0;return n[t].set(i,o+e.width),8+o+e.width/2},o=t.map(t=>({depth:0,arcSource:i("source",t),arcTarget:i("target",t)})),r=t.map((t,n)=>{const i=e(t.source.layer)[1]+o[n].arcSource,r=e(t.target.layer)[0]-o[n].arcTarget,a=t.width/2;return[Math.min(r,i)-a,Math.max(r,i)+a]});return t.forEach((e,n)=>{for(let e=0;e<n;e++)r[e][0]<r[n][1]&&r[n][0]<r[e][1]&&(o[n].depth=Math.max(o[n].depth,o[e].depth+t[e].width))}),o}function yJ(t,e){const n={top:0,right:0,bottom:0,left:0};for(const{side:i,links:o,lanes:r}of t)o.forEach((t,o)=>{const a=r[o],s=12+a.depth+t.width;n[i]=Math.max(n[i],s),t.source.layer===e&&(n.right=Math.max(n.right,a.arcSource+t.width/2)),0===t.target.layer&&(n.left=Math.max(n.left,a.arcTarget+t.width/2))});return n}function xJ(t,e,n,i){const o=i+("top"===n?-1:1)*(12+e.depth+t.width/2),r=t.y0,a=t.y1;return{side:n,xs:t.source.x1,sy:r,xt:t.target.x0,ty:a,laneY:o,xr:t.source.x1+e.arcSource,rs:Math.max(0,Math.min(e.arcSource,Math.abs(r-o)/2)),xl:t.target.x0-e.arcTarget,rt:Math.max(0,Math.min(e.arcTarget,Math.abs(a-o)/2))}}const bJ=.5523;function kJ(t){const{xs:e,sy:n,xt:i,ty:o,laneY:r,xr:a,rs:s,xl:c,rt:l}=t,h="top"===t.side?-1:1,u=[],d=(t,e,n,i,o)=>{u.push({to:t}),u.push({c1:[t[0]+e[0]*bJ*o,t[1]+e[1]*bJ*o],c2:[n[0]-i[0]*bJ*o,n[1]-i[1]*bJ*o],to:n})};return d([a-s,n],[1,0],[a,n+h*s],[0,h],s),d([a,r-h*s],[0,h],[a-s,r],[-1,0],s),d([c+l,r],[-1,0],[c,r-h*l],[0,-h],l),d([c,o+h*l],[0,-h],[c+l,o],[1,0],l),u.push({to:[i,o]}),{start:[e,n],steps:u}}function _J(t){return cJ(kJ(t))}function vJ(t,e){const n="top"===t.side?-1:1;return{...t,sy:t.sy-n*e,ty:t.ty-n*e,laneY:t.laneY+n*e,xr:t.xr+e,xl:t.xl-e,rs:Math.max(0,t.rs+e),rt:Math.max(0,t.rt+e)}}function wJ(t,e){return uJ(kJ(vJ(t,e)),kJ(vJ(t,-e)))}function MJ(t){return Z_([t.xr-t.rs,t.laneY],[t.xl+t.rt,t.laneY])}function SJ(t,e){let n=0,i=0;for(const o of e){const e=Number.isFinite(o.value)?o.value:0;o.source===t&&(n+=e),o.target===t&&(i+=e)}return Math.max(n,i)}function CJ(t,e){const n={source:new Map,target:new Map},i={source:new Map,target:new Map};for(const{side:e,links:o}of t){const t="top"===e?n:i;for(const n of o)for(const i of["source","target"]){const o=n[i],r=t[i].get(o)??0;t[i].set(o,r+n.width);const{y0:a,y1:s}=o,c="top"===e?a+r+n.width/2:s-r-n.width/2;"source"===i?n.y0=c:n.y1=c}}for(const t of e)t.y0+=n.source.get(t.source)??0,t.y1+=n.target.get(t.target)??0}function $J(t){const e=t.find(t=>"number"==typeof t.value&&t.value>0);return e?(e.y1-e.y0)/e.value:0}function AJ(t,e,n){const i=(t,e,n)=>{const i=t+e>n/2?n/2/(t+e):1;return[t*i,e*i]},[o,r]=i(t.top,t.bottom,n),[a,s]=i(t.left,t.right,e);return{top:o,right:s,bottom:r,left:a}}function zJ(t,e,n){const i=new Map;for(const e of t){const t=i.get(e.layer)??{count:0,total:0};t.count++,t.total+="number"==typeof e.value?e.value:0,i.set(e.layer,t)}const o=Math.max(0,...Array.from(i.values(),t=>t.count)),r=Math.min(n,e/(o-1));let a=1/0;for(const{count:t,total:n}of i.values())n>0&&(a=Math.min(a,(e-(t-1)*r)/n));return Number.isFinite(a)?Math.max(0,a):0}function DJ(t,e,n,i){let o=0,r=Math.max(0,i);for(let i=0;i<48;i++){const i=(o+r)/2;t(Math.max(0,n-e(i)))>=i?o=i:r=i}return o}function LJ(t,e,n,i){const o=n>0?(e-t-i)/n:0;return e=>[t+e*o,t+e*o+i]}function FJ(t){const{run:e,nodes:n,links:i,circular:o,width:r,height:a,padding:s}=t;if(e([[0,0],[r,a]]),!o.length||!n.length)return[];const c=t=>o.map(e=>({index:e.i,i:e.i,datum:e.datum,source:n[e.source],target:n[e.target],value:e.value,width:Number.isFinite(e.value)?Math.max(0,e.value)*t:0})),l=Math.max(...n.map(t=>t.depth??t.layer)),h=n[0].x1-n[0].x0,u=c($J(n)),d=new Map(u.map(t=>[t.i,fJ(t,0,a)])),f=new Map(["top","bottom"].flatMap(t=>pJ(u.filter(e=>d.get(e.i)===t),t).map((t,e)=>[t.i,e]))),m=(t,e)=>{const n=c(t);return["top","bottom"].map(t=>{const i=n.filter(e=>d.get(e.i)===t).sort((t,e)=>(f.get(t.i)??0)-(f.get(e.i)??0));return{side:t,links:i,lanes:gJ(i,e)}})},p=t=>{const e=LJ(0,r,l,h),{left:n,right:i}=yJ(m(t,e),l),o=LJ(n,r-i,l,h);return{...yJ(m(t,o),l),left:n,right:i}},g=DJ(t=>zJ(n,t,s),t=>{const e=p(t);return e.top+e.bottom},a,$J(n)),y=AJ(p(g),r,a);e([[y.left,y.top],[r-y.right,a-y.bottom]]);const x=new Map(n.map(t=>[t.layer,[t.x0,t.x1]])),b=m($J(n),t=>x.get(t)??[0,0]);CJ(b,i);const k=function(t,e){const n=Math.min(...e.map(t=>t.y0)),i=Math.max(...e.map(t=>t.y1)),o=new Map;for(const{side:e,links:r,lanes:a}of t)r.forEach((t,r)=>{const s=t;o.set(t.i,{source:t.source,target:t.target,value:t.value,datum:t.datum,width:t.width,y0:s.y0,y1:s.y1,circular:xJ(s,a[r],e,"top"===e?n:i)})});return o}(b,n);return o.map(t=>k.get(t.i))}const NJ=t=>Number.isFinite(t.value)?t.value:0;function BJ(t){let e=0;for(const n of t)e=Math.max(e,n.source+1,n.target+1);const n=Array.from({length:e},()=>[]);for(const e of t)e.source!==e.target&&n[e.source].push(e.target);const i=function(t,e){const n=Array.from({length:t},()=>[]),i=Array.from({length:t},()=>[]),o=new Int32Array(t);let r=0;const a=(t,e,n,i=-1)=>{r++,o[t]=r;const a=[t];for(let t=0;t<a.length;t++)for(const s of e[a[t]]){if(s===i)return null;o[s]!==r&&n(s)&&(o[s]=r,a.push(s))}return a};return(t,o)=>{if(t===o)return!1;const r=e[o],s=e[t];if(r<s){const c=a(o,n,t=>e[t]<=s,t);if(!c)return!1;const l=a(t,i,t=>e[t]>=r),h=(t,n)=>e[t]-e[n];l.sort(h),c.sort(h);const u=l.concat(c),d=u.map(t=>e[t]).sort((t,e)=>t-e);u.forEach((t,n)=>e[t]=d[n])}return n[t].push(o),i[o].push(t),!0}}(e,function(t,e){const n=new Int32Array(t),i=new Uint8Array(t);let o=t;for(let r=0;r<t;r++){if(i[r])continue;i[r]=1;const t=[r],a=[0];for(;t.length;){const r=t.length-1,s=t[r];if(a[r]<e[s].length){const n=e[s][a[r]++];i[n]||(i[n]=1,t.push(n),a.push(0))}else t.pop(),a.pop(),n[s]=--o}}return n}(e,n)),o=t.map((t,e)=>e).sort((e,n)=>NJ(t[n])-NJ(t[e])||e-n),r=new Uint8Array(t.length);for(const e of o)i(t[e].source,t[e].target)||(r[e]=1);const a=[],s=[];return t.forEach((t,e)=>(r[e]?s:a).push(t)),{kept:a,looped:s}}function EJ(t){const e=[],n=[],i=[];for(const o of t)void 0===o.source||void 0===o.target?n.push(o):o.source===o.target?i.push(o):e.push(o);return{drawn:e,unresolved:n,selfLinks:i}}function RJ(t,e){const n="number"==typeof t?t:Number(t);if(null!==t&&""!==t&&Number.isFinite(n)&&n>0)return n;const i=e.filter(t=>Number.isFinite(t)&&t>0);return i.length?Math.min(...i):1}function PJ(t){const e=1===t.length?"1 link":`${t.length} links`,n=Array.from(new Set(t.map(([t,e])=>`${t} → ${e}`))),i=n.length-10;return`Sankey can't draw a flow that loops back into a node it left, so it leaves out ${e} (${n.slice(0,10).join(", ")}${i>0?`, and ${i} more`:""}).`}const TJ=t=>({data:t.data,i:t.i,id:String(t.id)});function OJ(t){const e=function(t,e){const n=new Set;for(const i of t)for(const t of e)n.add(i[t]);return Array.from(n,t=>({id:t}))}(t.schema.links??[],[t.schema.linksSource,t.schema.linksTarget]),n=new Set(e.map((e,n)=>String(t.schema.nodeId(e,n))));return(t._filteredData??[]).forEach((i,o)=>{const r=t.schema.nodeId(i,o);null==r||n.has(String(r))||(n.add(String(r)),e.push(i))}),e}const WJ=({viz:t})=>{const e=t,{width:n,height:i}=wt(e),o=Array.isArray(e.schema.nodes)&&e.schema.nodes.length>0,r=Array.isArray(e.schema.links)&&e.schema.links.length>0;if(!o&&!r)return e.ctx.nodeLookup={},e.ctx.linkLookup={},{viz:t};const a=(o?e.schema.nodes:OJ(e)).map((t,n)=>({__d3plus__:!0,data:t,i:n,id:e.schema.nodeId(t,n),node:t,shape:"Rect"})),s=a.reduce((t,e,n)=>(t[String(e.id)]=n,t),{});e.ctx.nodeLookup=s;const c=function(t,e,n,i){const o=[t.schema.linksSource,t.schema.linksTarget],{drawn:r,selfLinks:a}=EJ(i?t.schema.links.map((t,e)=>({link:t,i:e,source:n[String(t[o[0]])],target:n[String(t[o[1]])]})):[]);return[...r,...a].sort((t,e)=>t.i-e.i).map(({link:n,i:i,source:r,target:a})=>{const s=iw(n,TJ(e[r]),TJ(e[a]),i,o);return{source:r,target:a,value:ow(s,t.schema.value(s,i)),datum:s,i:i}})}(e,a,s,r),{kept:l,looped:h}=BJ(c),u=!1!==e.schema.circularLinks;!u&&h.length&&Pt(e,"sankeyLoops",PJ(h.map(t=>[a[t.source].id,a[t.target].id])));const f=u?h:[],m=f.length?[...l,...f].sort((t,e)=>t.i-e.i):l;rw(e,m.map(t=>t.datum),a.map(TJ)),function(t,e,n){const i=new Set(n.flatMap(t=>[t.source,t.target])),o=n.map(t=>Number(t.value));e.forEach((e,n)=>{if(i.has(n))return;let r;try{r=t.schema.value(e.data,e.i)}catch{r=void 0}e.fixedValue=RJ(r,o)})}(e,a,m);for(const t of new Set(f.flatMap(t=>[t.source,t.target])))a[t].fixedValue=SJ(t,m);e.ctx.linkLookup=function(t){return t.reduce((t,e)=>(t[e.source]||(t[e.source]=[]),t[e.source].push(e.target),t[e.target]||(t[e.target]=[]),t[e.target].push(e.source),t),{})}(m);const p=e.ctx.sankey.nodeAlign(e.schema.nodeAlign).nodePadding(e.schema.nodePadding).nodeWidth(e.schema.nodeWidth).nodes(a).nodeSort(e.schema.nodeSort).links(l).linkSort(e.schema.linkSort).iterations(e.schema.iterations),g=FJ({run:t=>p.extent(t)(),nodes:a,links:l,circular:f,width:n,height:i,padding:e.schema.nodePadding}),y=Array.from(d.groups(a,t=>t.shape));return e.ctx.sankeyCtx={links:[...l,...g],nodeGroups:y,width:n,height:i},{shapeData:a}};function jJ(t){const e="number"==typeof t.width?t.width:0;return Math.max(1,e-2)}function HJ(t,e){return t.circular?wJ(t.circular,e):dJ(t.source.x1,t.y0??0,t.target.x0,t.y1??0,e)}const IJ=t=>LZ(t.map(t=>`${t.source.id??""}-${t.target.id??""}`));function GJ(t){if(t.circular)return MJ(t.circular);if("number"!=typeof t.y0||"number"!=typeof t.y1)return null;const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return ev([e,t.y0],[i,t.y0],[i,t.y1],[n,t.y1])}function qJ(t){if(t.circular)return Uw(_J(t.circular));if("number"!=typeof t.y0||"number"!=typeof t.y1)return null;const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return Uw(`M${e},${t.y0}C${i},${t.y0} ${i},${t.y1} ${n},${t.y1}`)}const VJ={center:t=>t.targetLinks.length?t.depth:t.sourceLinks.length?d.min(t.sourceLinks,t=>t.target.depth)-1:0,justify:GZ,left:t=>t.depth,right:(t,e)=>e-1-t.height};const KJ={name:"Sankey",layoutStage:WJ,emit:({viz:t})=>{const e=t.ctx.sankeyCtx;if(!e)return[];const n=[],i=t.schema.shapeConfig?.Path??{},o=IJ(e.links??[]);if(e.links&&e.links.length){const r=zw(t);for(const[a,s]of e.links.entries()){const e=s.datum,c=ew(e)?.index??0,l=Wg(i,e,c),h=r(e,s);h&&(l.fill=h,l.fillOpacity=Tg(i.fillOpacity,e,c)??.5);const u=jJ(s),d=`sankey-link-${o[a]}`;n.push({type:"path",shapeType:"Link",key:d,d:HJ(s,u/2),datum:e,index:c,paint:l,aria:{label:pw(t,e)}}),n.push({...Sw(d,HJ(s,u/2),e,0),paint:{fill:"transparent",stroke:"transparent",strokeWidth:8},shapeType:"Link"})}}const r=function(t,e){const n=[],i=[];for(const[o,r]of e.nodeGroups??[]){if(!r.length)continue;const a=Hg(t,o),s=n.length;for(let e=0;e<r.length;e++){const i=r[e],s=i.data??i,c=Wg(a,s,i.i??e),l={label:`${jg(t,i,e)}.`};if("Rect"===o)n.push({type:"rect",key:`sankey-${o}-${i.id}`,x:i.x0,y:i.y0,width:i.x1-i.x0,height:i.y1-i.y0,datum:s,paint:c,aria:l});else if("Circle"===o){const t=Number(Tg(a.r,s,i.i??e)??0);n.push({type:"circle",key:`sankey-${o}-${i.id}`,cx:(i.x0+i.x1)/2,cy:(i.y0+i.y1)/2,r:t,datum:s,paint:c,aria:l})}}n.push(...jS(a,n.slice(s),t=>{const e=r[t];return[e.data??e,e.i??t]}));const c=n_(t,r,a,e.width,e.height);i.push(...c),n.push(...c)}return{out:n,labels:i}}(t,e);return e.links&&e.links.length&&n.push(...function(t,e,n,i){return aM(t,e.links.map((t,e)=>({key:`sankey-link-${i[e]}`,link:t,i:e,anchor:GJ(t),path:qJ(t),priority:t.value})),{boxes:e.nodeGroups.flatMap(([,t])=>t.map(t=>({x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0}))),labels:rM(n)})}(t,e,r.labels,o)),n.push(...r.out),n},setup:t=>{const e=t;!function(t){t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),t._focus&&t._focus===n.id)return t.hover(!1),t.schema.on.mouseenter.bind(t)(n,i,o,r),void(t._focus=void 0);const a=(e,n)=>`${t.schema.nodeId(e,n)}`,s=nw(n)?gw(t,n,a):bw(t,n,a);s&&t.hover(s)}}(e),function(t){$I(t);const e=t.schema.on["click.shape"];t.schema.on["click.shape"]=function(n,i,o,r){nw(n)?CI(t,n,{nodeKey:(e,n)=>`${t.schema.nodeId(e,n)}`}):"function"==typeof e&&e.call(this,n,i,o,r)}}(t),e.links=function(){return arguments.length?(_n(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(_n(this,"nodes",arguments),this):this.schema.nodes},e.nodeAlign=function(t){return arguments.length?(this.schema.nodeAlign="function"==typeof t?t:VJ[t],this):this.schema.nodeAlign},e.nodeId=function(t){return arguments.length?(this.schema.nodeId="function"==typeof t?t:G(t),this):this.schema.nodeId},e.value=function(t){return arguments.length?(this.schema.value="function"==typeof t?t:G(t),this):this.schema.value},e.hover=mk},ctx:{linksDirected:!0,sankey:function(){const t={x0:0,y0:0,x1:1,y1:1,dx:24,dy:8,py:8,align:GZ,sort:void 0,linkSort:void 0,iterations:6};let e=[],n=[];const i=()=>{const i=e,o=n;!function(t,e,n){for(const[t,n]of e.entries())n.index=t,n.sourceLinks=[],n.targetLinks=[];const i=new Map(e.map((t,e)=>[e,t])),o=t=>{const e=i.get(t);if(!e)throw new Error("missing: "+t);return e};for(const[t,e]of n.entries()){e.index=t;const n=e;"object"!=typeof n.source&&(e.source=o(n.source)),"object"!=typeof n.target&&(e.target=o(n.target)),e.source.sourceLinks.push(e),e.target.targetLinks.push(e)}if(null!=t.linkSort)for(const{sourceLinks:n,targetLinks:i}of e)n.sort(t.linkSort),i.sort(t.linkSort)}(t,i,o);for(const t of i)t.value=void 0===t.fixedValue?Math.max(d.sum(t.sourceLinks,YZ),d.sum(t.targetLinks,YZ)):t.fixedValue;return UZ(i,"depth"),UZ(i,"height"),function(t,e){const n=function(t,e){const n=d.max(e,t=>t.depth)+1,i=n>1?(t.x1-t.x0-t.dx)/(n-1):0,o=new Array(n);for(const r of e){const e=Math.max(0,Math.min(n-1,Math.floor(t.align(r,n))));r.layer=e,r.x0=t.x0+e*i,r.x1=r.x0+t.dx,o[e]?o[e].push(r):o[e]=[r]}if(t.sort)for(const e of o)e.sort(t.sort);return o}(t,e);t.py=Math.min(t.dy,(t.y1-t.y0)/(d.max(n,t=>t.length)-1)),function(t,e){const n=d.min(e,e=>(t.y1-t.y0-(e.length-1)*t.py)/d.sum(e,YZ));for(const i of e){let e=t.y0;for(const o of i){o.y0=e,o.y1=e+o.value*n,e=o.y1+t.py;for(const t of o.sourceLinks)t.width=t.value*n}e=(t.y1-e+t.py)/(i.length+1);for(let t=0;t<i.length;++t){const n=i[t];n.y0+=e*(t+1),n.y1+=e*(t+1)}nJ(t,i)}}(t,n);for(let e=0;e<t.iterations;++e){const i=Math.pow(.99,e),o=Math.max(1-i,(e+1)/t.iterations);QZ(t,n,i,o),XZ(t,n,i,o)}}(t,i),function(t){for(const e of t){let t=e.y0,n=t;for(const n of e.sourceLinks)n.y0=t+n.width/2,t+=n.width;for(const t of e.targetLinks)t.y1=n+t.width/2,n+=t.width}}(i),{nodes:i,links:o}};return i.nodeAlign=e=>(t.align=e,i),i.nodeSort=e=>(t.sort=e,i),i.nodeWidth=e=>(t.dx=+e,i),i.nodePadding=e=>(t.dy=t.py=+e,i),i.nodes=t=>(e=t,i),i.links=t=>(n=t,i),i.linkSort=e=>(t.linkSort=e,i),i.size=e=>(t.x0=t.y0=0,t.x1=+e[0],t.y1=+e[1],i),i.extent=([[e,n],[o,r]])=>(t.x0=+e,t.y0=+n,t.x1=+o,t.y1=+r,i),i.iterations=e=>(t.iterations=+e,i),i}()},fields:[{key:"circularLinks",default:!0},{key:"iterations",default:6},...cM(),...Mn("links","nodes"),{key:"links",default:H("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:H("nodes")},{key:"nodeAlign",default:GZ},{key:"nodeId",default:H("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeTooltipLinks"},{key:"nodeTooltipStats",default:!0},{key:"nodeTooltipStatsConfig",merge:!0,default:{}},{key:"nodeWidth",default:30},{key:"value",default:W(1)},{key:"shape",default:W("Rect"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({Path:{fill:()=>Z(t._theme,t=>t.link===K.link?e.colorGray[800]:t.link,"#DBDBDB"),fillOpacity:.5,label:!1},Rect:{}})},{key:"tooltipConfig",merge:!0,factory:t=>Mw(t)}]};var YJ=fk(KJ);const UJ=t=>t instanceof Date?+t:"number"==typeof t&&Number.isFinite(t)?t:void 0;function XJ(t){const e=new Map;for(const n of t){if(null==n)continue;const t=n instanceof Date?+n:n;e.has(t)||e.set(t,n)}const n=[...e.values()];return n.every(t=>void 0!==UJ(t))?n.sort((t,e)=>UJ(t)-UJ(e)):n}function QJ(t,e){return e>t?"up":e<t?"down":"flat"}function ZJ(t,e,n,i){const o=XJ(t.map((t,e)=>n(t,e))),r=new Map(o.map((t,e)=>[t instanceof Date?+t:t,e])),a=new Map;t.forEach((t,o)=>{const s=n(t,o),c=r.get(s instanceof Date?+s:s),l=Number(i(t,o));if(void 0===c||!Number.isFinite(l))return;const h=`${e(t,o)}`,u=a.get(h);u?(c<u.first[0]&&(u.first=[c,l]),c>=u.last[0]&&(u.last=[c,l])):a.set(h,{first:[c,l],last:[c,l]})});const s=new Map;return a.forEach(({first:t,last:e},n)=>s.set(n,QJ(t[1],e[1]))),s}const JJ=Object.freeze({up:"#2f9e44",down:"#e03131",flat:"#767676"}),t0=Object.freeze({up:"#51cf66",down:"#ff6b6b",flat:"#adb5bd"});function e0(t,e,n){if(!t)return null;const i={...e?t0:JJ,...n?{flat:n}:{}};return!0===t?i:{...i,...t}}const n0={barConfig:{stroke:"transparent"},labels:[],ticks:[]},i0=t=>t instanceof Date?t.toISOString().slice(0,10):`${t}`;function o0(t){const e=t._filteredData,n=t._x,i=XJ(e.map((t,e)=>n(t,e)));i.length>2&&Pt(t,"slopePeriods",`SlopeChart compares two periods, but its data has ${i.length} (${i.map(i0).join(", ")}). Every period is drawn; filter the data to two periods to compare them.`),t.ctx.slope={directions:ZJ(e,t._id,n,t._y)}}function r0(t,e,n){const i=e0(t.schema.slopeColor,Boolean(t._theme?.dark),t._theme?.textMuted);if(!i)return;for(;e.__d3plus__&&e.data;)n=(e=e.data).i;const o=(t=>t.ctx.slope)(t)?.directions.get(`${t._id(e,n)}`);return o?i[o]:void 0}const a0={name:"SlopeChart",paintDriven:!0,setup:t=>{t._lineMarkers=!0,t._yConfig=r.assign({},t._yConfig??{},n0),t._yTitle=null;const e=t.schema.shapeConfig.fill;t.schema.shapeConfig.fill=(n,i)=>r0(t,n,i)??("function"==typeof e?e(n,i):e),t._lineMarkerConfig=r.assign({},t._lineMarkerConfig??{},{fill:(e,n)=>{const{shapeConfig:i}=t.schema,o=i.Line?.stroke??i.stroke;return"function"==typeof o?o(e,n):o}});const n=t._preDraw.bind(t);t._preDraw=()=>{n(),o0(t)}},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"lineLabels",default:"both"},{key:"lineLabelConfig",merge:!0,default:{value:!0}},{key:"slopeColor",default:!1}]};var s0=fk(a0,oW);var c0=fk({name:"StackedArea",paintDriven:!0,ctx:{},fields:[{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:ZN}]},QN);const l0={labels:[],ticks:[]},h0={name:"Streamgraph",paintDriven:!0,setup:t=>{t._stackOffset=PA("silhouette"),t._stackOrder=NA("insideOut"),t._yConfig=r.assign({},t._yConfig??{},l0)},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"shapeConfig",merge:!0,default:{Area:{curve:"monotoneX"}}}]};var u0=fk(h0,c0);const d0=2*Math.PI;function f0(t,e,n="equal",i){const o=Math.max(0,t);if(e<1)return[[0,o]];const r=e+1,a=void 0!==i&&Number.isFinite(i)?Math.min(Math.max(0,i),o):"area"===n?o*Math.sqrt(1/r):o/r,s=t=>"area"===n?Math.sqrt(a*a+(o*o-a*a)*t/e):a+(o-a)*t/e,c=[[0,a]];for(let t=1;t<=e;t++)c.push([s(t-1),s(t)]);return c}function m0(t,e,n,i){const o=n.endAngle-n.startAngle||1,r=t=>Math.min(d0,Math.max(0,(t-n.startAngle)/o*d0)),a=e-n.depth,s=i[i.length-1]?.[1]??0,[c,l]=a<0?[0,0]:i[a]??[s,s];return{innerRadius:c,outerRadius:l,startAngle:r(t.startAngle),endAngle:r(t.endAngle)}}function p0(t,e,n){if(e)return e;if(!n)return 0;const i=Math.sqrt(t.innerRadius**2+t.outerRadius**2);return i?n/i:0}function g0(t){return t<=180?t-90:t-270}function y0(t){return t>90&&t<270?t-180:t>=270?t-360:t}const x0=2*Math.PI;function b0(t){const{radii:e,...n}=t;return Cq({...n,breadth:x0},t=>{const[n,i]=e[t.depth]??[0,0];return{startAngle:t.x0,endAngle:t.x1,innerRadius:n,outerRadius:i}})}const k0=Aq;const _0=({viz:t})=>{const{width:e,height:n}=wt(t);t.ctx.sunburstWidth=e,t.ctx.sunburstHeight=n,t.ctx.sunburstNodes=new Map,t.ctx.sunburstGhosts=[];const i=function(t){return zq(t,"sunburstPass",()=>{const e={laid:t.ctx.sunburstLaid,radii:t.ctx.sunburstRadii,origin:t.ctx.sunburstZoomOrigin};return t.ctx.sunburstZoomOrigin=void 0,e})}(t),o=t._filteredData??[];if(!o.length)return t.ctx.sunburstLaid=[],t.ctx.sunburstRadii=void 0,t.ctx.sunburstEnterArcs=new Map,t.ctx.sunburstOuterRadius=0,{shapeData:[]};const r=t.schema.shapeConfig??{},a="number"==typeof r.strokeWidth?r.strokeWidth:1,s=Math.max(0,Math.min(e,n)/2-3*a/2),c=k0(t),l=t.schema.groupBy.slice(c.level+1,t._drawDepth+1),h=f0(s,l.length,t.schema.ringSize,function(t,e){const n=t.schema.innerRadius,i="function"==typeof n?n(e):n;return"number"==typeof i&&Number.isFinite(i)?i:void 0}(t,s)),u=b0({data:o,keys:l,firstLevel:c.level+1,focusPath:c.path,sum:t.schema.sum,sort:t.schema.sort,aggs:t.schema.aggs,radii:h}),{laid:d,radii:f,origin:m}=i;t.ctx.sunburstGhosts=m&&d?function(t,e,n,i){return Dq(t,e).map(t=>({id:t.id,datum:t.datum,i:t.i,level:t.level,arc:m0(t,t.depth,n,i)}))}(d,u,m,h):[],t.ctx.sunburstEnterArcs=d&&f?function(t,e,n){return Fq(t,e,(t,e)=>m0(t,t.depth,{startAngle:e.startAngle,endAngle:e.endAngle,depth:e.depth},n))}(d,u,f):new Map,t.ctx.sunburstLaid=u,t.ctx.sunburstRadii=h;const p=t.ctx.sunburstNodes;for(const t of u)Mh(t.datum,t.share),p.set(t.datum,t);return t.ctx.sunburstOuterRadius=s,{shapeData:u}},v0=2*Math.PI,w0=1e-6;function M0(t,e){const n=e.rotate*Math.PI/180,i=Math.cos(n),o=Math.sin(n),r=e.width/2,a=e.height/2,s=(t,n)=>[e.x+t*i-n*o,e.y+t*o+n*i],c=[s(-r,-a),s(r,-a),s(r,a),s(-r,a)];if(c.some(([e,n])=>Math.hypot(e,n)>t.outerRadius+w0))return!1;if(t.innerRadius>0){const n=-e.x*i-e.y*o,s=e.x*o-e.y*i;if(Math.hypot(Math.max(Math.abs(n)-r,0),Math.max(Math.abs(s)-a,0))<t.innerRadius-w0)return!1}const l=t.endAngle-t.startAngle;if(l>=v0-w0)return!0;const h=[...c];if(l>Math.PI)for(let t=1;t<8;t++){const e=t/8;h.push(s(2*r*e-r,-a),s(2*r*e-r,a),s(-r,2*a*e-a),s(r,2*a*e-a))}return h.every(e=>function(t,[e,n]){const i=((Math.atan2(e,-n)-t.startAngle)%v0+v0)%v0;return i<=t.endAngle-t.startAngle+w0||i>=v0-w0}(t,e))}function S0(t,e,n,i,o){const r=r=>M0(t,{x:e,y:n,width:r,height:o,rotate:i});if(!r(w0))return 0;let a=0,s=2*t.outerRadius;for(let t=0;t<16;t++){const t=(a+s)/2;r(t)?a=t:s=t}return a}function C0(t,e,n,i,o,r){const{padding:a,lineHeight:s,maxLines:c}=r;for(let r=1;r<=c;r++){const c=r*s*o+2*a,l=S0(t,e[0],e[1],n,c);if(l<=2*a)return null;if(XP(i,o,l-2*a)<=r)return{width:l,height:c}}return null}function $0(t,e,n,i,o={}){const r=qP(o),a=QP(o=>Boolean(C0(t,e,n,i,o,r)),r.fontMin,r.fontMax);if(null===a)return null;return{fontSize:a,...C0(t,e,n,i,a,r)}}function A0(t,e,n={}){const i=t.endAngle-t.startAngle;if(!(e.words.length&&i>0&&t.outerRadius>t.innerRadius))return null;const o=qP(n);if(t.innerRadius<=0&&i>=v0-w0){const n=$0(t,[0,0],0,e,o);return n?{orientation:"center",x:0,y:0,rotate:0,...n}:null}const r=(t.startAngle+t.endAngle)/2,a=(t.innerRadius+t.outerRadius)/2,s=[a*Math.sin(r),-a*Math.cos(r)],{tangential:c,radial:l}=(h=function(t){return(180*t/Math.PI%360+360)%360}(r),{tangential:y0(h),radial:g0(h)});var h;const u=$0(t,s,c,e,o),d=$0(t,s,l,e,o),f=(t,e,n)=>({orientation:t,x:s[0],y:s[1],rotate:e,...n});return u&&(!d||u.fontSize>=d.fontSize)?f("tangential",c,u):d?f("radial",l,d):null}function z0(t){const e=t.words.length,n=t.words.reduce((t,e)=>t+e,0)+t.space*Math.max(0,e-1);return t=>n*t}function D0(t,e,n,i){const{fontMin:o,fontMax:r}=i,a=new Map,s=new Map;for(const c of e){const e=UP(i.labelOf(c),c.datum,n);if(!e.words.length)continue;const l=i.arcOf(c),h=lT(t,c.datum,c.i??0),u="along"===h?null:A0(l,e,{fontMin:o,fontMax:r}),d="inside"===h||"outside"===h?null:aT(l,z0(e),{fontMin:o,fontMax:r}),f=cT(h,u?{fontSize:u.fontSize,truncated:!1}:null,d,"radial"===u?.orientation?"straight":"curved");"straight"===f&&u&&a.set(c,u),"curved"===f&&d&&s.set(c,d)}return{boxes:a,curves:s}}function L0(t,e,n,i){return HP(t,[...e].map(([t,e])=>({key:`sunburst-curved-${t.id}`,text:i.labelOf(t),fit:e,color:i.colorOf(t),datum:t.datum,index:t.i??0})),OP(n))}function F0(t,e,n){const i=0===t.depth;return{innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,padAngle:i?0:p0(t,e,n)}}function N0(t,e){return t._drawLabel(e.datum,e.i??0,e.level)}const B0=KP;const E0={out:.06,in:.06};const R0={prefix:"sunburst",origin:t=>({startAngle:t.startAngle,endAngle:t.endAngle,depth:t.depth})},P0={name:"Sunburst",layoutStage:_0,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=Hg(t,"Path"),r=Number(t.schema.padAngle)||0,s=Number(t.schema.padPixel)||0,c=t.schema.sum,l=t.schema.locale,h=function(t,e){return Uq(t.schema,e,{color:t.ctx.sunburstDefaultColor,fill:t.ctx.sunburstDefaultFill},"Path")}(t,o),u=t.ctx.sunburstEnterArcs??new Map,d=i.map(e=>{const n=e.i??0,i=F0(e,r,s),d=h(e);return{type:"path",key:`sunburst-${e.id}`,d:a.arcPath(i),arc:i,enterArc:u.has(e.id)?{...u.get(e.id),padAngle:0}:void 0,datum:e.datum,paint:{fill:Og(o,e.datum,n,d),stroke:Tg(o.stroke,e.datum,n),strokeWidth:Tg(o.strokeWidth,e.datum,n),opacity:Tg(o.opacity,e.datum,n)??1},aria:{label:`${t._drawLabel(e.datum,n,e.level)}, ${c(e.datum)}, ${p.formatAbbreviate(100*e.share,l)}%`}}}),f=jS(o,d,t=>[i[t].datum,i[t].i??0]),m=function(t,e){return(t.ctx.sunburstGhosts??[]).map(t=>{const n={...t.arc,padAngle:0};return{type:"path",key:`sunburst-${t.id}`,d:a.arcPath(n),arc:n,paint:{fill:e(t),opacity:1}}})}(t,h),g=function(t,n,i,o){const{padAngle:r,padPixel:a}=o,s=Ig(t,"Path")??{},c="number"==typeof s.fontMin?s.fontMin:8,l="number"==typeof s.fontMax?s.fontMax:24,h=e=>N0(t,e),{boxes:u,curves:d}=D0(t,n,s,{labelOf:h,arcOf:t=>F0(t,r,a),fontMin:c,fontMax:l}),f=n.filter(t=>u.has(t)),m=n=>e.colorContrast((n&&i(n))??"rgb(255, 255, 255)",t.schema.colorDefaults),p=e_({data:f,label:e=>N0(t,e),x:t=>u.get(t).x,y:t=>u.get(t).y,rotate:t=>u.get(t).rotate,aes:()=>({}),id:t=>`sunburst-${t.id}`,datum:t=>t.datum,labelBounds:t=>{const{width:e,height:n}=u.get(t);return{x:-e/2,y:-n/2,width:e,height:n}},labelConfig:{fontMax:l,fontMin:c,split:VP,fontResize:!0,padding:0,textAnchor:"middle",verticalAlign:"middle",fontColor:e=>{let n=e;for(;n&&n.__d3plus__&&n.data;)n=n.data;return m(t.ctx.sunburstNodes.get(n))},...s}});for(const t of p)t.fadeSwap=E0;const g=s.fontColor,y=L0(t,d,s,{labelOf:h,colorOf:t=>{const e=Tg(g,t.datum,t.i??0);return"string"==typeof e?e:m(t)}});return[...p,...y]}(t,i,h,{padAngle:r,padPixel:s}),y=t.ctx.sunburstRadii,x=y&&!i.some(t=>0===t.depth)?XT(t,{radius:y[0][1]},c):[];return[...m,...d,...f,...g,...x]},insetRegion:Ay,thresholdFunction:Oq,chartTransform:t=>Mt(t,t.ctx.sunburstWidth,t.ctx.sunburstHeight),chartBodyRect:t=>{const e=t.ctx.sunburstOuterRadius??0;return{x:-e,y:-e,width:2*e,height:2*e}},setup:t=>Vq(t,R0),shapeDepth:qq(R0),facet:{aspect:1},ctx:{},fields:[{key:"centerLabel",default:!1},{key:"centerLabelConfig",merge:!0,factory:KT},{key:"innerRadius"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"ringSize",default:"equal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...Kq})},{key:"sort",default:Wq,decorate:jq},{key:"sum",default:H("value"),coerce:Hq,onSet:Iq},{key:"shapeConfig",merge:!0,factory:t=>({Path:{labelConfig:{fontResize:!0}},stroke:()=>Tc(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[QT(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:Gq},{key:"legend",coerce:"const",factory:ZT}]};var T0=fk(P0);const O0=`${vh}Depth`,W0=new WeakSet;function j0(t){const e=t?$h(t)[O0]:void 0;return"number"==typeof e?e:void 0}function H0(t){return null==t||""===t}function I0(t){return t.schema.groupBy.slice(0,t._drawDepth+1)}function G0(t,e,n,i){const o=$h(e),r=I0(t);if(i<r.length&&!H0(r[i](o,n)))return i;for(let t=r.length-1;t>=0;t--)if(!H0(r[t](o,n)))return t}function q0(t,e,n){const i=(j0(e)??1)-1,o=G0(t,e,n,i);return o===i?t._drawLabel(e,n,i):t.schema.label||void 0===o?t._drawLabel(e,n):t._drawLabel(e,n,o)}function V0(t){return!H0(t.key)&&Array.isArray(t.values)}function K0(t,e){return t.flatMap(t=>H0(t.key)&&Array.isArray(t.values)?Y0(t,e-1):[t])}function Y0(t,e){const n=t.values;return e<1?n:n.flatMap(t=>Y0(t,e-1))}function U0(t,e){return n.merge(e.values.map(e=>V0(e)?U0(t,e):e),t.schema.aggs)}function X0(t,e,i){const o=t.ctx.tree.separation(t.schema.separation).size([e,i])(L.hierarchy({key:"root",values:K0(n.nest(t._filteredData,t.schema.groupBy.slice(0,t._drawDepth+1)),t._drawDepth+1)},t=>V0(t)?t.values:null).sort(t.schema.sort)).descendants().filter(e=>(e.depth??0)<=t._drawDepth+1&&!!e.parent);return o.forEach((e,n)=>{const i=e.data,o=V0(i)?U0(t,i):{...i};e.data=o,e.__d3plus__=!0,e.i=n,function(t,e){t[O0]=e,(void 0===t.depth||W0.has(t))&&(t.depth=e,W0.add(t))}(o,e.depth??1)}),o}function Q0(t,e,n,i,o){const r=t.schema.label;return{id:(e,n)=>function(t,e,n){const i=e.data,o=(e.depth??1)-1;return G0(t,i,n,o)===o?t._ids(i,n)[o]:I0(t).map(t=>`${t(i,n)}`).join("/")}(t,e,n),label:(e,n)=>{if(r)return r(e.data,n);const i=(e.depth??1)-1;if(G0(t,e.data,n,i)!==i)return q0(t,e.data,n);const o=t._ids(e.data,n).slice(0,e.depth??1);return o[o.length-1]},labelConfig:{fontResize:!1,textAnchor:e=>{const n=e.data??e;return i?"middle":n.children&&n.depth!==t._drawDepth+1?"end":"start"},verticalAlign:t=>{const e=t.data??t;return i?1===e.depth?"bottom":"top":"middle"}},hitArea:(r,a,s)=>{const c=e,l=s.r??(i?s.height/2:s.width/2),h=n[(r.depth??1)-1];return{width:i?h:2*l+h,height:o?c:2*l+c,x:i?-h/2:r.children&&r.depth!==t._drawDepth+1?-(l+h):-l,y:o?-c/2:r.children&&r.depth!==t._drawDepth+1?-(l+e):-l}},labelBounds:(o,r,a)=>{const s=e,c=i?"height":"width",l=a.r??(i?a.height/2:a.width/2),h=n[(o.depth??1)-1],u=i?"width":"height",d=i?"x":"y",f=i?"y":"x";return{[u]:h,[c]:s,[d]:-h/2,[f]:o.children&&o.depth!==t._drawDepth+1?-(l+s):l}}}}const Z0=({viz:t})=>{const e=t.schema.orient,i="vertical"===e,o="horizontal"===e,a=i?t.schema.height-t._margin.top-t._margin.bottom:t.schema.width-t._margin.left-t._margin.right,s=o?t.schema.height-t._margin.top-t._margin.bottom:t.schema.width-t._margin.left-t._margin.right,l=i?"left":"top",h=X0(t,s,a),{labelHeight:u,labelWidths:f}=function(t,e,i,o,r,a,s){let l=t.schema.shapeConfig.r;if("function"!=typeof l){const t=l;l=()=>t}const h=d.max(e,t=>1===t.depth?l(t.data,t.i):0),u=d.max(e,t=>t.children?0:l(t.data,t.i)),f=d.extent(e,t=>t.y),m=d.min([i?50:100,(f[1]-h-u)/(t._drawDepth+2)]);t.ctx.labelHeight=m;const p=n.nest(e,t=>t.depth).map(e=>{const n=e.values;return n.reduce((e,i,o)=>{const a=o<n.length-1?n[o+1].x:r+t._margin[s],c=o?n[o-1].x:t._margin[s];return d.min([e,a-i.x,i.x-c])},r)});t.ctx.labelWidths=p;const g=c.scaleLinear().domain(f).range([h+m,a-u-m]);return e.forEach(t=>{const e=g(t.y);o?(t.y=t.x,t.x=e):t.y=e}),{labelHeight:m,labelWidths:p}}(t,h,i,o,s,a,l);return function(t,e,i,o,a,s){const c=t.schema.shapeConfig,l=e.filter(t=>(t.depth??0)>1).map(t=>r.assign({},t)),h=Q0(t,i,o,a,s),u=t.schema.shape,d=n.nest(e,t=>u(t.data)),f=d.map(t=>t.key),m=(t.ctx.previousShapes??[]).filter(t=>!f.includes(t)),p=d.concat(m.map(t=>({key:t,values:[]})));t.ctx.linksData=l,t.ctx.linkD=t=>{let e=c.r;"function"==typeof e&&(e=e(t.data,t.i));const n=(t.parent.x??0)-(t.x??0)+(a?0:e),i=(t.parent.y??0)-(t.y??0)+(a?e:0),o=a?0:-e,r=a?-e:0;return a?`M${o},${r}C${o},${(r+i)/2} ${n},${(r+i)/2} ${n},${i}`:`M${o},${r}C${(o+n)/2},${r} ${(o+n)/2},${i} ${n},${i}`},t.ctx.shapeGroups=p,t.ctx.shapeConfig=h,t.ctx.previousShapes=f}(t,h,u,f,i,o),{shapeData:h}};function J0(t,e,n){const i=e.data??e,o=e.i??0,r=e.x??0,a=e.y??0;switch(t){case"Circle":{const t=Number(Tg(n.r,i,o)??0);return{geom:{type:"circle",cx:r,cy:a,r:t},aes:{r:t}}}case"Rect":{const t=Number(Tg(n.width,i,o)??0),e=Number(Tg(n.height,i,o)??0);return{geom:{type:"rect",x:r-t/2,y:a-e/2,width:t,height:e},aes:{width:t,height:e}}}case"Path":return{geom:{type:"path",d:String(Tg(n.d,i,o)??"")},aes:{}};default:return null}}const t1={name:"Tree",layoutStage:Z0,emit:({viz:t})=>{const e=t.ctx.linksData,n=t.ctx.linkD,i=t.ctx.shapeGroups,o=t.ctx.shapeConfig;if(!i||!o)return[];const r=[];if(e&&e.length&&n){const i=Hg(t,"Path");for(let a=0;a<e.length;a++){const s=e[a],c=s.data??s,l=Wg(i,c,a),h=o.id(s,s.i??a),u=s.x??0,d=s.y??0;r.push({type:"path",key:`tree-link-${h}`,d:n(s),datum:c,paint:l,transform:{x:u,y:d},aria:{label:`${q0(t,c,s.i??a)}.`}})}}for(const{key:e,values:n}of i){if(!n.length)continue;const i={...Hg(t,e),...o},a=n,s=[];for(let n=0;n<a.length;n++){const c=a[n],l=c.data??c,h=J0(e,c,i);if(!h)continue;const u=o.id(c,n),d=Wg(i,l,n),f={...h.geom,key:`tree-${e}-${u}`,datum:l,paint:d,aria:{label:`${q0(t,l,n)}.`}};r.push(f);const m=WS(i,f,l,n);m&&s.push(m)}r.push(...s);const c=e_({data:a,label:(t,e)=>o.label(t,e),x:t=>t.x??0,y:t=>t.y??0,aes:t=>J0(e,t,i)?.aes??{},rotate:W(0),id:(t,e)=>o.id(t,e),labelBounds:(t,e,n)=>o.labelBounds(t,e,n),labelConfig:{...Ig(t,e),...o.labelConfig}});r.push(...c)}return r},insetRegion:Ay,shapeDepth:(t,e)=>{const n=j0(e);return void 0===n?void 0:n-1},ctx:{tree:L.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(t,e)=>t.parent===e.parent?1:2},{key:"shape",default:W("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>q0(t,e,n),labelConfig:{fontColor:()=>Oc(t)},Path:{fill:"none",stroke:()=>t.schema.colorDefaults.missing,strokeWidth:2},r:W(7),width:W(12),height:W(12)})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>q0(t,e,n)})},{key:"legendTooltip",merge:!0,factory:t=>({title:jl.bind(t)})}]};var e1=fk(t1);const n1={fontSize:11,fontWeight:600,padding:3};function i1(t){if(!1===t.schema.groupLabels)return null;const e=t.schema.groupLabelConfig??{};return{...n1,fontFamily:t.schema.fontFamily,...e}}function o1(t){return Math.ceil(1.2*t.fontSize+2*t.padding)}function r1(t,e){const{drawDepth:n,padding:i,style:o}=t;return t=>{const r=t;if(!o||r.depth<1||r.depth>n||null==r.data.key||!function(t,e,n){return e>=2*o1(n)&&t>=3*n.fontSize+2*n.padding}(r.x1-r.x0,r.y1-r.y0,o))return i;const a=o1(o);return e.set(r,a),a+i}}function a1(t){return t.ancestors().reverse().slice(1).map(t=>`${t.data.key}`).join("/")}const s1=({viz:t})=>{const e=t._filteredData;if(!e||!e.length)return{shapeData:[]};const{width:i,height:o}=wt(t),r=n.nestGroups(e,t.schema.groupBy.slice(0,t._drawDepth+1)),a=L.hierarchy({values:r},t=>t.values).sum(t.schema.sum).sort(t.schema.sort),s=t.schema.layoutPadding,c=new Map,l=i1(t),h=t.ctx.treemap.padding(s).paddingTop(r1({drawDepth:t._drawDepth,padding:s,style:l},c)).size([i,o]).tile(t.schema.tile)(a),u=[];h.children&&function i(o){for(const r of o){if(r.depth<=t._drawDepth){i(r.children??[]);continue}const o=r.data,a=o.values??[],s=1===a.length?e.indexOf(a[0]):void 0,c=r;c.__d3plus__=!0,c.id=o.key,c.i=void 0!==s&&s>-1?s:void 0,c.data=n.merge(a,t.schema.aggs),c.x=r.x0+(r.x1-r.x0)/2,c.y=r.y0+(r.y1-r.y0)/2,u.push(c)}}(h.children);const d=t.schema.sort;u.slice().sort(d).forEach((t,e)=>{t.data.rank=e});const f=h.value;!function(t,e){for(const[i,o]of t){const t=i.leaves().map(t=>t.data),r=n.merge(t,e.aggs);delete r._isAggregation,delete r._threshold,delete r[Dh],r[fe]=i.depth-1;const a=e.label?e.label(r,0):void 0;null!=a&&!1!==a&&""!==a&&(r[me]=`${a}`),Mh(r,(i.value??0)/e.total),i.groupHeader={__d3plus__:!0,data:r,depth:i.depth-1,id:a1(i),x0:i.x0,y0:i.y0,x1:i.x1,y1:Math.min(i.y1,i.y0+o)}}}(c,{aggs:t.schema.aggs,label:l?.label,total:f});const m=t.schema.sum;return u.forEach(t=>{const e=m(t.data)/f;t.share=e,Mh(t.data,e)}),{shapeData:u}};function c1(t,n,o){if(!n.length)return[];const r=new Map,a=e=>{let n=r.get(e);return void 0===n&&(n=Tg(o.fill,e.data,0)??function(t,e,n){if(t.schema.colorScale)return jc(t);const o=Hg(t,"Rect"),r=i.color(`${Tg(o.fill,e,n)}`);return r?r.darker(.8).formatHex():jc(t)}(t,e.data,0),r.set(e,n)),n},s=t.schema.sum,c=e=>t._drawLabel(e.data,0,e.depth),l=n.map(e=>({type:"rect",key:`treemap-group-${e.id}`,x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0,datum:e.data,paint:{fill:a(e)},aria:{label:`${c(e)}, ${s(e.data)}, ${p.formatAbbreviate(100*Ch(e.data),t.schema.locale)}%`}})),h=new Map(n.map(t=>[t.data,t])),u=e_({data:n,label:t=>c(t),x:t=>t.x0,y:t=>t.y0,aes:t=>{const e=t;return{width:e.x1-e.x0,height:e.y1-e.y0}},rotate:W(0),id:t=>`group-${t.id}`,datum:t=>t.data,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;return{x:0,y:0,width:i,height:o}},labelConfig:{fontColor:i=>{const r=h.get(i.data)??n[0];return Tg(o.fontColor,r.data,0)??e.colorContrast(a(r),t.schema.colorDefaults)},...o.fontFamily?{fontFamily:o.fontFamily}:{},fontResize:!1,fontSize:o.fontSize,fontWeight:o.fontWeight,maxLines:1,padding:o.padding,textAnchor:"start",verticalAlign:"middle"}});for(const t of u)t.shapeType="Label";return[...l,...u]}const l1={treemapBinary:L.treemapBinary,treemapDice:L.treemapDice,treemapResquarify:L.treemapResquarify,treemapSlice:L.treemapSlice,treemapSliceDice:L.treemapSliceDice,treemapSquarify:L.treemapSquarify},h1=t=>!!t.children&&1===t.children.length&&!0===t.children[0].data._isAggregation,u1={name:"Treemap",layoutStage:s1,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=t.schema.locale,r=t._drawLabel,a=Hg(t,"Rect"),s=i.map(e=>{const n=Tg(a.fill,e.data,e.i),i=Tg(a.stroke,e.data,e.i),s=Tg(a.opacity,e.data,e.i),c=Tg(a.strokeWidth,e.data,e.i);return{type:"rect",key:`treemap-${e.id}`,x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0,datum:e.data,paint:{fill:Og(a,e.data,e.i,n),stroke:"string"==typeof i||null==i?i:String(i),opacity:s,strokeWidth:c},aria:{label:`${r(e.data,e.i??0)}, ${t.schema.sum(e.data)}, ${p.formatAbbreviate(100*e.share,o)}%`}}}),c=e_({data:i,label:t=>{const e=t;return[r(e.data,e.i??0),`${p.formatAbbreviate(100*e.share,o)}%`]},x:t=>{const e=t;return e.x0+(e.x1-e.x0)/2},y:t=>{const e=t;return e.y0+(e.y1-e.y0)/2},aes:t=>{const e=t;return{width:e.x1-e.x0,height:e.y1-e.y0}},rotate:W(0),id:t=>t.id,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;let r=Math.min(32,.5*(o-10));return r<8&&(r=0),[{width:i,height:o-r,x:-i/2,y:-o/2},{width:i,height:r+10,x:-i/2,y:o/2-r-10}]},labelConfig:{fontMax:32,textAnchor:t=>t&&0===t.l?"start":"middle",verticalAlign:t=>t&&0===t.l?"top":"bottom",fontColor:n=>{const i=n&&n.data?n.data:n,o=Tg(a.fill,i,i.i);return"string"==typeof o?e.colorContrast(o,t.schema.colorDefaults):void 0},...Ig(t,"Rect")}});for(const t of c)t.shapeType="Label";const l=jS(a,s,t=>[i[t].data,i[t].i]),h=i1(t),u=h?c1(t,function(t){const e=new Set;for(const n of t){let t=n.parent;for(;t;t=t.parent)t.groupHeader&&e.add(t.groupHeader)}return[...e].sort((t,e)=>t.depth-e.depth)}(i),h):[];return[...s,...l,...c,...u]},thresholdFunction:(t,e)=>kq(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)}),ctx:{treemap:L.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"groupLabels",default:!0},{key:"groupLabelConfig",default:{},merge:!0},{key:"sort",default:(t,e)=>(e.value??0)-(t.value??0),decorate:(t,e)=>{const n=e;return(t,e)=>{const i=h1(t),o=h1(e);return i&&!o?1:!i&&o?-1:n(t,e)}}},{key:"sum",default:H("value"),coerce:t=>"function"==typeof t?t:G(t),onSet:(t,e)=>{t.schema.thresholdKey=e}},{key:"tile",default:L.treemapSquarify,coerce:t=>{if("string"!=typeof t)return t;const e=`treemap${t.charAt(0).toUpperCase()}${t.slice(1)}`;return l1[e]??L.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i="number"==typeof e.rank?`${e.rank+1}. `:"",o=t.schema.sum;return`${i}${t._drawLabel(e,n)}, ${o(e,n)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[QT(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:t=>JT(t,"sum")},{key:"legend",coerce:"const",factory:ZT}]};var d1=fk(u1);function f1(t){const e=Array.isArray(t)?t:[t];return new Set(e.filter(t=>"box"===t||"quartiles"===t||"points"===t))}function m1(t){const e=t=>{t.interactive=!1;const n=t.children;n&&n.forEach(e)};return t.forEach(e),t}function p1(t,e,n){const i=t.value(e);return t.vertical?{x:n,y:i}:{x:i,y:n}}function g1(t,e,n,i){const{viz:o}=t,r=e.map(t=>t.slot.half*("both"===t.slot.side?.16:.08)),a=Math.max(3,Math.min(10,Math.min(...r))),s=n.vertical,c=Tc(o),l=e.map(({row:t,meta:e,slot:r})=>{const l=`density-box-${t.id}`,h="both"===r.side?r.center:r.center+("start"===r.side?-1:1)*Math.min(4,r.half/4),u=e.summary.values.map((t,e)=>({...p1(n,t,h),id:l,i:e})),d=Pg("Box").renderMode("compute").config({id:t=>t.id,orient:s?"vertical":"horizontal",rectWidth:a,rectConfig:{fill:i,stroke:i,strokeWidth:0},medianConfig:{fill:c},outlierConfig:{Circle:{fill:i,r:1.5,strokeWidth:0}},whiskerConfig:{endpoint:"Rect",endpointConfig:{Rect:{fill:i,height:s?1:a/2,width:s?a/2:1}},lineConfig:{stroke:i,strokeWidth:1}}}).config(o.schema.innerConfig?.box??{}).data(u);return d.render(),{type:"group",key:l,children:Gg(d)}});return dF(l,s?"x":"y"),m1(l)}function y1(t,e,n,i){const{viz:o}=t,r=o.schema.innerConfig?.quartiles??{},a=(t,o)=>{const a=[],s=new Map;e.forEach(({row:e,meta:i,slot:o})=>{t.forEach(t=>{const r=i.summary[t],c=wQ(i.summary.curve,r)*i.scale*o.half,[l,h]=TQ(o,c),u=`density-${t}-${e.id}`;s.set(u,o.center),a.push({id:u,...p1(n,r,l)},{id:u,...p1(n,r,h)})})});const c=Pg("Line").renderMode("compute").config({stroke:i,strokeWidth:1,strokeDasharray:o,curve:"linear"}).config(r).data(a);c.render();const l=Gg(c);return uF(l,n.vertical?"x":"y",s),m1(l)};return[...a(["q1","q3"],"4 3"),...a(["median"],"0")]}function x1(t,e,n){const{viz:i,events:o}=t,r=i.schema.innerConfig?.points??{},a="number"==typeof r.r?r.r:2.5,s=o$(e.map(({meta:t})=>t.summary.observed.map(t=>({value:n.value(t),r:a}))),{padding:.5,extent:Math.max(1,Math.min(...e.map(t=>t.slot.half*("both"===t.slot.side?.8:.4)))),overflow:"shrink"}),c=[];e.forEach(({row:t,meta:e,slot:i},o)=>{const r="both"===i.side?0:("start"===i.side?-1:1)*i.half*.45;e.summary.observed.forEach((a,l)=>{const h=e.summary.rows[l];c.push({__d3plus__:!0,data:h,i:l,id:`density-point-${t.id}-${l}`,...p1(n,a,i.center+r+s.offsets[o][l])})})});const l=Pg("Circle").renderMode("compute").config(Hg(i,"Circle")).config({r:a*s.scale,label:!1,x:t=>t.x,y:t=>t.y}).config(r).data(c);return i._wirePlotShapeEvents(l,"Circle",o),l.render(),Gg(l)}function b1(t,e,n){const i=f1(t.viz.schema.inner);if(!e.length||!i.size)return[];const o=Oc(t.viz),r=(t,e)=>e.length?[{type:"group",key:`violin-${t}`,children:e}]:[];return[...i.has("points")?r("points",x1(t,e,n)):[],...i.has("quartiles")?r("quartiles",y1(t,e,n,o)):[],...i.has("box")?r("box",g1(t,e,n,o)):[]]}const k1=(t,e)=>{const{viz:n,values:i,x:o,y:r,xRange:a,yRange:s,xDomain:c,yDomain:l}=t,h="y"!==n.schema.discrete,u=h?o:r,d=h?r:o,f=h?"x":"y",m=h?a:s,p=h?c:l,g=p.map(t=>u(t,f)).sort((t,e)=>t-e);let y=EQ(m[m.length-1]-m[0],p.length,.5);for(let t=1;t<g.length;t++)y=Math.min(y,g[t]-g[t-1]);const x=i.filter(t=>CQ(t)),b=RQ(x.map(t=>`${t[f]}`),{position:t=>u(t,f),step:y,gap:n._groupPadding??0,split:Boolean(n.schema.split)}),k=x.map((t,e)=>({row:t,meta:CQ(t),slot:b[e]})),_=[];k.forEach(({row:t,meta:e,slot:n})=>{PQ(e.summary.curve,e.scale,n.half).forEach(e=>{const[i,o]=TQ(n,e.extent);_.push({...t,id:$Q(t),__pos:d(e.value),__low:i,__high:o})})});const v=t=>t.__pos,w=t=>t.__low,M=t=>t.__high,S=h?{x:w,x0:w,x1:M,y:v,y0:v,y1:null}:{x:v,x0:v,x1:null,y:M,y0:M,y1:w},C=zF({...t,values:_,shapeConfig:{...t.shapeConfig,...S}},e);return uF(C,f,new Map(k.map(({row:t,slot:e})=>[$Q(t),e.center]))),C.concat(b1(t,k,{vertical:h,value:t=>d(t)}))},_1={name:"Violin",paintDriven:!0,defaults:{groupPadding:16},setup:t=>LQ(t,{valueAxis:t=>"y"===t.schema.discrete?"x":"y",categoryPadding:()=>[.5,.5],emit:k1}),ctx:{},fields:[{key:"discrete",default:"x"},{key:"inner",default:"box"},{key:"split",default:!1},...NQ(),...BQ(2),{key:"innerConfig",merge:!0,default:{box:{},quartiles:{},points:{}}},{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var v1=fk(_1,XN);const w1=t=>Number.isFinite(t)&&t>0?t:0;function M1(t,e){const n=t.map(w1),i=n.reduce((t,e)=>t+e,0),o=Math.max(0,Math.round(w1(e)));if(!i||!o)return n.map(()=>0);const r=n.map(t=>t/i*o),a=r.map(Math.floor);let s=o-a.reduce((t,e)=>t+e,0);const c=r.map((t,e)=>({i:e,r:t-a[e],v:n[e]})).filter(t=>t.v>0).sort((t,e)=>e.r-t.r||e.v-t.v||t.i-e.i);for(let t=0;s>0&&c.length;t=(t+1)%c.length)a[c[t].i]++,s--;return a}function S1(t,{cells:e,unit:n}){if(void 0!==n&&w1(n)){const e=t.map(w1).reduce((t,e)=>t+e,0);return M1(t,Math.round(e/n))}return M1(t,e)}function C1(t,{rows:e,columns:n,fillDirection:i,unit:o}){const r=Math.max(1,Math.round(w1(e))||1),a=Math.max(1,Math.round(w1(n))||1);if(void 0===o||!w1(o))return{rows:r,columns:a};const s=Math.max(1,t);return"column"===i?{rows:r,columns:Math.ceil(s/r)}:{rows:Math.ceil(s/a),columns:a}}function $1(t,{rows:e,columns:n,fillDirection:i,fillStart:o}){let r="column"===i?t%e:Math.floor(t/n),a="column"===i?Math.floor(t/e):t%n;return o.startsWith("bottom")&&(r=e-1-r),o.endsWith("right")&&(a=n-1-a),{row:r,column:a}}function A1(t,e,{rows:n,columns:i,padding:o}){const r=w1(t),a=w1(e),s=Math.max(1,n),c=Math.max(1,i);let l=w1(o),h=Math.min((r+l)/c,(a+l)/s);l>.4*h&&(l=.4*Math.min(r/c,a/s),h=Math.min((r+l)/c,(a+l)/s));const u=Math.max(0,h-l);return{size:u,padding:l,x:(r-(c*u+(c-1)*l))/2,y:(a-(s*u+(s-1)*l))/2}}const z1=["top-left","top-right","bottom-left","bottom-right"];function D1(t){const e=t.schema.fillStart,n=Number(t.schema.unit);return{fillDirection:"column"===t.schema.fillDirection?"column":"row",fillStart:z1.includes(e)?e:"top-left",unit:n>0&&Number.isFinite(n)?n:void 0}}const L1=({viz:t})=>{const e=t._filteredData??[];if(!e.length)return{shapeData:[]};const n=t.schema.sum,i=t.schema.sort,o=e.map((t,e)=>e);"function"==typeof i&&o.sort((t,n)=>i(e[t],e[n])||t-n);const r=o.map(t=>Number(n(e[t],t))),a=r.reduce((t,e)=>t+(Number.isFinite(e)&&e>0?e:0),0),s=r.map(t=>a&&Number.isFinite(t)&&t>0?t/a:0);o.forEach((t,n)=>Mh(e[t],s[n]));const{fillDirection:c,fillStart:l,unit:h}=D1(t),u=C1(0,{rows:Number(t.schema.rows),columns:Number(t.schema.columns),fillDirection:c}),d=S1(r,{cells:u.rows*u.columns,unit:h}),f=C1(d.reduce((t,e)=>t+e,0),{...u,fillDirection:c,unit:h}),{width:m,height:p}=wt(t),g=A1(m,p,{...f,padding:Number(t.schema.cellPadding)||0}),y=g.size+g.padding,x=[];let b=0;return o.forEach((n,i)=>{const o=e[n],r=t._ids(o,n).join("-"),a=s[i];for(let t=0;t<d[i];t++,b++){const e=$1(b,{...f,fillDirection:c,fillStart:l});x.push({__d3plus__:!0,data:o,i:n,id:`${r}-${t}`,k:b,n:t,...e,x:g.x+e.column*y,y:g.y+e.row*y,size:g.size,share:a})}}),t.ctx.waffleTotal=a,t.ctx.waffleGrid=f,t.ctx.waffleGeometry=g,{shapeData:x}};function F1(t,e){const{x:n,y:i,size:o}=t;if("circle"===e)return{type:"circle",cx:n+o/2,cy:i+o/2,r:o/2};const r={type:"rect",x:n,y:i,width:o,height:o};if("rounded"!==e)return r;const a=.25*o;return{...r,rx:a,ry:a}}function N1(t){return"rounded"===t||"circle"===t?t:"square"}function B1(t,e){return null!=t&&Number.isFinite(t)?`${p.formatAbbreviate(100*t,e)}%`:""}function E1(t,e){const n=t.schema.sum;if(e._isColorScaleBucket)return hh(t,e.color,n);const i=$h(e),o=Ch(i);return Number.isFinite(o)?o:Ah(i,t._legendData||[],t=>n(t,0))}function R1(t){const e=()=>t.schema.locale;return[[()=>t.schema.translate("Value"),(n,i,o)=>{if(o&&o._isColorScaleBucket)return"";const r=t.schema.sum,a=Number(r(n,i));return Number.isFinite(a)?p.formatAbbreviate(a,e()):""}],[()=>t.schema.translate("Share"),(n,i,o)=>B1(E1(t,o??{}),e())]]}const P1=t=>!0===t._isAggregation,T1={name:"Waffle",layoutStage:L1,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=N1(t.schema.cellShape),o=Hg(t,"circle"===i?"Circle":"Rect"),r=t.schema.icon,a=t.schema.sum,s=t.schema.locale,c=(t,e)=>r?Tg(r,t,e):void 0,l=n.map(e=>{const{data:n,i:r}=e,l=c(n,r),h=Tg(o.fill,n,r),u=l?{fill:"transparent"}:{fill:Og(o,n,r,h),stroke:Tg(o.stroke,n,r),strokeWidth:Tg(o.strokeWidth,n,r)},d=0===e.n?`${t._drawLabel(n,r)}, ${a(n,r)}, ${p.formatAbbreviate(100*e.share,s)}%`:void 0;return{...F1(e,i),key:`waffle-${e.id}`,index:r,datum:n,paint:{...u,opacity:Tg(o.opacity,n,r)},aria:d?{label:d}:{hidden:!0}}}),h=jS(r?{...o,backgroundImage:(t,e)=>c(t,e)||Tg(o.backgroundImage,t,e),backgroundImageFit:(t,e)=>c(t,e)?"contain":Tg(o.backgroundImageFit,t,e)}:o,l,t=>[n[t].data,n[t].i]);return[...l,...h]},insetRegion:Ay,thresholdFunction:(t,e)=>kq(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)}),facet:{aspect:1},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellShape",default:"square"},{key:"columns",default:10},{key:"fillDirection",default:"row"},{key:"fillStart",default:"top-left"},{key:"icon"},{key:"rows",default:10},{key:"sort",factory:t=>(t=>(e,n)=>{const i=t.schema.sum;return i(n)-i(e)})(t),decorate:(t,e)=>{const n=e;return(t,e)=>{const i=P1(t),o=P1(e);return i&&!o?1:!i&&o?-1:n(t,e)}}},{key:"sum",default:H("value"),coerce:t=>"function"==typeof t?t:G(t),onSet:(t,e)=>{t.schema.thresholdKey=e}},{key:"unit"},{key:"zoom",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:R1(t)})},{key:"legendTooltip",merge:!0,factory:t=>({tbody:R1(t)})},{key:"legendSort",factory:t=>(t=>(e,n)=>{const i=t.schema.sort;return"function"==typeof i?i(e,n):0})(t)}]};var O1=fk(T1);const W1={increase:"Increase",decrease:"Decrease",total:"Total"};function j1(t,n,i){const o=n[`${t}Color`];if("string"==typeof o&&o)return o;const r={...e.colorDefaults,...i};return"increase"===t?r.on:"decrease"===t?r.off:r.sequential}function H1(t,e){return"total"===t.kind?e(t.end):t.change>0?`+${e(t.change)}`:e(t.change)}const I1=t=>"total"===t.kind?t.end>=0:t.change>=0,G1={height:20,width:56,minWidth:64,gap:2};function q1(t,e,n){const i=I1(t),{gap:o}=G1;if(n){const t=Math.max(e.width,G1.minWidth),n=G1.height;return{x:-t/2,y:i?-e.height-n-o:e.height+o,width:t,height:n}}const r=G1.width;return{x:i?e.width+o:-e.width-r-o,y:-e.height/2,width:r,height:e.height}}function V1(t,e){const n=I1(t);return e?{textAnchor:"middle",verticalAlign:n?"bottom":"top"}:{textAnchor:n?"start":"end",verticalAlign:"middle"}}function K1(t,e,n){return t&&"total"!==t.kind?[[n("Running Total"),e(t.end)]]:[]}function Y1(t,e){return({data:n,x:i,y:o,x2:r})=>{if(r||!e.labels())return[i,o];const a=e.vertical(),s=a?o:i,c=n.map(e=>e.data?t(e.data):void 0).filter(t=>!!t),l=s.range(),h=Math.abs(l[l.length-1]-l[0]);if(!c.length||!h)return[i,o];const u=s.domain().slice();a&&u.reverse();const d=a?G1.height+G1.gap:G1.width+G1.gap,f=function(t,e,n){let[i,o]=t;const r=Math.min(Math.max(n,0),.45);if(!r||!e.length)return[i,o];let a=-1/0,s=1/0;for(const t of e)I1(t)?a=Math.max(a,t.end):s=Math.min(s,t.end);for(let t=0;t<8;t++){const t=o-i;Number.isFinite(a)&&(o=Math.max(o,a+r*t)),Number.isFinite(s)&&(i=Math.min(i,s-r*t))}return[i,o]}([u[0],u[1]],c,d/h);return a&&f.reverse(),s.domain(f),[i,o]}}function U1(t,e,n){const i=[],o=t=>{if("rect"===t.type&&"Bar"===t.shapeType&&t.datum?.data){const o=t.datum.data,r=e(o),a=n?(t.transform?.x??0)+(t.x??0):(t.transform?.y??0)+(t.y??0),s=(n?t.width:t.height)??0;r&&Number.isFinite(a)&&Number.isFinite(s)&&i.push({step:r,datum:o,lo:a,hi:a+s})}t.children?.forEach(o)};return t.forEach(o),i}function X1(t,e,n){const i=new Map;for(const e of t){let t=i.get(e.step.series);t||i.set(e.step.series,t=new Map),t.has(e.step.index)||t.set(e.step.index,e)}const o=[];return i.forEach(t=>{t.forEach(i=>{const r=t.get(i.step.index-1);if(!r||!i.step.joins)return;const a=e(r.step.end);if(!Number.isFinite(a))return;const s=i.lo+i.hi>=r.lo+r.hi,c=s?r.hi:r.lo,l=s?i.lo:i.hi;o.push(n?{from:r,x1:c,y1:a,x2:l,y2:a}:{from:r,x1:a,y1:c,x2:a,y2:l})})}),o}function Q1(t,e,n){return"function"==typeof t?t(e,n):t}function Z1(t,e){return t.map((t,n)=>{const i=t.from.datum,o={fill:"none",stroke:Q1(e.stroke,i,n),strokeWidth:Q1(e.strokeWidth,i,n),strokeOpacity:Q1(e.strokeOpacity,i,n)},r=cX(Q1(e.strokeDasharray,i,n));return r&&(o.strokeDasharray=r),{type:"line",key:`waterfall-connector-${t.from.step.series}-${t.from.step.index}`,points:[[t.x1,t.y1],[t.x2,t.y2]],curve:"linear",paint:o,interactive:!1,interactionGroup:"axis"}})}const J1=["increase","decrease","total"],t2=t=>"number"==typeof t&&Number.isFinite(t)?t:void 0;function e2(t,e){const n=Number(t instanceof Date?+t:t)-Number(e instanceof Date?+e:e);return Number.isNaN(n)?0:n}function n2(t,e,n){const i=t.values.filter(t=>void 0!==t),o=i.reduce((t,e)=>t+e,0),{series:r,index:a}=n;if(t.subtotal){const n=i.length?o:e;return{series:r,index:a,category:t.category,kind:"total",start:0,end:n,change:n-e,joins:a>0&&(s=n,c=e,Math.abs(s-c)<=1e-9*Math.max(1,Math.abs(s),Math.abs(c)))}}var s,c;if(i.length)return{series:r,index:a,category:t.category,kind:o<0?"decrease":"increase",start:e,end:e+o,change:o,joins:a>0}}function i2(t,e){const{category:n,series:i,value:o,subtotal:r,sort:a}=e,s=new Map;t.forEach((t,e)=>{const o=`${i(t,e)}`,r=n(t,e),a=r instanceof Date?""+ +r:`${r}`;let c=s.get(o);c||s.set(o,c=new Map);const l=c.get(a);l?l.rows.push([t,e]):c.set(a,{category:r,rows:[[t,e]]})});const c=new Map;return s.forEach((t,e)=>{const n=Array.from(t.values());!function(t,e){e?t.sort((t,n)=>e(t.rows[0][0],n.rows[0][0])):t.sort((t,e)=>e2(t.category,e.category))}(n,a);let i=0,s=0;for(const t of n){const n=n2({category:t.category,values:t.rows.map(([t,e])=>t2(o(t,e))),subtotal:!!r&&t.rows.some(([t,e])=>!!r(t,e))},i,{series:e,index:s});n&&(i=n.end,s++,t.rows.forEach(([t])=>c.set(t,n)))}}),c}function o2(t){const e=new Set;for(const n of t)n&&e.add(n.kind);return J1.filter(t=>e.has(t))}function r2(t,e){return void 0===t2(t)&&e&&"total"===e.kind?e.end:t}function a2(t){return e=>{for(const n of e){const e=n.key;for(const i of n){const n=(i.data??[]).find(t=>t.id===e),o=n&&n.data?t(n.data):void 0;o&&(i[0]=Math.min(o.start,o.end),i[1]=Math.max(o.start,o.end))}}}}const s2="__d3plusWaterfallKind",c2=t=>t.ctx.waterfall,l2=t=>"y"===t.schema.discrete?"y":"x",h2=t=>"x"===l2(t)?"y":"x";function u2(t){for(;t&&(t.__d3plus__||t.__d3plusShape__)&&t.data;)t=t.data;return t}function d2(t,e,n){const i="function"==typeof t.schema.facet?t.schema.facet:void 0,o=n&&"function"==typeof t.schema.time?t.schema.time:void 0,r=c2(t).accessors[l2(t)],a=o&&e.length&&o(e[0],0)!==r(e[0],0)?o:void 0;return(e,n)=>{const o=[t._ids(e,n).slice(0,(t._drawDepth??0)+1).join("_")];return i&&o.unshift(`${i(e,n)}`),a&&o.unshift(`${a(e,n)}`),o.join("|")}}function f2(t){const e=t.schema[`${l2(t)}Sort`];return"function"==typeof e&&e!==c2(t).ySort?e:void 0}const m2=t=>t instanceof Date?""+ +t:`${t}`;function p2(t){const e=c2(t),n=t.schema.ySort;void 0===n||n===e.ySort?"y"===l2(t)?t.schema.ySort=e.ySort=function(t,e){const n=n=>t.get(m2(e(n,0)))??-1;return(t,e)=>n(e)-n(t)}(function(t,e){const n=new Map;t.forEach((t,i)=>{const o=e(t,i),r=m2(o);n.has(r)||n.set(r,o)});const i=Array.from(n.entries()).sort((t,e)=>e2(t[1],e[1]));return new Map(i.map(([t],e)=>[t,e]))}(t._data||[],e.accessors.y),e.accessors.y):e.ySort&&(t.schema.ySort=e.ySort=void 0):e.ySort=void 0}function g2(t,e,n){const i=c2(t);if(!e||!e.length||i.laidOut.has(e))return;i.laidOut.add(e);i2(e,{category:i.accessors[l2(t)],series:d2(t,e,n),value:i.accessors[h2(t)],subtotal:t.schema.subtotal,sort:f2(t)}).forEach((t,e)=>i.steps.set(e,t))}function y2(t,e){const n=u2(e);if(n)return g2(t,t._filteredData,!1),t._axisPersist&&g2(t,t._data,!0),c2(t).steps.get(n)}function x2(t,e){const n=u2(e);if(!n)return;const i=n[s2];return"string"==typeof i?i:y2(t,n)?.kind}function b2(t){const e=u2(t)?.[s2];return"string"==typeof e?e:void 0}function k2(t){const e=t[`_${h2(t)}Config`];return e&&"function"==typeof e.tickFormat?e.tickFormat:e=>p.formatAbbreviate(e,t.schema.locale)}const _2=new WeakSet;const v2=(t,e)=>{const n=x2(t,e);return n?t.schema.translate(W1[n]):void 0},w2=t=>"x"===l2(t);const M2={name:"Waterfall",paintDriven:!0,thresholdFunction:(t,e)=>e,setup:t=>{t.ctx.waterfall={accessors:{x:t._x,y:t._y},steps:new WeakMap,laidOut:new WeakSet},function(t){const e=c2(t);["x","y"].forEach(n=>{const i=`_${n}`,o=t[i];_2.has(o)||(e.accessors[n]=o);const r=(i,o)=>{const r=e.accessors[n](i,o);return h2(t)!==n||void 0!==t2(r)?r:r2(r,y2(t,i))};_2.add(r),Object.defineProperty(t,i,{configurable:!0,enumerable:!0,get:()=>r,set:t=>{_2.has(t)||(e.accessors[n]=t)}})})}(t),t._stackOffset=a2(e=>y2(t,e)),t._stackGroup=(e,n)=>t._ids(e,n).slice(0,t._drawDepth+1).join("_"),t._stackShares=!1,t.schema.color=e=>x2(t,e),function(t){const e=t.schema.shapeConfig.fill;t.schema.shapeConfig.fill=(n,i)=>{const o=x2(t,n);return o?j1(o,t.schema,t.schema.colorDefaults):e(n,i)};const n=(e,n,i)=>{const o=y2(t,e);return o?V1(o,w2(t))[n]:i},i=t.schema.shapeConfig.Bar??{};t.schema.shapeConfig.Bar={...i,ariaLabel:(e,n)=>{const i=y2(t,e);return i?`${i.category}, ${v2(t,e)}: ${H1(i,k2(t))}.`:t._drawLabel(u2(e),n)},label:e=>{const n=y2(t,e);return!!n&&H1(n,k2(t))},labelBounds:(e,n,i)=>{const o=y2(t,e);return!!o&&q1(o,i,w2(t))},labelConfig:{...i.labelConfig??{},fontColor:()=>Oc(t),fontResize:!1,fontSize:12,fontStroke:"transparent",fontStrokeWidth:0,padding:0,textAnchor:t=>n(t,"textAnchor","middle"),verticalAlign:t=>n(t,"verticalAlign","middle")}}}(t),function(t){const e=(e,n)=>v2(t,e)??t._drawLabel(e,n),n=t.schema.legendConfig;t.schema.legendConfig={...n,label:e,shapeConfig:{...n.shapeConfig??{},ariaLabel:e}},t.schema.legendSort=(e,n)=>J1.indexOf(x2(t,e))-J1.indexOf(x2(t,n)),delete t.schema.on["click.legend"];const i=t.schema.on.mouseenter;t.schema.on.mouseenter=function(e,n,o,r){const a=b2(e);if(!a)return i.call(this,e,n,o,r);1!==t.schema.shapeConfig.hoverOpacity&&t.hover(e=>x2(t,e)===a)}}(t),t._buffer={...t._buffer,Bar:Y1(e=>y2(t,e),{vertical:()=>w2(t),labels:()=>!1!==t.schema.shapeConfig.Bar?.label})},t._plotUnderlay=(e,n,i)=>{if(!t.schema.connectors)return[];const o=w2(t);return Z1(X1(U1(e,e=>y2(t,e),o),o?t=>i(t):t=>n(t),o),t.schema.connectorConfig)};const e=t._preDraw.bind(t);t._preDraw=()=>{!function(t){const e=c2(t);e.steps=new WeakMap,e.laidOut=new WeakSet}(t),p2(t),e();const n=t._filteredData||[];t._legendData=o2(n.map(e=>y2(t,e))).map(t=>({[s2]:t}))}},ctx:{},fields:[{key:"connectors",default:!0},{key:"decreaseColor"},{key:"increaseColor"},{key:"legend",coerce:"const",factory:()=>(t,e)=>e.length>1},{key:"stacked",default:!0},{key:"subtotal",coerce:t=>"string"==typeof t?G(t):"function"==typeof t?t:void 0},{key:"totalColor"},{key:"connectorConfig",merge:!0,factory:t=>({stroke:()=>Oc(t),strokeDasharray:"",strokeOpacity:.6,strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>function(t,e,n){const i=u2(e);if(b2(i))return v2(t,i)??"";const o=t._drawLabel(i,n);return"undefined"===o?v2(t,i)??o:o}(t,e,n),tbody:e=>K1(y2(t,e),k2(t),t.schema.translate)})}]};var S2=fk(M2,tB);Object.defineProperty(t,"clearDataCache",{enumerable:!0,get:function(){return n.clearDataCache}}),Object.defineProperty(t,"CanvasRenderer",{enumerable:!0,get:function(){return a.CanvasRenderer}}),Object.defineProperty(t,"SvgRenderer",{enumerable:!0,get:function(){return a.SvgRenderer}}),t.ALLUVIAL_TITLE_GAP=8,t.AREA_LABEL_FONT_MAX=16,t.AREA_LABEL_FONT_MIN=8,t.AREA_LABEL_FONT_WEIGHT=400,t.AREA_LABEL_PADDING=4,t.Alluvial=d_,t.ArcDiagram=oC,t.Area=Xr,t.AreaPlot=QN,t.Axis=Ga,t.AxisBottom=qa,t.AxisLeft=Va,t.AxisRight=Ka,t.AxisTop=Ya,t.BIN_SIZE=12,t.BOTTOM_RIGHT_CONTRIBUTORS=Bb,t.Bar=Zr,t.BarChart=tB,t.BaseClass=Xt,t.Beeswarm=nB,t.Box=La,t.BoxWhisker=gB,t.BubbleChart=wB,t.Bullet=bE,t.BumpChart=_E,t.CANDLESTICK_SHAPE=zP,t.CHORD_LABEL_FONT_SIZE=11,t.CHORD_LABEL_PADDING=4,t.CIRCULAR_CLEARANCE=12,t.CIRCULAR_RADIUS=8,t.CLUSTER_LABEL_DEFAULTS=oK,t.CLUSTER_MAX=12,t.CONNECTOR_KEY_SUFFIX=KO,t.CONTOUR_DEFAULTS=rG,t.CONTOUR_LABEL_FONT_SIZE=10,t.CONTOUR_LABEL_MAX_LEVELS=5,t.Calendar=pR,t.Candlestick=PP,t.Chord=xT,t.Circle=na,t.ColorScale=Qs,t.DEFAULT_AGGS=TR,t.DEFAULT_BAND_OPACITY=IC,t.DENSITY=MQ,t.DOMAIN_CLIP_KEY=XD,t.Donut=VO,t.Dumbbell=iW,t.EDGE_BUNDLE_DEFAULTS=y_,t.END_LABEL_AXIS_CONFIG=uD,t.FACET_ASPECT=oe,t.FACET_PADDING=20,t.FACET_TITLE_DEFAULTS=ie,t.FORMAT_KEYS=gn,t.FanChart=aW,t.Funnel=QW,t.GAP_DASH=TL,t.GLOBE_KEY_DURATION=200,t.GLOBE_KEY_INSTRUCTIONS=FI,t.GLOBE_KEY_SHORTCUTS=LI,t.GLOBE_KEY_STEP=10,t.Gantt=eH,t.Gauge=oH,t.Geomap=VI,t.HEXBIN_META=oG,t.HEXBIN_SHAPE=iG,t.Hexbin=iq,t.Histogram=bq,t.IDLE_BUDGET=12,t.INSET_PRIORITY=wd,t.Icicle=dV,t.IdleQueue=Qe,t.Image=Na,t.KEYBOARD_NAV_INSTRUCTIONS=ll,t.LABEL_COMBOS=sb,t.LABEL_FONT_SIZE=12,t.LABEL_INDENT=12,t.LABEL_PADDING=8,t.LEADER_OPACITY=.5,t.LINK_HIT_WIDTH=8,t.LINK_LABEL_DEFAULTS=nM,t.LINK_LABEL_MAX_TURN=Yw,t.LINK_LABEL_MIN_RADIUS=2,t.LINK_LABEL_STRAIGHT_TURN=.03,t.LINK_SIZE_SHARE=.5,t.LOOP_ARROW="↻",t.Legend=is,t.Line=Ma,t.LinePlot=oW,t.Lollipop=SV,t.MARK_TYPES=ze,t.MAX_ROW_STEP=40,t.Marimekko=NV,t.Matrix=OV,t.Message=ac,t.NODE_STATS=Rv,t.NO_ROOM=DO,t.NO_SIDES=ab,t.Network=zK,t.OUTSIDE_ENTER=vO,t.OUTSIDE_LABEL_FONT_SIZE=12,t.OUTSIDE_MAX_SHARE=.3,t.PIE_MIN_SCALE=.6,t.POINT_DEFAULTS=aG,t.Pack=WK,t.ParallelCoordinates=jY,t.Path=Ea,t.Pie=qO,t.Plot=XN,t.PolarArea=KU,t.Priestley=XU,t.Pyramid=PX,t.RADIAL_BAR_MIN_LABEL_GAP=QX,t.REFERENCE_BAND=j$,t.REFERENCE_LINE=W$,t.REMAINING_MIX=.6,t.RESET=nt,t.RESOLVES_RESET=ot,t.RING_LABEL_FADE=TP,t.Radar=qX,t.RadialBar=dQ,t.RadialMatrix=xQ,t.Rect=ta,t.Ridgeline=IQ,t.Rings=IZ,t.STAT_PENDING="…",t.STEM_KEY_SUFFIX=fV,t.STRAIGHT_LABEL_DEFAULTS=OT,t.Sankey=YJ,t.Scatter=xB,t.Shape=Yr,t.SizeLegend=rc,t.SlopeChart=s0,t.StackedArea=c0,t.Streamgraph=u0,t.Sunburst=T0,t.TOP_LEFT_CONTRIBUTORS=Kp,t.TextBox=ei,t.Timeline=_c,t.Tooltip=Lc,t.Tree=e1,t.Treemap=d1,t.VIOLIN_PADDING=.5,t.VOLUME_DEFAULTS=iP,t.Violin=v1,t.Viz=dk,t.Waffle=O1,t.Waterfall=S2,t.Whisker=$a,t.absoluteFormat=rX,t.accessor=H,t.addDays=$E,t.aggregateAlluvial=kk,t.aggregateFunctionFields=HR,t.alignAxisLine=bD,t.alignInsets=db,t.allotEndLabelWidths=gD,t.alluvialColumns=Ck,t.alluvialDef=u_,t.alluvialDimensions=Bk,t.alluvialEmit=o_,t.alluvialGroupBy=Ek,t.alluvialHighlight=a_,t.alluvialMeta=Dk,t.alluvialNodeId=Xk,t.alluvialPathRows=Qk,t.alluvialPathText=_k,t.alluvialRibbon=Ak,t.alluvialTitleBoxes=Ik,t.alluvialTitleNodes=Kk,t.alluvialTitleStyle=qk,t.alluvialTitleTooltip=Gk,t.alluvialTooltipRows=l_,t.alluvialTooltipTitle=c_,t.alluvialValue=h_,t.alluvialValueTitle=Uk,t.anchorPoint=C$,t.angleCompatibility=k_,t.annotationLayer=SL,t.annotationTextNode=N$,t.annotationTextStyle=L$,t.appendFocusRing=El,t.applyAlluvialLayout=Jk,t.applyArcDiagramLayout=OS,t.applyAxisBreaks=ao,t.applyAxisRangeBreaks=Vo,t.applyBarWidths=ex,t.applyBulletLayout=aE,t.applyCalendarLayout=sR,t.applyChordLabelGeometry=mT,t.applyChordLayout=gT,t.applyFunnelLayout=CW,t.applyGanttLayout=Pj,t.applyGaugeLayout=TB,t.applyGeomapLayout=hI,t.applyIcicleLayout=oV,t.applyLineStates=TY,t.applyMatrixLayout=EV,t.applyNetworkLayout=eK,t.applyOverlayColorScheme=fp,t.applyPackLayout=NK,t.applyPaddedDomains=f$,t.applyParallelLayout=hY,t.applyPieLayout=IO,t.applyPolarAreaLayout=GU,t.applyPriestleyLayout=YU,t.applyRadarLayout=IX,t.applyRadialBarLayout=sQ,t.applyRadialMatrixLayout=pQ,t.applyRingArc=cZ,t.applyRingsLayout=DZ,t.applySankeyLayout=WJ,t.applySunburstLayout=_0,t.applySwarmLanes=l$,t.applyTreeLayout=Z0,t.applyTreemapLayout=s1,t.applyVizTheme=lp,t.applyWaffleLayout=L1,t.arcApex=pS,t.arcArrowEdge=xS,t.arcBox=bS,t.arcCubics=aZ,t.arcDiagramDef=iC,t.arcDiagramEmit=QS,t.arcEndTip=gS,t.arcFocus=ZS,t.arcLabelAnchor=HS,t.arcLabelPath=IS,t.arcLoopReach=AS,t.arcLoopRoom=LS,t.arcNodeGroup=BS,t.arcPathD=mS,t.arcPoint=fS,t.arcPointAlong=yS,t.arcRadiusScale=NS,t.arcScale=uS,t.arcSideOf=hS,t.arcSizeLegendScale=TS,t.arcTableData=nC,t.arcVisibleD=KS,t.arrowAlongChord=mM,t.arrowTrim=gv,t.arrowheadPoints=dL,t.autoForecastStart=function(t){const e=NC(Array.from(BC(t).values()));return e?e.value:null},t.autoLineOpacity=YK,t.awayFromAngle=RM,t.axisBarNodes=lo,t.axisDomain=XK,t.axisPixel=k$,t.axisPositions=UK,t.axisSpan=w$,t.axisTooltipTarget=kr,t.backContribution=Rf,t.backdropDecor=wF,t.backgroundImageNode=WS,t.backgroundImageNodes=jS,t.backgroundInk=Oc,t.bandAxisDefaults=nP,t.bandColor=Jx,t.bandFontWeight=Qx,t.bandOpacityTargets=UC,t.bandPolygon=VD,t.bandRibbonD=dJ,t.bandRows=cz,t.bandSections=Vx,t.bandStep=sX,t.barKey=Xy,t.barSpanAxisConfig=cx,t.barWidthAccessor=Qy,t.barWidthLabel=lx,t.barWidthTooltipRows=hx,t.baselineBreakAxisConfig=Mx,t.baselineBreakStyle=io,t.baselineDomainAxis=px,t.beeswarmDef=eB,t.betweenPoints=wC,t.binAccumulate=lq,t.binArea=ZI,t.binAriaLabel=TG,t.binBounds=XI,t.binCumulativeNormalize=cq,t.binData=uq,t.binMeasure=JI,t.binPath=QI,t.binPoints=UI,t.binRows=gG,t.bindAccessors=mh,t.bindSvgBackgroundClick=SI,t.binsInView=xG,t.blockDays=EE,t.blockGrid=IE,t.blockMonths=RE,t.blockWeeks=BE,t.bottomRightClearance=Pd,t.bottomRightControlsBox=Nd,t.bottomRightControlsDrop=Rd,t.bottomRightControlsFeature=Rb,t.bottomRightControlsInset=Ed,t.bottomRightControlsShortfall=Td,t.boundOrValue=QC,t.bowedEdge=gZ,t.boxCoverage=V_,t.boxHitsCircle=K_,t.boxLabelsOnly=eb,t.boxesOverlap=Y_,t.bracketPath=uj,t.breakGap=co,t.breakLineNodes=ID,t.breakLinePaint=HD,t.breakLines=nF,t.breakStyle=eo,t.breakStyleOf=no,t.breakTickValues=so,t.broadcastLegend=Ke,t.broadcastLink=Ge,t.brokenBarScene=ho,t.brokenScale=Zi,t.brokenScaleTicks=Ji,t.brokenTimeScale=Do,t.brushFromPixels=pY,t.brushTarget=lY,t.bsplinePolyline=m_,t.bubbleChartDef=vB,t.bubbleEmit=_B,t.buildRingsEdges=CZ,t.bulletAxis=IB,t.bulletBands=OB,t.bulletDef=xE,t.bulletExtents=nE,t.bulletStack=XB,t.bumpLineLabels=FD,t.bundleEdges=R_,t.bundleFlowLinks=DH,t.bundleLinkPaths=lH,t.bundleNetworkLinks=HV,t.bundledLinkAnchor=VV,t.bundledLinkEdge=GV,t.bundledLinkPath=qV,t.bundledTipBack=IV,t.calendarBlocks=NE,t.calendarDateFormat=rR,t.calendarDateSpecifier=OE,t.calendarDayKey=SE,t.calendarDef=mR,t.calendarEmit=dR,t.calendarFormatter=TE,t.calendarInsets=QE,t.calendarLabelStyle=oR,t.calendarLayout=JE,t.calendarOrient=iR,t.calendarPalette=cR,t.calendarPeriod=nR,t.calendarTimeLocale=PE,t.calloutNodes=kL,t.calloutPicker=xL,t.calloutRowNodes=bL,t.cancelIdleWork=tn,t.candleAriaLabel=CP,t.candleChange=kR,t.candleDirection=bR,t.candlePath=SR,t.candleTexture=FP,t.candleTooltipRows=SP,t.candleWidth=wR,t.candlestickBuffer=YR,t.candlestickDef=RP,t.canvasTooCoarse=Nm,t.capClusters=ZM,t.capReserve=AJ,t.cartesian=YH,t.cascadeTheme=$i,t.categoryGaps=ZO,t.categoryHalfStep=v$,t.categoryStep=EQ,t.cellCornerRadius=KE,t.centerLabelLines=GT,t.centeredSectorBox=PT,t.chartBackground=Tc,t.chartGridline=Wc,t.chartName=dl,t.chooseRingLabel=cT,t.chordAllCurved=fT,t.chordAngle=fM,t.chordArrowNodes=_M,t.chordCurves=dT,t.chordDef=yT,t.chordEndsPathD=kM,t.chordLabelFontSize=uT,t.chromeNode=Pk,t.circularLanes=gJ,t.circularLinkAnchor=MJ,t.circularLinkD=_J,t.circularLinkEdge=kJ,t.circularLinkOrder=pJ,t.circularLinkShape=xJ,t.circularLinkSide=fJ,t.circularReserve=yJ,t.circularRibbonD=wJ,t.claimRings=vZ,t.clampBarConfig=Ax,t.clampBox=hL,t.clampSides=LO,t.classTimelineMode=xc,t.clearGraphFocus=Cn,t.clearLinkFocus=wI,t.clearPanelSlots=lu,t.clearRingLabels=IP,t.clearStrip=MY,t.clientAnchor=vu,t.clientPoint=eu,t.clipBands=oF,t.clipSpan=M$,t.clipToPlotArea=oL,t.clipsToCircle=vH,t.closestFreeOffset=JC,t.clusterAutoActive=YM,t.clusterFields=KM,t.clusterHubs=JM,t.clusterLabelObstacles=lK,t.clusterLabelSettings=rK,t.clusterLegendRows=eS,t.clusterLegendSort=oS,t.clusterName=tS,t.clusterOf=iS,t.clusterRegion=pK,t.clustersMeaningful=XM,t.coerceFacet=re,t.coerceLinkColor=Cw,t.collectAnnotationGroup=vL,t.colorRows=kG,t.colorScaleColor=ch,t.colorScaleFeature=Jg,t.colorScaleRows=SG,t.colorScaleValue=sh,t.colorValue=lR,t.columnEdges=LJ,t.columnHighlight=gR,t.columnScale=zJ,t.compareCategories=e2,t.compareFacetValues=kg,t.comparisonOutline=aX,t.compatibilityGraph=A_,t.complementIntervals=GL,t.computeAxisLayout=function(t){return br(t),{bounds:t._outerBounds,d3Scale:t._d3Scale,d3ScaleNegative:t._d3ScaleNegative,getPosition:e=>t._getPosition(e),availableTicks:t._availableTicks,visibleTicks:t._visibleTicks,margin:t._margin}},t.computeFilteredData=cg,t.computeSizeLegend=ec,t.computeTimeFilter=sg,t.confidenceBands=KC,t.configOpenDomain=fx,t.configPrep=te,t.configWarnings=function(t){if(!arguments.length)return Ft;Ft=!!t},t.connectorBars=U1,t.connectorEndpoints=uL,t.connectorNodes=Z1,t.connectorSegments=X1,t.connectorStroke=eW,t.constant=W,t.contourAriaLabel=OG,t.contourLabelSpacing=GG,t.contourLabelStep=HG,t.contourLevelText=BG,t.contourLevels=tG,t.contourPath=eG,t.contourRings=jG,t.contourRows=yG,t.conversionModes=$W,t.conversionRates=bW,t.coordinateLabel=SH,t.coordinateVisible=wH,t.cornerControlsHeight=ly,t.cornerPlacements=hy,t.countRows=Yk,t.createKeyboardNavHost=fl,t.crossLayout=kS,t.crowdedRoom=BO,t.cubicAngle=tv,t.cubicArrowEdge=pM,t.cubicMidpoint=ev,t.cubicPathD=Mv,t.cubicPoint=J_,t.cubicPolyline=dM,t.cubicsArrowEdge=yM,t.cubicsPathD=gM,t.curveFactory=yC,t.curvePoints=Uw,t.curvePolyline=YL,t.curveRingsEdge=lZ,t.curvedLabelPad=eM,t.curvedLabelSpot=tM,t.dashArray=cX,t.dateExtent=FE,t.dayCount=$j,t.daysBetween=CE,t.defaultArrowSize=mv,t.defaultCalendarDate=fR,t.defaultSizeLegendValues=tc,t.densify=Yx,t.densityAt=wQ,t.densityContours=nG,t.densityGroups=kQ,t.densityMeta=CQ,t.densityShapeId=$Q,t.densityStats=bQ,t.densityTooltipRows=FQ,t.densityWidthScale=_Q,t.dependencyIds=kj,t.dependencyNodes=Gj,t.dependencyStyle=Oj,t.detectDimensions=IK,t.diamondPath=lj,t.dimensionAxisConfig=QK,t.dimensionDomain=qK,t.dimensionTitleStyle=ZK,t.dimensionTooltipRows=$Y,t.dimensionType=GK,t.discreteDirection=kF,t.discreteOrder=LC,t.discreteRank=FC,t.distanceAlong=Qw,t.domainEnds=fD,t.dragRotation=JH,t.drawChart=Lb,t.drawFacets=Db,t.drawWithInset=Oy,t.dropHiddenRows=eg,t.dropLegendHistory=Ae,t.dumbbellDef=nW,t.dumbbellEmit=QO,t.dumbbellSpans=YO,t.edgeArrowTrims=kv,t.edgeBundleCache=F_,t.edgeBundleKey=B_,t.edgeBundleOptions=N_,t.edgeCompatibility=function(t,e){return k_(t,e)*__(t,e)*v_(t,e)*M_(t,e)},t.edgeD=cJ,t.edgesBetween=dZ,t.effectiveDuration=Jt,t.elbowRoute=dj,t.ellipsize=gj,t.emitAnnotations=$L,t.emitArcLabels=CS,t.emitAreaLabels=tb,t.emitCandlesticks=NP,t.emitClusterLabels=yK,t.emitContourLabels=YG,t.emitEndLabels=kD,t.emitFillBetween=SC,t.emitFlowLabels=kI,t.emitFlowLinks=bI,t.emitForecast=vF,t.emitInner=b1,t.emitLineBands=NL,t.emitLineLabelConnectors=ND,t.emitLinkLabels=aM,t.emitOutsideLabels=Pw,t.emitVolume=bP,t.endLabelSpace=pD,t.estimatedColorRows=$G,t.expandArea=fb,t.expandReferenceBands=V$,t.expandReferenceLines=q$,t.extraBandValues=ZC,t.facetActive=de,t.facetAreaMargin=_b,t.facetBodyNode=bb,t.facetDimensions=ob,t.facetFilteredData=Mg,t.facetGrid=rb,t.facetGroups=wg,t.facetKey=xg,t.facetOuterAxes=he,t.facetPanelAt=su,t.facetPanelNode=kb,t.facetScalesShared=ue,t.facetTimeFilter=Sg,t.facetTitleBand=Cb,t.facetTitleNodes=xb,t.facetTitleStyle=Mb,t.facetTitleTexts=Sb,t.fanChartDef=rW,t.fanOrder=BM,t.fanParallelEdges=kZ,t.featureAnchor=dH,t.fillBetweenDefaults=_C,t.fillBetweenPairs=vC,t.findClusters=UM,t.finiteValue=yR,t.firstPerNeighbor=uZ,t.firstValue=NR,t.fitBreakSpace=ro,t.fitCalendar=jE,t.fitFontSize=AW,t.fitInset=Ey,t.fitLabel=yj,t.fitLabels=vS,t.fitLineLabelText=kz,t.fitRing=AT,t.fitSwarms=o$,t.fittedArea=ib,t.flowArc=bH,t.flowArrowEdge=xI,t.flowEndResolver=CH,t.flowHoverPredicate=zI,t.flowLinkBox=AI,t.flowLinkCoordinates=$H,t.flowLinkGray=pI,t.flowLinkKey=mI,t.flowLinkWidths=AH,t.focusLink=CI,t.focusRingNode=Gc,t.focusRingStyle=wl,t.focusTargets=al,t.forEachSceneRow=De,t.forecastDashOr=SF,t.forecastDefaults=DC,t.forecastLineDash=MF,t.forecastRow=EC,t.forecastRows=CF,t.forecastStart=PC,t.forgetLinkNodes=aw,t.formatAlluvialValue=i_,t.formatChange=wP,t.formatDimensionValue=CY,t.formatFacetValue=Cg,t.formatPayload=bn,t.formatPrice=vP,t.formatShare=B1,t.formatterFor=xn,t.frameTotals=eX,t.frozenAxis=DD,t.funnelCurve=MW,t.funnelDef=XW,t.funnelEmit=GW,t.funnelFacetHooks=YW,t.funnelFacetPanel=KW,t.funnelLabelNodes=WW,t.funnelOrder=_W,t.funnelOrient=wW,t.funnelStages=SW,t.funnelTooltipRows=UW,t.ganttAriaLabel=Fj,t.ganttDef=tH,t.ganttDomain=Ej,t.ganttDuration=Cj,t.ganttEmit=Qj,t.ganttLabelFont=mj,t.ganttRows=vj,t.ganttTasks=Bj,t.ganttTooltipRows=Lj,t.gapComparator=JO,t.gapIndex=ko,t.gapMiddle=nZ,t.gapsAfter=WL,t.gaugeDef=iH,t.geomapDef=qI,t.geomapFlowLinks=LH,t.geomapLinkFields=WI,t.geomapPointLabels=fI,t.gestureHolds=iu,t.gestureHoverEnd=au,t.gestureHoverMove=ru,t.gestureHoverStart=ou,t.gestureMoves=nu,t.getTopLeftContributions=Yp,t.globeHome=iI,t.globeKeyStep=PI,t.globeRotates=nI,t.goBack=Bf,t.graphLinkEnd=jM,t.graphNodeId=HM,t.graphNodeRows=IM,t.greatCircle=mH,t.greatCircleCut=yH,t.gridStroke=_i,t.groupFacets=vg,t.groupNodes=jj,t.growFromLine=uF,t.growRectsFromCenter=dF,t.gutterAxisDefaults=wX,t.gutterInset=mX,t.gutterStackOffset=pX,t.gutterWidth=yX,t.handleAxisTooltip=xh,t.hasBrushes=mY,t.hasColorValue=hR,t.hasFullConfigDomain=yx,t.hasOpenUserEnd=kx,t.hasUserDomain=gx,t.hexbinBuffer=DG,t.hexbinDef=nq,t.hexbinEmit=tq,t.hexbinMeta=cG,t.hexbinRow=hG,t.hexbinSettings=dG,t.hexbinState=fG,t.hexbinTooltipRows=PG,t.hexbinTooltipTitle=RG,t.hexbinValue=lG,t.hidesAllTime=Mo,t.histogramDef=xq,t.histogramHeightLabel=mq,t.hoverReach=gu,t.icicleBands=Qq,t.icicleCollapse=Jq,t.icicleDef=uV,t.icicleLabelBox=rV,t.icicleLayout=nV,t.icicleRect=Zq,t.icicleRootEdge=tV,t.icicleStagger=eV,t.idleQueue=Je,t.inPlot=S$,t.incomingBarycenters=Mk,t.inertAxis=Lr,t.inheritedFillStyle=AC,t.inkAxis=wi,t.inkBackground=ki,t.inkGrid=Mi,t.inkText=vi,t.innerSet=f1,t.insetBackground=zd,t.insetComponentOffset=Ld,t.insetFrame=Ad,t.insetOrient=$d,t.insetPlacementFor=Cd,t.insetStyle=Md,t.insideFontMin=Ow,t.installAlluvialHover=s_,t.installClusters=rS,t.installDensity=LQ,t.installFluent=kt,t.installFocusBackgroundClick=$I,t.installGlobeKeys=OI,t.installGlobeRotation=oI,t.installGraphFluent=WM,t.installVolumeStrip=gP,t.intersectIntervals=IL,t.intervalsDash=qL,t.isAggregatedBranch=vq,t.isAxisTooltipDatum=yh,t.isBrokenScale=Ui,t.isBrokenTimeScale=Co,t.isDarkColor=Y,t.isDomainClip=aL,t.isExpandOffset=$V,t.isFluentAccessor=xt,t.isFormatKey=yn,t.isFullTurn=vT,t.isHiddenTime=vo,t.isInsetPending=Sd,t.isLegendEntry=ke,t.isLinkDatum=nw,t.isLonLat=hH,t.isMilestone=xj,t.isMissing=HK,t.isMissingCategory=yk,t.isNumeric=jK,t.isNumericRange=uY,t.isOneSided=dx,t.isPointShape=mu,t.isRangeBreakRule=mo,t.isScaleValue=oh,t.isSelfLoop=vM,t.isSelfLoopMark=wM,t.isTimeAxis=nj,t.isVertical=x$,t.keepNumericRows=eq,t.keyedAccessor=zR,t.kindColor=j1,t.labelAlign=V1,t.labelBarWidth=Zy,t.labelBox=q1,t.labelColumnWidth=fj,t.labelCorners=iv,t.labelCut=vr,t.labelExpansions=lb,t.labelFitsInside=Lw,t.labelGoesOutside=bO,t.labelGutter=hb,t.labelHitsBox=cv,t.labelHitsCircle=sv,t.labelKey=cb,t.labelMetrics=KP,t.labelNodes=Wj,t.labelOverhang=mb,t.labelOverlapsLine=Mz,t.labelPadding=UE,t.labelPositionOf=Bw,t.labelReach=wS,t.labelSizeCap=OW,t.labelSizes=Ux,t.labelSpotBox=R$,t.labelStretch=Jw,t.labelWidth=pj,t.labelWidthLimit=MS,t.labelledLevels=IG,t.labelsAlongBand=qx,t.labelsOverCircles=LL;t.labelsOverlap=av,t.labelsXEnds=dD,t.largestFirst=kB,t.largestRadius=gV,t.largestRemainder=M1,t.largestSectorBox=TT,t.largestValue=lW,t.lastValue=BR,t.latestDrillEntry=_e,t.layOutCircular=FJ,t.layerOpacities=XC,t.layoutAlluvial=$k,t.layoutAxes=oY,t.layoutBarSpans=tx,t.layoutCandles=LP,t.layoutCircleLabels=Ew,t.layoutClusterLabels=gK,t.layoutEndLabels=yD,t.layoutSelfLoops=PM,t.layoutWithLabelRoom=PO,t.leaderPoints=function(t,e,n,i){return aO(t,e,n,i)[0]??null},t.leaderRoutes=aO,t.legendFeature=yg,t.legendLabelsWhole=fg,t.legendLargestFirst=JT,t.legendSnapshot=Me,t.legibleOn=Si,t.liftPolyline=pH,t.lineAriaLabel=LY,t.lineBoxes=LW,t.lineCurve=xC,t.lineGaps=ZL,t.lineLabelBox=RL,t.lineLabelCap=_z,t.lineLabelConfig=PL,t.lineLabelKey=Nx,t.lineLabelSides=zx,t.lineLabelSpace=Az,t.lineLabelText=Fx,t.lineLabelValue=Lx,t.linePoints=rY,t.lineRows=function(t){const e=t.find(([t])=>"Line"===t);return e?e[1]:[]},t.linkAriaLabel=pw,t.linkArrows=hw,t.linkAs=He,t.linkBundleCache=cH,t.linkBundleFields=hM,t.linkCellText=fw,t.linkColorResolver=zw,t.linkColorScaleRows=ah,t.linkEndLabel=uw,t.linkEndRef=MH,t.linkEndsBox=vI,t.linkFocusId=_I,t.linkHighlight=gw,t.linkHitPath=Sw,t.linkKeys=Oe,t.linkLabelSettings=iM,t.linkLabelText=oM,t.linkMembers=function(t){return Array.from(Le.get(t)??[])},t.linkMeta=ew,t.linkNodeOf=sw,t.linkPredicate=je,t.linkRow=$w,t.linkSizeMaxField=lM,t.linkStyleFields=cM,t.linkTooltipConfig=Mw,t.linkTooltipRows=mw,t.linkTooltipTitle=dw,t.linkValueColor=Aw,t.linkValues=We,t.linkWidthRange=jV,t.linkedColorDefaults=Te,t.listAxis=BN,t.loaderFormatFields=Mn,t.lollipopBuffer=yV,t.lollipopDef=MV,t.lollipopEmit=_V,t.loopAngle=zS,t.loopSide=$S,t.makeLinkDatum=iw,t.mapBox=Uc,t.mapper=Yc,t.marimekkoAxisDefaults=zV,t.marimekkoDef=FV,t.marimekkoFacetAxes=DV,t.marimekkoFixedAxes=LV,t.marimekkoPercentText=AV,t.markBoxes=Xc,t.maskBreaks=KD,t.maskPath=qD,t.matrixDef=TV,t.maxLengthRatio=S_,t.maxValue=ER,t.measureAxis=br,t.measureBars=Jy,t.measureEndLabels=mD,t.measureFacetTitles=yb,t.measureLabel=Fw,t.measureLineLabel=wz,t.measurePlotLineLabels=zz,t.measureTimeAxis=rj,t.measureTrackLabels=nQ,t.measuresTask=Bv,t.mergeBranch=Sq,t.mergeConfig=st,t.mergeConfigBag=ht,t.mergeStackOrder=jA,t.metricsWidth=z0,t.milestoneRadius=Yj,t.minValue=RR,t.monotoneSlopes=uW,t.monthLabelWeek=qE,t.monthOutlinePath=GE,t.motionReduced=Zt,t.narrowName=WE,t.naturalCompare=sS,t.nearestHoverSurface=hk,t.nearestPick=bu,t.nearestPoint=hK,t.neckConfig=jW,t.neckPaint=HW,t.nestPartition=_q,t.nestSunburst=_q,t.networkClusterLabels=xK,t.networkDef=AK,t.networkMeasures=Ev,t.nextTarget=cl,t.nodeConnectionRows=ww,t.nodeConnections=xw,t.nodeDegrees=aS,t.nodeHighlight=bw,t.nodeStatRows=Zv,t.nodeStatsFields=Pv,t.nodeStatsGraph=Wv,t.nodeStatsInIdle=qv,t.nodeTooltipLinkLimit=kw,t.nodeTooltipStatList=Tv,t.normalizeBreaks=Xi,t.normalizeProgress=bj,t.normalizeRangeBreaks=po,t.noteDrawRows=wG,t.noteLinkValue=rh,t.offsetBox=cL,t.offsetCircularShape=vJ,t.offsetVisible=So,t.ohlcAccessors=VR,t.ohlcBarPath=CR,t.ohlcExtent=_R,t.openDomainEnds=sA,t.openEnd=m$,t.openEndAxisConfig=_x,t.outsideBaselineBreak=Cx,t.outsideClaim=FO,t.outsideColumn=nO,t.outsideFontSize=xO,t.outsideIdealY=cO,t.outsideLabels=Tw,t.outsideMetrics=tO,t.outsideRoom=iO,t.outsideSide=eO,t.outsideSpace=wO,t.ownBoxes=Kc,t.packDef=OK,t.paddedBand=VG,t.pageIsDark=rp,t.pageTheme=op,t.panelAxisConfig=WN,t.panelBase=ub,t.panelLabels=vb,t.panelTitle=Ab,t.parallelCoordinatesDef=WY,t.parallelDimensionKeys=sY,t.parallelEmit=FY,t.parallelOffsets=fZ,t.parallelOrient=cY,t.parallelPath=aY,t.parseCalendarDate=ME,t.parseTime=ij,t.partitionFocus=Aq,t.partitionLayout=Cq,t.partitionLineage=$q,t.partitionShadeAmount=Yq,t.partitionSort=wq,t.partitionSplit=VP,t.pathPointBack=uM,t.pathRuns=_H,t.patternIntervals=HL,t.percent=Aj,t.percentText=FW,t.periodDate=QR,t.periodSpacing=vR,t.pickLabelSpot=P$,t.pieAspect=WO,t.pieBaseRadius=OO,t.pieDef=GO,t.pieLabelPlan=_O,t.pieLabelRoom=NO,t.pieMayLabelOutside=kO,t.pieOutsideLabels=zO,t.pieOutsideNodes=$O,t.pieRingLayout=HO,t.pieSharePct=yO,t.pieSliceLabels=fO,t.pieStraightLabels=pO,t.pieSweep=_T,t.pieSweepOf=TO,t.pixelCenter=MR,t.pixelPoints=XG,t.pixelsFromBrush=gY,t.placeArcLabel=SS,t.placeBandLabel=Zx,t.placeCalloutBox=pL,t.placeCircleLabels=Q_,t.placeClusterLabel=mK,t.placeEndLabels=xD,t.placeLinkLabels=lv,t.placeLoneNodes=XV,t.placeLoops=DS,t.placeOutsideLabels=MO,t.placeReferenceLabels=O$,t.placeRings=MZ,t.plainText=ul,t.planFunnelLabels=DW,t.planLabel=zW,t.planStageLabels=PW,t.plotAnnotationFrame=z$,t.plotAnnotationList=CL,t.plotAxisConfig=wx,t.plotAxisRounding=xx,t.plotCircleLabels=DL,t.plotEmit=XF,t.plotFacetChrome=PN,t.plotFacetHooks=GN,t.plotFacetInsets=IN,t.plotFacetPanel=HN,t.plotFrame=pG,t.plotPaint=function(t,e){return JF(t,e).nodes},t.plotRangeBreaks=Qp,t.plotSeriesIds=HA,t.plotTimeScale=ng,t.pointLabelSettings=Nw,t.pointLengths=jL,t.pointMarkTargets=pu,t.pointPath=bG,t.pointTarget=xu,t.pointTooltipAnchor=wu,t.pointVoronoi=du,t.polarAreaDef=VU,t.polarAreaDomainValues=IU,t.polarAreaEmit=qU,t.polarAreaSlotOf=HU,t.polarAxisConfig=HY,t.polarBoxesOverlap=wU,t.polarCategoryLayout=zU,t.polarCategoryNodes=DU,t.polarFacetHooks=YY,t.polarFacetPanel=VY,t.polarHorizontalLayout=SU,t.polarInnerRadius=PU,t.polarLabelFitRadius=_U,t.polarLabelPlacement=kU,t.polarLabelRoom=vU,t.polarLabelsCollide=MU,t.polarLevelNodes=LU,t.polarLevels=RU,t.polarPadAngle=EU,t.polarRadius=FU,t.polarSharedExtent=KY,t.polarSlotArc=TU,t.polarSlotTops=WU,t.polarSlots=NU,t.polarSpokeRotation=CU,t.polarStack=BU,t.polarValueRow=IY,t.polarWedgeLayout=jU,t.polarWedgeNodes=GY,t.polygonDistance=uu,t.polylineArrowEdge=xM,t.polylineAt=Gw,t.polylineBox=Vw,t.polylineLength=Iw,t.polylineMidpoint=qw,t.polylinePath=jw,t.polylineReach=Kw,t.polylinesCross=sO,t.poolStackPositions=OA,t.positionCompatibility=v_,t.prefersReducedMotion=Qt,t.prefixKeys=pb,t.prepareClusters=nS,t.prepareSlope=o0,t.priestleyDef=UU,t.profileKnots=dW,t.profileSlice=pW,t.progressAgg=Jj,t.progressSplit=hj,t.publishLinkGraph=rw,t.pullBack=fL,t.pyramidDef=RX,t.pyramidExtent=nX,t.pyramidSides=ZU,t.pyramidStackOrder=CV,t.pyramidTotal=tX,t.queuedFormatter=wn,t.radarDef=GX,t.radialBarCurvedLabels=lQ,t.radialBarCurvedRows=JX,t.radialBarDef=uQ,t.radialBarDomainValues=aQ,t.radialBarEmit=hQ,t.radialBarFootprint=YX,t.radialBarLabelRoom=KX,t.radialBarLabelSpot=cQ,t.radialBarRows=oQ,t.radialBarSweep=XX,t.radialBarTrackLabels=ZX,t.radialBarTrackLayout=iQ,t.radialBarTracks=VX,t.radialMatrixDef=yQ,t.rangeBreakGaps=bo,t.rangeBreakTest=_o,t.rangeBreakTime=fo,t.rangeBreaksTimeAxis=Zp,t.rangeText=hz,t.readOhlc=xR,t.readingOrder=rl,t.recordLegendChange=Se,t.recordStackLegendOrder=IA,t.referenceAxis=K$,t.referenceBandLabelAt=function(t,e="start"){return"end"===e?{x:t.x+t.width-4,y:t.y+4,align:"end"}:{x:t.x+4,y:t.y+4,align:"start"}},t.referenceBandLabelSpots=tA,t.referenceBandNodes=iA,t.referenceBandRect=X$,t.referenceDomainValues=oA,t.referenceLineLabelAt=Q$,t.referenceLineLabelSpots=J$,t.referenceLineNodes=nA,t.referenceLinePoints=U$,t.refreshColorScale=AG,t.registerLabelSpots=E$,t.registerLink=Re,t.remainingShade=Kj,t.removeLatestDrillEntry=ve,t.renderAxes=PD,t.renderPlotAnnotation=wL,t.renderTimeAxis=aj,t.requestIdle=Ue,t.reserveBottomRight=Eb,t.resolveAlluvialDimensions=gk,t.resolveAxisTooltip=ph,t.resolveBaselineBreak=oo,t.resolveBinValue=uG,t.resolveBrushStyle=OY,t.resolveColorBy=xk,t.resolveConfidenceBands=VC,t.resolveConnectGaps=OL,t.resolveDimensions=VK,t.resolveFacetAxes=ce,t.resolveFacetConfig=ae,t.resolveGraphLinks=qM,t.resolveGraphNodes=GM,t.resolveLineOpacity=DY,t.resolveLink=Ee,t.resolveSaveConfig=Am,t.resolveSpec=lg,t.resolveSwarm=c$,t.resolveTheme=Q,t.resolveWeekStart=LE,t.resolvesReset=dt,t.restoreLegendEntry=Ce,t.reverseEdge=lJ,t.ribbonD=uJ,t.ridgeOverlap=OQ,t.ridgelineDef=HQ,t.ridgelineEmit=jQ,t.ridgelinePadding=WQ,t.ringArcCubics=sZ,t.ringArcRadius=iZ,t.ringCentroid=j_,t.ringDistance=qG,t.ringExtent=ST,t.ringFontRange=uO,t.ringLabelFit=aT,t.ringLabelFont=OP,t.ringLabelNodes=HP,t.ringLabelPair=sT,t.ringLabelPosition=lT,t.ringLabelStretches=KG,t.ringNodeRadii=VQ,t.ringPoint=nT,t.ringRadius=eZ,t.ringReadsClockwise=iT,t.ringSizeFor=zT,t.ringTextPath=oT,t.ringTextWidth=WP,t.ringWeights=wZ,t.ringsDef=HZ,t.ringsEdgeAnchor=TZ,t.ringsEdgePath=OZ,t.ringsGeometry=qQ,t.ringsHops=GQ,t.ringsLinkKeys=PZ,t.ringsLoops=JQ,t.ringsNodeRadii=KQ,t.ringsVisibleD=EZ,t.rotateByStep=EI,t.rotationBetween=RI,t.roundOpenEnd=p$,t.roundPlotOpenEnds=y$,t.roundedDomain=ar,t.routePointerEvent=ku,t.rowBands=YC,t.rowDate=tR,t.rowLegend=ZT,t.rowLineLabelSides=Dx,t.rowPasses=fY,t.rowTime=sj,t.rowsExtent=eR,t.rtlLocale=lw,t.ruleMarker=go,t.runIndices=KL,t.runLayout=oy,t.runPath=VL,t.runPostDrawFeatures=Tb,t.runStages=vt,t.runVizPipeline=Pb,t.sameLegendIds=we,t.sankeyAcyclicLinks=BJ,t.sankeyBandThickness=jJ,t.sankeyDef=KJ,t.sankeyDrawableLinks=EJ,t.sankeyLinkAnchor=GJ,t.sankeyLinkIds=IJ,t.sankeyLinkPath=qJ,t.sankeyLoopWarning=PJ,t.sankeyNodeValue=SJ,t.sankeyRibbonD=HJ,t.sankeyScale=$J,t.saveChart=Bm,t.saveContribution=ep,t.saveFilename=Sm,t.saveFormats=Mm,t.savePixelRatio=Fm,t.scaleCompatibility=__,t.scatterDef=yB,t.sceneInsetRegion=Ay,t.scheduleNodeStats=Uv,t.screenArc=xH,t.searchContribution=Hp,t.secondaryAxisRounding=bx,t.sectorBoxAt=RT,t.sectorBoxRange=ET,t.sectorEdges=NT,t.seedTimeAggs=ej,t.segmentDistance=rO,t.segmentMidpoint=Z_,t.segmentWidth=fW,t.selfLoopAngles=NM,t.selfLoopArrows=OM,t.selfLoopD=LM,t.selfLoopExtent=CM,t.selfLoopGeometry=zM,t.selfLoopOpening=$M,t.selfLoopReach=SM,t.selfLoopSpread=FM,t.seriesForecastStarts=BC,t.setAlluvialMeta=Lk,t.setLinkValue=ow,t.setLoaderValue=_n,t.setupArcEvents=eC,t.setupGeomapLinks=DI,t.shareFunnelLabelSize=qW,t.shareFunnelScale=VW,t.sharePlotScales=TN,t.sharePolarScale=qY,t.shareRow=QT,t.sharedColorRows=MG,t.sharedDomains=KK,t.sharedScaleMax=vW,t.sharpestTurn=Zw,t.shiftEdge=hJ,t.sideAnchor=Rw,t.sideBox=O_,t.sideClip=MC,t.sideControlsDrop=cy,t.sideOrder=H_,t.sideSign=JU,t.sideTitleBoxes=hX,t.simplifyPolyline=p_,t.sizeAlluvialTitles=Vk,t.sizeLegendContribution=Nb,t.sliceExtent=xW,t.slicePath=yW,t.slideOnRim=mZ,t.slideSteps=T$,t.slopeChartDef=a0,t.slopeColors=e0,t.slopeColorsDark=t0,t.slopeColorsLight=JJ,t.slopeDirection=QJ,t.slopeDirections=ZJ,t.slopeFill=r0,t.slopePeriods=XJ,t.slopeValueAxis=n0,t.slotEdge=_F,t.slotPosition=HE,t.slotPositions=lS,t.smoothBundle=g_,t.snapMagnitude=oX,t.solveScale=DJ,t.sortAlluvialColumns=Sk,t.sortArcNodes=cS,t.sortByMedian=vQ,t.sortFacetValues=_g,t.sortTasks=_j,t.sourceRows=Fk,t.splitDash=XL,t.splitLength=UL,t.spreadLabelPositions=LD,t.stackCircularEnds=CJ,t.stackLegendSort=GA,t.stackOutsideLabels=oO,t.stackPositions=TA,t.stackReadingOrder=WA,t.stageAria=IW,t.stageBoxes=BW,t.stageLabelSize=TW,t.stageLines=NW,t.stageSpans=sW,t.stageWidths=hW,t.stampTickTooltips=zr,t.stampTitleTooltip=Dr,t.startOfDay=wE,t.startingSelection=ag,t.stemFromBar=mV,t.stemPoints=pV,t.stepLabel=H1,t.stepValue=r2,t.storePayload=kn,t.straightEdgeD=Sv,t.straightLabelLayout=IT,t.straightLabelOptions=jT,t.straightenPolyline=f_,t.streamValueAxis=l0,t.streamgraphDef=h0,t.stripLength=kY,t.stripSelection=_Y,t.stripSize=cP,t.subdividePolyline=z_,t.subtitleFeature=fy,t.sumValue=PR,t.summarizeBeforePreDraw=zQ,t.sunburstCurvedNodes=L0,t.sunburstDef=P0,t.sunburstFocus=k0,t.sunburstLabelBox=A0,t.sunburstLabelMetrics=B0,t.sunburstLabelPlacements=D0,t.sunburstLayout=b0,t.sunburstPadAngle=p0,t.sunburstRadii=f0,t.sunburstSplit=VP,t.surfaceOrigin=_u,t.surfaceToMap=eI,t.svgForSave=Lm,t.swarmExtent=e$,t.swarmFitScale=i$,t.swarmHidesAxis=h$,t.swarmLayout=t$,t.swarmPlacements=u$,t.sweepFraction=wT,t.symmetricDomain=iX,t.syncBrushDom=SY,t.syncDefaultAggs=jR,t.syncGapSort=tW,t.syncKeyboardNav=Bl,t.syncLoaderFormats=vn,t.tableViewContribution=vm,t.takeLegendState=$e,t.targetLabel=vl,t.taskAccessor=Zj,t.taskEnd=Hj,t.taskStart=Ij,t.taskTimes=zj,t.teardownKeyboardNav=Fl,t.textBroken=hT,t.textHalo=Vy,t.textLineBoxes=rM,t.textShownWhole=dO,t.themeBackground=up,t.themeBackgroundNode=hp,t.themeColorScheme=dp,t.themeDark=K,t.themeLight=V,t.themeOverlayStyle=mp,t.themeRamp=tt,t.themeScaleColor=J,t.themeStyle=et,t.themed=Z,t.thickRuns=Kx,t.thinBands=xX,t.tickRank=Ar,t.timeFields=tj,t.timeFormatter=Sj,t.timelineFeature=my,t.timelineModeClass=yc,t.timelineRangeBreaks=Jp,t.titleFeature=dy,t.titleHeight=jk,t.titleNodes=Hk,t.titleWidths=Wk,t.toFacetValue=bg,t.toLonLat=uH,t.todayNodes=Vj,t.todayValue=qj,t.tooltipEnabled=Yl,t.tooltipLevels=Kl,t.topLeftControlsFeature=Up,t.totalFeature=py,t.trackFontSize=eQ,t.treeDef=t1,t.treemapDef=u1,t.trendForecastStart=RC,t.trimCubic=wv,t.trimPolyline=Hw,t.trimSegment=_v,t.trimToNodes=Xw,t.twoLineWidth=gO,t.unbrokenPath=gH,t.unionBox=TM,t.unionExtent=EN,t.uniqueLinkKeys=LZ,t.unlinkedNodeValue=RJ,t.unregisterLink=Pe,t.unwatchPageTheme=cp,t.unwrapBreakMasks=UD,t.unwrapDomainClips=sL,t.unwrapHexbinRow=sG,t.unwrapRow=SQ,t.updateKeyboardNavHost=ml,t.uprightAngle=nv,t.usedRoom=EO,t.userAxisDomain=vx,t.userDomainBreaksBaseline=Sx,t.valueAxis=ux,t.valueAxisExtent=$x,t.valueDirection=CC,t.valuePasses=dY,t.versor=VH,t.versorDelta=UH,t.versorMultiply=XH,t.versorRotation=KH,t.violinDef=_1,t.violinEdges=TQ,t.violinEmit=k1,t.violinOutline=PQ,t.violinSlots=RQ,t.visibilityCompatibility=M_,t.visibleBetween=wo,t.visiblePointData=sI,t.visibleTimeValues=Ko,t.vizDraw=Jb,t.vizPostThresholdCtx=ck,t.vizPreDraw=lk,t.volumeAccessor=oP,t.volumeAriaLabel=$P,t.volumeScale=lP,t.volumeStripRect=yP,t.waffleCellGeometry=A1,t.waffleCellGeometryNode=F1,t.waffleCellPosition=$1,t.waffleCellShape=N1,t.waffleCounts=S1,t.waffleDef=T1,t.waffleFillOptions=D1,t.waffleGrid=C1,t.waffleShare=E1,t.waffleTooltipRows=R1,t.watchPage=ap,t.watchPageTheme=sp,t.waterfallDef=M2,t.waterfallKinds=o2,t.waterfallStackOffset=a2,t.waterfallStep=n2,t.waterfallSteps=i2,t.waterfallTooltipRows=K1,t.weekIndex=zE,t.weekdayLabelSlots=VE,t.weekdayNames=XE,t.weekdaySlot=AE,t.widenDomain=KR,t.widenReferenceDomains=lA,t.widenToValues=aA,t.widestGapAngle=EM,t.withFacetPanel=cu,t.withOpacity=U,t.withinArea=$n,t.wrapAnnotationText=F$,t.wrapLineCount=XP,t.wrapWidths=HT,t.xAxisRounding=Lz,t.zeroAnchoredRadius=Tz,t.zoomSizeLegendScale=nc,t.zoomToNodeBounds=VM});
|