semiotic 3.7.5 → 3.8.1
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/CLAUDE.md +63 -18
- package/README.md +121 -27
- package/agent-skill/semiotic-charts/SKILL.md +146 -0
- package/ai/cli.js +133 -45
- package/ai/componentMetadata.cjs +6 -1
- package/ai/dist/mcp-server.js +1741 -163
- package/ai/examples.md +174 -0
- package/ai/schema.json +2733 -536
- package/ai/surface-manifest.json +201 -0
- package/ai/system-prompt.md +20 -4
- package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
- package/dist/components/AccessibleNavTree.d.ts +7 -1
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartContainer.d.ts +91 -0
- package/dist/components/ChartGrid.d.ts +11 -1
- package/dist/components/CircularBrush.d.ts +61 -0
- package/dist/components/ContextLayout.d.ts +5 -1
- package/dist/components/DirectManipulationControl.d.ts +63 -0
- package/dist/components/LinkedCharts.d.ts +3 -1
- package/dist/components/MobileAnnotationCalloutList.d.ts +13 -0
- package/dist/components/MobileChartContainer.d.ts +51 -0
- package/dist/components/MobileStandardControls.d.ts +68 -0
- package/dist/components/SmallMultipleChart.d.ts +84 -0
- package/dist/components/Tooltip/FlippingTooltip.d.ts +21 -0
- package/dist/components/ai/ChartRecipe.d.ts +16 -0
- package/dist/components/ai/IntentMark.d.ts +15 -0
- package/dist/components/ai/chartCapabilities.d.ts +8 -1
- package/dist/components/ai/chartCapabilityTypes.d.ts +26 -1
- package/dist/components/ai/chartClinic.d.ts +91 -0
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
- package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
- package/dist/components/ai/chartRecipes.d.ts +278 -0
- package/dist/components/ai/dataPitfallsBridge.d.ts +102 -0
- package/dist/components/ai/describeChart.d.ts +7 -0
- package/dist/components/ai/describeRecipeChart.d.ts +16 -0
- package/dist/components/ai/generativeChart.d.ts +28 -3
- package/dist/components/ai/intentManifest.d.ts +62 -0
- package/dist/components/ai/navigationTree.d.ts +3 -0
- package/dist/components/ai/observedSceneAudit.d.ts +72 -0
- package/dist/components/ai/readerGrounding.d.ts +83 -0
- package/dist/components/ai/recipeCapability.d.ts +8 -0
- package/dist/components/ai/recipeNavigation.d.ts +13 -0
- package/dist/components/ai/recipeSemantics.d.ts +11 -0
- package/dist/components/ai/repairChartConfig.d.ts +9 -0
- package/dist/components/ai/suggestCharts.d.ts +11 -1
- package/dist/components/ai/useNavigationSync.d.ts +17 -2
- package/dist/components/chartContainerMobile.d.ts +9 -0
- package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
- package/dist/components/charts/custom/NetworkCustomChart.d.ts +8 -2
- package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
- package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
- package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +15 -3
- package/dist/components/charts/geo/FlowMap.d.ts +11 -7
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +15 -3
- package/dist/components/charts/geo/index.d.ts +2 -0
- package/dist/components/charts/index.d.ts +35 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +10 -2
- package/dist/components/charts/network/CirclePack.d.ts +1 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +26 -5
- package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
- package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
- package/dist/components/charts/network/SankeyDiagram.d.ts +10 -2
- package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
- package/dist/components/charts/network/Treemap.d.ts +1 -1
- package/dist/components/charts/network/useForceLayout.d.ts +17 -0
- package/dist/components/charts/ordinal/BarChart.d.ts +22 -1
- package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
- package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
- package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
- package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +12 -1
- package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
- package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +12 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -1
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
- package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
- package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +54 -0
- package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +60 -0
- package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +74 -0
- package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
- package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +99 -0
- package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +60 -0
- package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
- package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
- package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
- package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
- package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
- package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
- package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
- package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
- package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
- package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
- package/dist/components/charts/physics/gauntletController.d.ts +73 -0
- package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
- package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
- package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
- package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
- package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
- package/dist/components/charts/physics/physicsChartShared.d.ts +57 -0
- package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
- package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
- package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
- package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
- package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
- package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
- package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -1
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
- package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
- package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
- package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
- package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
- package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
- package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
- package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
- package/dist/components/charts/shared/colorContrast.d.ts +3 -0
- package/dist/components/charts/shared/colorUtils.d.ts +16 -1
- package/dist/components/charts/shared/datumTypes.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +6 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
- package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
- package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
- package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
- package/dist/components/charts/shared/formatUtils.d.ts +3 -3
- package/dist/components/charts/shared/hatchFill.d.ts +87 -0
- package/dist/components/charts/shared/hooks.d.ts +34 -10
- package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
- package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
- package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
- package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
- package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
- package/dist/components/charts/shared/sparseArray.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +17 -5
- package/dist/components/charts/shared/styleRules.d.ts +205 -0
- package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
- package/dist/components/charts/shared/types.d.ts +58 -7
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +11 -4
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +17 -5
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +25 -2
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
- package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
- package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
- package/dist/components/charts/shared/validateChartData.d.ts +7 -5
- package/dist/components/charts/shared/validationMap.d.ts +7 -9
- package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/components/charts/value/targetPresentation.d.ts +22 -0
- package/dist/components/charts/value/types.d.ts +5 -6
- package/dist/components/charts/xy/AreaChart.d.ts +9 -1
- package/dist/components/charts/xy/BubbleChart.d.ts +10 -1
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
- package/dist/components/charts/xy/Heatmap.d.ts +2 -2
- package/dist/components/charts/xy/LineChart.d.ts +12 -1
- package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
- package/dist/components/charts/xy/QuadrantChart.d.ts +8 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +11 -1
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
- package/dist/components/charts/xy/StackedAreaChart.d.ts +16 -4
- package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
- package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
- package/dist/components/controls/SentenceFilter.d.ts +97 -0
- package/dist/components/controls/controlAudit.d.ts +24 -0
- package/dist/components/controls/controlContract.d.ts +57 -0
- package/dist/components/data/fromFlintChart.d.ts +74 -0
- package/dist/components/data/fromVegaLite.d.ts +46 -9
- package/dist/components/data/portability/index.d.ts +6 -3
- package/dist/components/data/portability/result.d.ts +52 -0
- package/dist/components/data/portability/spec.d.ts +31 -0
- package/dist/components/data/portability/vegaLite.d.ts +24 -6
- package/dist/components/export/chartConfig.d.ts +11 -0
- package/dist/components/realtime/types.d.ts +11 -0
- package/dist/components/recipes/annotationLayout.d.ts +29 -0
- package/dist/components/recipes/axisFixedForce.d.ts +119 -0
- package/dist/components/recipes/{gofishBoba.d.ts → boba.d.ts} +2 -2
- package/dist/components/recipes/cyclical.d.ts +39 -0
- package/dist/components/recipes/edgeRouter.d.ts +103 -0
- package/dist/components/recipes/forceLayout.d.ts +48 -0
- package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
- package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
- package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
- package/dist/components/recipes/gofishIR.d.ts +178 -132
- package/dist/components/recipes/gofishIRExamples.d.ts +30 -81
- package/dist/components/recipes/intervalLanes.d.ts +87 -0
- package/dist/components/recipes/intervals.d.ts +80 -0
- package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
- package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
- package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
- package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
- package/dist/components/recipes/networkAnalysis.d.ts +102 -0
- package/dist/components/recipes/networkLayouts.d.ts +83 -0
- package/dist/components/recipes/physics.d.ts +122 -0
- package/dist/components/recipes/physicsReference.d.ts +102 -0
- package/dist/components/recipes/processAggregates.d.ts +32 -0
- package/dist/components/recipes/processChrome.d.ts +67 -0
- package/dist/components/recipes/processJourney.d.ts +54 -0
- package/dist/components/recipes/processPhysics.d.ts +300 -0
- package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
- package/dist/components/recipes/radialCoords.d.ts +69 -0
- package/dist/components/recipes/random.d.ts +2 -0
- package/dist/components/recipes/recipeChrome.d.ts +91 -0
- package/dist/components/recipes/recipeGlyph.d.ts +42 -0
- package/dist/components/recipes/recipeLegend.d.ts +53 -1
- package/dist/components/recipes/recipeUtils.d.ts +52 -0
- package/dist/components/recipes/runs.d.ts +59 -0
- package/dist/components/recipes/tokenEncoding.d.ts +157 -0
- package/dist/components/recipes/tokenLayer.d.ts +79 -0
- package/dist/components/recipes/unitize.d.ts +108 -0
- package/dist/components/recipes/vector.d.ts +28 -0
- package/dist/components/recipes/waffle.d.ts +43 -0
- package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
- package/dist/components/semiotic-ai-core.d.ts +47 -0
- package/dist/components/semiotic-ai.d.ts +53 -9
- package/dist/components/semiotic-controls.d.ts +20 -0
- package/dist/components/semiotic-experimental.d.ts +38 -9
- package/dist/components/semiotic-geo.d.ts +15 -0
- package/dist/components/semiotic-network.d.ts +15 -0
- package/dist/components/semiotic-ordinal.d.ts +14 -0
- package/dist/components/semiotic-physics-matter.d.ts +10 -0
- package/dist/components/semiotic-physics-rapier.d.ts +9 -0
- package/dist/components/semiotic-physics.d.ts +60 -0
- package/dist/components/semiotic-realtime-core.d.ts +34 -0
- package/dist/components/semiotic-realtime-react.d.ts +10 -0
- package/dist/components/semiotic-realtime.d.ts +4 -30
- package/dist/components/semiotic-recipes-core.d.ts +92 -0
- package/dist/components/semiotic-recipes-react.d.ts +7 -0
- package/dist/components/semiotic-recipes.d.ts +4 -43
- package/dist/components/semiotic-rough.d.ts +4 -0
- package/dist/components/semiotic-server-edge.d.ts +8 -0
- package/dist/components/semiotic-server-node.d.ts +5 -0
- package/dist/components/semiotic-server.d.ts +2 -2
- package/dist/components/semiotic-themes-core.d.ts +53 -0
- package/dist/components/semiotic-themes-react.d.ts +4 -0
- package/dist/components/semiotic-themes.d.ts +6 -76
- package/dist/components/semiotic-utils-core.d.ts +50 -0
- package/dist/components/semiotic-utils-react.d.ts +5 -0
- package/dist/components/semiotic-utils.d.ts +3 -39
- package/dist/components/semiotic-xy.d.ts +12 -0
- package/dist/components/semiotic.d.ts +44 -8
- package/dist/components/server/animatedGif.d.ts +36 -0
- package/dist/components/server/optionalImageTypes.d.ts +37 -0
- package/dist/components/server/renderEvidence.d.ts +1 -1
- package/dist/components/server/renderToStaticSVG.d.ts +3 -35
- package/dist/components/server/serverChartConfigShared.d.ts +21 -0
- package/dist/components/server/serverChartConfigs.d.ts +22 -12
- package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
- package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
- package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
- package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
- package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
- package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
- package/dist/components/server/staticAnnotations.d.ts +6 -3
- package/dist/components/server/staticGeo.d.ts +4 -0
- package/dist/components/server/staticLegend.d.ts +2 -2
- package/dist/components/server/staticNetwork.d.ts +8 -0
- package/dist/components/server/staticOrdinal.d.ts +11 -0
- package/dist/components/server/staticPhysics.d.ts +3 -0
- package/dist/components/server/staticSVGChrome.d.ts +110 -0
- package/dist/components/server/staticXY.d.ts +4 -0
- package/dist/components/store/ObservationStore.d.ts +23 -2
- package/dist/components/store/themeSerialization.d.ts +32 -0
- package/dist/components/store/useChartInterrogation.d.ts +9 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +7 -23
- package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
- package/dist/components/stream/CanvasHitTester.d.ts +4 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
- package/dist/components/stream/FocusRing.d.ts +4 -2
- package/dist/components/stream/FrameRuntime.d.ts +57 -0
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoParticlePool.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +62 -3
- package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
- package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +44 -36
- package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +10 -1
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
- package/dist/components/stream/OrdinalPipelineStore.d.ts +55 -11
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
- package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
- package/dist/components/stream/ParticlePool.d.ts +1 -1
- package/dist/components/stream/PipelineStore.d.ts +81 -174
- package/dist/components/stream/SVGOverlay.d.ts +6 -0
- package/dist/components/stream/SceneGraph.d.ts +12 -4
- package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
- package/dist/components/stream/StreamXYFrame.d.ts +2 -18
- package/dist/components/stream/accessibleDataRows.d.ts +33 -0
- package/dist/components/stream/accessorUtils.d.ts +25 -12
- package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
- package/dist/components/stream/brushAccessibility.d.ts +25 -0
- package/dist/components/stream/canvasBackground.d.ts +24 -0
- package/dist/components/stream/canvasSetup.d.ts +4 -1
- package/dist/components/stream/customLayoutFailure.d.ts +33 -0
- package/dist/components/stream/customLayoutPalette.d.ts +19 -9
- package/dist/components/stream/frameGraphics.d.ts +4 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
- package/dist/components/stream/frameThemeColors.d.ts +24 -0
- package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
- package/dist/components/stream/geoCartogram.d.ts +17 -0
- package/dist/components/stream/geoCustomLayout.d.ts +59 -0
- package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
- package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
- package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
- package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
- package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
- package/dist/components/stream/geoTypes.d.ts +97 -15
- package/dist/components/stream/glyphDef.d.ts +98 -0
- package/dist/components/stream/hitTarget.d.ts +170 -0
- package/dist/components/stream/hitTestUtils.d.ts +2 -2
- package/dist/components/stream/hoverUtils.d.ts +7 -2
- package/dist/components/stream/keyboardNav.d.ts +4 -1
- package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +58 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
- package/dist/components/stream/networkBezier.d.ts +10 -0
- package/dist/components/stream/networkColorAccessors.d.ts +49 -0
- package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
- package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
- package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
- package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
- package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
- package/dist/components/stream/networkFrameObservations.d.ts +15 -0
- package/dist/components/stream/networkFramePaint.d.ts +52 -0
- package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
- package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
- package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
- package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
- package/dist/components/stream/networkTypes.d.ts +103 -51
- package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
- package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
- package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/ordinalDomain.d.ts +38 -0
- package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +31 -0
- package/dist/components/stream/ordinalPulse.d.ts +10 -0
- package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
- package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
- package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
- package/dist/components/stream/ordinalTypes.d.ts +68 -9
- package/dist/components/stream/paintNeeds.d.ts +31 -0
- package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
- package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
- package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
- package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
- package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
- package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
- package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
- package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
- package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
- package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
- package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
- package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
- package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
- package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +86 -0
- package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +78 -0
- package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
- package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
- package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
- package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
- package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
- package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
- package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
- package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
- package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
- package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +317 -0
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
- package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
- package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
- package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +27 -0
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
- package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +18 -0
- package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
- package/dist/components/stream/pipelineConfig.d.ts +179 -0
- package/dist/components/stream/pipelineDecay.d.ts +21 -3
- package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
- package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
- package/dist/components/stream/pipelinePulse.d.ts +17 -3
- package/dist/components/stream/pipelineRibbons.d.ts +41 -0
- package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +33 -0
- package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
- package/dist/components/stream/pipelineTransitions.d.ts +3 -1
- package/dist/components/stream/pipelineUpdateContract.d.ts +69 -0
- package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
- package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
- package/dist/components/stream/renderBackend.d.ts +27 -0
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
- package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
- package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
- package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
- package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +45 -0
- package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
- package/dist/components/stream/streamStoreSync.d.ts +37 -0
- package/dist/components/stream/streamThemeTypes.d.ts +14 -0
- package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
- package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
- package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
- package/dist/components/stream/titleLayout.d.ts +31 -0
- package/dist/components/stream/types.d.ts +165 -72
- package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
- package/dist/components/stream/useFrame.d.ts +44 -2
- package/dist/components/stream/useHydration.d.ts +6 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
- package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
- package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
- package/dist/components/stream/workerModuleUrl.d.ts +10 -0
- package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
- package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
- package/dist/components/stream/xyCrosshair.d.ts +11 -0
- package/dist/components/stream/xyDateTicks.d.ts +9 -0
- package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +10 -9
- package/dist/controls.min.js +2 -0
- package/dist/controls.module.min.js +2 -0
- package/dist/forceLayoutWorker.js +1 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics-matter.min.js +1 -0
- package/dist/physics-matter.module.min.js +1 -0
- package/dist/physics-rapier.min.js +1 -0
- package/dist/physics-rapier.module.min.js +1 -0
- package/dist/physics.min.js +2 -0
- package/dist/physics.module.min.js +2 -0
- package/dist/physicsWorker.js +1 -0
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -0
- package/dist/rough.module.min.js +1 -0
- package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
- package/dist/semiotic-ai-core.d.ts +47 -0
- package/dist/semiotic-ai-core.min.js +1 -0
- package/dist/semiotic-ai-core.module.min.js +1 -0
- package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
- package/dist/semiotic-ai.d.ts +53 -9
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
- package/dist/semiotic-controls.d.ts +20 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.d.ts +38 -9
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +15 -0
- package/dist/semiotic-network.d.ts +15 -0
- package/dist/semiotic-ordinal.d.ts +14 -0
- package/dist/semiotic-physics-matter.d.ts +10 -0
- package/dist/semiotic-physics-rapier.d.ts +9 -0
- package/dist/semiotic-physics.d.ts +60 -0
- package/dist/semiotic-realtime-core.d.ts +34 -0
- package/dist/semiotic-realtime-core.min.js +1 -0
- package/dist/semiotic-realtime-core.module.min.js +1 -0
- package/dist/semiotic-realtime-react.d.ts +10 -0
- package/dist/semiotic-realtime-react.min.js +2 -0
- package/dist/semiotic-realtime-react.module.min.js +2 -0
- package/dist/semiotic-realtime.d.ts +4 -30
- package/dist/semiotic-recipes-core.d.ts +92 -0
- package/dist/semiotic-recipes-core.min.js +1 -0
- package/dist/semiotic-recipes-core.module.min.js +1 -0
- package/dist/semiotic-recipes-react.d.ts +7 -0
- package/dist/semiotic-recipes-react.min.js +2 -0
- package/dist/semiotic-recipes-react.module.min.js +2 -0
- package/dist/semiotic-recipes.d.ts +4 -43
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-rough.d.ts +4 -0
- package/dist/semiotic-server-edge.d.ts +8 -0
- package/dist/semiotic-server-edge.min.js +1 -0
- package/dist/semiotic-server-edge.module.min.js +1 -0
- package/dist/semiotic-server-node.d.ts +5 -0
- package/dist/semiotic-server-node.min.js +1 -0
- package/dist/semiotic-server-node.module.min.js +1 -0
- package/dist/semiotic-server.d.ts +2 -2
- package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
- package/dist/semiotic-themes-core.d.ts +53 -0
- package/dist/semiotic-themes-core.min.js +1 -0
- package/dist/semiotic-themes-core.module.min.js +1 -0
- package/dist/semiotic-themes-react.d.ts +4 -0
- package/dist/semiotic-themes-react.min.js +2 -0
- package/dist/semiotic-themes-react.module.min.js +2 -0
- package/dist/semiotic-themes.d.ts +6 -76
- package/dist/semiotic-themes.min.js +1 -2
- package/dist/semiotic-themes.module.min.js +1 -2
- package/dist/semiotic-utils-core.d.ts +50 -0
- package/dist/semiotic-utils-core.min.js +1 -0
- package/dist/semiotic-utils-core.module.min.js +1 -0
- package/dist/semiotic-utils-react.d.ts +5 -0
- package/dist/semiotic-utils-react.min.js +2 -0
- package/dist/semiotic-utils-react.module.min.js +2 -0
- package/dist/semiotic-utils.d.ts +3 -39
- package/dist/semiotic-utils.min.js +1 -2
- package/dist/semiotic-utils.module.min.js +1 -2
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +12 -0
- package/dist/semiotic.d.ts +44 -8
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/capturedFrameProps.d.ts +67 -0
- package/dist/test-utils/frameMock.d.ts +12 -9
- package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
- package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +259 -88
- package/spec/README.md +152 -0
- package/spec/bindings/README.md +35 -0
- package/spec/bindings/vega-lite.mjs +112 -0
- package/spec/v0.1/annotation-provenance.schema.json +127 -0
- package/spec/v0.1/audience-profile.schema.json +67 -0
- package/spec/v0.1/chart-capability.schema.json +186 -0
- package/dist/components/recipes/gofish.d.ts +0 -207
- package/dist/components/recipes/gofishInterpreter.d.ts +0 -52
- package/dist/components/recipes/gofishLambdas.d.ts +0 -145
- package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +0 -2
- package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +0 -1
- package/dist/semiotic-semiotic-BmrYbi99.js +0 -2
- package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +0 -1
- package/dist/xy-semiotic-xy-Dufu3D0-.js +0 -2
- package/dist/xy-statisticalOverlays-3Ni9bRph.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useEffect as s,useContext as l,useCallback as a,useSyncExternalStore as c,createContext as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as y,useImperativeHandle as g}from"react";import{select as p}from"d3-selection";import{brushX as v,brushY as m,brush as b}from"d3-brush";import{scaleLinear as x,scaleLog as k,scaleTime as w}from"d3-scale";import{quadtree as A}from"d3-quadtree";import{symbol as _,symbolCircle as S,symbolWye as M,symbolCross as P,symbolStar as C,symbolDiamond as O,symbolTriangle as T,symbolSquare as D,curveNatural as N,curveBasis as E,curveStepAfter as L,curveStepBefore as $,curveStep as I,curveCatmullRom as W,curveCardinal as z,curveMonotoneY as R,curveMonotoneX as j,line as F,area as Y,curveLinear as B,arc as H,pie as X}from"d3-shape";import{bin as G,min as V,groups as q,max as U,sum as K,mean as Q,group as Z}from"d3-array";import{packEnclose as J,hierarchy as tt,partition as et,pack as nt,treemap as it,treemapBinary as ot,cluster as rt,tree as st}from"d3-hierarchy";import lt from"regression";import{interpolateNumber as at}from"d3-interpolate";import{forceLink as ct,forceSimulation as ut,forceManyBody as dt,forceCenter as ht,forceX as ft,forceY as yt}from"d3-force";import{ribbon as gt,chord as pt}from"d3-chord";function vt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function mt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function bt({width:e,height:n,totalWidth:i,totalHeight:l,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:y,snapDuring:g,streaming:x}){const k=o(null),w=o(null),A=o(d);A.current=d;const _=o(u);_.current=u;const S=r(()=>y?[...y].sort((t,e)=>t-e):void 0,[y]),M=o(S);M.current=S;const P=o(!1),C=o(null);return s(()=>{if(!k.current)return;const t=p(k.current).select(".brush-g"),i="x"===c?v():"y"===c?m():b();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(P.current)return;const r=_.current;if(!r)return;if(!o.selection)return C.current=null,void A.current(null);let s,l;if("x"===c){const[t,e]=o.selection;s=[r.x.invert(t),r.x.invert(e)],l=[r.y.invert(n),r.y.invert(0)]}else if("y"===c){const[t,n]=o.selection;s=[r.x.invert(0),r.x.invert(e)],l=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;s=[r.x.invert(t),r.x.invert(n)],l=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===o.type||"brush"===o.type&&g)){const e=M.current;e&&e.length>0?s=function(t,e){return 0===e.length?t:[vt(t[0],e),mt(t[1],e)]}(s,e):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const n=r.x(s[0]),l=r.x(s[1]);if(P.current=!0,"x"===c)t.call(i.move,[n,l]);else if("xy"===c){const e=o.selection;t.call(i.move,[[n,e[0][1]],[l,e[1][1]]])}P.current=!1}const a={x:s,y:l};C.current=a,A.current(a)}),t.call(i),w.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),w.current=null}},[e,n,c,f,h,g]),s(()=>{if(!(x&&u&&w.current&&C.current))return;if(!k.current)return;if("y"===c)return;const t=C.current,e=u.x.domain()[0],n=p(k.current).select(".brush-g");if(e>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=M.current;t&&t.length>0?i=mt(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);o=!0}const r=u.x(i),s=u.x(t.x[1]);if(P.current=!0,"x"===c)n.call(w.current.move,[r,s]);else{const e=u.y(t.y[1]),i=u.y(t.y[0]);n.call(w.current.move,[[r,e],[s,i]])}if(P.current=!1,o){const e={x:[i,t.x[1]],y:t.y};C.current=e,A.current(e)}},[u,x,c,f,h]),t("svg",{ref:k,width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}const xt=Object.freeze([]);function kt(t){if(!t)return xt;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}class wt{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=kt(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=kt(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function At(e){let n=null;const i=()=>(n||(n=u(null)),n),s=_t(e);return[function({children:n,initialState:s}){const l=o(s),a=r(()=>_t(e,l.current),[]),c=i();return t(c.Provider,{value:a,children:n})},(t,e)=>{var n;const r=i(),u=null!==(n=l(r))&&void 0!==n?n:s,d=o(t);d.current=t;const h=o({hasValue:!1,value:void 0}),f=a(()=>{const t=d.current(u.getState()),n=h.current;return n.hasValue&&e&&e(n.value,t)?n.value:(h.current={hasValue:!0,value:t},t)},[u,e]),y=a(()=>d.current(u.getState()),[u]);return c(u.subscribe,f,y)}]}function _t(t,e){const n=new Set;let i=Object.assign(Object.assign({},t(function(t){const e=t(i);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){i=Object.assign(Object.assign({},i),e);for(const t of n)t()}})),null!=e?e:{});return{getState:()=>i,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function St(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Mt(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:Pt})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const Pt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Ct={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ot={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Tt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Pt,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Dt(t,e){if("light"===e)return Ct;if("dark"===e)return Ot;if("high-contrast"===e)return Tt;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Ot:Ct;return Mt(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return Mt(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[Nt,Et]=At(t=>({theme:Ct,setTheme(e){t(t=>({theme:Dt(t.theme,e)}))}}));class Lt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class $t{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function It(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),l=n(s);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=l,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+l)}}return r}function Wt(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}s.sort((t,e)=>t.px-e.px);const l=Array(s.length),a=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];l[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:a,style:o,datum:c,group:r}}function zt(t,e,n,i,o,r,s,l){const a=[];for(const r of t){const t=n(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=l?l(r):o;a.push({px:c,topY:e.y(s),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function Rt(t,e,n,i){var o,r,s;const l=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;l.set(i,-t/2)}else if("wiggle"===i){t.length>0&&l.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let a=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;a+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(o=l.get(r))&&void 0!==o?o:0;l.set(s,d-(c>0?a/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i+=(null!==(r=l.get(o))&&void 0!==r?r:0)+t/2}const o=i/t.length;for(const e of t)l.set(e,(null!==(s=l.get(e))&&void 0!==s?s:0)-o)}}else for(const e of t)l.set(e,0);return l}function jt(t,e,n,i,o,r,s){const l=n(t),a=i(t);if(!Number.isFinite(l)||!Number.isFinite(a))return null;const c={type:"point",x:e.x(l),y:e.y(a),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function Ft(t,e,n,i,o,r,s,l){const a=n(t),c=i(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(a),y:e.y(c),size:o,symbolType:r,style:s,datum:t};return void 0!==l&&(u.pointId=l),u}function Yt(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function Bt(t,e,n,i,o,r,s){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(l.showValues=!0,l.value=s.value,s.valueFormat&&(l.valueFormat=s.valueFormat)),l}function Ht(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Xt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Gt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Vt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}function qt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Ut(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Kt(t){const e=t.map(qt),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return Ut(t,n,i)}if(t>=1){const[t,i,o]=e[n];return Ut(t,i,o)}const i=t*n,o=Math.floor(i),r=i-o,[s,l,a]=e[o],[c,u,d]=e[o+1];return Ut(Math.round(s+(c-s)*r),Math.round(l+(u-l)*r),Math.round(a+(d-a)*r))}}const Qt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Zt=Kt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Jt=Kt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),te=Kt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=Kt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ne=Kt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ie=Kt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),oe=Kt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),re=Kt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),se=Kt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),le=Kt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ae=Kt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),ce=Kt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ue={blues:Zt,reds:Jt,greens:te,viridis:oe,oranges:ee,purples:ne,greys:ie,plasma:re,inferno:se,magma:le,cividis:ae,turbo:ce};Kt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Kt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Kt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Kt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Kt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Kt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Kt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const de=Object.assign({category10:Qt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},ue),he=Qt,fe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function ye(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,l=n-1-e;switch(t.type){case"linear":return s+(1-l/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return s+Math.pow(.5,l/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>l?1:s;default:return 1}}function ge(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function pe(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ve(t,e){return Math.min((t-e.startTime)/e.duration,1)}function me(t,e,n){return t+(e-t)*n}function be(t,e,n){var i,o,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function xe(t,e,n,i){return"function"==typeof e.style?e.style(i||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,i)}function ke(t,e,n,i){if(!t.scales)return null;const o=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=i.getTop(n),l=i.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(l))continue;const a=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(l);Number.isFinite(a)&&Number.isFinite(c)&&Number.isFinite(u)&&(o.push([a,c]),r.push([a,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:xe(t,i,n,e[0]),datum:e,group:n,interactive:i.interactive}}function we(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const i of t)i.perSeries?e.push(i):n.push(i);return{perSeries:e,aggregate:n}}function Ae(t,e,n){const i=[];for(const o of n){const n=ke(t,e,"__ribbon_aggregate",o);n&&i.push(n)}return i}function _e(t,e,n,i){const o=[];for(const r of i){const i=ke(t,e,n,r);i&&o.push(i)}return o}function Se(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const i of e){if("band"!==i.kind)continue;const e=i.getTop(t),o=i.getBottom(t);Number.isFinite(o)&&Number.isFinite(e)&&n.push({y0:o,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function Me(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const l=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(s)+"":void 0,c=jt(s,t.scales,t.getX,r,l,i,a);c&&n.push(c)}}}const Pe={topOpacity:.8,bottomOpacity:.05};function Ce(t){var e,n;if(t)return!0===t?Pe:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:Pe.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:Pe.bottomOpacity}}const Oe={circle:S,square:D,triangle:T,diamond:O,star:C,cross:P,wye:M},Te=["circle","triangle","diamond","star","square","chevron","cross","wye"];function De(t,e,n){var i,o;if(n)return n;const r=null!=t?t:"circle";if("chevron"===r)return function(t){const e=1.5*Ne(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e);const s=null!==(i=Oe[r])&&void 0!==i?i:S;return null!==(o=_(s,Math.max(1,e))())&&void 0!==o?o:""}function Ne(t){return Math.sqrt(Math.max(1,t)/Math.PI)}const Ee=new Map;function Le(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),l=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Xt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),y=(d-u||1)/s,g=(f-h||1)/l,p=s*l;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/y),s-1),d=Math.min(Math.floor((r-h)/g),l-1);if(0>a||0>d)continue;const f=d*s+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let b=1/0,x=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}b>e&&(b=e),e>x&&(x=e)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,A=n.height/l,_=t.config.showValues,S=t.config.heatmapValueFormat,M=[];for(let t=0;l>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-b)/k;M.push(Bt(n*w,(l-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i],xCenter:u+(n+.5)*y,yCenter:h+(t+.5)*g,agg:a},_?{value:o,showValues:!0,valueFormat:S}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const i=Xt(t.config.valueAccessor,"value"),o=Gt(t.config.xAccessor,"x"),r=Gt(t.config.yAccessor,"y"),s=new Map,l=new Map,a=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);a[t]=i,c[t]=u,s.has(i)||s.set(i,s.size),l.has(u)||l.set(u,l.size)}const u=s.size,d=l.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(l.keys()),y=h.every(t=>"number"==typeof t&&!isNaN(t)),g=f.every(t=>"number"==typeof t&&!isNaN(t));if(y){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(g){f.sort((t,e)=>t-e),l.clear();for(let t=0;f.length>t;t++)l.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),b=new Map;let x=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(a[t]),r=l.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=b.get(h);let y;void 0!==f?y=f:(y=x++,b.set(h,y)),p[y]=h,v[y]=d,m[y]=n}let k=1/0,w=-1/0;for(let t=0;x>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ue?t:"blues";let n=Ee.get(e);if(n)return n;n=Array(256);const i=(o=e)&&ue[o]||Zt;var o;for(let t=0;256>t;t++)n[t]=i(t/255);return Ee.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(w-k||1),S=n.width/u,M=n.height/d,P=t.config.showValues,C=t.config.heatmapValueFormat,O=[];for(let t=0;x>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;O.push(Bt(i*S,(d-1-(n-i)/u)*M,S,M,A[Math.min((e-k)*_+.5|0,255)],m[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return O}function $e(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:i,warned:o}=t;Ie(i)&&0===n.length&&We(o,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(t=>null==t.datum)&&We(o,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Ie(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Ie))}function We(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function ze(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Re(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=ze(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=Xt(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e-o:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:ze(t.y1Accessor,"y1"),getBottom:ze(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class je{constructor(t){if(this.xExtent=new $t,this.yExtent=new $t,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new Lt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Xt(t.timeAccessor||t.xAccessor,"time"),this.getY=Xt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Xt(t.xAccessor,"x"),this.getY=Xt(t.yAccessor,"y")),this.getGroup=Vt(t.groupAccessor),this.getCategory=Vt(t.categoryAccessor),this.getSize=t.sizeAccessor?Xt(t.sizeAccessor,"size"):void 0,this.getColor=Vt(t.colorAccessor),this.getSymbol=Vt(t.symbolAccessor),this.getY0=t.y0Accessor?Xt(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Re(t),this.getPointId=Vt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Xt(t.openAccessor,"open"):void 0,this.getHigh=Xt(t.highAccessor,"high"),this.getLow=Xt(t.lowAccessor,"low"),this.getClose=n?Xt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new Lt(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Xt(this.config.timeAccessor||this.config.xAccessor,"time"):Xt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}if(null!=t)if(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t));else{this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}}return!0}computeScene(t){var e,n,i,o,r,s,l,a,c,u,d,h,f,y;const{config:g,buffer:p}=this;if(!this.needsFullRebuild&&!g.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(p,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),m=this.xExtent.extent,b=this.yExtent.extent;let A=g.xExtent?[null!==(n=g.xExtent[0])&&void 0!==n?n:m[0],null!==(i=g.xExtent[1])&&void 0!==i?i:m[1]]:m,_=g.yExtent?[null!==(o=g.yExtent[0])&&void 0!==o?o:b[0],null!==(r=g.yExtent[1])&&void 0!==r?r:b[1]]:b;const S=g.yExtent&&null!=g.yExtent[0]&&null!=g.yExtent[1],M="exact"===g.axisExtent;if("stackedarea"===g.chartType&&!S&&p.size>0)if(g.normalize)_=[0,M?1:1+g.extentPadding];else{const t=`${p.size}:${this._ingestVersion}:${null!==(s=g.baseline)&&void 0!==s?s:"zero"}:${null!==(l=g.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)_=this._stackExtentCache.yDomain;else{const e=this.groupData(v),n=new Map,i=new Set;let o=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let l=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),i.add(t),l+=s;const a=(r.get(t)||0)+s;r.set(t,a),a>o&&(o=a)}n.set(t.key,e),s.set(t.key,l)}const l=null!==(a=g.stackOrder)&&void 0!==a?a:"key",f=(t,e)=>e>t?-1:t>e?1:0;let y;if("insideOut"===l){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(c=s.get(e))&&void 0!==c?c:0):(i.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0);y=[...i.reverse(),...n]}else y="asc"===l?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(i=s.get(e))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):"desc"===l?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===g.baseline||"silhouette"===g.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=Rt(t,y,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},g.baseline);let o=1/0,s=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,i=null!==(h=r.get(n))&&void 0!==h?h:0;o>t&&(o=t),t+i>s&&(s=t+i)}Number.isFinite(o)&&Number.isFinite(s)||(o=0,s=0);const l=s-o,a=M?0:l>0?l*g.extentPadding:1;_=[o-a,s+a]}else _=[0,o+(M?0:o>0?o*g.extentPadding:1)];this._stackExtentCache={key:t,yDomain:_}}}else if("bar"===g.chartType&&g.binSize&&!S&&p.size>0){const[,t]=function(t,e,n,i,o){const r=It(t,e,n,i,o);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(p,this.getX,this.getY,g.binSize,this.getCategory);_=[0,M?t:t+t*g.extentPadding]}else if("waterfall"===g.chartType&&!S&&p.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(p,this.getY),n=e-t,i=M?0:n>0?n*g.extentPadding:1;_=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!S&&_[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of v)for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(_[0]>n&&(_[0]=n),n>_[1]&&(_[1]=n)),Number.isFinite(i)&&(_[0]>i&&(_[0]=i),i>_[1]&&(_[1]=i))}const t=_[1]-_[0],e=M?0:t>0?t*g.extentPadding:1,n=null===(f=g.yExtent)||void 0===f?void 0:f[0],i=null===(y=g.yExtent)||void 0===y?void 0:y[1];_=[null!=n?_[0]:_[0]-e,null!=i?_[1]:_[1]+e],"log"!==g.yScaleType||_[0]>0||0>=b[0]||M||(_[0]=null!=n?_[0]:b[0]/(1+g.extentPadding))}if(g.yExtent&&!S){const t=g.yExtent[0],e=g.yExtent[1];null==t&&null==e||(_=[null!=t?t:_[0],null!=e?e:_[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===g.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];_[0]!==1/0&&_[1]!==-1/0||(_=[0,1]);const P="streaming"===g.runtimeMode,C=Math.max(0,Math.min(g.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(O=g.arrowOfTime)||"down"===O?"y":"x")){const e="right"===g.arrowOfTime?[C,t.width-C]:[t.width-C,C];this.scales={x:x().domain(A).range(e),y:x().domain(_).range([t.height-C,C])}}else{const e="down"===g.arrowOfTime?[C,t.height-C]:[t.height-C,C];this.scales={x:x().domain(_).range([C,t.width-C]),y:x().domain(A).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return k().domain(t).range(n).clamp(!0)}return"time"===t?w().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)};this.scales={x:e(g.xScaleType,A,[C,t.width-C]),y:e(g.yScaleType,_,[t.height-C,C])}}var O;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,je.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=A().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),l=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return k().domain(t).range(n).clamp(!0)}return"time"===t?w().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)},a=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:l(this.config.xScaleType,i,r[0]>r[1]?[t.width-a,a]:[a,t.width-a]),y:l(this.config.yScaleType,o,c?[a,t.height-a]:[t.height-a,a])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,i,o,r,s,l,a,c,u;const{config:d,scales:h}=this;if(!h)return[];if(d.customLayout){const u=null!==(n=d.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},f={data:e,scales:h,dimensions:{width:t.width,height:t.height,margin:u,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(i=d.themeSemantic)&&void 0!==i?i:{},categorical:null!==(o=d.themeCategorical)&&void 0!==o?o:fe},resolveColor:(t,e)=>{var n,i;const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(i=null===(n=d.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==i?i:"#4e79a7"},config:null!==(r=d.layoutConfig)&&void 0!==r?r:{},selection:null!==(s=d.layoutSelection)&&void 0!==s?s:null};let y;try{y=d.customLayout(f)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(l=y.overlays)&&void 0!==l?l:null;const g=null!==(a=y.nodes)&&void 0!==a?a:[];if(this._customRestyle=y.restyle,this.hasCustomRestyle=!!y.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of g)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(g,null!==(c=d.layoutSelection)&&void 0!==c?c:null)}return $e({label:"customLayout",nodes:g,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),g}if(this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const f={scales:h,config:d,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(d.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=we(t.ribbons);if(r.length>0&&o.push(...Ae(t,e,r)),n.length>0)for(const e of i)o.push(..._e(t,e.data,e.key,n))}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Wt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return Me(t,i,o),o}(f,e);case"area":return function(t,e){const n=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=we(t.ribbons);if(r.length>0&&i.push(...Ae(t,e,r)),o.length>0)for(const e of n)i.push(..._e(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=zt(e.data,t.scales,t.getX,t.getY,o,n,e.key,r),l=Ce(t.config.gradientFill);l&&(s.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return Me(t,n,i),i}(f,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=we(t.ribbons);if(r.length>0&&i.push(...Ae(t,e,r)),o.length>0)for(const e of n)i.push(..._e(t,e.data,e.key,o))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=zt(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),l=Ce(t.config.gradientFill);l&&(o.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Wt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return Me(t,n,i),i}(f,e);case"stackedarea":return function(t,e){var n,i,o,r;const s=t.groupData(e),l=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",a=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===l)a();else if("asc"===l||"desc"===l||"insideOut"===l){const e=new Map;for(const n of s){let i=0;for(const e of n.data){const n=t.getX(e),o=t.getY(e);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}e.set(n.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===l)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(t.key))&&void 0!==o?o:0)-(null!==(r=e.get(i.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else if("desc"===l)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else{const t=[...s].sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)}),r=[],l=[];let a=0,c=0;for(const n of t)c>a?(r.push(n),a+=null!==(i=e.get(n.key))&&void 0!==i?i:0):(l.push(n),c+=null!==(o=e.get(n.key))&&void 0!==o?o:0);s.length=0,s.push(...l.reverse(),...r)}}else a();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,i,o,r,s,l="zero"){var a,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const i of t)n+=(null===(a=h.get(i.key))||void 0===a?void 0:a.get(e))||0;f.set(e,n||1)}}const y=Rt(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},l),g=[],p=new Map,v=new Map;for(const t of d)v.set(t,null!==(c=y.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),i=[],l=[],a=new Map;for(const n of d){let o=t.get(n)||0;const s=v.get(n);r&&(o/=f.get(n));const c=s+o,u=e.x(n);l.push([u,e.y(s)]),i.push([u,e.y(c)]),v.set(n,c),a.set(n,c)}p.set(n.key,a);const c={type:"area",topPath:i,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),g.push(c)}return{nodes:g,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const i=h.get(n.key);if(i)for(const o of n.data){const n=t.getX(o),r=t.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||e.set(o,i.get(n))}}const n=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};Me(t,s,f,n)}return f}(f,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const l=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",c=t.getSymbol,u=t.config.symbolMap,d=new Map;let h=0;const f=t=>{const e=null==u?void 0:u[t];if(e)return e;let n=d.get(t);return n||(n=Te[h%Te.length],h++,d.set(t,n)),n};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(l&&t.getColor&&!e.fill){const i=t.getColor(n);i&&l.has(i)&&(e=Object.assign(Object.assign({},e),{fill:l.get(i)}))}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const o=f(c(n)+""),s=Ft(n,t.scales,t.getX,t.getY,Math.PI*r*r,o,e,u);s&&i.push(s)}else{const o=jt(n,t.scales,t.getX,t.getY,r,e,u);o&&i.push(o)}}return i}(f,e);case"heatmap":return Le(f,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=It(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.has(t)).sort(),l=n.filter(t=>e.has(t)),a=l.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...l,...s],t.barCategoryCache={key:a,order:r})}const s=[],l=t.scales,[a,c]=l.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,y={};(null==u?void 0:u.stroke)&&(y.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(y.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(y.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=l.x(n),g=l.x(o),p=Math.abs(g-h),v=p>f+1?f:0,m=Math.min(h,g)+v/2,b=Math.max(p-v,1);if(b>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=l.y(n),c=l.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(Yt(m,Math.min(a,c),b,Math.abs(a-c),Object.assign({fill:h},y),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=l.y(0),n=l.y(e.total);s.push(Yt(m,Math.min(t,n),b,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},y),{binStart:e.start,binEnd:e.end,total:e.total}))}}const g=new Set;for(const t of o.values())g.add(t.start),g.add(t.end);return{nodes:s,binBoundaries:Array.from(g).sort((t,e)=>t-e)}}(f,e);return this._barCategoryCache=null!==(u=f.barCategoryCache)&&void 0!==u?u:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,l;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,y=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(l=t.config.barColors)||void 0===l?void 0:l[e])||s}const c={type:"point",x:o,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:y},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(f,e);case"waterfall":return function(t,e,n){var i,o,r,s,l,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const y=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",g=null!==(a=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(l=t.config.themeSemantic)||void 0===l?void 0:l.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=x+r;let l;l=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==l?d.x(o+l):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){x=s;continue}const A=d.y(x),_=d.y(s),S=Math.min(A,_),M=Math.abs(A-_),P={fill:0>r?g:y,stroke:v,strokeWidth:m};null!=b&&(P.opacity=b),u.push(Yt(k,S,w,M,P,Object.assign(Object.assign({},i),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(f,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},l=s.rangeColor||"#6366f1",a=o?l:s.upColor||"#28a745",c=o?l:s.downColor||"#dc3545",u=o?l:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const l=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[l,h].some(t=>null==t||Number.isNaN(t)))continue;const y=h>=l,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(l),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:y,datum:n};o&&(g.isRange=!0),r.push(g)}return r}(f,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?ye(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const l=s.get(e[n]);null!=l?(i[n]=ye(t,l,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let l=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=ye(t,i,r),1>o[n]&&(l=!0)):o[n]=1}l&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=ye(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const l=ye(t,e,r);if("heatcell"===n.type)n.style={opacity:l};else if("candlestick"===n.type)n._decayOpacity=l;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*l})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const l=ge(t,r,s);l>o&&(o=l)}o>0&&(n._pulseIntensity=o,n._pulseColor=l);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=ge(t,o,s);r>0&&(n._pulseIntensity=r,n._pulseColor=l,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,s,l;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=be(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=be(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,s,l,a,c,u,d,h,f,y,g,p,v,m,b,x,k,w,A,_,S,M,P,C,O,T,D,N,E,L,$,I,W,z,R,j,F,Y,B,H,X;if(0===i.size&&0===o.size)return n;const G=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let V=!1;const q=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],T=be(t,r,e);if(!T)continue;if(r._transitionKey=T,"line"===r.type||"area"===r.type){const t=o.get(T);if(t){if(U.add(T),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(a=null!==(l=t.opacity)&&void 0!==l?l:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const D=i.get(T);if("point"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,D.x===t.x&&D.y===t.y&&D.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=D.x,r.y=D.y,r.r=null!==(d=D.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,D.x===t.x&&D.y===t.y&&D.w===t.w&&D.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=D.x,r.y=D.y,r.w=null!==(y=D.w)&&void 0!==y?y:r.w,r.h=null!==(g=D.h)&&void 0!==g?g:r.h,V=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,D.x===t.x&&D.y===t.y&&D.w===t.w&&D.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=D.x,r.y=D.y,r.w=null!==(b=D.w)&&void 0!==b?b:r.w,r.h=null!==(x=D.h)&&void 0!==x?x:r.h,V=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(D&&null!=D.openY){q.add(T);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(_=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==_?_:1,(D.x!==t.x||D.openY!==t.openY||D.closeY!==t.closeY||D.highY!==t.highY||D.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=D.x,r.openY=D.openY,r.closeY=null!==(S=D.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(M=D.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(P=D.lowY)&&void 0!==P?P:r.lowY,V=!0)}else r._targetOpacity=null!==(O=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==O?O:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(D=e.opacity)&&void 0!==D?D:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}for(const[t,e]of i)if(!q.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(N=e.r)&&void 0!==N?N:3,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(L=e.w)&&void 0!==L?L:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(I=e.opacity)&&void 0!==I?I:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(W=e.w)&&void 0!==W?W:0,h:null!==(z=e.h)&&void 0!==z?z:0,fill:"#999",datum:null,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(j=e.openY)&&void 0!==j?j:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(F=e.closeY)&&void 0!==F?F:i,highY:null!==(Y=e.highY)&&void 0!==Y?Y:i,lowY:null!==(B=e.lowY)&&void 0!==B?B:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:G}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,s,l,a,c;if(!n.activeTransition)return!1;const u=ve(t,n.activeTransition),d=pe(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=me(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=me(n.x,t._targetX,d),t.y=me(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=me(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=me(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=me(n.x,t._targetX,d),t.y=me(n.y,t._targetY,d),void 0!==n.w&&(t.w=me(n.w,t._targetW,d)),void 0!==n.h&&(t.h=me(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:me(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=me(n.x,t._targetX,d),t.y=me(n.y,t._targetY,d),void 0!==n.w&&(t.w=me(n.w,t._targetW,d)),void 0!==n.h&&(t.h=me(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:me(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=me(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=me(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=me(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=me(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=me(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:me(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=me(e[i][0],n[i][0],d),t.path[i][1]=me(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:me(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=me(e[n][0],i[n][0],d),t.topPath[n][1]=me(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=me(n[e][0],o[e][0],d),t.bottomPath[e][1]=me(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(this._groupDataCache&&this._groupDataCache.version===this._ingestVersion&&this._groupDataCache.group===this.getGroup&&this._groupDataCache.data===t)return this._groupDataCache.result;let e;if(this.getGroup){const n=new Map;for(const e of t){const t=this.getGroup(e);n.has(t)||n.set(t,[]),n.get(t).push(e)}e=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else e=[{key:"_default",data:t}];return this._groupDataCache={version:this._ingestVersion,group:this.getGroup,data:t,result:e},e}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||fe,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||fe;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>je.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,i;const o=this._customRestyle;if(o)for(const r of t){const t=null!==(i=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==i?i:{},s=o(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!Ht(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=a||!Ht(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Xt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Xt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Xt(this.config.xAccessor,"x"),this.getY=Xt(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Re(this.config)),s=!0,l=!0)}if("groupAccessor"in t&&!Ht(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Vt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!Ht(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Vt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!Ht(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Xt(this.config.sizeAccessor,"size"):void 0,s=!0),"symbolAccessor"in t&&!Ht(t.symbolAccessor,r.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Vt(this.config.symbolAccessor):void 0,s=!0),"colorAccessor"in t&&!Ht(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Vt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!Ht(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Xt(this.config.y0Accessor,"y0"):void 0,s=!0,l=!0),("boundsAccessor"in t&&!Ht(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Re(this.config),s=!0,l=!0),"pointIdAccessor"in t&&!Ht(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Vt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in t&&!Ht(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!Ht(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!Ht(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!Ht(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Xt(this.config.openAccessor,"open"):void 0,this.getHigh=Xt(this.config.highAccessor,"high"),this.getLow=Xt(this.config.lowAccessor,"low"),this.getClose=e?Xt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,l=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(l&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Fe(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:i.createElement(i.Fragment,null,...e)}je.GROUP_COLOR_MAP_CAP=1e3,je.QUADTREE_THRESHOLD=500;const Ye=i.createContext(null);function Be({value:e,children:n}){return t(Ye.Provider,{value:e,children:n})}function He(e,n){return null!=e?t(Be,{value:n,children:e}):e}function Xe(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Ge(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Ve(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function qe(t,e){const n=Ve(t);if(!n)return!1;const i=Ve(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function Ue(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Ke(t,e,n,i,o,r=t=>t.x,s=t=>t.y,l=t=>t.r){const a=Math.max(i,o+5,12),c=e-a,u=e+a,d=n-a,h=n+a;let f=null,y=1/0;return t.visit((t,o,a,g,p)=>{if(o>u||c>g||a>h||d>p)return!0;if(!t.length){let o=t;do{const t=o.data,a=r(t)-e,c=s(t)-n,u=Math.sqrt(a*a+c*c);Ge(l(t),i)>=u&&y>u&&(f=t,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}const Qe=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Ze=new WeakMap;let Je=0,tn=!1,en=null,nn=null,on=null;function rn(t,e){var n,i;if(!e)return e;const o=Qe.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(tn)return;if("undefined"==typeof window||"undefined"==typeof document)return;tn=!0;const t=()=>{Je++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(en=new MutationObserver(t),en.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{nn=window.matchMedia("(prefers-color-scheme: dark)"),on=t,"function"==typeof nn.addEventListener?nn.addEventListener("change",on):"function"==typeof nn.addListener&&nn.addListener(on)}catch(t){}}();let s=Ze.get(r);s&&s.version===Je||(s={version:Je,map:new Map},Ze.set(r,s));const l=s.map.get(e);if(void 0!==l)return l;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,a),a}function sn(t){switch(t){case"monotoneX":return j;case"monotoneY":return R;case"cardinal":return z;case"catmullRom":return W;case"step":return I;case"stepBefore":return $;case"stepAfter":return L;case"basis":return E;case"natural":return N;default:return null}}function ln(t,e,n){return null==e?n:"string"!=typeof e?e:rn(t,e)||n}function an(t,e,n,i,o,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const l=t.createLinearGradient(i,o,r,s);for(const t of n)l.addColorStop(t.offset,t.color);return l}const{topOpacity:l,bottomOpacity:a}=e;if(!Number.isFinite(l)||!Number.isFinite(a))return null;const c=Math.max(0,Math.min(1,l)),u=Math.max(0,Math.min(1,a)),d=t.createLinearGradient(i,o,r,s),[h,f,y]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${y},${c})`),d.addColorStop(1,`rgba(${h},${f},${y},${u})`),d}function cn(t,e,n,i,o,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const l=t.createLinearGradient(n,i,o,r);for(const t of s)l.addColorStop(t.offset,t.color);return l}const un=new WeakMap;function dn(t,e){const n=sn(e);if(!n)return t;const i=un.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,s,l,a){if(!o)return o=[l,a],void i.push([l,a]);const[c,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*l,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*a])}o=[l,a]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return F().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return un.set(t,o),o}function hn(t,e,n,i=30,o,r=0){let s=null;if(o){const t=Ke(o,e,n,i,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(o)break;t=yn(r,e,n,i);break;case"symbol":t=gn(r,e,n,i);break;case"line":t=pn(r,e,n,i);break;case"rect":if(null==r.datum)break;t=mn(r,e,n);break;case"heatcell":t=bn(r,e,n);break;case"area":if(!1===r.interactive)break;t=kn(r,e,n);break;case"candlestick":t=xn(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function fn(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=wn(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,l]=t[o],[a,c]=t[r];return a===s?l:l+Math.max(0,Math.min(1,(e-s)/(a-s)))*(c-l)}function yn(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>Ge(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function gn(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>Ge(Ne(t.size),i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function pn(t,e,n,i=30){var o,r;if(0===t.path.length)return null;const s=wn(t.path,e);if(0>s)return null;const[l,a]=t.path[s];let c;if(t.path.length>1){let i=1/0;const o=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[l,a]=t.path[s+1],c=vn(e,n,o,r,l,a);i>c&&(i=c)}c=i}else{const t=e-l,i=n-a;c=Math.sqrt(t*t+i*i)}const u=t.style,d=null!==(r=null!==(o=u.strokeWidth)&&void 0!==o?o:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:l,y:a,distance:c}}function vn(t,e,n,i,o,r){const s=o-n,l=r-i,a=s*s+l*l;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*l)/a;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function mn(t,e,n){const i=Xe(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function bn(t,e,n){const i=Xe(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function xn(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function kn(t,e,n){if(0===t.topPath.length)return null;const i=wn(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,l=n-r,a=Math.sqrt(s*s+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function wn(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function An(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:s}}function _n(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function Sn(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?Mn(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Mn(n,n.groups[t-1],r[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Mn(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function Pn(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function Cn(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const On={fresh:1,aging:1.5,stale:3};function Tn(t,e,n={}){var i,o,r;if(!Number.isFinite(e)||0>=e)return"fresh";if(Number.isNaN(t))return"fresh";if(t===1/0)return"expired";if(0>t)return"fresh";const s=null!==(i=n.fresh)&&void 0!==i?i:1,l=null!==(o=n.aging)&&void 0!==o?o:1.5,a=null!==(r=n.stale)&&void 0!==r?r:3;return e*s>t?"fresh":e*l>t?"aging":e*a>t?"stale":"expired"}const Dn={fresh:1,aging:.7,stale:.45,expired:.25},Nn={alpha:1,band:"fresh",isStale:!1};function En(t,e){var n,i;if(!t||0>=e)return Nn;const o=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},i=Tn(e,o,t.thresholds);return{alpha:Object.assign(Object.assign({},Dn),null!==(n=t.opacities)&&void 0!==n?n:{})[i],band:i,isStale:"fresh"!==i}}return e>o?{alpha:null!==(i=t.dimOpacity)&&void 0!==i?i:.5,band:"stale",isStale:!0}:Nn}function Ln(t,e,n,i,r,l){const a=o("fresh");s(()=>{if(!t)return;const o=setInterval(()=>{const o=e.current;if(!o||0===o.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=En(t,s-o.lastIngestTime);c.band===a.current&&c.isStale===r||(a.current=c.band,c.isStale!==r&&l(c.isStale),n.current=!0,i())},1e3);return()=>clearInterval(o)},[t,r,i])}function $n({isStale:e,position:n}){return t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===n?{top:4,left:4}:"bottom-left"===n?{bottom:4,left:4}:"bottom-right"===n?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"}),children:e?"STALE":"LIVE"})}const In={fill:(e,n)=>t("rect",{style:e,width:n,height:n}),line:(e,n)=>t("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function Wn(t,e,n,i,o){let r;return r="function"==typeof n?n(t):(0,In[n])(i(t,e),o),r}function zn({swatchSize:e}){return t("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Rn(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const jn=(n,i,o,r,s,l,a,c,u,d,h)=>{const{type:f="fill",styleFn:y,items:g}=n,p=[];let v=0;const m=!(!i&&!o),b="isolate"===d||void 0===d&&null!=s,{swatchSize:x,labelGap:k,rowHeight:w}=h;return g.forEach((n,d)=>{const h=Wn(n,d,f,y,x),A=Rn(n,r,s),_=s&&s.size>0&&s.has(n.label);p.push(e("g",{transform:`translate(0,${v})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?c===l&&d===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?_||!1:void 0,"aria-current":m&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:m?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+g.length)%g.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:m?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,_&&t(zn,{swatchSize:x}),t("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),v+=w}),p};function Fn({config:n,orientation:o="vertical",width:r=100}){const{colorFn:s,domain:l,label:a,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:s(l[0]+n*(l[1]-l[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),a&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(l[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(l[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:s(l[1]-n*(l[1]-l[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[a&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(l[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(l[0])})]})}function Yn(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:l,isolatedCategories:a,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical",legendLayout:y}=n,g=function(t){var e,n,i,o,r;const s=Math.max(1,null!==(e=null==t?void 0:t.swatchSize)&&void 0!==e?e:16),l=Math.max(s,null!==(n=null==t?void 0:t.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(i=null==t?void 0:t.labelGap)&&void 0!==i?i:6),itemGap:Math.max(0,null!==(o=null==t?void 0:t.itemGap)&&void 0!==o?o:10),rowHeight:l,align:"left"===(null==t?void 0:t.align)?"start":"right"===(null==t?void 0:t.align)?"end":null!==(r=null==t?void 0:t.align)&&void 0!==r?r:"start",maxWidth:null==t?void 0:t.maxWidth}}(y),[p,v]=i.useState(0),[m,b]=i.useState(0),x=i.useCallback((t,e)=>{v(t),b(e)},[]),k="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return e.forEach((e,y)=>{h+=5,f.push(t("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+y)),h+=8,e.label&&(h+=16,f.push(t("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+y)),h+=8),f.push(t("g",{className:"legend-item",transform:`translate(0,${h})`,children:jn(e,i,o,r,s,l,a,y,c,u,d)},"legend-group-"+y)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:g}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h,metrics:f})=>{var y;let g=0;const p=[];n.forEach((n,i)=>{var y;let v=0;n.label&&(v+=16);const m=((n,i,o,r,s,l,a,c,u,d,h,f)=>{const{type:y="fill",styleFn:g,items:p}=n,v=[],{swatchSize:m,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,A=!(!i&&!o),_="isolate"===d||void 0===d&&null!=s,S=p.map(t=>m+b+7*t.label.length),M=[];let P=0,C=0;S.forEach((t,e)=>{const n=0===C?t:C+x+t;f&&f>0&&C>0&&n>f?(M.push({start:P,end:e,width:C}),P=e,C=t):C=n}),p.length>0&&M.push({start:P,end:p.length,width:C}),M.forEach((n,d)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=p[f],w=Wn(n,f,y,g,m),M=Rn(n,r,s),P=s&&s.size>0&&s.has(n.label);v.push(e("g",{transform:`translate(${h},${d*k})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:A?c===l&&f===a?0:-1:void 0,role:A?"option":void 0,"aria-selected":A&&_?P||!1:void 0,"aria-current":A&&!_&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:A?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(f+("ArrowRight"===t.key?1:-1)+p.length)%p.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:A?t=>{u(c,f),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:A?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:A?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[A&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+b+2+7*n.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,P&&t(zn,{swatchSize:m}),t("text",{y:m/2,x:m+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=S[f]+x}});const O=Math.max(0,...M.map(t=>t.width)),T=M.length;return{items:v,offset:O,totalRows:T,totalHeight:T*k}})(n,r,s,l,a,c,u,i,d,h,f,null!==(y=f.maxWidth)&&void 0!==y?y:o);v+=m.offset+5,p.push(Object.assign(Object.assign({label:n.label},m),{offset:v,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=v+12});const v=null!==(y=f.maxWidth)&&void 0!==y?y:o;let m=g>v?0:"center"===f.align?Math.max(0,(v-g)/2):"end"===f.align?Math.max(0,v-g):0;const b=[];return p.forEach((e,o)=>{const r=n[o];r.label&&(b.push(t("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),m+=16),b.push(t("g",{className:"legend-item",transform:`translate(${m},0)`,children:e.items},"legend-group-"+o)),m+=e.offset+5,n[o+1]&&b.push(t("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),m+=12}),t("g",{children:b})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:g}),w=!(!r&&!s);return e("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),k]})}function Bn(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Hn(t){return"object"==typeof t&&null!==t&&"gradient"in t}function Xn(e){var n;const{legend:i,totalWidth:o,totalHeight:r,margin:s,legendPosition:l="right",legendLayout:a,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:y}=e;if(!i)return null;const g="top"===l||"bottom"===l,p=!!c,v=Math.max(1,g?null!==(n=null==a?void 0:a.maxWidth)&&void 0!==n?n:Math.max(0,o-s.left-s.right):100);let m,b;return"left"===l?(m=Math.max(4,s.left-v-10),b=s.top):"top"===l?(m=s.left,b=p?32:8):"bottom"===l?(m=s.left,b=r-s.bottom+38):(m=o-s.right+10,b=s.top),t("g",{transform:`translate(${m}, ${b})`,children:Hn(i)?t(Fn,{config:i.gradient,orientation:g?"horizontal":"vertical",width:v}):Bn(i)?t(Yn,{legendGroups:i.legendGroups,title:"",width:v,orientation:g?"horizontal":"vertical",legendLayout:a,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:y}):i})}function Gn(t){let e=1/0,n=-1/0;for(const i of t)e>i&&(e=i),i>n&&(n=i);return[e,n]}function Vn(t){return"string"==typeof t?{type:t}:t}function qn({orient:n,config:i,values:o,scale:s,size:l,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=r(()=>{if(0===o.length)return null;const i=s.domain(),r=l-8;if("boxplot"===c.type){const i=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!i)return null;const{q1:l,median:a,q3:d,whiskerLow:h,whiskerHigh:f}=i,y=Math.min(.5*r,20),g=(r-y)/2+4;if(u){const i=s(l),o=s(d),r=s(a),u=s(h),p=s(f),v="top"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:m+v*(g+y/2),x2:p,y2:m+v*(g+y/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:m+v*g,x2:u,y2:m+v*(g+y),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:p,y1:m+v*g,x2:p,y2:m+v*(g+y),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?m-g-y:m+g,width:Math.abs(o-i),height:y,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?m-g-y:m+g,x2:r,y2:"top"===n?m-g:m+g+y,stroke:c.fill,strokeWidth:2})]})}{const i=s(l),o=s(d),r=s(a),u=s(h),p=s(f),v="left"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:m+v*(g+y/2),y1:u,x2:m+v*(g+y/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*g,y1:u,x2:m+v*(g+y),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*g,y1:p,x2:m+v*(g+y),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?m-g-y:m+g,y:Math.min(i,o),width:y,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?m-g-y:m+g,y1:r,x2:"left"===n?m-g:m+g+y,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=G().domain(i).thresholds(c.bins)(o);if(0===d.length)return null;const h=function(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}(d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=s(e.x0),l=s(e.x1)-s(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(l,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=s(e.x0),l=s(e.x1)-s(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+l),width:o,height:Math.abs(l),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),l=s((t.x0+t.x1)/2);i.push(u?`${l},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${l}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const l=o.length/h*(r/2),a=s((o.x0+o.x1)/2);i.push(u?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?s(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=s((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):a;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?s(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):a;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,s,c,l,a,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Un(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function Kn(t,e,n,i){return"curly"===t?i?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Qn(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:s,title:l,orientation:a,align:c,wrap:u=120,noWrap:d}=n;if(!s&&!l)return t("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let y="start";"topBottom"===h?"right"===f?y="end":"middle"===f&&(y="middle"):y=0>i?"end":"start";const g=16,p=l?d?[l]:Un(l,u):[],v=s?d?[s]:Un(s,u):[],m="leftRight"===h?"end"===y?-4:4:0;let b=0;const x=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";n.useHTML||n.html?(x.push(t("foreignObject",{className:"annotation-note-html",x:"end"===y?m-u:"middle"===y?m-u/2:m,y:-16,width:u,height:Math.max(g,(p.length+v.length)*g+(l&&s?2:0))+g,style:{overflow:"visible"},children:e("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:k,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===y?"right":"middle"===y?"center":"left",whiteSpace:d?"nowrap":"normal",wordBreak:"break-word"},children:[l&&t("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:l}),s&&t("div",{className:"annotation-note-label",children:s})]})},"annotation-note-html")),b=p.length*g):(p.length>0&&(x.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:y,fontWeight:"bold",children:p.map((e,n)=>t("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-title")),b=p.length*g),v.length>0&&x.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:y,y:b,children:v.map((e,n)=>t("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-label")));let w=null;if((l||s)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===y?(n=-e,i=0):"middle"===y&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+v.length)*g+(v.length>0?g:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,p.length+v.length-1)*g;let _=0;return"topBottom"===h?_=0>o?-(A+2):18:"leftRight"===h&&(_="middle"===f?-(A+g+(v.length>0&&p.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==_?`translate(0,${_})`:void 0,children:x}),w]})}function Zn(e,n,i,o,r){var s;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&l.push(t("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;l.push(t("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;l.push(t("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&l.push(t("path",{d:Kn((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:l})}function Jn(e,n,i,o,r,s){var l;const a=[];let c=0,u=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,l=n-r;if(0!==s||0!==l){const e=Math.abs(s),n=Math.abs(l),a=t/2,d=i/2,h=e*d>n*a?a/e:d/n;c=o+s*h,u=r+l*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(c=t/2,u=n):void 0!==e&&(c=n,u=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);c=Math.cos(i)*t,u=Math.sin(i)*t}}const d=Math.sqrt(Math.pow(e-c,2)+Math.pow(n-u,2));if(d>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==i?void 0:i.type);let h=Math.atan2(n-u,e-c);if(s){const o=(null!==(l=null==i?void 0:i.curve)&&void 0!==l?l:.25)*d,s=(c+e)/2+-(n-u)/d*o,f=(u+n)/2+(e-c)/d*o;a.push(t("path",{className:"connector-curve",d:`M${c},${u}Q${s},${f} ${e},${n}`,fill:"none",stroke:r},"connector-line")),h=Math.atan2(f-u,s-c)}else a.push(t("line",{x1:c,y1:u,x2:e,y2:n,stroke:r},"connector-line"));if("arrow"===(null==i?void 0:i.end)){const e=10,n=16/180*Math.PI;a.push(t("path",{d:`M${c},${u}L${c+e*Math.cos(h+n)},${u+e*Math.sin(h+n)}L${c+e*Math.cos(h-n)},${u+e*Math.sin(h-n)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return t("g",{className:"annotation-connector",children:a})}function ti(t){var n,i;const{x:o=0,y:r=0,dx:s,dy:l,nx:a,ny:c,note:u,connector:d,subject:h,type:f,color:y,className:g,disable:p,opacity:v,strokeDasharray:m,events:b={},"data-testid":x}=t,k=Array.isArray(o)?null!==(n=o[0])&&void 0!==n?n:0:o,w=Array.isArray(r)?null!==(i=r[0])&&void 0!==i?i:0:r,A=new Set(Array.isArray(p)?p:[]);let _=s||0,S=l||0;null!=a&&(_=a-k),null!=c&&(S=c-w);const M="string"==typeof f?f:"label";if("bracket"===M&&h&&0===_&&0===S)if(void 0!==h.width){_=h.width/2;const t=h.depth||30;S=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;_=t+(0>t?-5:5),S=h.height/2}return e("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${k},${w})`,"data-testid":x},null!=v&&{opacity:v},m&&{strokeDasharray:m},b,{children:[!A.has("connector")&&Jn(_,S,d,y,M,h),!A.has("subject")&&Zn(M,h,y,k,w),!A.has("note")&&Qn(u,_,S,y)]}))}function ei(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),l=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t(ti,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t(ti,Object.assign({"data-testid":"semiotic-annotation",events:l},o,{type:s}),c)}function ni(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function ii(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function oi(t){return null==t?null:t+""}function ri(t,e,n){var i;return null===(i=e.stickyPositionCache)||void 0===i||i.set(t,n),n}function si(t,e,n){var i,o;const r=t.anchor||(null===(i=t.lifecycle)||void 0===i?void 0:i.anchor)||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const o=n.pointNodes[i];if(o.pointId===t.pointId)return ri(e,n,{x:o.x,y:o.y})}const i=function(t){var e,n,i,o,r,s;const l=t.data;if(!l||0===l.length)return null;const a=l[l.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i?ri(e,n,i):null}if("semantic"===r){const i=function(t,e,n){var i,o;const r=function(t){var e,n;return oi(null!==(n=null===(e=t.provenance)||void 0===e?void 0:e.stableId)&&void 0!==n?n:t.stableId)}(t);if(!r)return null;const s=null===(i=n.pointNodes)||void 0===i?void 0:i.find(t=>oi(t.pointId)===r);if(s)return ri(e,n,{x:s.x,y:s.y});const l=null===(o=n.data)||void 0===o?void 0:o.find(t=>function(t){var e,n,i;return oi(null!==(n=null!==(e=t.stableId)&&void 0!==e?e:t.id)&&void 0!==n?n:null===(i=t.provenance)||void 0===i?void 0:i.stableId)}(t)===r);if(!l)return null;const a=ni(l,n),c=ii(l,n);return null==a||null==c?null:ri(e,n,{x:a,y:c})}(t,e,n);if(i)return i}let s=null,l=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,l=e.y)}if(null!=s&&null!=l||(s=ni(t,n),l=ii(t,n)),null!=s&&null!=l)return ri(e,n,{x:s,y:l});if("sticky"===r){const t=null===(o=n.stickyPositionCache)||void 0===o?void 0:o.get(e);if(t)return t}return null}function li(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const ai={secondary:0,primary:3},ci=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function ui(t){return!0===(null==t?void 0:t._annotationDeferred)}function di(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function hi(t){var e;const n=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function fi(t){return Math.max(.72,.95-.06*t)}function yi(e){const n=e.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:hi(t.annotation),readingOrder:null,rank:1};var n}),i=n.some(t=>null!=t.emphasis||null!=t.confidence),o=e.some(t=>ui(t.annotation)),r=e.some(t=>null!=di(t.annotation)),s=e.some(t=>"layer"===di(t.annotation));if(!i&&!o&&!r)return e.map(t=>t.node);const l=n.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>{var n,i;return(null!==(n=e.confidence)&&void 0!==n?n:0)-(null!==(i=t.confidence)&&void 0!==i?i:0)||t.i-e.i});l.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,l.length)});for(const t of n)t.emphasis&&(t.rank=ai[t.emphasis]);const a=n.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(e=>{const{p:n,i:i,emphasis:o,readingOrder:r}=e,s=ui(n.annotation);let l=n.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;l=t("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o},"secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:fi(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+i)}const a=di(n.annotation);return a&&(l=t("g",{className:"annotation-cohesion--"+a,children:l},"annotation-cohesion-"+i)),s&&(l=t("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:l},"annotation-deferred-"+i)),l});return o&&a.unshift(t("style",{children:ci},"annotation-disclosure-style")),s&&a.unshift(t("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}const gi={linear:B,monotoneX:j,monotoneY:R,step:I,stepAfter:L,stepBefore:$,basis:E,cardinal:z,catmullRom:W};const pi=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function vi(t){return!!t&&"object"==typeof t&&pi.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function mi(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function bi(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function xi(t){var e,n;let i;const o=null==t?void 0:t.emphasis;i="primary"===o?100:"secondary"===o?10:50;const r=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(i+=15*function(t){return Math.max(0,Math.min(1,t))}(r)),null===(n=null==t?void 0:t.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":i+=8;break;case"aging":i+=4;break;case"stale":i+=1;break;case"expired":i-=200}return i}new Set(["label","callout","callout-circle","callout-rect"]);const ki=32,wi=6,Ai=4,_i=8,Si=72;const Mi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Pi(t){return vi(t)}function Ci(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),i=t.split(/\s+/).filter(Boolean),o=[];let r="";for(const t of i)r&&r.length+t.length+1>n?(o.push(r),r=t):r=r?`${r} ${t}`:t;return r&&o.push(r),o}function Oi(t,e,n,i,o){const r=t+n,s=e+i;return Math.abs(n)>Math.abs(i)?{x:0>n?r-o.width-4:r+4,y:0>i?s-o.height:s,width:o.width,height:o.height}:{x:0>n?r-o.width:r,y:0>i?s-o.height-4:s+4,width:o.width,height:o.height}}function Ti(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Di(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function Ni(t,e,n,i,o,r,s,l){const a=Ti(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,i){const o=Math.max(0,i-t.x),r=Math.max(0,i-t.y);return(o+Math.max(0,t.x+t.width-(e-i)))*t.height+(r+Math.max(0,t.y+t.height-(n-i)))*t.width}(a,o,r,l);for(const t of n)c+=12*Di(a,t);for(const t of i)c+=4*Di(a,t);return c}function Ei(t){var e;const{annotations:n,context:i,defaultOffset:o=ki,notePadding:r=wi,markPadding:s=Ai,edgePadding:l=_i,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:u=Si,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:y,cohesion:g,audience:p}=t,v=i.width||0,m=i.height||0;if(0===n.length||0>=v||0>=m)return n.slice();const b=[],x=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(i,s);let k=!1;const w=n.map((t,e)=>{if(!Pi(t))return t;const n=function(t,e,n){var i,o;if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=null!==(i=t.pointId)&&void 0!==i?i:t.nodeId;if(null!=r&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===r);if(t)return{x:t.x,y:t.y}}const s=t.coordinates,l=null===(o=n.scales)||void 0===o?void 0:o.geoProjection;if(Array.isArray(s)&&s.length>=2&&l){const t=s[0],e=s[1];if("number"==typeof t&&"number"==typeof e){const n=l([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?si(t,e,n):{x:t.x,y:t.y}}(t,e,i);if(!n)return t;const s=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...Ci("string"==typeof t.title?t.title:void 0,e),...Ci("string"==typeof t.label?t.label:void 0,e)],i=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*i)+10),height:Math.max(18,16*n.length+6)}}(t);if(a&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return b.push(Ti(Oi(n.x,n.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,s),r)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=Ni(Oi(n.x,n.y,t.dx,t.dy,s),t,b,x,v,m,r,l);f>e&&(h=t,f=e)}if(!h)return t;const y=Ti(Oi(n.x,n.y,h.dx,h.dy,s),r);b.push(y);const g=Math.hypot(h.dx,h.dy),p=c&&g>=u&&"text"!==t.type&&"widget"!==t.type?Object.assign(Object.assign({},t.connector||{end:"arrow"}),{type:"curve"}):t.connector;return k=!0,Object.assign(Object.assign(Object.assign({},t),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),A=k?w:n.slice();let _=A;if(f){let t=!1;const e=A.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:Object.assign(Object.assign({},t),{_redundantConnector:!0})}(e);return n!==e&&(t=!0),n});_=t?e:A}{let t=!1;const e=_.map(e=>{if(!0!==(null==e?void 0:e.defensive))return e;const n=function(t){var e;const n=null==t?void 0:t.provenance;if(!n||"object"!=typeof n)return t;const i="string"==typeof n.source?null!==(e=Mi[n.source])&&void 0!==e?e:n.source:null,o="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[i,o].filter(Boolean).join(" · "),s="string"==typeof t.label?t.label:"";return s.includes(`(${r})`)?t:Object.assign(Object.assign({},t),{label:s?`${s} (${r})`:`(${r})`})}(e);return n!==e&&(t=!0),n});_=t?e:_}const S=new Set;if(d){const t="object"==typeof d?d:{},n=function(t){if(!t)return 1;const e=function(t){const e=null==t?void 0:t.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(p),i=1===n?t:Object.assign(Object.assign({},t),{maxAnnotations:Math.max(0,Math.round((null!==(e=t.maxAnnotations)&&void 0!==e?e:bi(v,m,t))*n))}),{deferred:o}=function(t){var e;const{annotations:n,width:i,height:o}=t,r=Math.max(0,null!==(e=t.minVisible)&&void 0!==e?e:1),s=bi(i,o,t),l=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,vi(n))};var n}),a=l.filter(t=>t.note);if(0===a.length||s>=a.length)return{visible:n.slice(),deferred:[],budget:s};const c=a.filter(t=>mi(t.annotation)),u=a.filter(t=>!mi(t.annotation)).sort((t,e)=>xi(e.annotation)-xi(t.annotation)||t.index-e.index),d=Math.min(u.length,Math.max(Math.max(0,s-c.length),Math.max(0,r-c.length))),h=new Set([...c.map(t=>t.index),...u.slice(0,d).map(t=>t.index)]),f=[],y=[];for(const{annotation:t,index:e,note:n}of l)!n||h.has(e)?f.push(t):y.push(t);return{visible:f,deferred:y,budget:s}}(Object.assign({annotations:_,width:v,height:m},i));for(const t of o)S.add(t)}if(y&&("object"==typeof y&&"number"==typeof y.minWidth?y.minWidth:480)>=v)for(const t of _)Pi(t)&&"secondary"===t.emphasis&&S.add(t);if(S.size>0)for(const t of _)!0===(null==t?void 0:t.defensive)&&S.delete(t);let M;return M=0===S.size?_:h?_.map(t=>S.has(t)?Object.assign(Object.assign({},t),{_annotationDeferred:!0}):t):_.filter(t=>!S.has(t)),g?function(t,e){let n=!1;const i=t.map(t=>Pi(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,Object.assign(Object.assign({},t),{cohesion:e})):t);return n?i:t}(M,g):M}let Li={positions:new Map};const $i=new Set;function Ii(){for(const t of $i)t()}function Wi(t,e){const n=Li.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Li.positions);i.delete(t),Li={positions:i},Ii()}function zi(t,e){const n=Li.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Li.positions);i.delete(t),Li={positions:i},Ii()}function Ri(){return Li}function ji(t){return $i.add(t),()=>$i.delete(t)}const Fi={positions:new Map};function Yi(){return()=>{}}function Bi(){return Fi}function Hi(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),i=n[0],o=n[n.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,l=o instanceof Date?o.getTime():o;if(2>e||s===l)return r?[new Date(s),new Date(l)]:[s,l];const a=(l-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?l:s+t*a;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function Xi(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function Gi(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Vi(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>n&&(n=i.pixel);return{min:e,max:n}}function qi(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Ui(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function Ki(n){const{width:i,height:o,totalWidth:s,totalHeight:l,margin:a,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:y,axisExtent:g}=n,p=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||f||Qi,r=Math.max(2,Math.floor(i/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,l=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hi(c.x,"exact"===g?Math.max(2,s):Math.min(s,r),g),a=l.map(t=>t.valueOf()),u=l.map((t,e)=>({value:t,pixel:c.x(t),label:o(t,e,a)})),h=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Zi(u,Math.max(55,h+8))},[c,d,f,i,g]),v=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||y||Qi,r=Math.max(2,Math.floor(o/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return Zi((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hi(c.y,"exact"===g?Math.max(2,s):Math.min(s,r),g)).map(t=>({value:t,pixel:c.y(t),label:i(t)})),22)},[c,d,y,o,g]),m=h&&c,b=u&&c;if(!m&&!b)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),k=null==d?void 0:d.find(t=>"left"===t.orient),w=b&&(!x||!1!==x.baseline),A=b&&(!k||!1!==k.baseline),_=(null==x?void 0:x.jaggedBase)||!1,S=(null==k?void 0:k.jaggedBase)||!1,M="var(--semiotic-border, #ccc)";return t("svg",{width:s,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${a.left},${a.top})`,children:[m&&(()=>{var n,r;const s=qi(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),l=qi(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[p.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"xgrid-"+n)),v.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l},"ygrid-"+n))]})})(),w&&!_&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:M,strokeWidth:1}),_&&t("path",{d:Ui("bottom",i,o),fill:"none",stroke:M,strokeWidth:1}),A&&!S&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:M,strokeWidth:1}),S&&t("path",{d:Ui("left",i,o),fill:"none",stroke:M,strokeWidth:1})]})})}function Qi(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Zi(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Ji(l){var a,u;const{width:d,height:h,totalWidth:f,totalHeight:y,margin:g,scales:p,showAxes:v,axes:m,xLabel:b,yLabel:x,yLabelRight:k,xFormat:w,yFormat:A,axisExtent:_,showGrid:S,title:M,legend:P,legendHoverBehavior:C,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:D,legendPosition:N="right",legendLayout:E,foregroundGraphics:L,marginalGraphics:$,xValues:I,yValues:W,annotations:z,autoPlaceAnnotations:R,svgAnnotationRules:j,xAccessor:F,yAccessor:H,annotationData:X,pointNodes:G,curve:V,underlayRendered:q,canvasObscuresUnderlay:U=!0,linkedCrosshairName:K,linkedCrosshairSourceId:Q,children:Z}=l,tt=r(()=>{var t,e;if(!v||!p)return[];const n=null==m?void 0:m.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||w||Qi,o=Math.max(2,Math.floor(d/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,s=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hi(p.x,"exact"===_?Math.max(2,r):Math.min(r,o),_),l=s.map(t=>t.valueOf()),a=s.map((t,e)=>({value:t,pixel:p.x(t),label:i(t,e,l)})),c=a.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),u=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(c+8,55)):Math.max(55,c+8);let h=Zi(a,u);if(h.length>1&&(h=h.filter((t,e)=>0===e||t.label+""!=h[e-1].label+"")),(null==n?void 0:n.includeMax)&&h.length>0&&"exact"!==_&&!(null==n?void 0:n.tickValues)){const t=p.x.domain()[1],e=p.x(t),n=h[h.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t,h.length,l);u>e-n&&h.length>1&&(h=h.slice(0,-1)),h.push({value:t,pixel:e,label:o})}}return h},[v,p,m,w,d,_]),et=r(()=>{var t,e;if(!v||!p)return[];const n=null==m?void 0:m.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||A||Qi,o=Math.max(2,Math.floor(h/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=Zi((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hi(p.y,"exact"===_?Math.max(2,r):Math.min(r,o),_)).map(t=>({value:t,pixel:p.y(t),label:i(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),(null==n?void 0:n.includeMax)&&s.length>0&&"exact"!==_&&!(null==n?void 0:n.tickValues)){const t=p.y.domain()[1],e=p.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:o})}}return s},[v,p,m,A,h,_]),nt=r(()=>{var t,e;if(!v||!p)return[];const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n)return[];const i=n.tickFormat||A||Qi,o=Math.max(2,Math.floor(h/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return Zi((null!==(e=n.tickValues)&&void 0!==e?e:Hi(p.y,"exact"===_?Math.max(2,r):Math.min(r,o),_)).map(t=>({value:t,pixel:p.y(t),label:i(t)})),22)},[v,p,m,A,h,_]),it=o(new Map),ot=o(null!==(a=null==z?void 0:z.length)&&void 0!==a?a:0),rt=null!==(u=null==z?void 0:z.length)&&void 0!==u?u:0;ot.current!==rt&&(ot.current=rt,it.current=new Map);const st=r(()=>{if(!z||0===z.length)return null;const n=function(n,o,r){var s,l,a,c,u,d,h,f,y,g,p,v,m,b,x,k,w,A,_,S,M,P,C,O,T,D,N,E,L,$,I,W,z,R,j,F,H,X,G,V,q,U,K,Q,Z,tt,et,nt,it,ot,rt;switch(n.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const e=si(n,o,r);if(!e)return null;const{x:i,y:c}=e;if(!li(i,c,r))return null;const u="callout"===n.type?"callout-circle":n.type,d="callout-circle"===u?{radius:null!==(s=n.radius)&&void 0!==s?s:12,radiusPadding:n.radiusPadding}:"callout-rect"===u?{width:n.width,height:n.height}:void 0;return t(ei,{noteData:Object.assign(Object.assign({x:i,y:c,dx:null!==(l=n.dx)&&void 0!==l?l:30,dy:null!==(a=n.dy)&&void 0!==a?a:-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:u},d?{subject:d}:{}),{connector:n.connector||{end:"arrow"},color:n.color,disable:n.disable,opacity:n.opacity,strokeDasharray:n.strokeDasharray,className:n.className})},"ann-"+o)}case"x-threshold":{const i=ni(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,r);if(null==i)return null;const s=n.color||"#f97316",l=n.labelPosition||"top";let a;a="bottom"===l?(r.height||0)-4:"center"===l?(r.height||0)/2:12;const c=i>.6*(r.width||0),u=c?i-4:i+4,d=c?"end":"start";return e("g",{opacity:n.opacity,children:[t("line",{x1:i,y1:0,x2:i,y2:r.height||0,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:u,y:a,textAnchor:d,fill:s,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+o)}case"y-threshold":{const i=ii(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,r);if(null==i)return null;const s=n.color||"#f97316",l=n.labelPosition||"right";let a,c;return"left"===l?(a=4,c="start"):"center"===l?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end"),e("g",{opacity:n.opacity,children:[t("line",{x1:0,y1:i,x2:r.width||0,y2:i,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:a,y:i-4,textAnchor:c,fill:s,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+o)}case"enclose":{const i=(n.coordinates||[]).map(t=>({x:ni(Object.assign(Object.assign({},t),{type:"point"}),r),y:ii(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const s=J(i),l=n.padding||10;return e("g",{children:[t("circle",{cx:s.x,cy:s.y,r:s.r+l,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:s.x,y:s.y-s.r-l-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"rect-enclose":{const i=(n.coordinates||[]).map(t=>({x:ni(Object.assign(Object.assign({},t),{type:"point"}),r),y:ii(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const s=n.padding||10,l=i.map(t=>t.x),a=i.map(t=>t.y),[c,u]=Gn(l),[d,h]=Gn(a),f=c-s,y=u+s,g=d-s;return e("g",{children:[t("rect",{x:f,y:g,width:y-f,height:h+s-g,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(f+y)/2,y:g-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"highlight":{const e=r.data||[],i="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],s={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:i.map((e,i)=>{const o=ni(e,r),l=ii(e,r);if(null==o||null==l)return null;const a="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||s;return t("circle",Object.assign({cx:o,cy:l,r:a},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const e=ni(n,r),i=ii(n,r);return t(ei,{noteData:{x:null!=e?e:0,y:null!=i?i:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+o)}case"trend":{const i=r.data||[];if(2>i.length)return null;const s=r.xAccessor||"x",l=r.yAccessor||"y",a="ordinal"===r.frameType,p="horizontal"===r.projection,v=a?s:null,m=a?l:null;let b;const x=[],k=new Map;if(a&&v&&m){for(const t of i){const e=t[v];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,x.length),x.push(n))}b=i.map(t=>{const e=t[v],n=t[m];if(null==e||null==n)return null;const i=k.get(e+"");return null!=i?[i,+n]:null}).filter(t=>null!==t)}else b=i.map(t=>[t[s],t[l]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>b.length)return null;const w=null!==(u=null===(c=r.scales)||void 0===c?void 0:c.x)&&void 0!==u?u:null===(d=r.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=r.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=r.scales)||void 0===y?void 0:y.value;if(!w||!A)return null;const _=t=>e=>{const n=Math.max(0,Math.floor(e)),i=Math.min(x.length-1,n+1),o=e-n,r=t(x[n]);return r+(t(x[i])-r)*o},S=w,M=A;let P;if(a)if(p){const t=_(M);P=(e,n)=>[S(n),t(e)]}else{const t=_(S);P=(e,n)=>[t(e),M(n)]}else P=(t,e)=>[S(t),M(e)];const C=n.method||"linear";let O;O="loess"===C?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],y+=e*o[t]*r[t])}if(0===u){l.push([e,r[t]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))l.push([e,h/u]);else{const t=(u*y-d*h)/g;l.push([e,(h-t*d)/u+t*e])}}return l}(b,null!==(g=n.bandwidth)&&void 0!==g?g:.3):("polynomial"===C?lt.polynomial(b,{order:n.order||2}):lt.linear(b)).points;const T=O.map(([t,e])=>{const[n,i]=P(t,e);return`${n},${i}`}).join(" "),D=n.color||"#6366f1",N=O[O.length-1],[E,L]=P(N[0],N[1]);return e("g",{children:[t("polyline",{points:T,fill:"none",stroke:D,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:E+4,y:L-4,fill:D,fontSize:11,children:n.label})]},"ann-"+o)}case"band":{const i=null!==(v=null===(p=r.scales)||void 0===p?void 0:p.y)&&void 0!==v?v:null===(m=r.scales)||void 0===m?void 0:m.value,s=null!==(b=null==i?void 0:i(n.y0))&&void 0!==b?b:0,l=null!==(x=null==i?void 0:i(n.y1))&&void 0!==x?x:r.height||0;return e("g",{opacity:n.opacity,children:[t("rect",{x:0,y:Math.min(s,l),width:r.width||0,height:Math.abs(l-s),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(r.width||0)-4,y:Math.max(Math.min(s,l),0)+13,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+o)}case"envelope":{const i=r.data||[];if(2>i.length)return null;const s=r.xAccessor||"x",l=null!==(w=null===(k=r.scales)||void 0===k?void 0:k.x)&&void 0!==w?w:null===(A=r.scales)||void 0===A?void 0:A.time,a=null!==(S=null===(_=r.scales)||void 0===_?void 0:_.y)&&void 0!==S?S:null===(M=r.scales)||void 0===M?void 0:M.value;if(!l||!a)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=i.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=gi[r.curve||"linear"]||B,y=Y().x(t=>l(t[s])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!y)return null;const g=n.fill||"#6366f1";return e("g",{children:[t("path",{d:y,fill:g,fillOpacity:null!==(P=n.fillOpacity)&&void 0!==P?P:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:l(h[h.length-1][s])+4,y:a(h[h.length-1][c])-4,fill:g,fontSize:11,children:n.label})]},"ann-"+o)}case"anomaly-band":{const i=r.data||[];if(2>i.length)return null;const s=r.yAccessor||"y",l=null!==(O=null===(C=r.scales)||void 0===C?void 0:C.x)&&void 0!==O?O:null===(T=r.scales)||void 0===T?void 0:T.time,a=null!==(N=null===(D=r.scales)||void 0===D?void 0:D.y)&&void 0!==N?N:null===(E=r.scales)||void 0===E?void 0:E.value;if(!l||!a)return null;const c=i.map(t=>t[s]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(L=n.threshold)&&void 0!==L?L:2,y=u-f*h,g=!1!==n.showBand,p=n.fill||"#6366f1",v=null!==($=n.fillOpacity)&&void 0!==$?$:.1,m=n.anomalyColor||"#ef4444",b=null!==(I=n.anomalyRadius)&&void 0!==I?I:6,x=a(u+f*h),k=a(y),w=i.filter(t=>{const e=t[s];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[g&&t("rect",{x:0,y:Math.min(x,k),width:r.width||0,height:Math.abs(k-x),fill:p,fillOpacity:v}),w.map((e,n)=>{const i=ni(e,r),o=ii(e,r);return null==i||null==o?null:t("circle",{cx:i,cy:o,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(r.width||0)-4,y:Math.min(x,k)-4,textAnchor:"end",fill:p,fontSize:11,children:n.label})]},"ann-"+o)}case"forecast":{const i=r.data||[];if(3>i.length)return null;const s=r.xAccessor||"x",l=r.yAccessor||"y",a=null!==(z=null===(W=r.scales)||void 0===W?void 0:W.x)&&void 0!==z?z:null===(R=r.scales)||void 0===R?void 0:R.time,c=null!==(F=null===(j=r.scales)||void 0===j?void 0:j.y)&&void 0!==F?F:null===(H=r.scales)||void 0===H?void 0:H.value;if(!a||!c)return null;const u=i.map(t=>[t[s],t[l]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=lt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,l=(n-s*e)/t;d=t=>l+s*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),y=Math.sqrt(f/Math.max(h-2,1)),g=u.reduce((t,e)=>t+e[0],0)/h,p=u.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),v=null!==(X=n.confidence)&&void 0!==X?X:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,b=null!==(G=n.steps)&&void 0!==G?G:5,x=u[h-1][0],k=(x-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;b>=t;t++)w.push(x+t*k);const A=[];for(const t of w){const e=d(t),n=y*Math.sqrt(1+1/h+(p>0?Math.pow(t-g,2)/p:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const _=`M${A.map(t=>`${a(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${c(t.yLower)}`).join(" L")} Z`,S=A.map(t=>`${a(t.x)},${c(t.yCenter)}`).join(" "),M=`${a(x)},${c(d(x))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:_,fill:n.fill||"#6366f1",fillOpacity:null!==(V=n.fillOpacity)&&void 0!==V?V:.15,stroke:"none"}),t("polyline",{points:`${M} ${S}`,fill:"none",stroke:P,strokeWidth:null!==(q=n.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(U=n.strokeDasharray)&&void 0!==U?U:"6,3"}),n.label&&A.length>0&&t("text",{x:a(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+o)}case"widget":{let e=null,i=null;if(null!=n.px&&null!=n.py)e=n.px,i=n.py;else{const t=si(n,o,r);if(!t)return null;e=t.x,i=t.y}if(null==e||null==i)return null;if(!li(e,i,r))return null;const s=null!==(K=n.dx)&&void 0!==K?K:0,l=null!==(Q=n.dy)&&void 0!==Q?Q:0,a=null!==(Z=n.width)&&void 0!==Z?Z:32,c=null!==(tt=n.height)&&void 0!==tt?tt:32,u=null!==(et=n.content)&&void 0!==et?et:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+s-a/2,y:i+l-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const s=si(n,o,r);if(!s)return null;const{x:l,y:a}=s,c=l+(n.dx||0),u=a+(n.dy||0),d=n.color||"var(--semiotic-text, #333)",h=t("text",{x:c,y:u,fill:d,fontSize:n.fontSize||11,opacity:n.opacity,strokeDasharray:n.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label});return!0!==n._redundantConnector?i.cloneElement(h,{key:"ann-text-"+o}):e("g",{opacity:n.opacity,strokeDasharray:n.strokeDasharray,children:[t("line",{x1:l,y1:a,x2:c,y2:u,stroke:d,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),i.cloneElement(h,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+o)}case"category-highlight":{const i=n.category;if(null==i)return null;const s=t=>"function"==typeof t&&"function"==typeof t.bandwidth,l=null===(nt=r.scales)||void 0===nt?void 0:nt.o,a=null===(it=r.scales)||void 0===it?void 0:it.x,c=null===(ot=r.scales)||void 0===ot?void 0:ot.y,u=s(l)?l:s(a)?a:s(c)?c:null;if(!u)return null;const d=u(i+"");if(null==d)return null;const h=u.bandwidth(),f=n.color||"var(--semiotic-primary, #4589ff)",y=null!==(rt=n.opacity)&&void 0!==rt?rt:.15,g=n.label;return e("g",(r.projection?"vertical"===r.projection:u===a)?{children:[t("rect",{x:d,y:0,width:h,height:r.height||0,fill:f,fillOpacity:y}),g&&t("text",{x:d+h/2,y:12,textAnchor:"middle",fill:f,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t("rect",{x:0,y:d,width:r.width||0,height:h,fill:f,fillOpacity:y}),g&&t("text",{x:12,y:d+h/2,dominantBaseline:"middle",fill:f,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+o)}default:return null}},o={scales:p?{x:p.x,y:p.y,time:p.x,value:p.y}:null,timeAxis:"x",xAccessor:F,yAccessor:H,width:d,height:h,data:X,frameType:"xy",pointNodes:G,curve:V,stickyPositionCache:it.current};return function(t,e,n,i){const o=[];return t.forEach((t,r)=>{let s;if(n){const o=n(t,r,i);s=null!=o?o:e(t,r,i)}else s=e(t,r,i);s&&o.push({node:s,annotation:t})}),yi(o)}(R?Ei(Object.assign({annotations:z,context:o},"object"==typeof R?R:{})):z,n,j,o)},[z,R,j,d,h,F,H,X,p,G,V]),at=function(t){var e;const n=c(t?ji:Yi,t?Ri:Bi,t?Ri:Bi);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(K);return s(()=>{if(!(null==at?void 0:at.locked)||!K)return;const t=t=>{"Escape"===t.key&&zi(K)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==at?void 0:at.locked,K]),v||M||P||L||$||st&&st.length>0||S||Z||at?e("svg",{role:"img",width:f,height:y,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof M?M:"XY Chart"}),t("desc",{children:"string"==typeof M?M+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[S&&p&&(!q||U)&&(()=>{var n,i;const o=qi(null===(n=null==m?void 0:m.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=qi(null===(i=null==m?void 0:m.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[tt.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:h,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),et.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:d,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&p&&(()=>{const n=null==m?void 0:m.find(t=>"left"===t.orient),i=null==m?void 0:m.find(t=>"bottom"===t.orient),o=!n||!1!==n.baseline,r=!i||!1!==i.baseline,s=(null==n?void 0:n.jaggedBase)||!1,l=(null==i?void 0:i.jaggedBase)||!1,a=null==i?void 0:i.landmarkTicks,c=null==n?void 0:n.landmarkTicks,u="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",p=!!(null==i?void 0:i.autoRotate)&&tt.length>1&&(()=>{const t=d/Math.max(tt.length-1,1),e=tt.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})(),v={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=null==i?void 0:i.tickAnchor,S=null==n?void 0:n.tickAnchor,M=Vi(tt),P=Vi(et);return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!q||U)&&r&&!l&&t("line",{x1:0,y1:h,x2:d,y2:h,stroke:u,strokeWidth:1}),(!q||U)&&l&&t("path",{d:Ui("bottom",d,h),fill:"none",stroke:u,strokeWidth:1}),tt.map((n,i)=>{const o=!!a&&("function"==typeof a?a(n.value,i):qe(n.value,i>0?tt[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${h})`,children:[t("line",{y2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:p?10:18,textAnchor:p?"end":Xi(_,n.pixel===M.min,n.pixel===M.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:v),transform:p?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"center",userSelect:"none"},v),children:n.label})})]},"xtick-"+i)}),b&&t("text",{x:d/2,y:h+40,textAnchor:"middle",fill:y,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:b})]}),e("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!q||U)&&o&&!s&&t("line",{x1:0,y1:0,x2:0,y2:h,stroke:u,strokeWidth:1}),(!q||U)&&s&&t("path",{d:Ui("left",d,h),fill:"none",stroke:u,strokeWidth:1}),et.map((n,i)=>{const o=!!c&&("function"==typeof c?c(n.value,i):qe(n.value,i>0?et[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:Gi(S,n.pixel===P.min,n.pixel===P.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:v),children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"right",userSelect:"none"},v),children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==n?void 0:n.label)||x;return e?t("text",{x:15-g.left,y:h/2,textAnchor:"middle",fill:y,transform:`rotate(-90, ${15-g.left}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:e}):null})()]}),(()=>{const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n||0===nt.length)return null;const i=!1!==n.baseline,o=n.landmarkTicks,r=n.label||k,s=n.tickAnchor,l=Vi(nt);return e("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&t("line",{x1:d,y1:0,x2:d,y2:h,stroke:u,strokeWidth:1}),nt.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):qe(n.value,i>0?nt[i-1].value:void 0));return e("g",{transform:`translate(${d},${n.pixel})`,children:[t("line",{x2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:Gi(s,n.pixel===l.min,n.pixel===l.max),fontWeight:r?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},r?w:v),children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"left",userSelect:"none"},v),children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:d+g.right-15,y:h/2,textAnchor:"middle",fill:y,transform:`rotate(90, ${d+g.right-15}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:r})]})})()]})})(),st,$&&p&&I&&W&&e(n,{children:[$.top&&t("g",{transform:"translate(0, 0)",children:t(qn,{orient:"top",config:Vn($.top),values:I,scale:p.x,size:g.top,length:d})}),$.bottom&&t("g",{transform:`translate(0, ${h})`,children:t(qn,{orient:"bottom",config:Vn($.bottom),values:I,scale:p.x,size:g.bottom,length:d})}),$.left&&t("g",{transform:"translate(0, 0)",children:t(qn,{orient:"left",config:Vn($.left),values:W,scale:p.y,size:g.left,length:h})}),$.right&&t("g",{transform:`translate(${d}, 0)`,children:t(qn,{orient:"right",config:Vn($.right),values:W,scale:p.y,size:g.right,length:h})})]}),L,at&&at.sourceId!==Q&&(null==p?void 0:p.x)&&(()=>{const e=p.x(at.xValue);if(null==e||0>e||e>d)return null;const n=at.locked;return t("line",{x1:e,y1:0,x2:e,y2:h,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),Z]}),M&&t("text",{x:f/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof M?M:null}),Xn({legend:P,totalWidth:f,totalHeight:y,margin:g,legendPosition:N,title:M,legendLayout:E,legendHoverBehavior:C,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:D})]}):null}function to(t){var e,n,i,o;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(i=t.br)&&void 0!==i?i:0)>0||(null!==(o=t.bl)&&void 0!==o?o:0)>0}const eo={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function no(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const io="undefined"==typeof window||"undefined"==typeof document,oo="undefined"!=typeof window?h:s;function ro(){const[t,e]=d(!1);return oo(()=>{e(!0)},[]),t}const so=()=>()=>{},lo=()=>!1,ao=()=>!0;function co(){const t=c(so,lo,ao);return o(t).current}function uo(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:l,cleanup:a}=t;oo(()=>{var t,o;e&&n&&(null===(o=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===o||o.call(t)),r.current=!0,l.current()},[e,n]);const c=o(a);c.current=a,s(()=>()=>{var t;return null===(t=c.current)||void 0===t?void 0:t.call(c)},[])}function ho(t){const e=o(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return yo(t,e);if(!go(t)||!go(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!yo(n,o))return!1}else{if(!go(n)||!go(o))return!1;if(!fo(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function fo(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function yo(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function go(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const po=i.createContext(null);function vo(){return i.useContext(po)}const mo={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function bo(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===(null==e?void 0:e.datum))continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const i=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function xo(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const ko=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function wo(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,i]of Object.entries(t))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(e[n]=i):"string"==typeof i?e[n]=i:"boolean"==typeof i?e[n]=i+"":i instanceof Date&&(e[n]=i.toISOString().slice(0,10)));return e}const Ao="semiotic-accessible-data-table",_o=Ao+" semiotic-accessible-data-table-hidden",So=Ao+" semiotic-accessible-data-table-visible",Mo=So+" semiotic-accessible-data-table-network",Po={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Co={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Oo={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},To={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Do={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},No={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Eo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Lo={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function $o({scene:n,chartType:o,tableId:r,chartTitle:s}){var l;const[a,c]=i.useState(!1),[u,d]=i.useState(5),h=vo(),f=null!==(l=null==h?void 0:h.visible)&&void 0!==l&&l,y=a||f,g=i.useRef(null),p=s?"Data summary for "+s:r?`Data summary for ${o} ${r}`:"Data summary for "+o;i.useEffect(()=>{y||d(5)},[y]);const v=i.useCallback(t=>{t.target===t.currentTarget&&(a||f||c(!0))},[a,f]),m=i.useCallback(t=>{var e;f||(null===(e=g.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[f]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:mo}):null;if(!y)return t("div",{id:r,className:_o,tabIndex:-1,onFocus:v,style:mo,role:"region","aria-label":p,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const b=function(t){var e,n,i,o,r,s,l,a,c,u,d,h,f,y,g,p,v;const m=[];if(!Array.isArray(t))return m;const b=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const x of t)if(x&&"object"==typeof x&&null!==x.datum)try{switch(x.type){case"point":if(b)break;m.push({label:"Point",values:wo(x.datum)});break;case"line":case"area":{const t=Array.isArray(x.datum)?x.datum:[],e="line"===x.type?"Line point":"Area point";for(const n of t)m.push({label:e,values:wo(n)});break}case"rect":{const t=null!=x.datum&&"object"==typeof x.datum?x.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:x.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;m.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const t=wo(x.datum);null==t.value&&"number"==typeof x.value&&Number.isFinite(x.value)&&(t.value=x.value),m.push({label:"Cell",values:t});break}case"wedge":m.push({label:"Wedge",values:{category:null!==(a=null!==(s=null===(r=x.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(l=x.datum)||void 0===l?void 0:l.label)&&void 0!==a?a:"",value:null!==(u=null===(c=x.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":m.push({label:"Node",values:wo(x.datum)});break;case"arc":m.push({label:"Arc",values:wo(x.datum)});break;case"candlestick":m.push({label:"Candlestick",values:wo(x.datum)});break;case"geoarea":m.push({label:"Region",values:{name:null!==(g=null!==(f=null===(h=null===(d=x.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(y=x.datum)||void 0===y?void 0:y.name)&&void 0!==g?g:"",value:null!==(v=null===(p=x.datum)||void 0===p?void 0:p.value)&&void 0!==v?v:""}})}}catch(t){}return m}(n),x=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(b),k=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ko(t.min)} to ${ko(t.max)}, mean ${ko(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(b.length,x),w=Math.min(u,b.length),A=b.slice(0,w),_=b.length-w,S=new Set;for(const t of A)for(const e of Object.keys(t.values))S.add(e);const M=Array.from(S);return e("div",{ref:g,id:r,className:So,tabIndex:-1,onBlur:m,style:Po,role:"region","aria-label":p,children:[t("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{f&&h&&h.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:Oo,children:"×"}),t("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Co,children:k}),e("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+o,style:To,children:[t("caption",{className:"semiotic-accessible-data-table-caption",style:Eo,children:_>0?`First ${w} of ${b.length} data points`:`All ${b.length} data points`}),t("thead",{children:e("tr",{children:[t("th",{style:Do,children:"type"}),M.map(e=>t("th",{style:Do,children:e},e))]})}),t("tbody",{children:A.map((n,i)=>e("tr",{children:[t("td",{style:No,children:n.label}),M.map(e=>{return t("td",{style:No,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":ko(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]}),_>0&&e("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>d(t=>t+25),style:Lo,children:["Show ",Math.min(25,_)," more"," ",1===_?"row":"rows"," (",_," remaining)"]})]})}function Io({nodes:n,edges:o,chartType:r,tableId:s,chartTitle:l}){var a,c,u,d,h,f,y,g,p,v,m,b,x,k;const[w,A]=i.useState(!1),[_,S]=i.useState(5),M=vo(),P=null!==(a=null==M?void 0:M.visible)&&void 0!==a&&a,C=w||P,O=l?"Data summary for "+l:s?`Data summary for ${r} ${s}`:"Data summary for "+r,T=i.useRef(null);i.useEffect(()=>{C||S(5)},[C]);const D=i.useCallback(t=>{t.target===t.currentTarget&&(w||P||A(!0))},[w,P]),N=i.useCallback(t=>{var e;P||(null===(e=T.current)||void 0===e?void 0:e.contains(t.relatedTarget))||A(!1)},[P]);if(!n||0===n.length)return s?t("span",{id:s,tabIndex:-1,style:mo}):null;if(!C)return t("div",{id:s,className:_o,tabIndex:-1,onFocus:D,style:mo,role:"region","aria-label":O,children:e("button",{type:"button",onClick:()=>A(!0),children:["View data summary (",n.length," nodes, ",o.length," edges)"]})});const E=Array.isArray(n)?n:[],L=Array.isArray(o)?o:[],$=new Map,I=new Map,W=new Map,z=new Map;for(const t of L){if(!t||"object"!=typeof t)continue;const e=null!==(c=t.datum)&&void 0!==c?c:t,n="object"==typeof e.source?null===(u=e.source)||void 0===u?void 0:u.id:e.source,i="object"==typeof e.target?null===(d=e.target)||void 0===d?void 0:d.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";I.set(t,(null!==(h=I.get(t))&&void 0!==h?h:0)+1),z.set(t,(null!==(f=z.get(t))&&void 0!==f?f:0)+o)}if(null!=i&&""!==i){const t=i+"";$.set(t,(null!==(y=$.get(t))&&void 0!==y?y:0)+1),W.set(t,(null!==(g=W.get(t))&&void 0!==g?g:0)+o)}}const R=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(v=null===(p=e.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:e.id,i=null!=n?n+"":"node-"+t,o=null!==(m=$.get(i))&&void 0!==m?m:0,r=null!==(b=I.get(i))&&void 0!==b?b:0,s=null!==(x=W.get(i))&&void 0!==x?x:0,l=null!==(k=z.get(i))&&void 0!==k?k:0;R.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:s+l,wInDeg:s,wOutDeg:l})}R.sort((t,e)=>e.degree-t.degree);let j=0,F=0;if(R.length>0){let t=0;for(const e of R)t+=e.degree,e.degree>F&&(F=e.degree);j=t/R.length}const Y=L.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),B=[`${R.length} nodes, ${L.length} edges.`];R.length>0&&B.push(`Mean degree: ${ko(j)}, max degree: ${F}.`);const H=Math.min(_,R.length),X=R.slice(0,H),G=R.length-H;return e("div",{ref:T,id:s,className:Mo,tabIndex:-1,onBlur:N,style:Po,role:"region","aria-label":O,children:[t("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{P&&M&&M.setVisible(!1),A(!1)},"aria-label":"Close data summary",style:Oo,children:"×"}),t("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Co,children:B.join(" ")}),e("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+r,style:To,children:[t("caption",{className:"semiotic-accessible-data-table-caption",style:Eo,children:G>0?`Top ${H} of ${R.length} nodes by degree`:`All ${R.length} nodes by degree`}),t("thead",{children:e("tr",{children:[t("th",{style:Do,children:"id"}),t("th",{style:Do,children:"degree"}),t("th",{style:Do,children:"in"}),t("th",{style:Do,children:"out"}),Y&&t("th",{style:Do,children:"w. degree"}),Y&&t("th",{style:Do,children:"w. in"}),Y&&t("th",{style:Do,children:"w. out"})]})}),t("tbody",{children:X.map((n,i)=>e("tr",{children:[t("td",{style:No,children:n.id}),t("td",{style:No,children:n.degree}),t("td",{style:No,children:n.inDeg}),t("td",{style:No,children:n.outDeg}),Y&&t("td",{style:No,children:ko(n.wDegree)}),Y&&t("td",{style:No,children:ko(n.wInDeg)}),Y&&t("td",{style:No,children:ko(n.wOutDeg)})]},i))})]}),G>0&&e("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>S(t=>t+25),style:Lo,children:["Show ",Math.min(25,G)," more"," ",1===G?"node":"nodes"," (",G," remaining)"]})]})}function Wo({summary:e}){return e?t("div",{role:"note",style:mo,children:e}):null}function zo({tableId:e}){return t("a",{href:"#"+e,style:mo,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,mo)},children:"Skip to data table"})}function Ro({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:mo,children:n})}const jo="var(--semiotic-focus, #005fcc)";function Fo({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:l}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=l){const e=Math.max(s,4),n=Math.max(l,4);u=t("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:jo,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:jo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:jo,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Yo(t){return Array.isArray(t)?t[0]:t}function Bo(t,e,n,i){return Object.assign({data:Yo(t),x:e,y:n,__semioticHoverData:!0},i)}const Ho=["name","label","title"],Xo=["type","kind","category","group","class","status","role","shape"],Go=["value","amount","total","count","weight","score"],Vo=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function qo(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}const Uo={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Ko({x:e,y:n,containerWidth:o,containerHeight:r,margin:s,children:l,className:a="stream-frame-tooltip",zIndex:c=1}){const u=Number.isFinite(e)&&Number.isFinite(n),d=i.useRef(null),[h,f]=i.useState(null);i.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=t.getBoundingClientRect();f(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[l,a,o,r]);let y;y=h?`translate(${h.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const g=function(t){if(!i.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(l),p=g?null:Uo;return u?t("div",{ref:d,className:g?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:s.left+e,top:s.top+n,transform:y,pointerEvents:"none",zIndex:c,width:"max-content"}),children:l}):null}const Qo="undefined"==typeof window?s:h;function Zo(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Jo(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return s(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[l,c]=function(t,e,n){const i=o(null),[r,l]=d(null);return s(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;l(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),u=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=c[0]-u.left-u.right,f=c[1]-u.top-u.bottom,y=Zo(t.foregroundGraphics,c,u),g=Zo(t.backgroundGraphics,c,u),p=Et(t=>t.theme),{transition:v,introEnabled:m}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),b="semiotic-table-"+i.useId(),x=o(0),k=o(()=>{}),w=a(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);s(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const A=o(()=>{}),_=o(()=>{}),S=o(null),M=o(0),P=a(()=>{M.current=0;const t=S.current;S.current=null,t&&A.current(t)},[]),C=a(t=>{S.current={clientX:t.clientX,clientY:t.clientY},0===M.current&&(M.current=requestAnimationFrame(P))},[P]),O=a(()=>{S.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0),_.current()},[]);s(()=>()=>{S.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0)},[]);const T=t.themeDirtyRef;return Qo(()=>{T&&(Je++,T.current=!0,w())},[p,w,T]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:l,size:c,margin:u,adjustedWidth:h,adjustedHeight:f,resolvedForeground:y,resolvedBackground:g,currentTheme:p,transition:v,introEnabled:m,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:_,onPointerMove:C,onPointerLeave:O}}function tr(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,l=e[0]+"px",a=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function er(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function nr(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function ir(t,e,n,i,o,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const l=s[s.length-1];if(0===l)return;const a=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;a>i&&(r*=i/a),a>l-i&&(r*=(l-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const or=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"line"===t.type);for(const l of s){if(2>l.path.length)continue;const a=l._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=l.style.stroke||"#007bff",u=rn(t,c)||c,d=l.style.strokeWidth||2,h=l.colorThresholds,f=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=d,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const v=null!==(o=l.style.opacity)&&void 0!==o?o:1;ir(t,l.path,u,d,v,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=sn(l.curve),g=h&&h.length>0&&f&&f.length===l.path.length,p=l._decayOpacities;if(p&&p.length===l.path.length&&!g){t.strokeStyle=u;const m=null!==(r=l.style.opacity)&&void 0!==r?r:1;for(let b=0;l.path.length-1>b;b++)t.globalAlpha=.5*(p[b]+p[b+1])*m,t.beginPath(),t.moveTo(l.path[b][0],l.path[b][1]),t.lineTo(l.path[b+1][0],l.path[b+1][1]),t.stroke()}else if(g){let x=null,k=null,w=null,A=null,_=!1;function S(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),_=!0}function M(){_&&(t.stroke(),_=!1)}for(let P=0;l.path.length>P;P++){const[C,O]=l.path[P],T=f[P],D=nr(T,h,u);if(null!==x&&null!==A&&null!==w){if(D===A)t.lineTo(C,O);else{const N=[];for(const E of h){const L=E.value;(w>L||L>T)&&(L>w||T>L)||w===L||T===L||N.push({t:(L-w)/(T-w)})}N.sort((t,e)=>t.t-e.t);for(const $ of N){const I=x+(C-x)*$.t,W=k+(O-k)*$.t,z=nr(w+(T-w)*Math.min($.t+1e-4,1),h,u);t.lineTo(I,W),M(),S(z,I,W)}t.lineTo(C,O)}x=C,k=O,w=T,A=D}else S(D,C,O),x=C,k=O,w=T,A=D}M()}else{t.beginPath();const R=l.strokeGradient&&l.path.length>=2?cn(t,l.strokeGradient,l.path[0][0],0,l.path[l.path.length-1][0],0):null;if(t.strokeStyle=R||u,y)F().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[j,Y]=l.path[0];t.moveTo(j,Y);for(let B=1;l.path.length>B;B++)t.lineTo(l.path[B][0],l.path[B][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=ln(t,l.style.fill,l.style.fill),y&&!g)F().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[X,G]=l.path[0];t.moveTo(X,G);for(let V=1;l.path.length>V;V++)t.lineTo(l.path[V][0],l.path[V][1])}const H=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function rr(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function sr(t,e,n=.3){rr(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function lr(t,e,n=.6){var i,o,r,s,l;if(!rr(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(l=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function ar(t,e,n,i=.35){rr(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function cr(t,e){const n=sn(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const i=Y().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const ur=(t,e,n,i)=>{var o,r,s;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const l=e._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,i.width*l,i.height),t.clip());const a=ln(t,e.style.fill,"#4e79a7"),c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=a;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(c[i]+c[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(c[n]+c[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(cr(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=an(t,e.fillGradient,"string"==typeof a?a:"#4e79a7",0,n,0,i);t.fillStyle=o||a,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=a}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(cr(t,e),ar(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?cn(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=sn(e.curve);if(t.beginPath(),i)F().x(t=>t[0]).y(t=>t[1]).curve(i).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==l&&1>l&&t.restore(),n&&t.restore(),t.globalAlpha=1}},dr=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"point"===t.type);if(0!==s.length){t.save();try{const e=t.globalAlpha;for(const n of s){t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI);const i=null!==(r=null!==(o=n.style.opacity)&&void 0!==o?o:n.style.fillOpacity)&&void 0!==r?r:1;t.globalAlpha=e*i,t.fillStyle=ln(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=ln(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),lr(t,n)}}finally{t.restore()}}},hr=new Map;function fr(t){var e;try{if(t.path)return new Path2D(t.path);const n=`${null!==(e=t.symbolType)&&void 0!==e?e:"circle"}:${Math.round(t.size)}`;let i=hr.get(n);return i||(i=new Path2D(De(t.symbolType,t.size)),hr.size>256&&hr.clear(),hr.set(n,i)),i}catch(t){return null}}const yr=(t,e)=>{var n,i,o,r;const s=t.globalAlpha;for(const l of e){if("symbol"!==l.type)continue;const e=l;if(0>=e.size)continue;const a=fr(e);if(!a)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const c=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*(null!==(i=e._decayOpacity)&&void 0!==i?i:1);e.style.fill&&(t.globalAlpha=s*c*(null!==(o=e.style.fillOpacity)&&void 0!==o?o:1),t.fillStyle=ln(t,e.style.fill,"#4e79a7"),t.fill(a)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=s*c,t.strokeStyle=ln(t,e.style.stroke,e.style.stroke),t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.stroke(a)),t.restore()}t.globalAlpha=s};function gr(t,e){const{x:n,y:i,w:o,h:r}=e,{tl:s,tr:l,br:a,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,i=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}(e);t.beginPath(),t.moveTo(n+s,i),t.lineTo(n+o-l,i),l>0&&t.arcTo(n+o,i,n+o,i+l,l),t.lineTo(n+o,i+r-a),a>0&&t.arcTo(n+o,i+r,n+o-a,i+r,a),t.lineTo(n+c,i+r),c>0&&t.arcTo(n,i+r,n,i+r-c,c),t.lineTo(n,i+s),s>0&&t.arcTo(n,i,n+s,i,s),t.closePath()}function pr(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const vr=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)mr(t,e);else if(e.cornerRadii&&to(e.cornerRadii)){const n=ln(t,e.style.fill,rn(t,"var(--semiotic-primary, #007bff)")),i=pr(e),o=e.fillGradient&&"string"==typeof n?an(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,gr(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=ln(t,e.style.fill,rn(t,"var(--semiotic-primary, #007bff)")),i=pr(e),o=e.fillGradient&&"string"==typeof n?an(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:l,w:a,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,l),t.lineTo(s+a-r,l),t.arcTo(s+a,l,s+a,l+r,r),t.lineTo(s+a,l+c-r),t.arcTo(s+a,l+c,s+a-r,l+c,r),t.lineTo(s,l+c);break;case"left":t.moveTo(s+a,l),t.lineTo(s+r,l),t.arcTo(s,l,s,l+r,r),t.lineTo(s,l+c-r),t.arcTo(s,l+c,s+r,l+c,r),t.lineTo(s+a,l+c);break;case"bottom":t.moveTo(s,l),t.lineTo(s+a,l),t.lineTo(s+a,l+c-r),t.arcTo(s+a,l+c,s+a-r,l+c,r),t.lineTo(s+r,l+c),t.arcTo(s,l+c,s,l+c-r,r);break;default:t.moveTo(s,l+c),t.lineTo(s,l+r),t.arcTo(s,l,s+r,l,r),t.lineTo(s+a-r,l),t.arcTo(s+a,l,s+a,l+r,r),t.lineTo(s+a,l+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=ln(t,e.style.fill,rn(t,"var(--semiotic-primary, #007bff)")),i=pr(e),o=e.fillGradient&&"string"==typeof n?an(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}sr(t,e),t.globalAlpha=1}};function mr(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function br(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function xr(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const kr=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=rn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),sr(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):xr(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=br(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},wr=(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const l=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==l&&(t.globalAlpha=l);const a=rn(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=rn(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}};function Ar(t,e,n,i){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:{key:void 0,fn:null}}const _r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Sr(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${_r[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${_r[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Mr={line:[ur,or,dr],area:[ur,dr],stackedarea:[ur,dr],scatter:[dr,yr],bubble:[dr,yr],heatmap:[kr],bar:[vr],swarm:[dr],waterfall:[(t,e,n,i)=>{var o;vr(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,l=null==s?void 0:s._connectorStroke;if(l){t.save(),t.strokeStyle=rn(t,l)||l,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],s=i.datum,l=o.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==l?void 0:l.baseline))continue;const a=n.y(s.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[wr],mixed:[ur,or,dr],custom:[ur,vr,kr,or,dr,yr,wr]},Pr={top:20,right:20,bottom:30,left:40},Cr={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function Or(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Tr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Dr({hover:n}){var i,o,r;const s=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",l=null!==(i=n.data)&&void 0!==i?i:{},a=null!==(o=l.y)&&void 0!==o?o:l.value,c=null!==(r=l.x)&&void 0!==r?r:l.time;return e("div",{className:"semiotic-tooltip",style:Tr,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:s(a)}),t("div",{style:{opacity:.7,fontSize:11},children:s(c)})]})}Dr.ownsChrome=!0;const Nr=f(function(n,l){var c,u,h,f,p,v,m,b,x,k,w,A,_;const{chartType:S,runtimeMode:M,data:P,chunkThreshold:C,chunkSize:O,xAccessor:T,yAccessor:D,colorAccessor:N,sizeAccessor:E,symbolAccessor:L,symbolMap:$,groupAccessor:I,lineDataAccessor:W,curve:z,normalize:R,baseline:j,stackOrder:F,binSize:Y,valueAccessor:B,arrowOfTime:H="right",windowMode:X="sliding",windowSize:G=200,timeAccessor:V,xExtent:q,yExtent:U,extentPadding:K=.1,scalePadding:Q,sizeRange:Z,size:J=[500,300],responsiveWidth:tt,responsiveHeight:et,margin:nt,className:it,background:ot,lineStyle:rt,pointStyle:st,areaStyle:lt,barStyle:at,waterfallStyle:ct,swarmStyle:ut,barColors:dt,colorScheme:ht,boundsAccessor:ft,boundsStyle:yt,y0Accessor:gt,band:pt,gradientFill:vt,lineGradient:mt,areaGroups:xt,openAccessor:At,highAccessor:_t,lowAccessor:Mt,closeAccessor:Pt,candlestickStyle:Ct,showAxes:Ot=!0,axes:Tt,xLabel:Dt,yLabel:Nt,yLabelRight:Et,xFormat:Lt,yFormat:$t,axisExtent:It,tickFormatTime:Wt,tickFormatValue:zt,hoverAnnotation:Rt,tooltipContent:jt,customHoverBehavior:Ft,customClickBehavior:Yt,enableHover:Bt,hoverRadius:Ht=30,tooltipMode:Xt,annotations:Gt,autoPlaceAnnotations:Vt,svgAnnotationRules:qt,showGrid:Ut,legend:Kt,legendHoverBehavior:Qt,legendClickBehavior:Zt,legendHighlightedCategory:Jt,legendIsolatedCategories:te,legendPosition:ee,legendLayout:ne,legendCategoryAccessor:ie,onCategoriesChange:oe,backgroundGraphics:re,foregroundGraphics:se,canvasPreRenderers:le,svgPreRenderers:ae,title:ce,categoryAccessor:ue,brush:de,onBrush:he,decay:fe,pulse:ye,transition:ge,animate:pe,staleness:ve,heatmapAggregation:me,heatmapXBins:be,heatmapYBins:xe,showValues:ke,heatmapValueFormat:we,marginalGraphics:Ae,pointIdAccessor:_e,xScaleType:Me,yScaleType:Pe,accessibleTable:Ce=!0,description:Oe,summary:Te,linkedCrosshairName:Ne,linkedCrosshairSourceId:Ee,customLayout:Le,layoutConfig:$e,layoutSelection:Ie}=n,We=y().replace(/:/g,""),ze=o(!1),Re=o({w:-1,h:-1}),Ye=Jo({sizeProp:J,responsiveWidth:tt,responsiveHeight:et,userMargin:nt,marginDefault:Pr,animate:pe,transitionProp:ge,themeDirtyRef:ze}),Be=ro(),Xe=co(),{reducedMotionRef:Ge,responsiveRef:Ve,size:qe,currentTheme:Ue,transition:Ke,introEnabled:Qe,tableId:Ze,rafRef:Je,renderFnRef:tn,scheduleRender:en}=Ye;let nn=Ye.margin;if(Ae){const t=60,e=Object.assign({},Ye.margin);Ae.top&&t>e.top&&(e.top=t),Ae.bottom&&t>e.bottom&&(e.bottom=t),Ae.left&&t>e.left&&(e.left=t),Ae.right&&t>e.right&&(e.right=t),nn=e}const on="function"==typeof se?se({size:qe,margin:nn}):se,sn="function"==typeof re?re({size:qe,margin:nn}):re,ln=qe[0]-nn.left-nn.right,an=qe[1]-nn.top-nn.bottom,cn=r(()=>kt(P),[P]),un=null!=Rt?Rt:Bt,yn=o(null),gn=o(null),[pn,vn]=d(0),mn=o(0),[bn,xn]=d(null),kn=o(null),Mn=o(null),[Pn,On]=d(null),Tn=o(Cr.primary),Dn=o([]),Nn=o(ie),In=o(oe);Nn.current=ie,In.current=oe;const[Wn,zn]=d(!1),[Rn,jn]=d([]),[Fn,Yn]=d([]),Bn="streaming"===M||["bar","swarm","waterfall"].includes(S),Hn=r(()=>{var t,e,n;return{chartType:S,runtimeMode:Bn?"streaming":"bounded",windowSize:G,windowMode:X,arrowOfTime:Bn?H:"right",extentPadding:K,scalePadding:Q,axisExtent:It,xAccessor:T,yAccessor:D,timeAccessor:Bn?V:void 0,valueAccessor:B,colorAccessor:N,sizeAccessor:E,symbolAccessor:L,symbolMap:$,groupAccessor:I||(W?"_lineGroup":void 0),categoryAccessor:ue,lineDataAccessor:W,xScaleType:Me,yScaleType:Pe,xExtent:q,yExtent:U,sizeRange:Z,binSize:Y,normalize:R,baseline:j,stackOrder:F,boundsAccessor:ft,boundsStyle:yt,y0Accessor:gt,band:pt,gradientFill:!0===vt?{topOpacity:.8,bottomOpacity:.05}:!1===vt?void 0:vt,areaGroups:xt?new Set(xt):void 0,lineGradient:mt,openAccessor:At,highAccessor:_t,lowAccessor:Mt,closeAccessor:Pt,candlestickStyle:Ct,lineStyle:rt,pointStyle:st,areaStyle:lt,swarmStyle:ut,waterfallStyle:ct,colorScheme:ht,barColors:dt,barStyle:at,annotations:Gt,decay:fe,pulse:ye,transition:Ke,introAnimation:Qe,staleness:ve,heatmapAggregation:me,heatmapXBins:be,heatmapYBins:xe,showValues:ke,heatmapValueFormat:we,pointIdAccessor:_e,curve:z,themeCategorical:null===(t=null==Ue?void 0:Ue.colors)||void 0===t?void 0:t.categorical,themeSemantic:St(Ue),themeSequential:null===(e=null==Ue?void 0:Ue.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Ue?void 0:Ue.colors)||void 0===n?void 0:n.diverging,customLayout:Le,layoutConfig:$e,layoutMargin:nn}},[S,G,X,H,K,Q,It,T,D,V,B,Me,Pe,N,E,L,$,I,ue,W,q,U,Z,Y,R,j,F,ft,yt,gt,pt,vt,mt,xt,At,_t,Mt,Pt,Ct,rt,st,lt,ut,ct,at,ht,dt,Gt,fe,ye,null==Ke?void 0:Ke.duration,null==Ke?void 0:Ke.easing,Qe,ve,me,be,xe,ke,we,Bn,_e,z,Ue,Le,$e,nn]),Xn=ho(Hn),Gn=o(null);Gn.current||(Gn.current=new je(Xn));const Vn=a(()=>{var t,e;const n=Nn.current,i=In.current;if(!i||!n)return;const o=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(null!==(e=null===(t=Gn.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(o,Dn.current)||(Dn.current=o,i(o))},[]);s(()=>{var t;null===(t=Gn.current)||void 0===t||t.updateConfig(Xn),ze.current=!0,en()},[Xn,en]);const qn=o(null);s(()=>{const t=Gn.current;if(!t)return;const e=null!=Ie?Ie:null;qn.current!==e&&(qn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):ze.current=!0,en())},[Ie,en]);const Un=o(null);Un.current||(Un.current=new wt(t=>{const e=Gn.current;e&&e.ingest(t)&&(ze.current=!0,en())},{chunkThreshold:C,chunkSize:O})),s(()=>{var t;null===(t=Un.current)||void 0===t||t.updateChunkOptions({chunkThreshold:C,chunkSize:O})},[C,O]);const Kn=a(t=>{var e;null===(e=Un.current)||void 0===e||e.push(t)},[]),Qn=a(t=>{var e;null===(e=Un.current)||void 0===e||e.pushMany(t)},[]),Zn=a(()=>{var t,e;null===(t=Un.current)||void 0===t||t.clear(),null===(e=Gn.current)||void 0===e||e.clear(),ze.current=!0,en()},[en]);g(l,()=>({push:Kn,pushMany:Qn,remove:t=>{var e,n,i;null===(e=Un.current)||void 0===e||e.flush();const o=null!==(i=null===(n=Gn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(kn.current&&o.some(t=>{var e;return t===(null===(e=kn.current)||void 0===e?void 0:e.data)})&&(kn.current=null,On(null)),ze.current=!0,en()),o},update:(t,e)=>{var n,i,o;null===(n=Un.current)||void 0===n||n.flush();const r=null!==(o=null===(i=Gn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(ze.current=!0,en()),r},clear:Zn,getData:()=>{var t,e,n;return null===(t=Un.current)||void 0===t||t.flush(),null!==(n=null===(e=Gn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Gn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Gn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Kn,Qn,Zn,en]),s(()=>{var t,e;if(P){if(W&&cn.length>0&&"object"==typeof cn[0]&&null!==cn[0]){const e="string"==typeof W?W:"coordinates";if(Array.isArray(cn[0][e])){const n=[];for(const t of cn){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=Un.current)||void 0===t||t.setBoundedData(n))}}null===(e=Un.current)||void 0===e||e.setBoundedData(cn)}},[P,cn,W]);const{hoverHandlerRef:Jn,hoverLeaveRef:ti,onPointerMove:ei,onPointerLeave:ni}=Ye;Jn.current=t=>{var e,n,i,o;if(!un)return;const r=yn.current;if(!r)return;const s=r.getBoundingClientRect(),l=t.clientX-s.left-nn.left,a=t.clientY-s.top-nn.top;if(0>l||l>ln||0>a||a>an)return void(kn.current&&(kn.current=null,Mn.current=null,On(null),Ft&&(Ft(null),ze.current=!0),en()));const c=Gn.current;if(!c||0===c.scene.length)return;const u=hn(c.scene,l,a,Ht,c.quadtree,c.maxPointRadius),d="multi"===Xt,h=()=>{kn.current&&(kn.current=null,Mn.current=null,On(null),Ft&&Ft(null),en())};if(!u&&!d)return void h();const f=d||!u?l:u.x,y=d||!u?a:u.y,g=(null==u?void 0:u.datum)?Se(u.datum,c.resolvedRibbons):{},p=null===(n=null===(e=c.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,v="function"==typeof p?p(f):void 0;let m=Bo(g,f,y,null!=v?{xValue:v,xPx:f}:void 0);if(d&&c.scene.length>0&&c.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=fn(dn(t.path,t.curve),e,n);if(null===r)continue;const s=wn(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=dn(t.topPath,t.curve),s=dn(t.bottomPath,t.curve),l=fn(r,e,n);if(null===l)continue;const a=fn(s,e,n),c=wn(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:l,y0:null!=a?a:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(c.scene,f,Math.max(Ht,ln));if(t.length>0){const e=c.scales.y.invert,n=Tn.current,i=p?p(f):f;if(u)m.xValue=i,m.xPx=f;else{const t={xValue:i};"string"==typeof T&&(t[T]=i),m=Bo(t,f,y,{xValue:i,xPx:f})}m.allSeries=t.map(t=>{const i=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===S&&null!=o?i-o:i,valuePx:t.y,color:t.color||n,datum:Se(t.datum,c.resolvedRibbons)}})}}u||(null===(i=m.allSeries)||void 0===i?void 0:i.length)?(kn.current=m,Mn.current=null!==(o=null==u?void 0:u.node)&&void 0!==o?o:null,On(m),Ft&&(Ft(m),ze.current=!0),en()):h()},ti.current=()=>{kn.current&&(kn.current=null,Mn.current=null,On(null),Ft&&(Ft(null),ze.current=!0),en())};const ii=o(()=>{});ii.current=t=>{var e,n;if(!Yt)return;const i=yn.current;if(!i)return;const o=i.getBoundingClientRect(),r=t.clientX-o.left-nn.left,s=t.clientY-o.top-nn.top;if(0>r||r>ln||0>s||s>an)return void Yt(null);const l=Gn.current;if(!l||0===l.scene.length)return void Yt(null);const a=hn(l.scene,r,s,Ht,l.quadtree,l.maxPointRadius);if(!a)return void Yt(null);const c=a.datum||{},u=null===(n=null===(e=l.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,d="function"==typeof u?u(a.x):void 0;Yt(Bo(c,a.x,a.y,null!=d?{xValue:d,xPx:a.x}:void 0))};const oi=a(t=>ii.current(t),[]),ri=o(-1),si=o(null),li=o(null),ai=a(t=>{const e=Gn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(li.current&&li.current.version===n)i=li.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=r.size)break;o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=An(t),li.current={version:n,graph:i}}const o=ri.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),ri.current=0;const n=i.flat[0];si.current={shape:n.shape,w:n.w,h:n.h};const o=Cn(Object.assign(Object.assign({},n),{datum:Se(n.datum,e.resolvedRibbons)}));return kn.current=o,On(o),Ft&&Ft(o),void en()}const r=_n(i,o),s=Sn(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return ri.current=-1,si.current=null,kn.current=null,Mn.current=null,On(null),Ft&&Ft(null),void en();ri.current=s;const l=i.flat[s];si.current={shape:l.shape,w:l.w,h:l.h};const a=Cn(Object.assign(Object.assign({},l),{datum:Se(l.datum,e.resolvedRibbons)}));kn.current=a,On(a),Ft&&Ft(a),en()},[Ft,en]),ci=a(t=>{ri.current=-1,si.current=null,ei(t)},[ei]);tn.current=()=>{Je.current=0;const t=yn.current,e=gn.current;if(!t||!e)return;const n=Gn.current;if(!n)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=n.advanceTransition(Ge.current?i+1e6:i),r=!Ge.current&&o,s=Re.current.w!==ln||Re.current.h!==an,l=ze.current||o||s;let a=!1;!l||r&&!s||(n.computeScene({width:ln,height:an}),Re.current={w:ln,h:an},a=!0,Vn());const c=er(),u=function(t){if(!t)return Cr;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||l||n||r?{axisStroke:a||Cr.axisStroke,tickText:s||Cr.tickText,crosshair:s?Or(s,"66"):Cr.crosshair,hoverFill:c?Or(c,"4D"):Cr.hoverFill,hoverStroke:s?Or(s,"99"):Cr.hoverStroke,pointRing:c||Cr.pointRing,primary:r||Cr.primary}:Cr}(t);Tn.current=u.primary;const d=En(ve,n.lastIngestTime>0?i-n.lastIngestTime:0),h=ve&&d.isStale;if(l){const e=tr(t,qe,nn,c);if(e){if(e.clearRect(-nn.left,-nn.top,qe[0],qe[1]),ve&&1>d.alpha&&(e.globalAlpha=d.alpha),"transparent"!==ot&&!re){const n=getComputedStyle(t).getPropertyValue("--semiotic-bg").trim(),i=ot||(n&&"transparent"!==n?n:null),o=i?rn(e,i):null;o&&(e.fillStyle=o,e.fillRect(-nn.left,-nn.top,qe[0],qe[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,ln,an),e.clip()),le&&n.scales)for(const t of le)e.save(),t(e,n.scene,n.scales,{width:ln,height:an}),e.restore();const i=Le?Mr.custom:Mr[S];if(i&&n.scales)for(const t of i)t(e,n.scene,n.scales,{width:ln,height:an});e.restore(),ve&&1>d.alpha&&(e.globalAlpha=1)}}{const t=tr(e,qe,nn,c);if(t&&(t.clearRect(-nn.left,-nn.top,qe[0],qe[1]),un&&kn.current&&n.scales&&function(t,e,n,i,o,r,s){var l;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(l=e.xPx)&&void 0!==l?l:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,kn.current,ln,an,"object"==typeof un?un:{},Mn.current,u),Mn.current&&Array.isArray(Rt))){const e=Rt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,n.scene,Mn.current,e,u)}}l&&t&&t.setAttribute("aria-label",bo(n.scene,S+" chart"));const f=ze.current;if(ze.current=f&&r&&!a,f&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!bn||t(bn.x.domain()[0])!==t(n.scales.x.domain()[0])||t(bn.x.domain()[1])!==t(n.scales.x.domain()[1])||t(bn.y.domain()[0])!==t(n.scales.y.domain()[0])||t(bn.y.domain()[1])!==t(n.scales.y.domain()[1])||bn.x.range()[0]!==n.scales.x.range()[0]||bn.x.range()[1]!==n.scales.x.range()[1]||bn.y.range()[0]!==n.scales.y.range()[0]||bn.y.range()[1]!==n.scales.y.range()[1])&&xn(n.scales),Ae){const t=n.getData(),e="function"==typeof T?T:t=>t[T||"x"],i="function"==typeof D?D:t=>t[D||"y"];jn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Yn(t.map(t=>i(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Gt&&Gt.length>0||Le)&&(a||r))||!a&&33>i-mn.current||(vn(t=>t+1),mn.current=i),(null==ve?void 0:ve.showBadge)&&zn(!!h),(r||null!=n.activeTransition||n.hasActivePulses)&&(Je.current=requestAnimationFrame(()=>tn.current()))},uo({hydrated:Be,wasHydratingFromSSR:Xe,storeRef:Gn,dirtyRef:ze,renderFnRef:tn,cleanup:()=>{var t;return null===(t=Un.current)||void 0===t?void 0:t.clear()}}),s(()=>{ze.current=!0,en()},[S,ln,an,Ot,ot,rt,le,en]),Ln(ve,Gn,ze,en,Wn,zn);const ui=r(()=>{if(Lt||Wt)return;const t=Gn.current;return(null==t?void 0:t.xIsDate)&&bn?Sr(bn.x.domain()):void 0},[Lt,Wt,bn]),di=Lt||Wt||ui,hi=un&&Pn?jt?jt(Pn):t(Dr,{hover:Pn}):null,fi=hi?t(Ko,{x:Pn.x,y:Pn.y,containerWidth:ln,containerHeight:an,margin:nn,className:"stream-frame-tooltip",children:hi}):null,yi=si.current,gi=t(Fo,{active:ri.current>=0,hoverPoint:Pn,margin:nn,size:qe,shape:null==yi?void 0:yi.shape,width:null==yi?void 0:yi.w,height:null==yi?void 0:yi.h}),pi=Ar(T,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),vi=Ar(D,B,"__semiotic_resolvedY","__semiotic_resolvedValue"),mi=pi.key,bi=vi.key,xi=function(t,e,n){return i=>{if(!i||!n||!t.fn&&!e.fn)return i;let o=!1;const r=i.map(n=>{const i=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!i&&!r)return n;o=!0;const s=Object.assign({},n);return i&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return o?r:i}}(pi,vi,Gt&&Gt.length>0||!1);if(io||!Be&&Xe){const n=Gn.current;n&&P&&(n.ingest({inserts:cn,bounded:!0}),n.computeScene({width:ln,height:an}));const o=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(u=null==n?void 0:n.scales)&&void 0!==u?u:null,s=di||(()=>{if((null==n?void 0:n.xIsDate)&&r)return Sr(r.x.domain())})();return e("div",{ref:Ve,className:"stream-xy-frame"+(it?" "+it:""),role:"img","aria-label":Oe||("string"==typeof ce?ce:"XY chart"),style:{position:"relative",width:tt?"100%":qe[0],height:et?"100%":qe[1]},children:[t(Wo,{summary:Te}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:qe[0],height:qe[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${nn.left},${nn.top})`,children:sn}),e("g",{transform:`translate(${nn.left},${nn.top})`,children:[ot&&t("rect",{x:0,y:0,width:ln,height:an,fill:ot}),ae&&r&&ae.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:ln,height:an})},"svgpre-"+n)),o.map((n,i)=>function(n,i,o){var r,s,l,a,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${o?o+"-":""}area-clip-${i}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:no(c.style.fill),fillOpacity:null!==(s=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==s?s:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+i)}return t("path",{d:u,fill:no(c.style.fill),fillOpacity:null!==(a=null!==(l=c.style.fillOpacity)&&void 0!==l?l:c.style.opacity)&&void 0!==a?a:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:no(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"symbol":return function(e,n){const i=De(e.symbolType,e.size,e.path);return t("path",{d:i,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?no(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+n)}(n,i);case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:no(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,s,l]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*r+.587*s+.114*l>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),s=Math.max(Math.abs(o.openY-o.closeY),1),l=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:s,fill:l,stroke:l,strokeWidth:1})]},"candle-"+i)}default:return null}}(n,i,We)).filter(Boolean)]})]}),t(Ji,{width:ln,height:an,totalWidth:qe[0],totalHeight:qe[1],margin:nn,scales:r,showAxes:Ot,axes:Tt,xLabel:Dt,yLabel:Nt,yLabelRight:Et,xFormat:s,yFormat:$t||zt,axisExtent:It,showGrid:Ut,title:ce,legend:Kt,legendHoverBehavior:Qt,legendClickBehavior:Zt,legendHighlightedCategory:Jt,legendIsolatedCategories:te,legendPosition:ee,legendLayout:ne,foregroundGraphics:Fe(on,He(null===(h=Gn.current)||void 0===h?void 0:h.customLayoutOverlays,null!=Ie?Ie:null)),marginalGraphics:Ae,xValues:[],yValues:[],annotations:Gt,autoPlaceAnnotations:Vt,svgAnnotationRules:qt,annotationFrame:0,xAccessor:mi,yAccessor:bi,annotationData:xi(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof z?z:void 0,linkedCrosshairName:Ne,linkedCrosshairSourceId:Ee})]})}return e("div",{ref:Ve,className:"stream-xy-frame"+(it?" "+it:""),role:"group","aria-label":Oe||("string"==typeof ce?ce:"XY chart"),tabIndex:0,style:{position:"relative",width:tt?"100%":qe[0],height:et?"100%":qe[1],overflow:"visible"},onKeyDown:ai,children:[Ce&&t(zo,{tableId:Ze}),Ce&&t($o,{scene:null!==(p=null===(f=Gn.current)||void 0===f?void 0:f.scene)&&void 0!==p?p:[],chartType:S+" chart",tableId:Ze,chartTitle:"string"==typeof ce?ce:void 0}),t(Wo,{summary:Te}),t(Ro,{hoverPoint:Pn}),e("div",{role:"img","aria-label":Oe||("string"==typeof ce?ce:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:un?ci:void 0,onMouseLeave:un?ni:void 0,onClick:Yt?oi:void 0,children:[sn&&t("svg",{style:{position:"absolute",left:0,top:0,width:qe[0],height:qe[1],pointerEvents:"none"},children:t("g",{transform:`translate(${nn.left},${nn.top})`,children:sn})}),t(Ki,{width:ln,height:an,totalWidth:qe[0],totalHeight:qe[1],margin:nn,scales:bn,showAxes:Ot,axes:Tt,showGrid:Ut,xFormat:di,yFormat:$t||zt,axisExtent:It}),t("canvas",{ref:yn,"aria-label":bo(null!==(m=null===(v=Gn.current)||void 0===v?void 0:v.scene)&&void 0!==m?m:[],S+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:gn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(Ji,{width:ln,height:an,totalWidth:qe[0],totalHeight:qe[1],margin:nn,scales:bn,showAxes:Ot,axes:Tt,xLabel:Dt,yLabel:Nt,yLabelRight:Et,xFormat:di,yFormat:$t||zt,axisExtent:It,showGrid:Ut,title:ce,legend:Kt,legendHoverBehavior:Qt,legendClickBehavior:Zt,legendHighlightedCategory:Jt,legendIsolatedCategories:te,legendPosition:ee,legendLayout:ne,foregroundGraphics:Fe(on,He(null===(b=Gn.current)||void 0===b?void 0:b.customLayoutOverlays,null!=Ie?Ie:null)),marginalGraphics:Ae,xValues:Rn,yValues:Fn,annotations:Gt,autoPlaceAnnotations:Vt,svgAnnotationRules:qt,annotationFrame:pn,xAccessor:mi,yAccessor:bi,annotationData:xi(null===(x=Gn.current)||void 0===x?void 0:x.getData()),pointNodes:null===(k=Gn.current)||void 0===k?void 0:k.scene.filter(t=>"point"===t.type),curve:"string"==typeof z?z:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==ot&&!re,linkedCrosshairName:Ne,linkedCrosshairSourceId:Ee}),(de||he)&&t(bt,{width:ln,height:an,totalWidth:qe[0],totalHeight:qe[1],margin:nn,dimension:null!==(w=null==de?void 0:de.dimension)&&void 0!==w?w:"xy",scales:bn,onBrush:null!=he?he:()=>{},binSize:Y,snap:null==de?void 0:de.snap,binBoundaries:null!==(A=null==de?void 0:de.binBoundaries)&&void 0!==A?A:"bar"===S?null===(_=Gn.current)||void 0===_?void 0:_.getBinBoundaries():void 0,snapDuring:null==de?void 0:de.snapDuring,streaming:"streaming"===M}),(null==ve?void 0:ve.showBadge)&&t($n,{isStale:Wn,position:ve.badgePosition}),gi,fi]})]})});Nr.displayName="StreamXYFrame";const Er={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Lr={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class $r{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(!l||!l.bezier){s.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[s.edgeIndex])&&void 0!==o?o:1;s.t+=t*e*a*(l.bezier.circular?.3:1),1>s.t?Ir(l.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function Ir(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,s=e*r,l=Math.min(Math.floor(s),r-1),a=s-l,[c,u,d,h]=t[l];Wr(c,u,d,h,a,o);const f=h.x-c.x,y=h.y-c.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;o.x+=-y/g*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,s,l]=t.points;Wr(o,r,s,l,e,i);const a=l.x-o.x,c=l.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function Wr(t,e,n,i,o,r){const s=1-o,l=s*s,a=l*s,c=o*o,u=c*o;r.x=a*t.x+3*l*o*e.x+3*s*c*n.x+u*i.x,r.y=a*t.y+3*l*o*e.y+3*s*c*n.y+u*i.y}function zr(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Rr(t,e){var n,i=[],o=[],r=[],s={},l=[];function a(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;l[t].length>e;e++){var h=s[i=l[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),l=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,s[a]=-1,l[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var y=r[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=i[g]=u,o[g]=!0,u+=1,a.push(g),c.push(g);break}o[g]&&(i[e]=0|Math.min(i[e],i[g])),0>s[g]||l[e].push(s[g])}r[e]=y}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(y=a.length-1;y>=0;--y){var b=a[y];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,s[b]=d.length,b===e){a.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var y=h[a];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var l=0;o[s].length>l;l++)r>o[s][l]&&(r=o[s][l],n=s);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return i}function jr(t){return t.y0-t.y1>0?"up":"down"}function Fr(t,e){return e(t.source)==e(t.target)}function Yr(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function Br(t){return t.target.x0-t.source.x1}function Hr(t,e){var n=Gr(t),i=Br(e)/Math.tan(n);return"up"==jr(t)?t.y1-i:t.y1+i}function Xr(t,e){var n=Gr(t),i=Br(e)/Math.tan(n);return"up"==jr(t)?t.y1+i:t.y1-i}function Gr(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Vr(t,e){return e(t)}function qr(t){return Kr(t.source)}function Ur(t){return Kr(t.target)}function Kr(t){return(t.y0+t.y1)/2}function Qr(t){return t.virtual?0:t.value}function Zr(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Fr(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Fr(t,e)?i+1:i}),n+i}function Jr(t){return t.target.depth}function ts(t,e){return t.sourceLinks.length?t.depth:e-1}function es(t,e){return t.y0-e.y0}function ns(t,e){return e.y0-t.y0}function is(t,e){return t.y1-e.y1}function os(t,e){return e.y1-t.y1}function rs(t,e){return ls(t.source,e.source)||t.index-e.index}function ss(t,e){return ls(t.target,e.target)||t.index-e.index}function ls(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function as(t,e){return cs(t)==cs(e)?"bottom"==t.circularLinkType?ns(t,e):es(t,e):cs(e)-cs(t)}function cs(t){return t.target.column-t.source.column}function us(t,e){return ds(t)==ds(e)}function ds(t){return t.y0-t.y1>0?"up":"down"}function hs(t,e,n,i,o){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var l=V(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var a=r.links.filter(function(t){return t.circular});return a.sort(function(t,e){return e.value-t.value}),a.forEach(function(t,e){t._circularStub=e>=4}),fs(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),fs(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Fr(t,e)&&Yr(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?ns:es);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?os:is),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=l-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function fs(t,e,n){t.sort(as);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Fr(t,e)&&Yr(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var l=i[s];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&ys(t,l)){var a=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ys(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function gs(t){return function(){return t}}function ps(t){return t.index}function vs(t){return t.nodes}function ms(t){return t.links}function bs(t,e,n){var i=q(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var l=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Kr(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Kr(t.target)*e,i+=e}}),i>0?o/i:NaN);l.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=l.get(t),i=l.get(e),o=n.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Zr(e,n)-Zr(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Zr(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function xs(t,e,n,i,o,r){var s=q(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var l=1,a=r;a>0;--a)c(l*=.99,n),u();function c(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var l;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Zr(o,n)>0){var a=Q(o.sourceLinks,Ur),c=Q(o.targetLinks,qr),u=a&&c?(a+c)/2:a||c;if(u){var d=(u-Kr(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=t.y1/2-(l=o.y1-o.y0)/2,o.y1=t.y1/2+l/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(l=o.y1-o.y0)/2,o.y1=t.y1/2+l/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)l=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+l;else{var h=Q(o.sourceLinks,Ur),f=Q(o.targetLinks,qr),y=((h&&f?(h+f)/2:h||f)-Kr(o))*e;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var r,s,l,a=t.y0,c=n.length;for(n.sort(e||ls),l=0;c>l;++l)(s=a-(r=n[l]).y0)>0&&(r.y0+=s,r.y1+=s),a=r.y1+i;if((s=a-i-t.y1)>0)for(a=r.y0-=s,r.y1-=s,l=c-2;l>=0;--l)(s=(r=n[l]).y1+o-a)>0&&(r.y0-=s,r.y1-=s),a=r.y0})}}function ks(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ss),t.targetLinks.sort(rs)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function ws(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,l=ps,a=ts,c=void 0,u=32,d=2,h=vs,f=ms;function y(){var y={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return Z(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=zr(n,i)),"object"!=typeof o&&(o=t.target=zr(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,l),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,l=r.target.index;i[s]||(i[s]=[]),i[l]||(i[l]=[]),-1===i[s].indexOf(l)&&i[s].push(l)}var a=Rr(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){Vr(t,e)!=Vr(o.source,e)&&Vr(t,e)!=Vr(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Fr(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(K(t.sourceLinks,Qr),K(t.targetLinks,Qr)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==l?s:s+1,l=e(t)==l?l:e(t),t.column=s})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,a);var f=r;if(null!==s){var y=q(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=U(y,function(t){return t.length});g>1&&(f=Math.max(1,(i-e)*s/(g-1)))}(function(t,e,n){var i=q(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=V(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/K(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=U(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,o),bs(h,c,l),xs(h,c,l,f,f,u),ks(h),hs(h,l,d,10,8),bs(h,c,l),xs(h,c,l,f,f,u),ks(h),hs(h,l,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return Vr(n.source,e)==Vr(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!us(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Hr(e,t);return t.y1-n}if(e.target.column>t.target.column)return Hr(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(h,l),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return Vr(n.target,e)==Vr(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!us(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Xr(e,t);return t.y0-n}if(e.source.column>t.source.column)return Xr(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(h,l),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=V(e,function(t){return t.y0}),s=U(e,function(t){return t.y1}),l=(t.y1-t.y0)/(s-r);function a(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1)}),n.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,n=a(t.y0)-t.y0;t.y0=a(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),hs(h,l,d,10,8)}(y),y}return y.update=function(t){return ks(t),hs(t,l,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(h="function"==typeof t?t:gs(t),y):h},y.links=function(t){return arguments.length?(f="function"==typeof t?t:gs(t),y):f},y.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:gs(t),y):l},y.nodeAlign=function(t){return arguments.length?(a="function"==typeof t?t:gs(t),y):a},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(d=+t,y):d},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],y):[[t,e],[n,i]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],y):[n-t,i-e]},y}const As=t=>{let e,n,i,o,r,s,l,a,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=at(r,s),a=l(.5),c=l(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${a} ${o},${r}Z`;const u=t.sankeyWidth/2,d=at(t.source.x1,t.target.x0),{pathD:h}=function(t){const{sx:e,sTop:n,sBot:i,tx:o,tTop:r,tBot:s,cp1X:l,cp2X:a}=t,c=(n+i)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${l},${n} ${a},${r} ${o},${r}`,`L${o},${s}`,`C${a},${s} ${l},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:l,y:c},{x:a,y:u},{x:o,y:u}],halfWidth:(i-n)/2}}}({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function _s(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-a},${s-n}L${r-a},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,l=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${l},${a-h*n}L${l},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const Ss=new Set,Ms=new WeakMap;function Ps(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Ms.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Ms.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Ss.has(t)||(Ss.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,i)}});return n.set(e,i),i}const Cs={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Jr))-1:0},justify:ts};function Os(t){return"string"==typeof t?t:t.id}const Ts={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,l,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,g=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const b=ws().extent(m).links(v).nodes(p).nodeAlign(Cs[h]||ts).nodeId(t=>t.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(a=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==a?a:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of p){const e=x.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=Os(t.source),n=Os(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=x.get(e),r=x.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,s,l,a,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Qt,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const v=[],m=[],b=[],x=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=d?d(Ps(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};x.set(e.id,("string"==typeof o.fill?o.fill:null)||p.get(e.id)||"#4d430c"),v.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";o="function"==typeof y?y(t)||o:"target"===y?x.get(i.id)||p.get(i.id)||o:x.get(e.id)||p.get(e.id)||o;const u=h?h(Ps(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||o;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?_s(t):As(t),!d)continue;const g={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};m.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:g,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let s,l,a;"down"===u?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,a="start"):(i[0]/2>n.x0+t/2?(s=n.x0-6,a="end"):(s=n.x1+6,a="start"),l=n.y0+o/2),b.push({x:s,y:l,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:b}}},Ds={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=i[0]/2,a=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Ns(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=Es(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=Es(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=l+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:h?40:f,g=Ls(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t);if(y>0){const n=ct().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=ut().force("charge",dt().strength(t=>-25*p(t))).force("center",ht(l,a).strength(.8)).force("x",ft(l).strength(.15)).force("y",yt(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));n.links(t),i.force("link",n)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;y>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Ls(n.nodeSize,n.nodeSizeRange,t),y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Qt,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],v=[],m=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Ps(e,"nodeSize")),i=d?d(Ps(e,"nodeStyle")):{},l={fill:i.fill||g.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:2,opacity:i.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),i="object"==typeof t.target?t.target:b.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(Ps(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};v.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=f(Ps(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}};function Ns(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function Es(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Ls(t,e,n){var i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],r=[];for(const e of n){const n=null===(i=e.data)||void 0===i?void 0:i[t];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[s,l]=Gn(r);if(s===l)return()=>(o[0]+o[1])/2;const a=x().domain([s,l]).range(o).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?o[0]:a(i)}}const $s=Qt,Is={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,l=Math.min(i[0],i[1])/2,a=l-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);g[n][i]=o}const p=pt().padAngle(o);s&&p.sortGroups(s);const v=p(g),m=v.groups,b=H().innerRadius(a).outerRadius(l);for(const e of m){const n=t[e.index],i=b.centroid({innerRadius:a,outerRadius:l,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+c,n.y=i[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=x.get("string"==typeof t.source?t.source:t.source.id),i=x.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of v){const n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){var o,r,s,l;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,f=i[1]/2,y=n.nodeStyle,g=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:$s,m=new Map;t.forEach((t,e)=>{m.set(t.id,v[e%v.length])});const b=gt().radius(d),x=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=y?y(Ps(n,"nodeStyle")).fill||m.get(n.id)||v[e%v.length]:m.get(n.id)||v[e%v.length];const s=y?y(Ps(n,"nodeStyle")):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=b(e);if(!i)continue;const o=Ws(i,h,f);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(g)a=g(Ps(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===p&&n?a=m.get(n.id)||a:e&&(a=m.get(e.id)||a)}const u=g?g(Ps(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;w.push({x:h+Math.cos(s)*i,y:f+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:x,sceneEdges:k,labels:w}}};function Ws(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const zs=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Rs(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}function js(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Fs(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>{var n;return e(null!==(n=t.data)&&void 0!==n?n:t)}}return e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}}function Ys(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:zs}function Bs(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Hs(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Xs={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,l=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,u=tt(r,l);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,h]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=st();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=rt();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,l=null!==(r=e.paddingTop)&&void 0!==r?r:0,a=it().size([n,i]).tile(ot).padding(s);l>0&&a.paddingTop(l),a(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;nt().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;et().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:js(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Gs(r,i,n):"treemap"===s||"partition"===s?Vs(r,i):"circlepack"===s&&qs(r,i),r.__hierarchyNode=i,t.push(r),y.set(i,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,l,a,c,u,d,h,f;const y=[],g=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,b=i[0]/2,x=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=b,i+=x);const r=o(Ps(e,"nodeStyle"));let a=r.fill||Bs(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ys(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:r.opacity};y.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,l=i.x,a=i.y;m&&(o+=b,s+=x,l+=b,a+=x);const f=Hs(o,s,l,a,v),y=r(Ps(t,"edgeStyle")),p={fill:"none",stroke:y.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=y.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=y.opacity)&&void 0!==h?h:A};g.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=Fs(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,l=n.y;if(m&&(s+=b,l+=x),m){const t=s-b,e=l-x,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=l+e/n*10,r=0>t?"end":"start"):(i=s,o=l-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=l):(i=s,o=l+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:y,sceneEdges:g,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,s,l,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const l=i(Ps(n,"nodeStyle"));let a=l.fill||Bs(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ys(e);a=t[n.depth%t.length]}const u={fill:a,stroke:l.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Fs(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let y=i(Ps(c,"nodeStyle")).fill||Bs(e);if(e.colorByDepth&&void 0!==c.depth){const t=Ys(e);y=t[c.depth%t.length]}const g="string"==typeof y?Rs(y):null!==(a=null===(l=e.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:g}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,l,a,c,u,d,h,f;const y=[],g=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(Ps(n,"nodeStyle"));let c=a.fill||Bs(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ys(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=a.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};y.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Fs(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=i(Ps(o,"nodeStyle")).fill||Bs(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ys(e);l=t[o.depth%t.length]}if(s){const n="string"==typeof l?Rs(l):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";g.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else g.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:y,sceneEdges:[],labels:g}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Gs(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Vs(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function qs(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Us(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Ks={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,s;const l=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,y=Us(n);y.metaMap.clear(),i.length=0,o.length=0;const g=new Map;function p(t){var e;const n=null!==(e=g.get(t))&&void 0!==e?e:0;return g.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,b=Math.min(e[0],e[1])/2*.85,x=p(a(t));i.push({id:x,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,u,d,g){const v=l(e);if(!(null==v?void 0:v.length))return;const m=v.length;let b=0,x=0,k=0;for(;m>x;)x+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let m=0;b>m;m++){const x=c[Math.min(m,c.length-1)],k=v.slice(w,w+x);if(!k.length)break;const A=(m+1)/b,_={id:n,depth:d,data:e,parentId:n},S=g?u/h(_)*A:u*A,M=X().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=M(k),C=f(_);for(let e=0;k.length>e;e++){const l=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(a(c)),h=r+S*Math.sin(l),f=s+S*Math.cos(l)*C;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),y.metaMap.set(u,{ring:S,angle:l,depth:d,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,S,d+1,!0)}w+=x}}(t,x,v,m,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,y=[],g=[],p=[];if(!1!==n.orbitShowRings){const e=Us(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of o)for(let o=0;r>o;o++){const l=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;g.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Ps(e,"nodeSize")),i=d?d(Ps(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};y.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&g.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(Ps(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:y,sceneEdges:g,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Us(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+l*a*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Qs={sankey:Ts,force:Ds,chord:Is,tree:Xs,cluster:Xs,treemap:Xs,circlepack:Xs,partition:Xs,orbit:Ks};function Zs(t){return Qs[t]}function Js(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(i)%t.length])&&void 0!==n?n:"#4e79a7"}}class tl{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},Er),t.tensionConfig),t.showParticles&&("sankey"===t.chartType||t.customNetworkLayout)&&(this.particlePool=new $r(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),void 0===t.layoutSelection&&null!=e.layoutSelection&&(t.layoutSelection=e.layoutSelection),this.config=t,this.tensionConfig=Object.assign(Object.assign({},Er),t.tensionConfig),!t.showParticles||"sankey"!==t.chartType&&!t.customNetworkLayout||this.particlePool||(this.particlePool=new $r(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,l="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},el(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=u(n),s=null==r?NaN:Number(r),l=Number.isFinite(s)?s:1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},el(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},el(o)),{data:n}));const d=`${i}\0${o}\0${t}`,h={source:i,target:o,value:l,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:d};n&&"object"==typeof n&&nl(n.bezier)&&(h.bezier=n.bezier),this.edges.set(d,h)}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,el(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,el(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,r=!0);const l=this.edgeKey(e,n),a=this.edges.get(l);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,s,l,a;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=Zs(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const l of u)if(void 0!==l._prevX0){const a=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);t.set(l.id,{x:(null!==(r=l._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(s=l._prevY0)&&void 0!==s?s:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),y=null!==(a=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&y>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:y}}else f&&y>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:y});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const t=new Set(this.nodes.keys()),e=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of t)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)t.has(e)||this.removedNodes.add(e);for(const t of e)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)e.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=t,this.previousEdgeKeys=e}setLayoutSelection(t){this.config.layoutSelection=t}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const t of this.sceneNodes)this._baseStyles.set(t,t.style);for(const t of this.sceneEdges)this._baseStyles.set(t,t.style)}restyleScene(t){var e,n;if(this._customRestyle){const n=this._customRestyle;for(const i of this.sceneNodes){const o=null!==(e=this._baseStyles.get(i))&&void 0!==e?e:i.style,r=n(i,t);i.style=r?Object.assign(Object.assign({},o),r):o}}if(this._customRestyleEdge){const e=this._customRestyleEdge;for(const i of this.sceneEdges){const o=null!==(n=this._baseStyles.get(i))&&void 0!==n?n:i.style,r=e(i,t);i.style=r?Object.assign(Object.assign({},o),r):o}}}buildScene(t){var e,n,i,o,r,s,l,a,c;if(this._sceneNodesRevision++,this.config.customNetworkLayout){const u=Array.from(this.nodes.values()),d=Array.from(this.edges.values()),h=function(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=de[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,Qt),f={nodes:u,edges:d,dimensions:{width:t[0],height:t[1],plot:{x:0,y:0,width:t[0],height:t[1]}},theme:{semantic:null!==(e=this.config.themeSemantic)&&void 0!==e?e:{},categorical:[...h]},resolveColor:Js(h),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{},selection:null!==(i=this.config.layoutSelection)&&void 0!==i?i:null};let y;try{y=this.config.customNetworkLayout(f)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,void(this.customLayoutHtmlMarks=[])}return this.sceneNodes=null!==(o=y.sceneNodes)&&void 0!==o?o:[],this.sceneEdges=null!==(r=y.sceneEdges)&&void 0!==r?r:[],this.labels=null!==(s=y.labels)&&void 0!==s?s:[],this.customLayoutOverlays=null!==(l=y.overlays)&&void 0!==l?l:null,this.customLayoutHtmlMarks=null!==(a=y.htmlMarks)&&void 0!==a?a:[],this._customRestyle=y.restyle,this._customRestyleEdge=y.restyleEdge,this.hasCustomRestyle=!(!y.restyle&&!y.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(null!==(c=this.config.layoutSelection)&&void 0!==c?c:null)),void $e({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[];const u=Zs(this.config.chartType);if(!u)return;const d=u.hierarchical?Array.from(this.nodes.values()):this.nodesArray,h=u.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:f,sceneEdges:y,labels:g}=u.buildScene(d,h,this.config,t);this.sceneNodes=f,this.sceneEdges=y,this.labels=g}rebuildNodeQuadtree(){let t=0,e=0;for(const n of this.sceneNodes)"circle"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxNodeRadius=e,tl.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const n=Array(t);let i=0;for(const t of this.sceneNodes)"circle"===t.type&&(n[i++]=t);this._nodeQuadtree=A().x(t=>t.cx).y(t=>t.cy).addAll(n)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const t=Zs(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Zs(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(i,o,this.config,t,e)}cancelIntroAnimation(){this.transition=null;for(const t of this.nodes.values())t._prevX0=void 0,t._prevX1=void 0,t._prevY0=void 0,t._prevY1=void 0;for(const t of this.edges.values())t._prevY0=void 0,t._prevY1=void 0,t._prevSankeyWidth=void 0,t._introFromZero=!1}advanceTransition(t){if(!this.transition)return!1;const e=ve(t,this.transition),n=pe(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=me(t._prevX0,t._targetX0,n),t.x1=me(t._prevX1,t._targetX1,n),t.y0=me(t._prevY0,t._targetY0,n),t.y1=me(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=me(t._prevY0,t._targetY0,n),t.y1=me(t._prevY1,t._targetY1,n),t.sankeyWidth=me(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,s=at(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:s(.5)},{x:t.y1,y:s(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,s=at(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:s(.5),y:t.y0},{x:s(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const s=this.config.pulse;if(!s)return;const l=null!==(e=s.duration)&&void 0!==e?e:500,a=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=s.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;l>o&&(e._pulseIntensity=1-o/l,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,s="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!s)continue;const c=this.edgeTimestamps.get(`${i}\0${s}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;if(!this._decaySortedNodes){this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]);const t=new Map;for(let e=0;this._decaySortedNodes.length>e;e++)t.set(this._decaySortedNodes[e][0],e);this._decayAgeMap=t}const o=this._decayAgeMap;for(const r of this.sceneNodes){const s=r.id;if(!s)continue;const l=o.get(s);if(void 0===l)continue;const a=ye(n,l,i),c=null!==(e=null===(t=r.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;r.style=Object.assign(Object.assign({},r.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const a=i.metric(l);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),s&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){s.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return s.length>0&&(this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now()),s}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&(this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now()),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}}function el(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function nl(t){if(!t||"object"!=typeof t)return!1;const e=t;if("boolean"!=typeof e.circular)return!1;if("number"!=typeof e.halfWidth||!Number.isFinite(e.halfWidth))return!1;if(e.circular){if(!Array.isArray(e.segments)||0===e.segments.length)return!1;for(const t of e.segments)if(!il(t))return!1;return!0}return il(e.points)}function il(t){if(!Array.isArray(t)||4!==t.length)return!1;for(const e of t){if(!e||"object"!=typeof e)return!1;const t=e;if("number"!=typeof t.x||!Number.isFinite(t.x))return!1;if("number"!=typeof t.y||!Number.isFinite(t.y))return!1}return!0}function ol(t,e,n,i,o=30,r,s=0){let l=null,a=o,c=1/0;if(r){const t=Ke(r,n,i,o,s,t=>t.cx,t=>t.cy,t=>t.r);t&&(l={type:"node",datum:t.node.datum,x:t.node.cx,y:t.node.cy,distance:t.distance},a=t.distance)}for(const e of t){if(r&&"circle"===e.type)continue;const t=rl(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;c>n&&(l=t,c=n)}else a>t.distance&&(l=t,a=t.distance)}if(l)return l;for(const t of e){if(!1===t.interactive)continue;const e=ul(t,n,i);e&&a>e.distance&&(l=e,a=e.distance)}return l}function rl(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,s=Math.sqrt(o*o+r*r);return s>Ge(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);case"rect":return function(t,e,n){const i=Xe(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const s=Ue(Math.atan2(o,i)),l=Ue(t.startAngle),a=Ue(t.endAngle);if(l>a?s>=l||a>=s:s>=l&&a>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);case"symbol":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,s=Math.sqrt(o*o+r*r);return s>Ge(Ne(t.size),i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);default:return null}}tl.QUADTREE_THRESHOLD=500;let sl=null,ll=null;function al(){return ll||(sl=document.createElement("canvas"),sl.width=1,sl.height=1,ll=sl.getContext("2d")),ll}function cl(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function ul(t,e,n){switch(t.type){case"bezier":return function(t,e,n){if(!t.pathD)return null;const i=cl(t),o=al();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(i,e,n);if(o.lineWidth=r,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const l=t.x1+s*i,a=t.y1+s*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=cl(t),o=al();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(i,e,n);if(o.lineWidth=r,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function dl(o){const{width:r,height:s,totalWidth:l,totalHeight:a,margin:c,labels:u,title:d,legend:h,legendHoverBehavior:f,legendClickBehavior:y,legendHighlightedCategory:g,legendIsolatedCategories:p,legendPosition:v="right",legendLayout:m,foregroundGraphics:b,sceneNodes:x,annotations:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=o,_=i.useMemo(()=>{const t=(x||[]).flatMap(t=>{const e=function(t){var e,n,i,o;const r=null!==(e=t.cx)&&void 0!==e?e:null!=t.x&&null!=t.w?t.x+t.w/2:t.x,s=null!==(n=t.cy)&&void 0!==n?n:null!=t.y&&null!=t.h?t.y+t.h/2:t.y;return"number"!=typeof r||"number"!=typeof s?null:{x:r,y:s,r:"number"==typeof t.r?Math.max(1,t.r):"number"==typeof t.outerR?Math.max(1,t.outerR):"number"==typeof t.size?Math.max(1,Ne(t.size)):Math.max(1,null!==(i=t.w)&&void 0!==i?i:0,null!==(o=t.h)&&void 0!==o?o:0)/2}}(t),n=function(t){var e,n,i,o,r,s,l,a;const c=null!==(s=null!==(i=null!==(e=t.id)&&void 0!==e?e:null===(n=t.datum)||void 0===n?void 0:n.id)&&void 0!==i?i:null===(r=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)&&void 0!==s?s:null===(a=null===(l=t.datum)||void 0===l?void 0:l.data)||void 0===a?void 0:a.name;return null==c?void 0:c+""}(t);return e?[Object.assign({pointId:n},e)]:[]});return{scales:null,width:r,height:s,frameType:"network",pointNodes:t,sceneNodes:x}},[s,x,r]),S=i.useMemo(()=>k&&w?Ei(Object.assign({annotations:k,context:_},"object"==typeof w?w:{})):k,[k,w,_]),M=S?yi(S.reduce((e,n,o)=>{if("widget"===n.type||!A)return e;const r=A(n,o,_);return r&&e.push({node:t(i.Fragment,{children:r},"annotation-"+o),annotation:n}),e},[])):null,P=!0===(null==S?void 0:S.some(t=>"widget"===t.type&&!0===t._annotationDeferred));return e(n,{children:[P&&t("style",{children:ci},"annotation-widget-disclosure-style"),e("svg",{role:"img",width:l,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t("title",{children:"string"==typeof d?d:"Network Chart"}),t("desc",{children:"string"==typeof d?d+" — network data visualization":"Network data visualization"}),e("g",{transform:`translate(${c.left},${c.top})`,children:[u.map((e,n)=>t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+n)),M,b]}),d&&"string"==typeof d?t("text",{x:l/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:d}):d?t("foreignObject",{x:0,y:0,width:l,height:c.top,children:d}):null,Xn({legend:h,totalWidth:l,totalHeight:a,margin:c,legendPosition:v,title:d,legendLayout:m,legendHoverBehavior:f,legendClickBehavior:y,legendHighlightedCategory:g,legendIsolatedCategories:p})]}),null==S?void 0:S.filter(t=>"widget"===t.type&&t.nodeId&&x).map((e,n)=>{var i,o,r,s,l,a,u,d,h;const f=!0===e._annotationDeferred,y=x.find(t=>{var n,i,o,r,s;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(s=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===e.nodeId});if(!y)return null;const g=c.left+(null!==(i=y.cx)&&void 0!==i?i:null!=y.x&&null!=y.w?y.x+y.w/2:null!==(o=y.x)&&void 0!==o?o:0),p=c.top+(null!==(r=y.cy)&&void 0!==r?r:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(s=y.y)&&void 0!==s?s:0),v=null!==(l=e.dx)&&void 0!==l?l:0,m=null!==(a=e.dy)&&void 0!==a?a:-16,b=null!==(u=e.width)&&void 0!==u?u:32,k=null!==(d=e.height)&&void 0!==d?d:32,w=null!==(h=e.content)&&void 0!==h?h:t("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t("div",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:g+v-b/2,top:p+m-k/2,width:b,height:k,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:w},"widget-"+n)})]})}dl.displayName="NetworkSVGOverlay";const hl={position:"absolute",top:0,left:0,pointerEvents:"none"};function fl({marks:e,margin:n,selection:o=null,overscan:r=400}){const s=i.useRef(null),l=function(t,e,n){const[o,r]=i.useState(null);return i.useLayoutEffect(()=>{const t=e.current,n=function(t){var e;let n=null!==(e=null==t?void 0:t.parentElement)&&void 0!==e?e:null;for(;n;){const{overflow:t,overflowX:e,overflowY:i}=window.getComputedStyle(n);if(/(auto|scroll|overlay)/.test(`${t} ${i} ${e}`))return n;n=n.parentElement}return null}(t);if(!t||!n)return void r(null);let i=0;const o=()=>{i=0;const e=n.getBoundingClientRect(),o=t.getBoundingClientRect();r(0!==e.width&&0!==e.height?{scroll:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},originX:o.left,originY:o.top}:null)},s=()=>{0===i&&(i=window.requestAnimationFrame(o))};o(),n.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(n),()=>{0!==i&&window.cancelAnimationFrame(i),n.removeEventListener("scroll",s),l.disconnect()}},[e,t,n]),i.useMemo(()=>{if(!t||!o)return t;const{scroll:e,originX:i,originY:r}=o,s=e.left-n,l=e.right+n,a=e.top-n,c=e.bottom+n;return t.filter(t=>{const e=i+t.x,n=r+t.y;return!(s>e+t.width||e>l||a>n+t.height||n>c)})},[t,o,n])}(e,s,r);if(!e||0===e.length)return null;const a=t("div",{className:"semiotic-network-html-marks",ref:s,style:Object.assign(Object.assign({},hl),{transform:`translate(${n.left}px, ${n.top}px)`}),children:(null!=l?l:e).map(e=>t("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=o?t(Be,{value:o,children:a}):a}const yl=new Map;function gl(t){var e;try{if(t.path)return new Path2D(t.path);const n=`${null!==(e=t.symbolType)&&void 0!==e?e:"circle"}:${Math.round(t.size)}`;let i=yl.get(n);return i||(i=new Path2D(De(t.symbolType,t.size)),yl.size>256&&yl.clear(),yl.set(n,i)),i}catch(t){return null}}function pl(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function vl(t,e){var n,i,o,r,s,l;if(!e.pathD)return;t.save();const a=pl(e);if(e.style.fill&&"none"!==e.style.fill){const s=e._gradient;if(s){const o=t.createLinearGradient(s.x0,0,s.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l="string"==typeof e.style.fill?e.style.fill:"#999",a=rn(t,l)||l;o.addColorStop(0,1===s.from?a:"transparent"),o.addColorStop(1,1===s.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(s=e.style.strokeWidth)&&void 0!==s?s:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function ml(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=rn(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function bl(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=pl(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(s)),t.restore()}function xl(t,e){var n,i;if(!e.pathD)return;t.save();const o=pl(e),r=e.style.stroke||"#999";t.strokeStyle=rn(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}const kl={top:20,right:80,bottom:20,left:80},wl={top:40,right:40,bottom:40,left:40},Al=new Set(["chord","force","circlepack","orbit"]),_l=[800,600],Sl={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ml({data:n}){var i,o,r,s,l,a,c;if("edge"===n.nodeOrEdge){const t=n.data;return t?e("div",{className:"semiotic-tooltip",style:Sl,children:[e("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&e("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const u=n.data;if(!u)return null;const d=u.__hierarchyNode;if(d){const n=[];let l=d;for(;l;){const t=null!==(s=null!==(o=null===(i=l.data)||void 0===i?void 0:i.name)&&void 0!==o?o:null===(r=l.data)||void 0===r?void 0:r.id)&&void 0!==s?s:u.id;null!=t&&n.unshift(t+""),l=l.parent}n.length>1&&n.shift();const a=n.length-1;return e("div",{className:"semiotic-tooltip",style:Sl,children:[t("div",{children:n.map((n,i)=>e("span",{children:[i>0&&t("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),i===a?t("strong",{children:n}):t("span",{style:{opacity:.7},children:n})]},i))}),null!=u.value&&u.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof u.value?u.value.toLocaleString():u.value+""})]})}const h=((null===(l=u.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(a=u.targetLinks)||void 0===a?void 0:a.length)||0),f=(u.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(u.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0),y=function(t,e={}){var n;if(!t||"object"!=typeof t)return{entries:[]};const i=null!==(n=e.maxEntries)&&void 0!==n?n:6,o=!1!==e.skipPositional,r=[];for(const[e,n]of Object.entries(t)){if(e.startsWith("_"))continue;if("data"===e)continue;if(o&&Vo.has(e.toLowerCase()))continue;if(null==n)continue;const t=typeof n;("string"===t||"number"===t||"boolean"===t||n instanceof Date)&&r.push({key:e,lower:e.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let s=r.findIndex(t=>Ho.includes(t.lower));const l=s>=0;0>s&&(s=r.findIndex(t=>"id"===t.lower)),0>s&&(s=r.findIndex(t=>"string"==typeof t.value));const a=0>s?void 0:r[s];let c=r.filter((t,e)=>e!==s);l&&(c=c.filter(t=>"id"!==t.lower));const u=qo(c,Xo),d=qo(c,Go),h=new Set(Xo),f=new Set(Go),y=[];u&&y.push({key:u.key,value:u.value}),d&&y.push({key:d.key,value:d.value});for(const t of c){if(y.length>=i)break;t!==u&&t!==d&&(h.has(t.lower)||f.has(t.lower)||y.push({key:t.key,value:t.value}))}return{titleKey:null==a?void 0:a.key,title:null==a?void 0:a.value,entries:y}}(null!==(c=u.data)&&void 0!==c?c:u),g=null!=y.title?y.title+"":u.id,p=y.entries.some(t=>Pl.test(t.key));return e("div",{className:"semiotic-tooltip",style:Sl,children:[t("div",{style:{fontWeight:600},children:g}),y.entries.map(t=>{return e("div",{style:{marginTop:4,opacity:.8},children:[t.key,": ",(n=t.value,null==n?"–":"number"==typeof n?Math.abs(n)>9999?n.toLocaleString():n+"":n instanceof Date?n.toLocaleDateString():n+"")]},t.key);var n}),!p&&null!=u.value&&u.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof u.value?u.value.toLocaleString():u.value+""]}),h>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",h,f!==h&&` (weighted: ${f.toLocaleString()})`]})]})}const Pl=/^(value|amount|total|count|weight|score)$/i;Ml.ownsChrome=!0;const Cl=f(function(n,i){var l,c,u,h,f,y,p,v,m,b,x,k,w,A,_,S,M,P,C;const{chartType:O,nodes:T,edges:D,data:N,initialEdges:E,nodeIDAccessor:L="id",sourceAccessor:$="source",targetAccessor:I="target",valueAccessor:W="value",edgeIdAccessor:z,childrenAccessor:R,hierarchySum:j,orientation:F="horizontal",nodeAlign:Y="justify",nodePaddingRatio:B=.05,nodeWidth:X=15,iterations:G=300,forceStrength:V=.1,padAngle:q=.01,groupWidth:U=20,sortGroups:K,edgeSort:Q,treeOrientation:Z="vertical",edgeType:J="curve",padding:tt,paddingTop:et,tensionConfig:nt,showParticles:it=!1,particleStyle:ot,nodeStyle:rt,edgeStyle:st,colorBy:lt,colorScheme:at="category10",edgeColorBy:ct="source",edgeOpacity:ut=.5,colorByDepth:dt=!1,nodeSize:ht=8,nodeSizeRange:ft=[5,20],nodeLabel:yt,showLabels:gt=!0,labelMode:pt,size:vt=_l,responsiveWidth:mt,responsiveHeight:bt,margin:xt,className:wt,background:At,enableHover:_t=!0,tooltipContent:Mt,customHoverBehavior:Pt,customClickBehavior:Ct,onObservation:Ot,chartId:Tt,onTopologyChange:Dt,annotations:Nt,autoPlaceAnnotations:Et,svgAnnotationRules:Lt,legend:$t,legendPosition:It,legendLayout:Wt,legendHoverBehavior:zt,legendClickBehavior:Rt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,title:Yt,foregroundGraphics:Bt,backgroundGraphics:Ht,decay:Xt,pulse:Gt,transition:Vt,animate:qt,staleness:Ut,thresholds:Kt,accessibleTable:Qt=!0,description:Zt,summary:Jt,orbitMode:te,orbitSize:ee,orbitSpeed:ne,orbitRevolution:ie,orbitRevolutionStyle:oe,orbitEccentricity:re,orbitShowRings:se,orbitAnimated:le,customNetworkLayout:ae,layoutConfig:ce,layoutSelection:ue}=n,de=Al.has(O)?wl:kl,fe=o(!0),ye=Jo({sizeProp:vt,responsiveWidth:mt,responsiveHeight:bt,userMargin:xt,marginDefault:de,foregroundGraphics:Bt,backgroundGraphics:Ht,animate:qt,transitionProp:Vt,themeDirtyRef:fe}),{reducedMotionRef:ge,responsiveRef:pe,size:ve,margin:me,adjustedWidth:be,adjustedHeight:xe,resolvedForeground:ke,resolvedBackground:we,transition:Ae,introEnabled:_e,tableId:Se,rafRef:Me,renderFnRef:Pe,scheduleRender:Ce,currentTheme:Oe}=ye,Te=ro(),Ne=co(),Ee=r(()=>kt(T),[T]),Le=r(()=>Array.isArray(D)?kt(D):D,[D]),$e=r(()=>Object.assign(Object.assign({},Er),nt),[nt]),Ie=r(()=>Object.assign(Object.assign({},Lr),ot),[ot]),We=r(()=>{var t;return{chartType:O,nodeIDAccessor:L,sourceAccessor:$,targetAccessor:I,valueAccessor:W,edgeIdAccessor:z,childrenAccessor:R,hierarchySum:j,orientation:F,nodeAlign:Y,nodePaddingRatio:B,nodeWidth:X,iterations:G,forceStrength:V,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Q,treeOrientation:Z,edgeType:J,padding:tt,paddingTop:et,tensionConfig:$e,showParticles:it,particleStyle:Ie,nodeStyle:rt,edgeStyle:st,nodeLabel:yt,showLabels:gt,labelMode:pt,colorBy:lt,colorScheme:at,themeCategorical:null===(t=null==Oe?void 0:Oe.colors)||void 0===t?void 0:t.categorical,themeSemantic:St(Oe),edgeColorBy:ct,edgeOpacity:ut,colorByDepth:dt,nodeSize:ht,nodeSizeRange:ft,decay:Xt,pulse:Gt,transition:Ae,introAnimation:_e,staleness:Ut,thresholds:Kt,orbitMode:te,orbitSize:ee,orbitSpeed:ne,orbitRevolution:ie,orbitRevolutionStyle:oe,orbitEccentricity:re,orbitShowRings:se,orbitAnimated:le,customNetworkLayout:ae,layoutConfig:ce}},[O,L,$,I,W,R,j,F,Y,B,X,G,V,q,U,K,Q,Z,J,tt,et,$e,it,Ie,rt,st,yt,gt,pt,lt,at,ct,ut,dt,ht,ft,Xt,Gt,null==Ae?void 0:Ae.duration,null==Ae?void 0:Ae.easing,_e,Ut,Kt,te,ee,ne,ie,oe,re,se,le,Oe,ae,ce]),ze=ho(We),Re=ho({chartType:O,nodeIDAccessor:L,sourceAccessor:$,targetAccessor:I,valueAccessor:W,childrenAccessor:R,hierarchySum:j,orientation:F,nodeAlign:Y,nodePaddingRatio:B,nodeWidth:X,iterations:G,forceStrength:V,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Q,treeOrientation:Z,edgeType:J,padding:tt,paddingTop:et,tensionConfig:$e,orbitMode:te,orbitSize:ee,orbitEccentricity:re,customNetworkLayout:ae}),je=o(null),Ye=o(0),Be=o(0),Xe=o(!1),Ge=o(null);Ge.current||(Ge.current=new tl(ze));const[Ve,qe]=d(null),[Ue,Ke]=d(0),[Qe,Ze]=d(0),[Je,tn]=d(!1),en=o(null),nn=o(new Map),on=o(0),sn=a(t=>{if("function"==typeof lt)return lt(t)+"";if("string"==typeof lt&&t.data){const e=t.data[lt];if(void 0!==e){if(!nn.current.has(e+"")){const t=Array.isArray(at)?at:he;nn.current.set(e+"",t[on.current++%t.length])}return nn.current.get(e+"")}}if(nn.current.has(t.id))return nn.current.get(t.id);const e=Array.isArray(at)?at:he,n=lt?e[on.current++%e.length]:e[0];return nn.current.set(t.id,n),n},[lt,at]),ln=(null===(l=null==Oe?void 0:Oe.colors)||void 0===l?void 0:l.border)||(null===(c=null==Oe?void 0:Oe.colors)||void 0===c?void 0:c.secondary)||(null===(u=null==Oe?void 0:Oe.colors)||void 0===u?void 0:u.primary)||"#999",an=a(t=>{var e,n;return t?"object"==typeof t?t:null!==(n=null===(e=Ge.current)||void 0===e?void 0:e.nodes.get(t))&&void 0!==n?n:null:null},[]),cn=a(t=>{if("function"==typeof ct)return ct(t);const e=an(t.source),n=an(t.target);return"target"===ct&&n?sn(n):e?sn(e):ln},[ct,sn,ln,an]),un=a(t=>{if("function"==typeof Ie.color){const e=an(t.source);return e?Ie.color(t,e):ln}if(!(null==ot?void 0:ot.colorBy))return cn(t);const e=Ie.colorBy,n=an(t.source),i=an(t.target);return"target"===e&&i?sn(i):n?sn(n):ln},[null==ot?void 0:ot.colorBy,Ie.color,Ie.colorBy,sn,cn,ln,an]),dn=("sankey"===O||!!ae)&&it||!!Gt||null!==(f=null===(h=Ge.current)||void 0===h?void 0:h.isAnimating)&&void 0!==f&&f;s(()=>{var t;null===(t=Ge.current)||void 0===t||t.updateConfig(ze),fe.current=!0,Ce()},[ze,Ce]);const hn=o(null);s(()=>{const t=Ge.current;if(!t)return;const e=null!=ue?ue:null;hn.current!==e&&(hn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):fe.current=!0,Ce())},[ue,Ce]),s(()=>{var t;const e=Ge.current;if(e){e.buildScene([be,xe]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&nn.current.set(n.id,n.style.fill);fe.current=!0,Ce()}},[Oe,be,xe,Ce]);const fn=a(()=>{var t;const e=Ge.current;if(!e)return;e.runLayout([be,xe]),e.buildScene([be,xe]),fe.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&nn.current.set(n.id,n.style.fill);const n=Array.isArray(at)?at:he,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];nn.current.has(e.id)||nn.current.set(e.id,n[t%n.length])}if(on.current=i.length,Ke(e.layoutVersion),Dt){const{nodes:t,edges:n}=e.getLayoutData();Dt(t,n)}},[be,xe,Dt,at]),yn=a(t=>{if(null==t||"object"!=typeof t)return;const e=Ge.current;e&&(e.ingestEdge(t)&&fn(),Ce())},[fn,Ce]),gn=a(t=>{const e=Ge.current;if(!e)return;let n=!1;for(const i of t)null!=i&&"object"==typeof i&&e.ingestEdge(i)&&(n=!0);n&&fn(),Ce()},[fn,Ce]),pn=a(()=>{var t,e,n;null===(t=Ge.current)||void 0===t||t.clear(),nn.current.clear(),on.current=0,Ke(null!==(n=null===(e=Ge.current)||void 0===e?void 0:e.layoutVersion)&&void 0!==n?n:0),qe(null),en.current=null,fe.current=!0,Ce()},[Ce]),vn=a(()=>{const t=Ge.current;t&&(t.tension+=999,fn(),Ce())},[fn,Ce]);g(i,()=>({push:yn,pushMany:gn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Ge.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=en.current)||void 0===i?void 0:i.data)?"function"==typeof L?L(en.current.data):en.current.data[L]:void 0;en.current&&"node"===en.current.nodeOrEdge&&e===t&&(en.current=null,qe(null)),nn.current.delete(t),fn(),fe.current=!0,Ce()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ge.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(en.current&&"edge"===en.current.nodeOrEdge){const n=en.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!z||!n||("function"==typeof z?z:t=>null==t?void 0:t[z])(n)===t,i&&(en.current=null,qe(null))}fn(),fe.current=!0,Ce()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ge.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(fe.current=!0,Ce()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Ge.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(fn(),fe.current=!0,Ce()),r},clear:pn,getTopology:()=>{var t,e;return null!==(e=null===(t=Ge.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Ge.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:vn,getTension:()=>{var t,e;return null!==(e=null===(t=Ge.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[yn,gn,pn,vn,fn,Ce]);const mn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(O),bn=mn?N||(Array.isArray(D)?void 0:D):void 0;s(()=>{var t;const e=Ge.current;if(e)if(mn&&bn)e.ingestHierarchy(bn,[be,xe]),e.buildScene([be,xe]),fe.current=!0,Ce();else{const n=Ee,i=Array.isArray(Le)?Le:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[be,xe]),e.buildScene([be,xe]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&nn.current.set(n.id,n.style.fill+"");const o=Array.isArray(at)?at:he,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];nn.current.has(e.id)||nn.current.set(e.id,o[t%o.length])}on.current=r.length,fe.current=!0,Ce()}},[Ee,Le,N,bn,mn,be,xe,Re,Ce,at]),s(()=>{E&&E.length>0&&gn(E)},[]);const xn=a(t=>{if(Pt&&Pt(t),Ot){const e=Date.now();Ot(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Tt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Tt})}},[Pt,Ot,Tt]),kn=a(t=>{if(Ct&&Ct(t),Ot){const e=Date.now();Ot(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Tt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Tt})}},[Ct,Ot,Tt]),{hoverHandlerRef:wn,hoverLeaveRef:Mn,onPointerMove:Cn,onPointerLeave:On}=ye,Tn=()=>{var t,e;return!ae||null!==(e=null===(t=Ge.current)||void 0===t?void 0:t.hasCustomRestyle)&&void 0!==e&&e};wn.current=t=>{if(!_t)return;const e=Tn(),n=je.current;if(!n)return;const i=n.getBoundingClientRect(),o=t.clientX-i.left-me.left,r=t.clientY-i.top-me.top;if(0>o||o>be||0>r||r>xe)return void(en.current&&(en.current=null,qe(null),xn&&(xn(null),e&&(fe.current=!0)),e&&Ce()));const s=Ge.current;if(!s)return;const l=ol(s.sceneNodes,s.sceneEdges,o,r,30,s.nodeQuadtree,s.maxNodeRadius);if(!l)return void(en.current&&(en.current=null,qe(null),xn&&(xn(null),e&&(fe.current=!0)),e&&Ce()));const a=Bo(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});en.current=a,qe(a),xn&&(xn(a),e&&(fe.current=!0)),e&&Ce()},Mn.current=()=>{if(en.current){const t=Tn();en.current=null,qe(null),xn&&(xn(null),t&&(fe.current=!0)),t&&Ce()}};const Dn=o(()=>{});Dn.current=t=>{if(!Ct&&!Ot)return;const e=je.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-me.left,o=t.clientY-n.top-me.top;if(0>i||i>be||0>o||o>xe)return;const r=Ge.current;if(!r)return;const s=ol(r.sceneNodes,r.sceneEdges,i,o,30,r.nodeQuadtree,r.maxNodeRadius);kn(s?Bo(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const Nn=a(t=>Dn.current(t),[]),En=o(-1),In=o(null),Wn=o(-1),zn=a(t=>{var e;const n=Ge.current;if(!n)return;const i=function(t){var e,n,i,o,r,s,l,a;const c=[];for(const u of t)if("circle"===u.type&&null!=u.cx){if(0>=u.r)continue;c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(n=null===(e=u.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"})}else if("rect"===u.type&&null!=u.x){if(0>=u.w||0>=u.h)continue;c.push({x:u.x+u.w/2,y:u.y+u.h/2,datum:u.datum,shape:"rect",w:u.w,h:u.h,group:null!==(o=null===(i=u.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"})}else if("arc"===u.type&&null!=u.cx)c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(s=null===(r=u.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});else if("symbol"===u.type&&null!=u.cx){if(0>=u.size)continue;c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(a=null===(l=u.datum)||void 0===l?void 0:l.id)&&void 0!==a?a:"_default"})}return c.sort((t,e)=>t.x-e.x||t.y-e.y),c}(n.sceneNodes);if(0===i.length)return;const o=An(i),r=En.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),En.current=0,Wn.current=-1;const e=o.flat[0];In.current={shape:e.shape,w:e.w,h:e.h};const n=Bo(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return en.current=n,qe(n),xn&&(xn(n),fe.current=!0),void Ce()}const s=_n(o,r),l=function(t,e,n,i,o){var r,s,l;const a=n.flat[e.flatIndex];if(!a)return Sn(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(s=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const s=t.flat[r];if(s===e)continue;const l=s.x-e.x,a=s.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(l)}if(!c)continue;const u=l*l+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==s?s:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n;const i=t+"",o=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,r=Pn(e.source),s=Pn(e.target),l=null!=r,a=null!=s;l&&r+""===i&&a?o.push(s+""):a&&s+""===i&&l&&o.push(r+"")}return o}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(l=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==l?l:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=Sn(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,s,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],Wn);if(null===l)return;if(t.preventDefault(),0>l)return En.current=-1,In.current=null,Wn.current=-1,en.current=null,qe(null),xn&&(xn(null),fe.current=!0),void Ce();En.current=l;const a=o.flat[l];In.current={shape:a.shape,w:a.w,h:a.h};const c={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};en.current=c,qe(c),xn&&(xn(c),fe.current=!0),Ce()},[xn,Ce]),Rn=a(t=>{En.current=-1,In.current=null,Cn(t)},[Cn]);Pe.current=()=>{var t,e,n,i,o,r,s;Me.current=0;const l=je.current;if(!l)return;const a=l.getContext("2d");if(!a)return;const c=Ge.current;if(!c)return;const u=performance.now(),d=Ye.current?Math.min((u-Ye.current)/1e3,.1):.016;Ye.current=u;const h=c.advanceTransition(ge.current?u+1e6:u),f=!ge.current&&h,y=!ge.current&&c.tickAnimation([be,xe],d);(h||fe.current||y)&&c.buildScene([be,xe]);const g=er();if(!tr(l,ve,me,g))return;if(a.clearRect(-me.left,-me.top,ve[0],ve[1]),At){const t=rn(a,At);t&&(a.fillStyle=t,a.fillRect(0,0,be,xe))}Xt&&c.applyDecay(),Gt&&c.applyPulse(u),Kt&&c.applyThresholds(u),!1!==qt&&c.applyTopologyDiff(u);const p=null!==(t=null==Ut?void 0:Ut.threshold)&&void 0!==t?t:5e3,v=Ut&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Ut?void 0:Ut.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":vl(t,n);break;case"line":ml(t,n);break;case"ribbon":bl(t,n);break;case"curved":xl(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),sr(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),lr(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),function(t,e){var n,i,o;const r=t.globalAlpha;for(const s of e){if("symbol"!==s.type)continue;const e=s;if(0>=e.size)continue;const l=gl(e);if(!l)continue;t.save(),t.translate(e.cx,e.cy),e.rotation&&t.rotate(e.rotation);const a=null!==(n=e.style.opacity)&&void 0!==n?n:1;e.style.fill&&(t.globalAlpha=r*a*(null!==(i=e.style.fillOpacity)&&void 0!==i?i:1),t.fillStyle="string"==typeof e.style.fill&&rn(t,e.style.fill)||e.style.fill,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=r*a,t.strokeStyle=rn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:1,t.stroke(l)),t.restore()}}(a,c.sceneNodes),it&&c.particlePool&&!v){const t=c.edgesArray;if(t.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:Lr.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:Lr.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=l)continue;const r=o.value*s*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,d,Ie);const e=.5*(null!==(n=Ie.speedMultiplier)&&void 0!==n?n:1);let i;if(Ie.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,s;const l=null!==(r=i.radius)&&void 0!==r?r:Lr.radius,a=null!==(s=i.opacity)&&void 0!==s?s:Lr.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(!a)continue;let c;c="string"==typeof i.color&&"inherit"!==i.color?i.color:o(a),t.fillStyle=rn(t,c)||c,t.beginPath(),t.arc(s.x,s.y,l,0,2*Math.PI),t.fill()}t.globalAlpha=1}(a,c.particlePool,t,Ie,un)}}v&&(a.globalAlpha=1);const m=fe.current;if(fe.current=!1,m||f||y){const t=je.current;t&&t.setAttribute("aria-label",xo(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}const b=m||f||y||Xe.current;b&&u-Be.current>=33?(Ze(t=>t+1),Be.current=u,Xe.current=!1):Xe.current=!!b,(dn||f||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||!1!==qt&&c.hasActiveTopologyDiff||Xe.current)&&(Me.current=requestAnimationFrame(()=>Pe.current()))},uo({hydrated:Te,wasHydratingFromSSR:Ne,storeRef:Ge,dirtyRef:fe,renderFnRef:Pe}),s(()=>{fe.current=!0,Ce()},[O,be,xe,At,Ce]),Ln(Ut,Ge,fe,Ce,Je,tn);const jn=_t&&Ve?t(Ko,{x:Ve.x,y:Ve.y,containerWidth:be,containerHeight:xe,margin:me,className:"stream-network-tooltip",zIndex:2,children:Mt?Mt(Ve):t(Ml,{data:Ve})}):null;if(io||!Te&&Ne){const n=Ge.current;if(n){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(O),e=t?N||(Array.isArray(D)?void 0:D):void 0;if(t&&e)n.ingestHierarchy(e,[be,xe]),n.buildScene([be,xe]);else{const t=Ee,e=Array.isArray(Le)?Le:[];(t.length>0||e.length>0)&&(n.ingestBounded(t,e,[be,xe]),n.buildScene([be,xe]))}}const i=null!==(y=null==n?void 0:n.sceneNodes)&&void 0!==y?y:[],o=null!==(p=null==n?void 0:n.sceneEdges)&&void 0!==p?p:[],r=null!==(v=null==n?void 0:n.labels)&&void 0!==v?v:[];return e("div",{ref:pe,className:"stream-network-frame"+(wt?" "+wt:""),role:"img","aria-label":Zt||("string"==typeof Yt?Yt:"Network chart"),style:{position:"relative",width:mt?"100%":ve[0],height:bt?"100%":ve[1]},children:[t(Wo,{summary:Jt}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:ve[0],height:ve[1],style:{position:"absolute",left:0,top:0},children:[we&&t("g",{transform:`translate(${me.left},${me.top})`,children:we}),e("g",{transform:`translate(${me.left},${me.top})`,children:[At&&t("rect",{x:0,y:0,width:be,height:xe,fill:At}),o.map((e,n)=>function(e,n){switch(e.type){case"line":return t("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t("path",{d:i.pathD,fill:no(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t("path",{d:i.pathD,fill:no(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t("path",{d:i.pathD,fill:no(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),i.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=H().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(eo)||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}case"symbol":{const i=e,o=De(i.symbolType,i.size,i.path);return t("path",{d:o,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?no(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-symbol-"+n)}default:return null}}(e,n)).filter(Boolean),r.map((e,n)=>function(e,n){return t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t(dl,{width:be,height:xe,totalWidth:ve[0],totalHeight:ve[1],margin:me,labels:r,sceneNodes:i,title:Yt,legend:$t,legendPosition:It,legendLayout:Wt,legendHoverBehavior:zt,legendClickBehavior:Rt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,foregroundGraphics:Fe(ke,He(null===(m=Ge.current)||void 0===m?void 0:m.customLayoutOverlays,null!=ue?ue:null)),annotations:Nt,autoPlaceAnnotations:Et,svgAnnotationRules:Lt,annotationFrame:0}),t(fl,{marks:null==n?void 0:n.customLayoutHtmlMarks,margin:me,selection:null!=ue?ue:null})]})}const Fn=Ge.current;return e("div",{ref:pe,className:"stream-network-frame"+(wt?" "+wt:""),role:"group","aria-label":Zt||("string"==typeof Yt?Yt:"Network chart"),tabIndex:0,style:{position:"relative",width:mt?"100%":ve[0],height:bt?"100%":ve[1],overflow:"visible"},onKeyDown:zn,children:[Qt&&t(zo,{tableId:Se}),Qt&&t(Io,{nodes:null!==(b=null==Fn?void 0:Fn.sceneNodes)&&void 0!==b?b:[],edges:null!==(x=null==Fn?void 0:Fn.sceneEdges)&&void 0!==x?x:[],chartType:"Network chart",tableId:Se,chartTitle:"string"==typeof Yt?Yt:void 0}),t(Wo,{summary:Jt}),t(Ro,{hoverPoint:Ve}),e("div",{role:"img","aria-label":Zt||("string"==typeof Yt?Yt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:_t?Rn:void 0,onMouseLeave:_t?On:void 0,onClick:Ct||Ot?Nn:void 0,children:[we&&t("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ve[0],height:ve[1],pointerEvents:"none",overflow:"visible"},children:t("g",{transform:`translate(${me.left},${me.top})`,children:we})}),t("canvas",{ref:je,"aria-label":xo(null!==(w=null===(k=null==Fn?void 0:Fn.sceneNodes)||void 0===k?void 0:k.length)&&void 0!==w?w:0,null!==(_=null===(A=null==Fn?void 0:Fn.sceneEdges)||void 0===A?void 0:A.length)&&void 0!==_?_:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t(dl,{width:be,height:xe,totalWidth:ve[0],totalHeight:ve[1],margin:me,labels:(null==Fn?void 0:Fn.labels)||[],sceneNodes:null==Fn?void 0:Fn.sceneNodes,title:Yt,legend:$t,legendPosition:It,legendLayout:Wt,legendHoverBehavior:zt,legendClickBehavior:Rt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,foregroundGraphics:Fe(ke,He(null===(S=Ge.current)||void 0===S?void 0:S.customLayoutOverlays,null!=ue?ue:null)),annotations:Nt,autoPlaceAnnotations:Et,svgAnnotationRules:Lt,annotationFrame:Qe}),t(fl,{marks:null==Fn?void 0:Fn.customLayoutHtmlMarks,margin:me,selection:null!=ue?ue:null}),t(Fo,{active:En.current>=0,hoverPoint:Ve,margin:me,size:ve,shape:null===(M=In.current)||void 0===M?void 0:M.shape,width:null===(P=In.current)||void 0===P?void 0:P.w,height:null===(C=In.current)||void 0===C?void 0:C.h}),jn,(null==Ut?void 0:Ut.showBadge)&&t($n,{isStale:Je,position:Ut.badgePosition})]})]})});Cl.displayName="StreamNetworkFrame";class Ol{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(t){if(!Number.isFinite(t))return;this._count+=1;const e=t-this._mean;this._mean+=e/this._count,this._m2+=e*(t-this._mean),this._min>t&&(this._min=t),t>this._max&&(this._max=t)}merge(t){if(0===t._count)return;if(0===this._count)return this._count=t._count,this._mean=t._mean,this._m2=t._m2,this._min=t._min,void(this._max=t._max);const e=this._count+t._count,n=t._mean-this._mean;this._mean+=n*t._count/e,this._m2+=t._m2+n*n*this._count*t._count/e,this._count=e,this._min>t._min&&(this._min=t._min),t._max>this._max&&(this._max=t._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new Ol;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}}class Tl{constructor(t){var e,n,i;this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=null!==(e=t.window)&&void 0!==e?e:"tumbling",this.size=t.size;const o=null!==(n=t.hop)&&void 0!==n?n:t.size;this.hop=o>0&&t.size>=o?o:t.size,this.gap=null!==(i=t.gap)&&void 0!==i?i:t.size,this.retain=null!=t.retain&&t.retain>0?t.retain:1/0}push(t,e){Number.isFinite(t)&&Number.isFinite(e)&&(t>this.latest&&(this.latest=t),"session"===this.type?this.pushSession(t,e):this.pushFixed(t,e),this.prune())}pushFixed(t,e){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(t/this.size)*this.size,e);const n=this.hop,i=Math.floor(t/n);for(let o=Math.floor((t-this.size)/n)+1;i>=o;o++)this.bump(o*n,e)}bump(t,e){let n=this.windows.get(t);n||(n=new Ol,this.windows.set(t,n)),n.push(e)}pushSession(t,e){const n=this.gap,i=new Ol;i.push(e);let o=t,r=t;const s=[],l={start:o,end:r,stats:i};for(const e of this.sessions)t-n>e.end||e.start>t+n?s.push(e):(l.stats.merge(e.stats),o>e.start&&(o=e.start),e.end>r&&(r=e.end));l.start=o,l.end=r,s.push(l),s.sort((t,e)=>t.start-e.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const t=[...this.windows.keys()].sort((t,e)=>t-e),e=t.length-this.retain;for(let n=0;e>n;n++)this.windows.delete(t[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const t=[];for(const[e,n]of this.windows){const i=e+this.size;t.push(this.row(e,i,n,i>this.latest))}return t.sort((t,e)=>t.start-e.start),t}emitSessions(){return this.sessions.map(t=>this.row(t.start,t.end,t.stats,this.gap>this.latest-t.end))}row(t,e,n,i){return{start:t,end:e,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:i}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}}function Dl(t,e){switch(e){case"sum":return t.sum;case"min":return t.min;case"max":return t.max;case"count":return t.count;default:return t.mean}}function Nl(t,e,n,i=1){if("none"===e)return null;if("minmax"===e)return[t.min,t.max];const o=Dl(t,n),r=t.stddev*i;return[o-r,o+r]}const El={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Ll=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function $l(t){if("number"==typeof t)return Number.isFinite(t)&&t>0?t:null;if("string"!=typeof t)return null;const e=t.trim();if(""===e)return null;Ll.lastIndex=0;let n,i=0,o=0;for(;null!==(n=Ll.exec(e));){const t=parseFloat(n[1]),e=El[n[2]];if(null==e||!Number.isFinite(t))return null;i+=t*e,o+=n[0].length}return o!==e.length?null:i>0?i:null}class Il{constructor(t){var e;this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=t.lateness>0?t.lateness:0,this.getTime=t.getTime,this.latePolicy=null!==(e=t.latePolicy)&&void 0!==e?e:"drop"}push(t){const e=this.getTime(t);if(!Number.isFinite(e))return{released:[t],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>e?(this._lateCount+=1,n.push(t),"drop"===this.latePolicy?{released:[],late:n}:{released:[t],late:n}):(e>this._watermark&&(this._watermark=e),this.held.push(t),{released:this.drain(),late:n})}drain(){const t=this._watermark-this.lateness;if(0===this.held.length)return[];const e=[],n=[];for(const i of this.held)this.getTime(i)>t?n.push(i):e.push(i);return this.held=n,e.sort((t,e)=>this.getTime(t)-this.getTime(e)),e}flush(){const t=this.held;return this.held=[],t.sort((t,e)=>this.getTime(t)-this.getTime(e)),t}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}}function Wl(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function zl(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function Rl(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}const[jl,Fl]=At(t=>({selections:new Map,setClause(e,n){t(t=>{const i=t.selections.get(e),o=null==i?void 0:i.clauses.get(n.clientId);if(o&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,i]of n){const n=e.fields[t];if(!n||!Rl(i,n))return!1}return!0}(o,n))return{};const r=new Map(t.selections),s=zl(r,e),l=new Map(s.clauses);return l.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},s),{clauses:l})),{selections:r}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i||!i.clauses.has(n))return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=t.selections.get(e);if((null==i?void 0:i.resolution)===n)return{};const o=new Map(t.selections),r=zl(o,e);return o.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const i=new Map(t.selections);return i.set(e,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:i}})}})),[Yl,Bl]=At(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Hl(t){const e=y(),n=t.clientId||e,{name:i}=t,o=Fl(t=>t.selections.get(i)),s=Fl(t=>t.setClause),l=Fl(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Wl(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:a(t=>{const e={};let o=!1;for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)},o=!0;o&&s(i,{clientId:n,type:"point",fields:e})},[n,i,s]),selectInterval:a(t=>{const e={};let o=!1;for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i},o=!0;o&&s(i,{clientId:n,type:"interval",fields:e})},[n,i,s]),clear:a(()=>{l(i,n)},[l,i,n]),clientId:n}}function Xl(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function Gl(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function Vl(t,e,n){var i;const o=null!==(i=t.xValue)&&void 0!==i?i:null==e?void 0:e[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function ql(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function Ul({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:l,chartId:c,onClick:u,hoverHighlight:h,colorByField:f}){const g=y(),p=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),v="series"===(null==p?void 0:p.mode)?[p.seriesField||f||n[0]].filter(t=>!!t):(null==p?void 0:p.fields)||n||[],m=Hl({name:(null==t?void 0:t.name)||"__unused__"}),b=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:s}=Hl({name:e});return{onHover:a(t=>{if(!t)return void s();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Gl(e)&&r(e)},[n,r,s,e]),predicate:i,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:v}),x=Bl(t=>t.pushObservation),k=t?{isActive:m.isActive,predicate:m.predicate}:null,[w,A]=d(null),_=f||n[0],S=r(()=>{if(!h||null==w||!_)return null;const t=w,e=_;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,w,_]),M=a(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const n=Vl(t,e,p.xField);null!=n&&function(t,e,n){const i=Li.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Li={positions:new Map(Li.positions).set(t,{xValue:e,sourceId:n})},Ii())}(p.name||"hover",n,g)}"x-position"!==(null==p?void 0:p.mode)&&b.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&Wi(p.name||"hover",g),"x-position"!==(null==p?void 0:p.mode)&&b.onHover(null);if(h&&_)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[_];A(null!=n?n+"":null)}else A(null);if(o||x){const e={timestamp:Date.now(),chartType:l||"unknown",chartId:c};if(t){const r=ql(t),s=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),x&&x(t)}}},[e,b,p,g,o,l,c,x,h,_]),P=a(t=>{var e,n,i,r;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=Vl(t,e,p.xField);null!=n&&function(t,e,n){const i=Li.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Li.positions);return e.delete(t),Li={positions:e},Ii(),!1}Li={positions:new Map(Li.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Ii()}(p.name||"hover",n,g)}if(t&&u){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),u(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||x){const e={timestamp:Date.now(),chartType:l||"unknown",chartId:c};if(t){const n=ql(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),x&&x(t)}}},[u,o,x,l,c,p,g]);return s(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{zi(t,g),Wi(t,g)}},[null==p?void 0:p.mode,null==p?void 0:p.name,g]),{activeSelectionHook:k,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:P,crosshairSourceId:g}}const Kl={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Ql(t,e,n){var i,o,r,s,l,a,c;const u=Kl[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=e.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:Zl(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function Zl(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}const Jl={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ta={opacity:.7,marginRight:4};function ea(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function na(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function ia(t={}){const{timeAccessor:n,valueAccessor:i,xLabel:o="x",yLabel:r="y"}=t;return t=>{var s;const l=null!==(s=null==t?void 0:t.data)&&void 0!==s?s:null,a=ea(l,n,"time"),c=ea(l,i,"value");return e("div",{className:"semiotic-tooltip",style:Jl,children:[e("div",{children:[e("span",{style:ta,children:[o,":"]}),na(a)]}),e("div",{children:[e("span",{style:ta,children:[r,":"]}),na(c)]})]})}}"undefined"!=typeof process&&process;const oa={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},ra={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function sa(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},oa),{width:n,height:i}),children:o||"No data available"}):null}function la(e,n,i,o){if(!e)return null;if(!1===o)return null;if(null!=o)return t("div",{style:{width:n,height:i,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(i/40)),s=Math.max(8,Math.floor(i/(3*r))),l=Math.max(6,Math.floor(i/(2.5*r))),a=Math.floor((i-(r*(s+l)-l))/2);return t("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,i)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ra),{position:"absolute",top:a+i*(s+l),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:s,opacity:.5+i%2*.2})},i))})}function aa(t,e){var n;return null!=t?t:Math.max(null!==(n=null==e?void 0:e.length)&&void 0!==n?n:0,200)}const ca="time",ua="value",da="__aggLower",ha="__aggUpper",fa="__aggPartial",ya="count",ga="__aggStart",pa="__aggEnd";function va(t,e){var n,i,o;const r=null!==(n=e.stat)&&void 0!==n?n:"mean",s=null!==(i=e.band)&&void 0!==i?i:"none",l=null!==(o=e.sigma)&&void 0!==o?o:1;return t.emit().map(t=>{const e={[ca]:(t.start+t.end)/2,[ua]:Dl(t,r),[ya]:t.count,[fa]:t.partial,[ga]:t.start,[pa]:t.end},n=Nl(t,s,r,l);return n&&(e[da]=n[0],e[ha]=n[1]),e})}function ma(t,e,n){const i="function"==typeof e?e(t):t[null!=e?e:n];if(null==i)return null;if(i instanceof Date)return i.getTime();const o=Number(i);return Number.isFinite(o)?o:null}const ba=f(function(e,n){var i,r,l,c,u,h,f,y,p,v,m;const b=Ql(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(c=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:x,margin:k,className:w,arrowOfTime:A="right",windowMode:_="sliding",windowSize:S,data:M,timeAccessor:P,valueAccessor:C,timeExtent:O,valueExtent:T,extentPadding:D,stroke:N="#007bff",strokeWidth:E=2,strokeDasharray:L,opacity:$,background:I,tooltipContent:W,tooltip:z,onHover:R,annotations:j,autoPlaceAnnotations:F,svgAnnotationRules:Y,tickFormatTime:B,tickFormatValue:H,decay:X,pulse:G,staleness:V,transition:q,linkedHover:U,selection:K,onObservation:Q,chartId:Z,loading:J,loadingContent:tt,emptyContent:et,emphasis:nt,legendPosition:it,aggregate:ot,eventTime:rt}=e,st=b.showAxes,lt=b.enableHover,at=null!=k?k:b.marginDefaults,ct=null!=x?x:[b.width,b.height],ut=null!==(u=null!=W?W:z)&&void 0!==u?u:ia({timeAccessor:P,valueAccessor:C}),dt=o(null),{customHoverBehavior:ht}=Ul({selection:K,linkedHover:U,unwrapData:!0,onObservation:Q,chartType:"RealtimeLineChart",chartId:Z}),ft=a(t=>{R&&R(t),ht(t)},[R,ht]),yt=null!=ot,[gt,pt]=d([]),vt=o(null),mt=o(ot);mt.current=ot;const bt=o(yt);bt.current=yt;const xt=o(gt);xt.current=gt;const kt=o({timeAccessor:P,valueAccessor:C});kt.current={timeAccessor:P,valueAccessor:C};const wt=yt?[null!==(h=ot.window)&&void 0!==h?h:"tumbling",ot.size,null!==(f=ot.hop)&&void 0!==f?f:"",null!==(y=ot.gap)&&void 0!==y?y:"",null!==(p=ot.retain)&&void 0!==p?p:""].join("|"):"";s(()=>{if(!yt)return void(vt.current=null);const t=mt.current,e=function(t){var e,n;const i=null!==(e=t.window)&&void 0!==e?e:"tumbling",o=$l("session"===i&&null!==(n=t.gap)&&void 0!==n?n:t.size);if(null==o)return null;const r=null!=t.hop?$l(t.hop):void 0,s=null!=t.gap?$l(t.gap):void 0;return new Tl({window:i,size:o,hop:null!=r?r:void 0,gap:null!=s?s:void 0,retain:t.retain})}(t);if(vt.current=e,e&&M){const{timeAccessor:t,valueAccessor:n}=kt.current;for(const i of M){const o=ma(i,t,"time"),r=ma(i,n,"value");null!=o&&null!=r&&e.push(o,r)}}pt(e?va(e,t):[])},[wt,yt,M]),s(()=>{yt&&vt.current&&pt(va(vt.current,mt.current))},[null==ot?void 0:ot.stat,null==ot?void 0:ot.band,null==ot?void 0:ot.sigma]);const At=a(t=>{const e=vt.current,n=mt.current;if(!e||!n)return;const{timeAccessor:i,valueAccessor:o}=kt.current;for(const n of t){const t=ma(n,i,"time"),r=ma(n,o,"value");null!=t&&null!=r&&e.push(t,r)}pt(va(e,n))},[]),_t=null!=rt,St=o(null),Mt=o(rt);Mt.current=rt;const Pt=o(_t);Pt.current=_t;const Ct=o(Q);Ct.current=Q;const Ot=o(Z);Ot.current=Z;const Tt=_t?`${rt.lateness}|${null!==(v=rt.latePolicy)&&void 0!==v?v:"drop"}`:"";s(()=>{St.current=_t?function(t){var e;const n=$l(t.lateness);return null==n?null:new Il({lateness:n,getTime:t=>{var e;return null!==(e=ma(t,kt.current.timeAccessor,"time"))&&void 0!==e?e:NaN},latePolicy:null!==(e=t.latePolicy)&&void 0!==e?e:"drop"})}(Mt.current):null},[Tt,_t]);const Dt=a(t=>{var e;0!==t.length&&(bt.current?At(t):null===(e=dt.current)||void 0===e||e.pushMany(t))},[At]),Nt=a(t=>{var e,n,i;const o=St.current;if(!Pt.current||!o)return void Dt(t);const r=[];for(const s of t){const t=o.push(s);if(t.released.length&&r.push(...t.released),t.late.length){const r=Ct.current;if(r){const{timeAccessor:s}=kt.current,l=null!==(n=null===(e=Mt.current)||void 0===e?void 0:e.latePolicy)&&void 0!==n?n:"drop";for(const e of t.late)r({type:"late-data",datum:e,eventTime:null!==(i=ma(e,s,"time"))&&void 0!==i?i:NaN,watermark:o.watermark,policy:l,lateCount:o.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:Ot.current})}}}Dt(r)},[Dt]);g(n,()=>({push:t=>Nt([t]),pushMany:t=>Nt(t),remove:t=>{var e,n;return bt.current?[]:null!==(n=null===(e=dt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return bt.current?[]:null!==(i=null===(n=dt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t,e,n;null===(t=St.current)||void 0===t||t.clear(),bt.current?(null===(e=vt.current)||void 0===e||e.clear(),pt([])):null===(n=dt.current)||void 0===n||n.clear()},getData:()=>{var t,e;return bt.current?xt.current:null!==(e=null===(t=dt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=dt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[Nt]);const Et=la(J,ct[0],ct[1],tt),Lt=Et?null:sa(yt?void 0:M,ct[0],ct[1],et),$t={stroke:N,strokeWidth:E,strokeDasharray:L};null!=$&&($t.opacity=$);const It=aa(S,M),Wt=nt?`${w||""} semiotic-emphasis-${nt}`.trim():w,zt=yt?gt:M,Rt=yt?ca:P,jt=yt?ua:C,Ft=yt?"growing":_,Yt=null!==(m=null==ot?void 0:ot.retain)&&void 0!==m?m:Math.max(gt.length,600),Bt=yt?Math.max(1,Yt):It,Ht=yt&&ot&&function(t){var e;return"none"!==(null!==(e=t.band)&&void 0!==e?e:"none")}(ot)?{y0Accessor:da,y1Accessor:ha,perSeries:!1}:void 0;return Et||Lt||t(Nr,{ref:dt,chartType:"line",runtimeMode:"streaming",size:ct,margin:at,className:Wt,arrowOfTime:A,windowMode:Ft,windowSize:Bt,data:zt,timeAccessor:Rt,valueAccessor:jt,xExtent:O,yExtent:T,extentPadding:D,band:Ht,lineStyle:$t,showAxes:st,background:I,hoverAnnotation:lt,tooltipContent:ut,customHoverBehavior:ft,annotations:j,autoPlaceAnnotations:F,svgAnnotationRules:Y,tickFormatTime:B,tickFormatValue:H,decay:X,pulse:G,staleness:V,transition:q,pointIdAccessor:e.pointIdAccessor,legendPosition:it})});function xa(t,e,n){const i="function"==typeof e?e(t):t[null!=e?e:n];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const o=Number(i);return Number.isFinite(o)?o:null}ba.displayName="RealtimeLineChart";const ka=f(function(n,i){var s,l,c,u,d;const h=Ql(n.mode,{width:null!==(l=null===(s=n.size)||void 0===s?void 0:s[0])&&void 0!==l?l:n.width,height:null!==(u=null===(c=n.size)||void 0===c?void 0:c[1])&&void 0!==u?u:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:f,size:y,margin:p,className:v,arrowOfTime:m="right",windowMode:b="sliding",windowSize:x,data:k,timeAccessor:w,valueAccessor:A,direction:_="up",timeExtent:S,valueExtent:M,extentPadding:P,categoryAccessor:C,colors:O,fill:T,stroke:D,strokeWidth:N,opacity:E,gap:L,background:$,tooltipContent:I,tooltip:W,onHover:z,annotations:R,autoPlaceAnnotations:j,svgAnnotationRules:F,tickFormatTime:Y,tickFormatValue:B,linkedHover:H,selection:X,decay:G,pulse:V,staleness:q,transition:U,onObservation:K,chartId:Q,loading:Z,loadingContent:J,emptyContent:tt,emphasis:et,legendPosition:nt,brush:it,onBrush:ot,linkedBrush:rt}=n,st=h.showAxes,lt=h.enableHover,at=null!=p?p:h.marginDefaults,ct=null!=y?y:[h.width,h.height],ut=null!==(d=null!=I?I:W)&&void 0!==d?d:function(n={}){const{timeAccessor:i,valueAccessor:o}=n;return n=>{var r;const s=null!==(r=null==n?void 0:n.data)&&void 0!==r?r:null;if(null==(null==s?void 0:s.binStart)||null==(null==s?void 0:s.binEnd)){const n=ea(s,i,"time"),r=ea(s,o,"value");return e("div",{className:"semiotic-tooltip",style:Jl,children:[e("div",{children:[t("span",{style:ta,children:"x:"}),na(n)]}),e("div",{children:[t("span",{style:ta,children:"y:"}),na(r)]})]})}return e("div",{className:"semiotic-tooltip",style:Jl,children:[e("div",{children:[t("span",{style:ta,children:"range:"}),na(s.binStart),"–",na(s.binEnd)]}),null!=s.total&&e("div",{children:[t("span",{style:ta,children:"count:"}),na(s.total)]}),null!=s.category&&e("div",{children:[t("span",{style:ta,children:"category:"}),na(s.category)]})]})}}({timeAccessor:w,valueAccessor:A}),dt=o(null),{customHoverBehavior:ht}=Ul({selection:X,linkedHover:H,unwrapData:!0,onObservation:K,chartType:"RealtimeHistogram",chartId:Q}),ft=a(t=>{z&&z(t),ht(t)},[z,ht]),yt=!0===it?{dimension:"x",snap:"bin"}:"x"===it?{dimension:"x"}:"object"==typeof it?it:void 0,gt=(pt=rt)?"string"==typeof pt?{name:pt}:pt:null;var pt;const vt=function(t){const{name:e,xField:n,yField:i}=t,{predicate:o,isActive:s,selectInterval:l,clear:c}=Hl({name:e}),u=n&&i?"xyBrush":n?"xBrush":"yBrush",d=a(t=>{if(!t)return void c();const e={};"xyBrush"===u&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),i&&(e[i]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&Xl(t)?n&&(e[n]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===u&&Xl(t)&&i&&(e[i]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),Gl(e)&&l(e)},[u,n,i,l,c]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:o,isActive:s,clear:c}}(Object.assign({name:(null==gt?void 0:gt.name)||"__unused_hist_brush__",xField:(null==gt?void 0:gt.xField)||("string"==typeof w?w:"time")},(null==gt?void 0:gt.yField)?{yField:gt.yField}:{})),mt=o(vt.brushInteraction);mt.current=vt.brushInteraction;const bt=a(t=>{if(ot&&ot(t),K&&K(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:Q}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:Q}),gt){const e=mt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[ot,K,Q,gt]);g(i,()=>({push:t=>{var e;return null===(e=dt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=dt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=dt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=dt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=dt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=dt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=dt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const xt=la(Z,ct[0],ct[1],J),kt=xt?null:sa(k,ct[0],ct[1],tt),wt={};null!=T&&(wt.fill=T),null!=D&&(wt.stroke=D),null!=N&&(wt.strokeWidth=N),null!=E&&(wt.opacity=E),null!=L&&(wt.gap=L);const At=et?`${v||""} semiotic-emphasis-${et}`.trim():v,_t=aa(x,k),St=r(()=>"down"!==_?M:function({data:t,valueAccessor:e,timeAccessor:n,binSize:i,valueExtent:o,extentPadding:r}){var s;if(o)return[o[1],o[0]];if(!t||0===t.length)return;const l=new Map;for(const o of t){const t=xa(o,n,"time"),r=xa(o,e,"value");if(null==t||null==r)continue;const a=Math.floor(t/i)*i;l.set(a,(null!==(s=l.get(a))&&void 0!==s?s:0)+r)}let a=0;for(const t of l.values())t>a&&(a=t);return[a>0?a+a*(null!=r?r:.1):1,0]}({data:k,valueAccessor:A,timeAccessor:w,binSize:f,valueExtent:M,extentPadding:P}),[_,k,A,w,f,M,P]);return xt||kt||t(Nr,{ref:dt,chartType:"bar",runtimeMode:"streaming",size:ct,margin:at,className:At,arrowOfTime:m,windowMode:b,windowSize:_t,data:k,timeAccessor:w,valueAccessor:A,xExtent:S,yExtent:St,extentPadding:P,binSize:f,categoryAccessor:C,barColors:O,barStyle:wt,showAxes:st,background:$,hoverAnnotation:lt,tooltipContent:ut,customHoverBehavior:ft,annotations:R,autoPlaceAnnotations:j,svgAnnotationRules:F,tickFormatTime:Y,tickFormatValue:B,decay:G,pulse:V,staleness:q,transition:U,pointIdAccessor:n.pointIdAccessor,legendPosition:nt,brush:yt||(rt?{dimension:"x"}:void 0),onBrush:yt||rt?bt:void 0})});function wa(e){return t(ka,Object.assign({},e,{windowMode:"growing"}))}ka.displayName="RealtimeHistogram",wa.displayName="TemporalHistogram";const Aa=f(function(e,n){var i,r,s,l,c;const u=Ql(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(l=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:p="sliding",windowSize:v,data:m,timeAccessor:b,valueAccessor:x,timeExtent:k,valueExtent:w,extentPadding:A,categoryAccessor:_,colors:S,radius:M,fill:P,opacity:C,stroke:O,strokeWidth:T,background:D,tooltipContent:N,tooltip:E,onHover:L,annotations:$,autoPlaceAnnotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:R,linkedHover:j,selection:F,onObservation:Y,chartId:B,loading:H,loadingContent:X,emptyContent:G,emphasis:V,legendPosition:q}=e,U=u.showAxes,K=u.enableHover,Q=null!=h?h:u.marginDefaults,Z=null!=d?d:[u.width,u.height],J=null!==(c=null!=N?N:E)&&void 0!==c?c:ia({timeAccessor:b,valueAccessor:x}),tt=o(null),{customHoverBehavior:et}=Ul({selection:F,linkedHover:j,unwrapData:!0,onObservation:Y,chartType:"RealtimeSwarmChart",chartId:B}),nt=a(t=>{L&&L(t),et(t)},[L,et]);g(n,()=>({push:t=>{var e;return null===(e=tt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=tt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=tt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=tt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=tt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=tt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=tt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const it=la(H,Z[0],Z[1],X),ot=it?null:sa(m,Z[0],Z[1],G),rt={};null!=M&&(rt.radius=M),null!=P&&(rt.fill=P),null!=C&&(rt.opacity=C),null!=O&&(rt.stroke=O),null!=T&&(rt.strokeWidth=T);const st=V?`${f||""} semiotic-emphasis-${V}`.trim():f,lt=aa(v,m);return it||ot||t(Nr,{ref:tt,chartType:"swarm",runtimeMode:"streaming",size:Z,margin:Q,className:st,arrowOfTime:y,windowMode:p,windowSize:lt,data:m,timeAccessor:b,valueAccessor:x,xExtent:k,yExtent:w,extentPadding:A,categoryAccessor:_,barColors:S,swarmStyle:rt,showAxes:U,background:D,hoverAnnotation:K,tooltipContent:J,customHoverBehavior:nt,annotations:$,autoPlaceAnnotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:R,legendPosition:q,pointIdAccessor:e.pointIdAccessor})});Aa.displayName="RealtimeSwarmChart";const _a=f(function(n,i){var r,s,l,c,u;const d=Ql(n.mode,{width:null!==(s=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==s?s:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:f,className:y,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m,data:b,timeAccessor:x,valueAccessor:k,timeExtent:w,valueExtent:A,extentPadding:_,positiveColor:S,negativeColor:M,connectorStroke:P,connectorWidth:C,gap:O,stroke:T,strokeWidth:D,opacity:N,background:E,tooltipContent:L,tooltip:$,onHover:I,annotations:W,autoPlaceAnnotations:z,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:F,linkedHover:Y,selection:B,onObservation:H,chartId:X,loading:G,loadingContent:V,emptyContent:q,emphasis:U,legendPosition:K}=n,Q=d.showAxes,Z=d.enableHover,J=null!=f?f:d.marginDefaults,tt=null!=h?h:[d.width,d.height],et=null!==(u=null!=L?L:$)&&void 0!==u?u:function(n={}){const{timeAccessor:i,valueAccessor:o}=n;return n=>{var r,s;const l=null!==(r=null==n?void 0:n.data)&&void 0!==r?r:null,a=ea(l,i,"time"),c=null!==(s=null==l?void 0:l.delta)&&void 0!==s?s:ea(l,o,"value"),u=null==l?void 0:l.cumEnd,d="number"==typeof c?0>c?na(c):"+"+na(c):na(c);return e("div",{className:"semiotic-tooltip",style:Jl,children:[e("div",{children:[t("span",{style:ta,children:"x:"}),na(a)]}),e("div",{children:[t("span",{style:ta,children:"Δ:"}),d]}),null!=u&&e("div",{children:[t("span",{style:ta,children:"total:"}),na(u)]})]})}}({timeAccessor:x,valueAccessor:k}),nt=o(null),{customHoverBehavior:it}=Ul({selection:B,linkedHover:Y,unwrapData:!0,onObservation:H,chartType:"RealtimeWaterfallChart",chartId:X}),ot=a(t=>{I&&I(t),it(t)},[I,it]);g(i,()=>({push:t=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=nt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=nt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=nt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=nt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=nt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const rt=la(G,tt[0],tt[1],V),st=rt?null:sa(b,tt[0],tt[1],q),lt={};null!=S&&(lt.positiveColor=S),null!=M&&(lt.negativeColor=M),null!=P&&(lt.connectorStroke=P),null!=C&&(lt.connectorWidth=C),null!=O&&(lt.gap=O),null!=T&&(lt.stroke=T),null!=D&&(lt.strokeWidth=D),null!=N&&(lt.opacity=N);const at=U?`${y||""} semiotic-emphasis-${U}`.trim():y,ct=aa(m,b);return rt||st||t(Nr,{ref:nt,chartType:"waterfall",runtimeMode:"streaming",size:tt,margin:J,className:at,arrowOfTime:p,windowMode:v,windowSize:ct,data:b,timeAccessor:x,valueAccessor:k,xExtent:w,yExtent:A,extentPadding:_,waterfallStyle:lt,showAxes:Q,background:E,hoverAnnotation:Z,tooltipContent:et,customHoverBehavior:ot,annotations:W,autoPlaceAnnotations:z,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:F,legendPosition:K,pointIdAccessor:n.pointIdAccessor})});_a.displayName="RealtimeWaterfallChart";const Sa=f(function(n,i){var r,s,l,c,u;const d=Ql(n.mode,{width:null!==(s=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==s?s:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:f,className:y,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m,data:b,timeAccessor:x,valueAccessor:k,categoryAccessor:w,timeExtent:A,valueExtent:_,extentPadding:S,heatmapXBins:M=20,heatmapYBins:P=20,aggregation:C="count",background:O,tooltipContent:T,tooltip:D,onHover:N,annotations:E,autoPlaceAnnotations:L,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:W,decay:z,pulse:R,staleness:j,linkedHover:F,selection:Y,onObservation:B,chartId:H,loading:X,loadingContent:G,emptyContent:V,emphasis:q,legendPosition:U}=n,K=d.showAxes,Q=d.enableHover,Z=null!=f?f:d.marginDefaults,J=null!=h?h:[d.width,d.height],tt=null!==(u=null!=T?T:D)&&void 0!==u?u:function(n={}){const{timeAccessor:i,valueAccessor:o,xLabel:r="x",yLabel:s="y"}=n;return n=>{var l,a,c,u;const d=null!==(l=null==n?void 0:n.data)&&void 0!==l?l:null,h=null!==(a=null==d?void 0:d.xCenter)&&void 0!==a?a:ea(d,i,"time"),f=null!==(c=null==d?void 0:d.yCenter)&&void 0!==c?c:ea(d,o,"value"),y=null==d?void 0:d.count,g=null==d?void 0:d.sum,p=null==d?void 0:d.value,v=null!==(u=null==d?void 0:d.agg)&&void 0!==u?u:"count";return e("div",{className:"semiotic-tooltip",style:Jl,children:[e("div",{children:[e("span",{style:ta,children:[r,":"]}),na(h)]}),e("div",{children:[e("span",{style:ta,children:[s,":"]}),na(f)]}),null!=y&&e("div",{children:[t("span",{style:ta,children:"count:"}),na(y)]}),"sum"===v&&null!=g&&e("div",{children:[t("span",{style:ta,children:"sum:"}),na(g)]}),"mean"===v&&null!=p&&e("div",{children:[t("span",{style:ta,children:"mean:"}),na(p)]})]})}}({timeAccessor:x,valueAccessor:k}),et=o(null),{customHoverBehavior:nt}=Ul({selection:Y,linkedHover:F,unwrapData:!0,onObservation:B,chartType:"RealtimeHeatmap",chartId:H}),it=a(t=>{N&&N(t),nt(t)},[N,nt]);g(i,()=>({push:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=et.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=et.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=et.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=et.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=et.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const ot=la(X,J[0],J[1],G),rt=ot?null:sa(b,J[0],J[1],V),st=q?`${y||""} semiotic-emphasis-${q}`.trim():y,lt=aa(m,b);return ot||rt||t(Nr,{ref:et,chartType:"heatmap",runtimeMode:"streaming",size:J,margin:Z,className:st,arrowOfTime:p,windowMode:v,windowSize:lt,data:b,timeAccessor:x,valueAccessor:k,categoryAccessor:w,xExtent:A,yExtent:_,extentPadding:S,heatmapXBins:M,heatmapYBins:P,heatmapAggregation:C,showAxes:K,background:O,hoverAnnotation:Q,tooltipContent:tt,customHoverBehavior:it,annotations:E,autoPlaceAnnotations:L,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:W,decay:z,pulse:R,staleness:j,legendPosition:U,pointIdAccessor:n.pointIdAccessor})});Sa.displayName="RealtimeHeatmap";const Ma=Symbol("semiotic.useStreamStatus.wrapped");function Pa(t={}){const{staleThresholdMs:e=5e3,pollIntervalMs:n=1e3}=t,i=o(null),[l,c]=d("idle"),[u,h]=d(null),f=r(()=>{const t={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return t._frame},set current(e){const n=t._frame;if(n&&n!==e&&t._origPush&&t._origPushMany&&(n.push=t._origPush,n.pushMany=t._origPushMany,delete n[Ma]),t._frame=e,!e)return t._origPush=null,void(t._origPushMany=null);if(e[Ma])return;e[Ma]=!0;const i=e.push,o=e.pushMany,r=i.bind(e),s=o.bind(e);t._origPush=i,t._origPushMany=o,e.push=t=>(y(),r(t)),e.pushMany=t=>(t&&t.length>0&&y(),s(t))}}},[]),y=a(()=>{const t="undefined"!=typeof performance?performance.now():Date.now();i.current=t,h(t),c(t=>"active"===t?t:"active")},[]);return s(()=>{const t=setInterval(()=>{const t=i.current;if(null==t)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-t>e;c(t=>{const e=n?"stale":"active";return t===e?t:e})},n);return()=>clearInterval(t)},[e,n]),{ref:f,status:l,lastPushTime:u}}export{On as DEFAULT_LIFECYCLE_THRESHOLDS,$t as IncrementalExtent,Sa as RealtimeHeatmap,ka as RealtimeHistogram,ba as RealtimeLineChart,Aa as RealtimeSwarmChart,_a as RealtimeWaterfallChart,Il as ReorderBuffer,Lt as RingBuffer,Ol as RunningStats,Cl as StreamNetworkFrame,Nr as StreamXYFrame,wa as TemporalHistogram,Tl as WindowAccumulator,Nl as bandBounds,Tn as bandFromAge,$l as parseWindowDuration,Dl as statValue,Pa as useStreamStatus};
|
|
2
|
+
import*as e from"react";import{useRef as t,useState as n,useEffect as r,useMemo as o,useCallback as i,useImperativeHandle as s,useId as a,forwardRef as c,memo as l}from"react";import{useRef as u,useEffect as h,useMemo as d}from"react";import{select as f}from"d3-selection";import{brush as y,brushX as p,brushY as g}from"d3-brush";import*as m from"react";import{jsx as v,jsxs as x}from"react/jsx-runtime";function b(e,t,n,r){const[o,i]=[Math.min(...t),Math.max(...t)],s=(i-o)/20;let[a,c]=e;if(r)0>n?a=Math.max(o,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(o,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function k(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function w(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function A({width:e,height:t,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:A,snapDuring:S,streaming:_}){const M=u(null),C=u(null),P=u(a);P.current=a;const T=u(s);T.current=s;const R=d(()=>A?[...A].sort((e,t)=>e-t):void 0,[A]),D=u(R);D.current=R;const N=u(!1),L=u(null),E=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const r=m.useId().replace(/:/g,""),o=m.useRef(n);return o.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:m.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),o.current?.(t))},[])}}}({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=T.current,n=C.current;if(!t||!n||!M.current)return;const r=f(M.current).select(".brush-g");if("clear"===e.type)return N.current=!0,r.call(n.move,null),N.current=!1,L.current=null,void P.current(null);const o=t.x.domain(),s=t.y.domain(),a=L.current;let c=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==i&&(c=b(c,o,h,e.resize)),u||"x"===i||(l=b(l,s,h,e.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:c,y:l};N.current=!0,r.call(n.move,"x"===i?[t.x(c[0]),t.x(c[1])]:"y"===i?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),N.current=!1,L.current=d,P.current(d)}});return h(()=>{if(!M.current)return;const n=f(M.current).select(".brush-g"),r="x"===i?p():"y"===i?g():y();return r.extent([[0,0],[e,t]]),r.on("brush end",o=>{if(N.current)return;const s=T.current;if(!s)return;if(!o.selection)return L.current=null,void P.current(null);let a,u;if("x"===i){const[e,n]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===i){const[t,n]=o.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,r]]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===l&&"y"!==i&&("end"===o.type||"brush"===o.type&&S)){const e=D.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[k(e[0],t),w(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(N.current=!0,"x"===i)n.call(r.move,[t,l]);else if("xy"===i){const e=o.selection;n.call(r.move,[[t,e[0][1]],[l,e[1][1]]])}N.current=!1}const h={x:a,y:u};L.current=h,P.current(h)}),n.call(r),C.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),C.current=null}},[e,t,i,l,c,S]),h(()=>{if(!(_&&s&&C.current&&L.current))return;if(!M.current)return;if("y"===i)return;const e=L.current,t=s.x.domain()[0],n=f(M.current).select(".brush-g");if(t>=e.x[1])return N.current=!0,n.call(C.current.move,null),N.current=!1,L.current=null,void P.current(null);let r=e.x[0],o=!1;if(t>e.x[0]){if(r=t,"bin"===l){const e=D.current;e&&e.length>0?r=w(t,e):c&&c>0&&(r=Math.ceil(t/c)*c)}if(r>=e.x[1])return N.current=!0,n.call(C.current.move,null),N.current=!1,L.current=null,void P.current(null);o=!0}const a=s.x(r),u=s.x(e.x[1]);if(N.current=!0,"x"===i)n.call(C.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(C.current.move,[[a,t],[u,r]])}if(N.current=!1,o){const t={x:[r,e.x[1]],y:e.y};L.current=t,P.current(t)}},[s,_,i,l,c]),x("svg",{ref:M,width:n,height:r,...E.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[v("title",{children:E.svgProps["aria-label"]}),v("desc",{id:E.descriptionId,children:E.description}),v("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var S=Object.freeze([]);function _(e){if(!e)return S;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var M=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=_(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=_(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import{createContext as C,useCallback as P,useContext as T,useMemo as R,useRef as D,useSyncExternalStore as N}from"react";import{jsx as L}from"react/jsx-runtime";function E(e){let t=null;const n=()=>(t||(t=C(null)),t),r=I(e);return[function({children:t,initialState:r}){const o=D(r),i=R(()=>I(e,o.current),[]),s=n();return L(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=T(o)??r,s=D(e);s.current=e;const a=D({hasValue:!1,value:void 0}),c=P(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=P(()=>s.current(i.getState()),[i]);return N(i.subscribe,c,l)}]}function I(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function W(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function $(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:z}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var z=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],O={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},F={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},B={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:z,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Y(e,t){if("light"===t)return O;if("dark"===t)return F;if("high-contrast"===t)return B;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?F:O;return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[j,H]=E(e=>({theme:O,setTheme(t){e(e=>({theme:Y(e.theme,t)}))}})),X=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,r=[];t.length>e&&(n=t.length-e,r=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},G=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function V(e,t){return e===t}function q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function U(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function K(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Q=/^\d{4}-\d{1,2}$/;function Z(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Q.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function J(e){return e instanceof Date?e.getTime():"string"==typeof e?Z(e):+e}function ee(e){return new Set(Array.isArray(e)?e:[e])}import{scaleOrdinal as te}from"d3-scale";function ne(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function re(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function oe(e){const t=e.map(ne),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return re(e,n,r)}if(e>=1){const[e,r,o]=t[n];return re(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,c]=t[o],[l,u,h]=t[o+1];return re(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(h-c)*i))}}var ie=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],se=oe(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ae=oe(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ce=oe(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),le=oe(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ue=oe(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),he=oe(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),de=oe(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),fe=oe(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),ye=oe(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),pe=oe(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ge=oe(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),me=oe(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ve={blues:se,reds:ae,greens:ce,viridis:de,oranges:le,purples:ue,greys:he,plasma:fe,inferno:ye,magma:pe,cividis:ge,turbo:me};oe(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),oe(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),oe(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),oe(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),oe(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var xe={category10:ie,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ve},be=ie,ke=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function we(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ae(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Se(e,t){return Math.min((e-t.startTime)/t.duration,1)}function _e(e,t,n){return e+(t-e)*n}function Me(){return"undefined"!=typeof performance?performance.now():Date.now()}var Ce={fresh:1,aging:1.5,stale:3};function Pe(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}function Te(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Re(e){const{data:t,encoding:n}=e,r=[],o=new Map;return t.forEach((e,t)=>{const i=Te(n.id,e,t);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Te(n.process?.group,e,t),c=Te(n.process?.stage,e,t),l=Te(n.accessible?.group,e,t)??(null!=a?a+"":null!=c?c+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Te(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:Te(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Te(n.placement?.x,e,t),y:Te(n.placement?.y,e,t),lane:Te(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:Te(n.kinematics?.velocityX,e,t),velocityY:Te(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:c,target:Te(n.process?.target,e,t),work:Te(n.process?.work,e,t)},evidence:u,accessible:{description:Te(n.accessible?.description,e,t),group:l,label:Te(n.accessible?.label,e,t)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function De(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}function Ne(e,t){const n=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Le(e,t,n){return Number.isFinite(n)&&n>0?Ne((t.x-e.x)/n,(t.y-e.y)/n):Ne(0,0)}function Ee(e,t,n){if(1>=n)return 1;const r=n-1;return De({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Ie(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function We(e,t,n){const r=e.duration??500,o=n-t;return r>o?1-o/r:0}function $e(e,t,n,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==n&&(e._pulseColor=n,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function ze(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Oe(e,t,n,r,o,i){const s=[];for(const o of e){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:o,datum:l,group:i}}function Fe(e,t,n,r,o,i,s,a){const c=[];for(const i of e){const e=n(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):o;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:i,datum:e,group:s}}function Be(e,t,n,r){const o=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const o of t)e+=n(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],s=e[r];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=o.get(i)??0;o.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r+=(o.get(i)??0)+e/2}const i=r/e.length;for(const t of e)o.set(t,(o.get(t)??0)-i)}}else for(const t of e)o.set(t,0);return o}function Ye(e,t,n,r,o,i,s){const a=n(e),c=r(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:o,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function je(e,t,n,r,o,i,s,a){const c=n(e),l=r(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:o,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function He(e,t,n,r,o,i,s){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:s}}function Xe(e,t,n,r,o,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Ge(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function Ve(e,t,n,r){if(!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(o.push([c,l]),i.push([c,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Ge(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function qe(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function Ue(e,t,n){const r=[];for(const o of n){const n=Ve(e,t,"__ribbon_aggregate",o);n&&r.push(n)}return r}function Ke(e,t,n,r){const o=[];for(const i of r){const r=Ve(e,t,n,i);r&&o.push(r)}return o}function Qe(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),o=r.getBottom(e);Number.isFinite(o)&&Number.isFinite(t)&&n.push({y0:o,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function Ze(e,t,n,r){if(!e.config.pointStyle)return;const o=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Ye(i,e.scales,e.getX,o,s,r,a);c&&n.push(c)}}}function Je(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var et={topOpacity:.8,bottomOpacity:.05};function tt(e){if(e)return!0===e?et:"colorStops"in e?e:{topOpacity:e.topOpacity??et.topOpacity,bottomOpacity:e.bottomOpacity??et.bottomOpacity}}import{symbol as nt,symbolCircle as rt,symbolCross as ot,symbolDiamond as it,symbolSquare as st,symbolStar as at,symbolTriangle as ct,symbolWye as lt}from"d3-shape";var ut={circle:rt,square:st,triangle:ct,diamond:it,star:at,cross:ot,wye:lt},ht=["circle","triangle","diamond","star","square","chevron","cross","wye"];function dt(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):nt(ut[r]??rt,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var yt=new Map;function pt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=q(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),h=(c-a||1)/r,d=(u-l||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),r-1),g=Math.min(Math.floor((u-l)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const v=s(i);p[m]+=isFinite(v)?v:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(i){case"sum":t=p[e];break;case"mean":t=p[e]/y[e];break;default:t=y[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const v=m-g||1,x=n.width/r,b=n.height/o,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;o>e;e++){const t=e*r;for(let n=0;r>n;n++){const r=t+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const c=(s-g)/v;A.push(Xe(n*x,(o-1-e)*b,x,b,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:l+(e+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=q(e.config.valueAccessor,"value"),o=U(e.config.xAccessor,"x"),i=U(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),u=i(n);c[e]=r,l[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(y){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),v=Array(t.length),x=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],o=s.get(c[e]),i=a.get(l[e]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=x.get(d);let y;void 0!==f?y=f:(y=b++,x.set(d,y)),g[y]=d,m[y]=h,v[y]=n}let k=1/0,w=-1/0;for(let e=0;b>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in ve?e:"blues";let n=yt.get(t);if(n)return n;n=Array(256);const r=(o=t)&&ve[o]||se;var o;for(let e=0;256>e;e++)n[e]=r(e/255);return yt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,C=e.config.showValues,P=e.config.heatmapValueFormat,T=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;T.push(Xe(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((t-k)*S+.5|0,255)],v[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return T}function gt(e,t,n,r,o){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/r)*r;let l=i.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},i.set(c,l)),l.total+=a,o){const e=o(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;vt(r)&&0===n.length&&xt(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&xt(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function vt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(vt))}function xt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function bt(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function kt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function wt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=kt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=q(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:kt(e.y1Accessor,"y1"),getBottom:kt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as At,scaleLog as St,scaleSymlog as _t,scaleTime as Mt}from"d3-scale";function Ct(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Pt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return St().domain(e).range(n).clamp(!0)}return"symlog"===e?_t().domain(t).range(n):"time"===e?Mt().domain([new Date(t[0]),new Date(t[1])]).range(n):At().domain(t).range(n)}function Tt(e,t,n,r){const o=e.push(t);return n&&n.push(r),o}var Rt=new WeakMap;function Dt(){return this.updateResults.last}function Nt(){return this.updateResults.last}function Lt(e){return this.updateResults.subscribe(e)}function Et(e){this.config.layoutSelection=e}function It(){Rt.set(this,!0)}function Wt(){const e=!0===Rt.get(this);return Rt.delete(this),e}function $t(e){Object.assign(e.prototype,{getLastUpdateResult:Dt,getUpdateSnapshot:Nt,subscribeUpdateResult:Lt,setLayoutSelection:Et,markStylePaintPending:It,consumeStylePaintPending:Wt})}var zt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Ot(e,t){const n={...e};for(const e of t)n[zt[e]]++;return n}function Ft(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Ot(n,r)}}var Bt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Ft({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Ft(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Yt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jt=["scene-style","data-paint","accessibility","evidence"],Ht=(e,t)=>({retainedData:e,invalidations:t}),Xt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ut=["scene-geometry","data-paint","accessibility","evidence"],Kt=["scene-style","data-paint","accessibility","evidence"],Qt=[],Zt={chartType:Ht("rebuild",Xt),runtimeMode:Ht("rebuild",Xt),xAccessor:Ht("rebuild",Xt),yAccessor:Ht("rebuild",Xt),timeAccessor:Ht("rebuild",Xt),valueAccessor:Ht("rebuild",Xt),y0Accessor:Ht("rebuild",Xt),boundsAccessor:Ht("rebuild",Xt),band:Ht("rebuild",Xt),openAccessor:Ht("rebuild",Xt),highAccessor:Ht("rebuild",Xt),lowAccessor:Ht("rebuild",Xt),closeAccessor:Ht("rebuild",Xt),candlestickRangeMode:Ht("rebuild",Xt),accessorRevision:Ht("rebuild",Xt),groupAccessor:Ht("rebuild",Gt),categoryAccessor:Ht("rebuild",Gt),lineDataAccessor:Ht("rebuild",Gt),colorAccessor:Ht("rebuild",Kt),sizeAccessor:Ht("rebuild",Ut),symbolAccessor:Ht("rebuild",Ut),pointIdAccessor:Ht("rebuild",Ut),xScaleType:Ht("preserve",Vt),yScaleType:Ht("preserve",Vt),xExtent:Ht("preserve",Vt),yExtent:Ht("preserve",Vt),extentPadding:Ht("preserve",Vt),scalePadding:Ht("preserve",Vt),axisExtent:Ht("preserve",Vt),binSize:Ht("preserve",Vt),normalize:Ht("preserve",Vt),heatmapAggregation:Ht("preserve",Vt),heatmapXBins:Ht("preserve",Vt),heatmapYBins:Ht("preserve",Vt),arrowOfTime:Ht("preserve",qt),baseline:Ht("preserve",qt),stackOrder:Ht("preserve",qt),sizeRange:Ht("preserve",qt),curve:Ht("preserve",qt),areaGroups:Ht("preserve",qt),customLayout:Ht("preserve",qt),layoutConfig:Ht("preserve",qt),layoutMargin:Ht("preserve",qt),symbolMap:Ht("preserve",Ut),showValues:Ht("preserve",Ut),heatmapValueFormat:Ht("preserve",Ut),lineStyle:Ht("preserve",Kt),pointStyle:Ht("preserve",Kt),areaStyle:Ht("preserve",Kt),barStyle:Ht("preserve",Kt),swarmStyle:Ht("preserve",Kt),waterfallStyle:Ht("preserve",Kt),candlestickStyle:Ht("preserve",Kt),boundsStyle:Ht("preserve",Kt),gradientFill:Ht("preserve",Kt),lineGradient:Ht("preserve",Kt),colorScheme:Ht("preserve",Kt),themeCategorical:Ht("preserve",Kt),themeSemantic:Ht("preserve",Kt),themeSequential:Ht("preserve",Kt),themeDiverging:Ht("preserve",Kt),barColors:Ht("preserve",Kt),decay:Ht("preserve",Kt),pulse:Ht("preserve",Kt),staleness:Ht("preserve",Kt),layoutSelection:Ht("preserve",Kt),annotations:Ht("preserve",["overlay","accessibility","evidence"]),windowSize:Ht("preserve",Qt),windowMode:Ht("preserve",Qt),maxCapacity:Ht("preserve",Qt),clock:Ht("preserve",Qt),transition:Ht("preserve",Qt),introAnimation:Ht("preserve",Qt),onLayoutError:Ht("preserve",Qt)},Jt=Ht("preserve",qt),en=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Yt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Zt[r]??Jt;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as tn}from"d3-quadtree";var nn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);this.tree=tn().x(e=>e.x).y(e=>e.y).addAll(o)}},rn=class e{constructor(e){if(this.xExtent=new G,this.yExtent=new G,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new en,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new nn,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=o??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const c=We(e,s,i);c>o&&(o=c)}a&&(c=$e(n,o,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const o=r.get(t);c=$e(n,null==o?0:We(e,o,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new X(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=q(e.timeAccessor||e.xAccessor,"time"),this.getY=q(e.valueAccessor||e.yAccessor,"value")):(this.getX=q(e.xAccessor,"x"),this.getY=q(e.yAccessor,"y")),this.getGroup=K(e.groupAccessor),this.getCategory=K(e.categoryAccessor),this.getSize=e.sizeAccessor?q(e.sizeAccessor,"size"):void 0,this.getColor=K(e.colorAccessor),this.getSymbol=K(e.symbolAccessor),this.getY0=e.y0Accessor?q(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=wt(e),this.getPointId=K(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?q(e.openAccessor,"open"):void 0,this.getHigh=q(e.highAccessor,"high"),this.getLow=q(e.lowAccessor,"low"),this.getClose=n?q(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new X(e.windowSize))}currentTime(){return this.config.clock?.()??Me()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(e,t){const n=new X(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?q(this.config.timeAccessor||this.config.xAccessor,"time"):q(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(Z(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>J(t[e]):e=>J(n(e))}}o=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of e.inserts)Tt(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Tt(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}var n,r,o;return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=Ct(this.xExtent.extent,t.xExtent),c=Ct(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:o}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=r(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let y,p;if("input"===d)y=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let o=0,i=0;for(const n of e)i>o?(t.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...t]}else y="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Be(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,o=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>o&&(o=e+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,l=i?0:s>0?s*t.extentPadding:1;p=[r-l,o+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,o=0;for(const i of e){let e=0,s=0;for(const r of t){const t=n(r,i)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>o&&(o=e)}return[r,o]}(e,y,(e,t)=>a.get(e)?.get(t)||0),o=r-n,s=i?0:o>0?o*t.extentPadding:1;p=[n-s,r+s]}else p=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,r,o,i,s){const[,a]=function(e,t,n,r,o){const i=gt(e,t,n,r,o);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,r){const[o,i]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(e,t),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,h):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[r,o]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(c,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const r=t[0],o=t[1];return null==r&&null==o?e:[null!=r?r:e[0],null!=o?o:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:o}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:At().domain(r).range(e),y:Pt(t.yScaleType,o,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Pt(t.yScaleType,o,[s,n.width-s]),y:At().domain(r).range(e)}}var a;return{x:Pt(t.xScaleType,r,[s,n.width-s]),y:Pt(t.yScaleType,o,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Pt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,o,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??ke},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,r=bt("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),r=[],o=e.config.annotations?.filter(Je).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(i.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return Ze(e,n,r),r}(o,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Fe(t.data,e.scales,e.getX,e.getY,o,n,t.key,i),a=tt(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return Ze(e,n,r),r}(o,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=Fe(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=tt(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return Ze(e,n,r),r}(o,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",o=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}t.set(r.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:o(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,r,o,i,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of l){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Be(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,v=new Map;for(const e of l)g.set(e,d.get(e)??0),m.set(e,0),v.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],c=[]};for(const n of l){const o=e.has(n);let s,l,u=o?e.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=v.get(n),l=s+u,v.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const y=t.x(n);c.push([y,t.y(s)]),a.push([y,t.y(l)]),r.set(n,l)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=c.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>t.get(n)??e.getY(n);Ze(e,n,l,r)}return l}(o,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=ht[h%ht.length],h++,u.set(e,n)),n};for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},l=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(l=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(o);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(c){const r=d(c(o)+""),i=je(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);i&&n.push(i)}else{const r=Ye(o,e.scales,e.getX,e.getY,l,t,u);r&&n.push(r)}}return n}(o,t);case"heatmap":return pt(o,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const o=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(o),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=o.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:c,order:r})}const o=[],i=e.scales,[s,a]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,v=Math.max(p-g,1);if(v>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(He(m,Math.min(a,u),v,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=i.y(0),n=i.y(t.total);o.push(He(m,Math.min(e,n),v,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...d},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(o,t);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},o=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,c=r.strokeWidth;for(const r of t){const t=e.getX(r),l=e.getY(r);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),h=e.scales.y(l);let d=i;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...y}=e.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(o,t);case"waterfall":return function(e,t,n){const r=[],o=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const y=s[t],p=e.getX(y),g=e.getY(y),m=f+g;let v;v=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const x=o.x(p),b=0!==v?o.x(p+v):x+n.width/10,k=Math.min(x,b)+l/2,w=Math.max(x,b)-l/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),_=Math.min(A,S),M=Math.abs(A-S),C={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(He(k,_,w,M,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const r=[],o=e.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",c=n?i:o.wickColor||"#333",l=o.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));r>0&&t>r&&(t=r)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(o),u=e.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:e.getOpen(o),f=n?u:e.getClose(o);if(!n&&[d,f].some(e=>null==e||Number.isNaN(e)))continue;const y=f>=d,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(d),closeY:e.scales.y(f),highY:e.scales.y(i),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const o=e.boundsStyle;return"function"==typeof o?o(n||{},t):o&&"object"==typeof o?o:{fill:r(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Ee(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Ie(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Ie(n)){const o=n.length;if(o>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(i[n]=Ee(e,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=r.get(t[n]);null!=i?(s[n]=Ee(e,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=Ee(e,t,o);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const i=Ee(e,t,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,o=t.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){n.clear(),r.clear();for(let o=0;t.length>o;o++){const i=t[o],s=ze(e,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=ze(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o,i=Me()){if(0===r.size&&0===o.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=ze(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=o.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=r.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of o)if(!l.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){if(!n.activeTransition)return!1;const o=Se(e,n.activeTransition),i=Ae(o,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=_e(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=_e(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=_e(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=_e(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=_e(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=_e(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=_e(t[r][0],n[r][0],i),e.path[r][1]=_e(t[r][1],n[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=_e(t[n][0],r[n][0],i),e.topPath[n][1]=_e(t[n][1],r[n][1],i);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=_e(n[t][0],o[t][0],i),e.bottomPath[t][1]=_e(n[t][1],o[t][1],i)}}if(o>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}o=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:n,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:r};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||ke,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const o=e.areaStyle(n||{});if(o&&!o.fill&&t){const e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||ke;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,r.set(t,l),r.size>o){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ee(e),n=this.getPointId,r=e=>t.has(n(e));!function(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ee(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!V(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!V(n,s);(a||c)&&(e?(this.getX=q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=q(this.config.xAccessor,"x"),this.getY=q(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=wt(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!V(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?K(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!V(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?K(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!V(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!V(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?K(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!V(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?K(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!V(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!V(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=wt(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!V(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?K(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!V(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!V(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!V(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!V(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?q(this.config.openAccessor,"open"):void 0,this.getHigh=q(this.config.highAccessor,"high"),this.getLow=q(this.config.lowAccessor,"low"),this.getClose=t?q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of n)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};rn.GROUP_COLOR_MAP_CAP=1e3;var on=rn;$t(on);import{memo as sn,useEffect as an,useRef as cn}from"react";var ln={sceneGeometry:0,layout:0,domain:0};function un(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function hn(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var dn="production"!==process.env.NODE_ENV,fn={revisions:ln,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},yn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ln,this.lastObserved=ln,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){dn&&(this.lastObserved=hn(this.lastObserved,un(e)))}beforeCompute(e,t){if(!dn)return fn;const n=hn(un(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(dn){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function pn(e){return cn(new yn(e))}var gn=sn(function({store:e,diagnostics:t}){return an(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});import*as mn from"react";function vn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:mn.createElement(mn.Fragment,null,...t)}import*as xn from"react";import{jsx as bn}from"react/jsx-runtime";var kn=xn.createContext(null);function wn({value:e,children:t}){return bn(kn.Provider,{value:e,children:t})}function An(e,t){return null!=e?bn(wn,{value:t,children:e}):e}import{useEffect as Sn,useRef as _n}from"react";function Mn(e,t,n,r){Sn(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function Cn(e,t,n,r){const o=_n(null);Sn(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function Pn(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Tn(e,t=30){return Math.max((e??4)+5,12,t)}function Rn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Dn(e,t){const n=Rn(e);if(!n)return!1;const r=Rn(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Nn(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Ln=[40,40],En=[.5,.5];function In(e,t){const[n,r]=e.viewBox??Ln,[o,i]=e.anchor??En,s=r>0?r:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-i*l}}function Wn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var $n=null;function zn(e){if("undefined"==typeof Path2D)return null;$n||($n=new Map);const t=$n.get(e);if(t)return t;const n=new Path2D(e);return $n.size>1024&&$n.clear(),$n.set(e,n),n}function On(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Ln,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Fn(e,t){const n=In(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Bn(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=zn(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=o?"none"===s.fill?void 0:o:Wn(s.fill,n,r);l&&(e.fillStyle=i(l),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:Wn(s.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function Yn(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(r,o+5,12),l=t-c,u=t+c,h=n-c,d=n+c;let f=null,y=1/0;return e.visit((e,o,c,p,g)=>{if(o>u||l>p||c>d||h>g)return!0;if(!e.length){let o=e;do{const e=o.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);Tn(a(e),r)>=u&&y>u&&(f=e,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var jn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Hn=new WeakMap,Xn=0,Gn=!1,Vn=null,qn=null;function Un(e,t){if(!t)return t;const n=jn.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(Gn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Gn=!0;const e=()=>{Xn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Vn=window.matchMedia("(prefers-color-scheme: dark)"),qn=e,"function"==typeof Vn.addEventListener?Vn.addEventListener("change",qn):"function"==typeof Vn.addListener&&Vn.addListener(qn)}catch{}}();let o=Hn.get(r);o&&o.version===Xn||(o={version:Xn,map:new Map},Hn.set(r,o));const i=o.map.get(t);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return o.map.set(t,s),s}var Kn=null;import{jsx as Qn,jsxs as Zn}from"react/jsx-runtime";function Jn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function er(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var tr=new Map;function nr(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return Zn("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&Qn("rect",{width:c,height:c,fill:n}),Qn("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a}),Qn("line",{x1:i,y1:0,x2:i,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function rr(e,t,n="#4e79a7"){if(Jn(e)){const n=function(e,t){let n=2166136261;const r=er(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:nr(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}import{curveMonotoneX as or,curveMonotoneY as ir,curveCardinal as sr,curveCatmullRom as ar,curveStep as cr,curveStepBefore as lr,curveStepAfter as ur,curveBasis as hr,curveNatural as dr}from"d3-shape";function fr(e){switch(e){case"monotoneX":return or;case"monotoneY":return ir;case"cardinal":return sr;case"catmullRom":return ar;case"step":return cr;case"stepBefore":return lr;case"stepAfter":return ur;case"basis":return hr;case"natural":return dr;default:return null}}function yr(e,t,n){if(null==t)return n;if(Jn(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${er(e)}@${n}`,o=tr.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Kn||(Kn=document.createElement("canvas")),Kn.width=e,Kn.height=e,Kn)}(a)}catch{return null}const l=c.getContext("2d");if(!l)return null;n&&"transparent"!==n?(l.fillStyle=n,l.fillRect(0,0,a,a)):l.clearRect(0,0,a,a),l.strokeStyle=r,l.lineWidth=o,l.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=i)l.beginPath(),l.moveTo(t,0),l.lineTo(t+e*a,a),l.stroke()}else{l.save(),l.translate(a/2,a/2),l.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=i)l.beginPath(),l.moveTo(-e,t),l.lineTo(e,t),l.stroke();l.restore()}return(t||l).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return tr.set(r,i),i}(t,e);return r||t.background&&Un(e,t.background)||n}return"string"!=typeof t?t:Un(e,t)||n}function pr(e,t,n,r,o,i,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(r,o,i,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),h=e.createLinearGradient(r,o,i,s),[d,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${l})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function gr(e,t,n,r,o,i){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,o,i);for(const e of s)a.addColorStop(e.offset,e.color);return a}import{line as mr}from"d3-shape";var vr=new WeakMap;function xr(e,t){const n=fr(t);if(!n)return e;const r=vr.get(e);if(r)return r;const o=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let o=null;const i={moveTo(e,t){o=[e,t],r.push([e,t])},lineTo(e,t){o=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,s,a,c){if(!o)return o=[a,c],void r.push([a,c]);const[l,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*l+3*d*d*h*e+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*c])}o=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){o=[n,i],r.push([n,i])}};return mr().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,n);return vr.set(e,o),o}function br(e,t,n,r=30,o,i=0){let s=null;if(o){const e=Yn(o,t,n,r,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(o)break;e=wr(i,t,n,r);break;case"symbol":e=Ar(i,t,n,r);break;case"glyph":e=Sr(i,t,n,r);break;case"line":e=_r(i,t,n,r);break;case"rect":if(null==i.datum)break;e=Cr(i,t,n);break;case"heatcell":e=Pr(i,t,n);break;case"area":if(!1===i.interactive)break;e=Rr(i,t,n);break;case"candlestick":e=Tr(i,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function kr(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=Dr(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[s,a]=e[o],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function wr(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ar(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Sr(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.x+o.centerDx,s=e.y+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function _r(e,t,n,r=30){if(0===e.path.length)return null;const o=Dr(e.path,t);if(0>o)return null;const[i,s]=e.path[o];let a;if(e.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(e.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=e.path[o],[a,c]=e.path[o+1],l=Mr(t,n,i,s,a,c);r>l&&(r=l)}a=r}else{const e=t-i,r=n-s;a=Math.sqrt(e*e+r*r)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function Mr(e,t,n,r,o,i){const s=o-n,a=i-r,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-r)**2);let l=((e-n)*s+(t-r)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(r+l*a))**2)}function Cr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Pr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Tr(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function Rr(e,t,n){if(0===e.topPath.length)return null;const r=Dr(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],s=t-o,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:c}}function Dr(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as Nr,useRef as Lr}from"react";var Er={fresh:1,aging:.7,stale:.45,expired:.25},Ir={alpha:1,band:"fresh",isStale:!1};function Wr(e,t){if(!e||0>=t)return Ir;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=Pe(t,n,e.thresholds);return{alpha:{...Er,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ir}function $r(e,t,n,r,o,i){const s=Lr("fresh");Nr(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Wr(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===o||(s.current=l.band,l.isStale!==o&&i(l.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}import{jsx as zr}from"react/jsx-runtime";function Or({isStale:e,position:t}){return zr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Fr,useRef as Br,useEffect as Yr}from"react";import*as jr from"react";import{jsx as Hr,jsxs as Xr}from"react/jsx-runtime";var Gr={fill:(e,t)=>Hr("rect",{style:e,width:t,height:t}),line:(e,t)=>Hr("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Vr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Gr[n])(r(e,t),o),i}function qr({swatchSize:e}){return Hr("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ur(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Kr=(e,t,n,r,o,i,s,a,c,l,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=o,{swatchSize:v,labelGap:x,rowHeight:b}=u;return f.forEach((e,l)=>{const u=Vr(e,l,h,d,v),k=Ur(e,r,o),w=o&&o.size>0&&o.has(e.label);y.push(Xr("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+x+2+7*e.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&Hr(qr,{swatchSize:v}),Hr("text",{y:v/2,x:v+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),p+=b}),y};function Qr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+jr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&Hr("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),Hr("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),Hr("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[i&&Hr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),Hr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),Hr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),Hr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function Zr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:h}=e,d=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(h),[f,y]=jr.useState(0),[p,g]=jr.useState(0),m=jr.useCallback((e,t)=>{y(e),g(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push(Hr("line",{stroke:"gray",x1:0,y1:h,x2:t,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,e.label&&(h+=16,d.push(Hr("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),h+=8),d.push(Hr("g",{className:"legend-item",transform:`translate(0,${h})`,children:Kr(e,n,r,o,i,s,a,f,c,l,u)},"legend-group-"+f)),h+=e.items.length*u.rowHeight+8}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const p=((e,t,n,r,o,i,s,a,c,l,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:v,rowHeight:x,align:b}=u,k=!(!t&&!n),w="isolate"===l||void 0===l&&null!=o,A=y.map(e=>g+m+7*e.label.length),S=[];let _=0,M=0;A.forEach((e,t)=>{const n=0===M?e:M+v+e;h&&h>0&&M>0&&n>h?(S.push({start:_,end:t,width:M}),_=t,M=e):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((e,l)=>{let u="center"===b?Math.max(0,((h??e.width)-e.width)/2):"end"===b?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],b=Vr(e,h,d,f,g),S=Ur(e,r,o),_=o&&o.size>0&&o.has(e.label);p.push(Xr("g",{transform:`translate(${u},${l*x})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{c(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,_&&Hr(qr,{swatchSize:g}),Hr("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),u+=A[h]+v}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*x}})(e,r,o,i,s,a,c,t,l,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:e.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(g.push(Hr("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),g.push(Hr("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push(Hr("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),Hr("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),x=!(!n&&!r);return Xr("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&Hr("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),v]})}function Jr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as eo}from"react/jsx-runtime";function to(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,v;return"left"===i?(m=Math.max(4,o.left-g-10),v=o.top):"top"===i?(m=o.left,v=y?32:8):"bottom"===i?(m=o.left,v=r-o.bottom+38):(m=n-o.right+10,v=o.top),eo("g",{transform:`translate(${m}, ${v})`,children:(x=t,"object"==typeof x&&null!==x&&"gradient"in x?eo(Qr,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Jr(t)?eo(Zr,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var x}import{useMemo as no}from"react";import{bin as ro}from"d3-array";function oo(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}import{jsx as io,jsxs as so}from"react/jsx-runtime";function ao(e){return"string"==typeof e?{type:e}:e}function co({orient:e,config:t,values:n,scale:r,size:o,length:i}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=no(()=>{if(0===n.length)return null;const t=r.domain(),c=o-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:o,median:i,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*c,20),f=(c-d)/2+4;if(a){const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="top"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:c,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:c,y1:g+p*f,x2:c,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="left"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:g+p*(f+d/2),y1:c,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:c,x2:g+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=ro().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return io("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/u*c;if(a){const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:i,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:"left"===e?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const o of l){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(c/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let o=l.length-1;o>=0;o--){const i=l[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return io("g",{"data-testid":"marginal-violin-"+e,children:io("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${o},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-o-4:o+4}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${n},${o}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${i}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return io("g",{"data-testid":"marginal-ridgeline-"+e,children:io("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,e,a,4]);return c?io("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}import*as lo from"react";import{jsx as uo,jsxs as ho}from"react/jsx-runtime";function fo(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function yo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function po(e,t,n,r){if(!e)return uo("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!o&&!i)return uo("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,y=i?l?[i]:fo(i,c):[],p=o?l?[o]:fo(o,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const v=[],x=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?v.push(uo("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:ho("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:x,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&uo("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&uo("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(v.push(uo("text",{className:"annotation-note-title",fill:x,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&v.push(uo("text",{className:"annotation-note-label",fill:x,textAnchor:d,y:m,children:p.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),ho("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[uo("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:v}),b]})}function go(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(uo("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(uo("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(uo("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push(uo("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(uo("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(uo("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(uo("path",{d:yo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return uo("g",{className:"annotation-subject",children:i})}function mo(e,t,n,r,o,i){const s=[];let a=0,c=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=o+s*d,c=i+l*d}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,c=Math.sin(r)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(i){const r=(a+e)/2,i=(c+t)/2,h=-(t-c)/l,d=(e-a)/l,f=(n?.curve??.25)*l,y=r+h*f,p=i+d*f;s.push(uo("path",{className:"connector-curve",d:`M${a},${c}Q${y},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-c,y-a)}else s.push(uo("line",{x1:a,y1:c,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push(uo("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return uo("g",{className:"annotation-connector",children:s})}function vo(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,v=Array.isArray(t)?t[0]??0:t,x=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-v),null!=s&&(w=s-x);const A="string"==typeof u?u:"label";if("bracket"===A&&l&&0===k&&0===w)if(void 0!==l.width){k=l.width/2;const e=l.depth||30;w=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;k=e+(0>e?-5:5),w=l.height/2}return ho("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${v},${x})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&mo(k,w,c,h,A,l),!b.has("subject")&&go(A,l,h,v,x),!b.has("note")&&po(a,k,w,h)]})}function xo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return uo(vo,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return uo("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return uo(vo,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}import{packEnclose as bo}from"d3-hierarchy";import{area as ko,curveLinear as wo,curveMonotoneX as Ao,curveMonotoneY as So,curveStep as _o,curveStepAfter as Mo,curveStepBefore as Co,curveBasis as Po,curveCardinal as To,curveCatmullRom as Ro}from"d3-shape";function Do(e){return Math.round(100*e)/100}function No(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(Do);return{points:e.map(([e])=>[Do(e),Do(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function Lo(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Eo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Io(e){return null==e?null:e+""}function Wo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function $o(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return Wo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?Wo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return Io(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>Io(e.pointId)===r);if(o)return Wo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return Io(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=Lo(i,n),a=Eo(i,n);return null==s||null==a?null:Wo(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=Lo(e,n),i=Eo(e,n)),null!=o&&null!=i)return Wo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function zo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}import{jsx as Oo}from"react/jsx-runtime";var Fo={secondary:0,primary:3},Bo=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function Yo(e){return!0===e?._annotationDeferred}function jo(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Ho(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Xo(e){return Math.max(.72,.95-.06*e)}import*as Go from"react";var[Vo,qo]=E(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Uo(e){const t=qo(e=>e.pushObservation),n=Go.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Go.useMemo(()=>({...e,onObservation:n}),[n,e])}function Ko(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function Qo(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}import{jsx as Zo,jsxs as Jo}from"react/jsx-runtime";var ei="var(--semiotic-bg, #ffffff)";function ti(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=e,d=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>Zo("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??ei,strokeWidth:d.haloWidth??3});const y=d.padding??{x:6,y:3},p="number"==typeof y?y:y.x,g="number"==typeof y?y:y.y,m=function(e,t){return(e+"").length*t*.6}(r,i),v=i+2*g;let x,b;return x="middle"===c?t-m/2-p:"end"===c?t-m-p:t-p,b="middle"===l||"central"===l?n-v/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*i-g,Jo("g",{className:h,children:[Zo("rect",{x:x,y:b,width:m+2*p,height:v,rx:d.radius??3,ry:d.radius??3,fill:d.fill??ei,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}import{jsx as ni,jsxs as ri}from"react/jsx-runtime";var oi={linear:wo,monotoneX:Ao,monotoneY:So,step:_o,stepAfter:Mo,stepBefore:Co,basis:Po,cardinal:To,catmullRom:Ro};function ii(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Ho(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Yo(e.annotation)),o=e.some(e=>null!=jo(e.annotation)),i=e.some(e=>"layer"===jo(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Fo[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=Yo(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=Oo("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Xo(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=jo(t.annotation);return a&&(s=Oo("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=Oo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(Oo("style",{children:Bo},"annotation-disclosure-style")),i&&a.unshift(Oo("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}function si(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!zo(o,i,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return ni(xo,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Lo(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),c=a?t-4:t+4,l=a?"end":"start";return ri("g",{opacity:e.opacity,children:[ni("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:c,y:s,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Eo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end");const l=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return ri("g",{opacity:e.opacity,children:[ni("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:a,y:l,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=bo(t),i=e.padding||10;return ri("g",{children:[ni("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=oo(i),[l,u]=oo(s),h=a-o,d=c+o,f=l-o;return ri("g",{children:[ni("rect",{x:h,y:f,width:d-h,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return ni("g",{children:o.map((t,n)=>{const o=Lo(t,r),s=Eo(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return ni("circle",{cx:o,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Lo(e,r),o=Eo(e,r);return ni(xo,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,c=s?o:null,l=s?i:null;let u;const h=[],d=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,y=r.scales?.y??r.scales?.value;if(!f||!y)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),o=t-n,i=e(h[n]);return i+(e(h[r])-i)*o},g=f,m=y;let v;if(s)if(a){const e=p(m);v=(t,n)=>[g(n),e(t)]}else{const e=p(g);v=(t,n)=>[e(t),m(n)]}else v=(e,t)=>[g(e),m(t)];const x=e.method||"linear";let b;if("loess"===x)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),c=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:r[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,h+=t*o[e],d+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([t,d/u]);else{const e=(u*y-h*d)/p;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===x?No(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:Do((n*t[3]-t[0]*t[1])/r),i=Do(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[Do(e),Do(o*e+i)]),equation:[o,i]}}(u);b=t.points}const k=b.map(([e,t])=>{const[n,r]=v(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,_]=v(A[0],A[1]);return ri("g",{children:[ni("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.(e.y0)??0,a=t?.(e.y1)??(r.height||0),c=rr(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[c.def&&ni("defs",{children:c.def}),ni("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:c.fill,fillOpacity:e.fillOpacity||.1}),e.label&&ni(ti,{x:(r.width||0)-4,y:(o=s,i=a,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==o||null==i)return null;const s=rr(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[s.def&&ni("defs",{children:s.def}),ni("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:r.height||0,fill:s.fill,fillOpacity:e.fillOpacity??.1}),e.label&&ni(ti,{x:Math.min(o,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const h=oi[r.curve||"linear"]||wo,d=ko().x(e=>i(e[o])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return ri("g",{children:[ni("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&ni("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),h=e.threshold??2,d=c-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,v=s(c+h*u),x=s(d),b=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-c)>h*u});return ri("g",{children:[f&&ni("rect",{x:0,y:Math.min(v,x),width:r.width||0,height:Math.abs(x-v),fill:y,fillOpacity:p}),b.map((e,t)=>{const n=Lo(e,r),o=Eo(e,r);return null==n||null==o?null:ni("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&ni("text",{x:(r.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=No(c,e.order||2).equation;l=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=c.length;let t=0,n=0,r=0,o=0;for(const[e,i]of c)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,h=c.map(([e,t])=>t-l(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),y=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-y)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,v=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),k=[];for(let e=1;v>=e;e++)k.push(x+e*b);const w=[];for(const e of k){const t=l(e),n=f*Math.sqrt(1+1/u+(p>0?(e-y)**2/p:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),_=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return ri("g",{children:[ni("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),ni("polyline",{points:`${_} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&ni("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=$o(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!zo(o,i,r))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??ni("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return ni("foreignObject",{x:o+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:ni("div",{...Ko(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=ni("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?lo.cloneElement(l,{key:"ann-text-"+n}):ri("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[ni("line",{x1:o,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),lo.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,c=o(i)?i:o(s)?s:o(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return ri("g",(r.projection?"vertical"===r.projection:c===s)?{children:[ni("rect",{x:l,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&ni(ti,{x:l+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[ni("rect",{x:0,y:l,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&ni(ti,{x:12,y:l+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}var ai=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function ci(e){return!!e&&"object"==typeof e&&ai.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function li(e){return"primary"===e?.emphasis||!0===e?.defensive}function ui(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function hi(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var di=32,fi=6,yi=4,pi=8,gi=72;var mi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function vi(e){if(!xi(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function xi(e){return ci(e)}function bi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ki(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function wi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ai(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Si(e,t,n,r,o,i,s,a){const c=wi(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(c,o,i,a);for(const e of n)l+=12*Ai(c,e);for(const e of r)l+=4*Ai(c,e);return l}function _i(e){const{annotations:t,context:n,defaultOffset:r=di,notePadding:o=fi,markPadding:i=yi,edgePadding:s=pi,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=gi,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,v=n.height||0,x="object"==typeof y?y:{},b=x.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==x.preferShortText?t.map(vi):t,A=k&&!u?{maxAnnotations:x.maxAnnotations??("callout-list"===x.strategy?1:2),minVisible:x.minVisible??1}:u,S=h||k&&(!1!==x.progressiveDisclosure||"callout-list"===x.strategy),_=k&&!f?x.responsive??{minWidth:b}:f,M=k&&!p?x.cohesion:p;if(0===w.length||0>=m||0>=v)return w.slice();const C=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const R=w.map((e,t)=>{if(!xi(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?$o(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...bi("string"==typeof e.title?e.title:void 0,t),...bi("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push(wi(ki(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var h;let d=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Si(ki(i.x,i.y,e.dx,e.dy,u),e,C,P,m,v,o,s);f>t&&(d=e,f=t)}if(!d)return e;const y=wi(ki(i.x,i.y,d.dx,d.dy,u),o);C.push(y);const p=Math.hypot(d.dx,d.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return T=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),D=T?R:w.slice();let N=D;if(d){let e=!1;const t=D.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});N=e?t:D}{let e=!1;const t=N.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?mi[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});N=e?t:N}const L=new Set;if(A){const e="object"==typeof A?A:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ui(m,v,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=ui(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,ci(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>li(e.annotation)),l=a.filter(e=>!li(e.annotation)).sort((e,t)=>hi(t.annotation)-hi(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,o-c.length))),h=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:i}}({annotations:N,width:m,height:v,...n});for(const e of r)L.add(e)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const e of N)xi(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of N)!0===e?.defensive&&L.delete(e);let E;return E=0===L.size?N:S?N.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):N.filter(e=>!L.has(e)),M?function(e,t){let n=!1;const r=e.map(e=>xi(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(E,M):E}import{useSyncExternalStore as Mi}from"react";var Ci={positions:new Map},Pi=new Set;function Ti(){for(const e of Pi)e()}function Ri(e,t){const n=Ci.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Di(e,t){const n=Ci.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Ni(){return Ci}function Li(e){return Pi.add(e),()=>Pi.delete(e)}var Ei={positions:new Map};function Ii(){return()=>{}}function Wi(){return Ei}function $i(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function zi(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Oi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Fi(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function Bi(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Yi(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*o}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${r+4*o},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}import{Fragment as ji,jsx as Hi,jsxs as Xi}from"react/jsx-runtime";function Gi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:h,axisExtent:d}=e,f=Fr(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=e?.tickValues??$i(s.x,i,d),l=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return qi(h,Math.max(55,f+8))},[s,c,u,t,d]),y=Fr(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||h||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return qi((e?.tickValues??$i(s.y,i,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,h,n,d]),p=l&&s,g=a&&s;if(!p&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),v=c?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return Hi("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[f.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),y.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),x&&!k&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function Vi(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function qi(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ui(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:C,annotations:P,onAnnotationActivate:T,onObservation:R,chartId:D,chartType:N,autoPlaceAnnotations:L,svgAnnotationRules:E,xAccessor:I,yAccessor:W,annotationData:$,pointNodes:z,curve:O,underlayRendered:F,canvasObscuresUnderlay:B=!0,linkedCrosshairName:Y,linkedCrosshairSourceId:j,children:H}=e,X=Uo({onAnnotationActivate:T,onObservation:R,chartId:D,chartType:N}),G=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),l=e?.tickValues??$i(s.x,i,y),u=l.map(e=>e.valueOf()),h=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),p=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=qi(h,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:o})}}return g},[a,s,c,d,t,y]),V=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let l=qi((e?.tickValues??$i(s.y,i,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=l[l.length-1].pixel;if(Math.abs(n-r)>1){const o=t(e);22>Math.abs(n-r)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:o})}}return l},[a,s,c,f,n,y]),q=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e.ticks??5;return qi((e.tickValues??$i(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,y]),U=Br(new Map),K=Br(P?.length??0),Q=P?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=Fr(()=>{if(!P||0===P.length)return null;const e=si(0,X),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:I,yAccessor:W,width:t,height:n,data:$,frameType:"xy",pointNodes:z,curve:O,stickyPositionCache:U.current};return ii(L?_i({annotations:P,context:r,..."object"==typeof L?L:{}}):P,e,E,r)},[P,L,E,t,n,I,W,$,s,z,O,X]),J=function(e){const t=Mi(e?Li:Ii,e?Ni:Wi,e?Ni:Wi);return e?t.positions.get(e)??null:null}(Y);return Yr(()=>{if(!J?.locked||!Y)return;const e=e=>{"Escape"===e.key&&Di(Y)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,Y]),a||g||m||S||_||Z&&Z.length>0||p||H||J?Xi("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Hi("title",{children:"string"==typeof g?g:"XY Chart"}),Hi("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!F||B)&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[G.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),V.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),o=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",v=!!r?.autoRotate&&G.length>1&&(()=>{const e=t/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x=v?12:18,b=n+(v?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,_=e?.tickAnchor,M=Fi(G),C=Fi(V);return Xi("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Xi("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!F||B)&&s&&!d&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&d&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),G.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):Dn(e.value,t>0?G[t-1].value:void 0));return Xi("g",{transform:`translate(${e.pixel},${n})`,children:[Hi("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{y:x,textAnchor:v?"end":zi(S,e.pixel===M.min,e.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:v?"rotate(-45)":void 0,children:e.label}):Hi("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),l&&Hi("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:l})]}),Xi("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||B)&&o&&!a&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&a&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:p,strokeWidth:1}),V.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):Dn(e.value,t>0?V[t-1].value:void 0));return Xi("g",{transform:`translate(0,${e.pixel})`,children:[Hi("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:-8,textAnchor:"end",dominantBaseline:Oi(_,e.pixel===C.min,e.pixel===C.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:e.label}):Hi("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?Hi("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const r=!1!==e.baseline,o=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,l=Fi(q);return Xi("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&Hi("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),q.map((e,n)=>{const r=!!o&&("function"==typeof o?o(e.value,n):Dn(e.value,n>0?q[n-1].value:void 0));return Xi("g",{transform:`translate(${t},${e.pixel})`,children:[Hi("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:8,textAnchor:"start",dominantBaseline:Oi(a,e.pixel===l.min,e.pixel===l.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):Hi("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&Hi("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),Z,_&&s&&M&&C&&Xi(ji,{children:[_.top&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"top",config:ao(_.top),values:M,scale:s.x,size:i.top,length:t})}),_.bottom&&Hi("g",{transform:`translate(0, ${n})`,children:Hi(co,{orient:"bottom",config:ao(_.bottom),values:M,scale:s.x,size:i.bottom,length:t})}),_.left&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"left",config:ao(_.left),values:C,scale:s.y,size:i.left,length:n})}),_.right&&Hi("g",{transform:`translate(${t}, 0)`,children:Hi(co,{orient:"right",config:ao(_.right),values:C,scale:s.y,size:i.right,length:n})})]}),S,J&&J.sourceId!==j&&s?.x&&(()=>{const e=s.x(J.xValue);if(null==e||0>e||e>t)return null;const r=J.locked;return Hi("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),H]}),g&&"string"==typeof g?Hi("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?Hi("foreignObject",{x:0,y:0,width:r,height:i.top,children:g}):null,to({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}import*as Ki from"react";import{arc as Qi}from"d3-shape";function Zi(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}import{jsx as Ji,jsxs as es}from"react/jsx-runtime";var ts={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ns(e,t="#4e79a7"){return Jn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function rs(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=In(o,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=On(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:Wn(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Wn(n.stroke??"none",a,e.accent);return o||i?Ji("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return es("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&Ji("clipPath",{id:l,children:Ji("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?Ji("g",{children:h(e.ghostColor)}):null,c&&l?Ji("g",{clipPath:`url(#${l})`,children:h()}):h()]},r)}var os="undefined"==typeof window||"undefined"==typeof document;import{useEffect as is,useLayoutEffect as ss,useRef as as,useState as cs,useSyncExternalStore as ls}from"react";var us="undefined"!=typeof window?ss:is;function hs(){const[e,t]=cs(!1);return us(()=>{t(!0)},[]),e}var ds=()=>()=>{},fs=()=>!1,ys=()=>!0;function ps(){const e=ls(ds,fs,ys);return as(e).current}import{useRef as gs}from"react";function ms(e){const t=gs(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return xs(e,t);if(!bs(e)||!bs(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!xs(n,o))return!1}else{if(!bs(n)||!bs(o))return!1;if(!vs(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function vs(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function xs(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function bs(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ks(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(r)return!1;const l=n||(o&&"transparent"!==o?o:"")||null;if(!l)return!1;const u=Un(e,l);return!!u&&(e.fillStyle=u,e.fillRect(i,s,a,c),!0)}var ws={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function As(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],o=n[3];return`#${e}${e}${r}${r}${o}${o}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}import*as Ss from"react";import*as _s from"react";import{jsx as Ms}from"react/jsx-runtime";var Cs=_s.createContext(null);function Ps(){return _s.useContext(Cs)}import{jsx as Ts}from"react/jsx-runtime";var Rs={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ds({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return Ts("div",{"aria-live":"polite","aria-atomic":"true",style:Rs,children:t})}function Ns(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function Ls(e){return e&&"object"==typeof e?e:{}}function Es(e){return Ls(e.accessibility).tableFields??e.accessibleDatum??e.datum}import{jsx as Is,jsxs as Ws}from"react/jsx-runtime";function $s(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function zs(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var Os=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Fs="semiotic-accessible-data-table",Bs=Fs+" semiotic-accessible-data-table-hidden",Ys=Fs+" semiotic-accessible-data-table-visible",js=Ys+" semiotic-accessible-data-table-network",Hs={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Xs={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Gs={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Vs={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},qs={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Us={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Ks={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Qs={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Zs({scene:e,chartType:t,tableId:n,chartTitle:r}){const[o,i]=Ss.useState(!1),[s,a]=Ss.useState(5),c=Ps(),l=c?.visible??!1,u=o||l,h=Ss.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ss.useEffect(()=>{u||a(5)},[u]);const f=Ss.useCallback(e=>{e.target===e.currentTarget&&(o||l||i(!0))},[o,l]),y=Ss.useCallback(e=>{l||h.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?Is("span",{id:n,tabIndex:-1,style:Rs}):null;if(!u)return Is("div",{id:n,className:Bs,tabIndex:-1,onFocus:f,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const p=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Ns(Es(r))});break;case"line":case"area":{const e=Es(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Ns(e)});break}case"rect":{const e=Es(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Ns(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=Ns(Es(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Es(r),n=Ns(e);if(null==n.category){const t=Ls(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Ns(Es(r))});break;case"arc":t.push({label:"Arc",values:Ns(Es(r))});break;case"candlestick":t.push({label:"Candlestick",values:Ns(Es(r))});break;case"geoarea":{const e=Ls(Es(r)),n=Ns(e);if(null==n.name){const t=Ls(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Os(e.min)} to ${Os(e.max)}, mean ${Os(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),v=Math.min(s,p.length),x=p.slice(0,v),b=p.length-v,k=new Set;for(const e of x)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return Ws("div",{ref:h,id:n,className:Ys,tabIndex:-1,onBlur:y,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:m}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:b>0?`First ${v} of ${p.length} data points`:`All ${p.length} data points`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"type"}),w.map(e=>Is("th",{style:qs,children:e},e))]})}),Is("tbody",{children:x.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.label}),w.map(t=>{return Is("td",{style:Us,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Os(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Qs,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function Js({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Ss.useState(!1),[a,c]=Ss.useState(5),l=Ps(),u=l?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ss.useRef(null);Ss.useEffect(()=>{h||c(5)},[h]);const y=Ss.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),p=Ss.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?Is("span",{id:r,tabIndex:-1,style:Rs}):null;if(!h)return Is("div",{id:r,className:Bs,tabIndex:-1,onFocus:y,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],v=new Map,x=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";x.set(e,(x.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";v.set(e,(v.get(e)??0)+1),b.set(e,(b.get(e)??0)+o)}}const w=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=v.get(r)??0,i=x.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let A=0,S=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>S&&(S=t.degree);A=e/w.length}const _=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${Os(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),T=w.length-C;return Ws("div",{ref:f,id:r,className:js,tabIndex:-1,onBlur:p,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:M.join(" ")}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:T>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"id"}),Is("th",{style:qs,children:"degree"}),Is("th",{style:qs,children:"in"}),Is("th",{style:qs,children:"out"}),_&&Is("th",{style:qs,children:"w. degree"}),_&&Is("th",{style:qs,children:"w. in"}),_&&Is("th",{style:qs,children:"w. out"})]})}),Is("tbody",{children:P.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.id}),Is("td",{style:Us,children:e.degree}),Is("td",{style:Us,children:e.inDeg}),Is("td",{style:Us,children:e.outDeg}),_&&Is("td",{style:Us,children:Os(e.wDegree)}),_&&Is("td",{style:Us,children:Os(e.wInDeg)}),_&&Is("td",{style:Us,children:Os(e.wOutDeg)})]},t))})]}),T>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Qs,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function ea({summary:e}){return e?Is("div",{role:"note",style:Rs,children:e}):null}function ta({tableId:e}){return Is("a",{href:"#"+e,style:Rs,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Rs)},children:"Skip to data table"})}import{jsx as na}from"react/jsx-runtime";var ra="var(--semiotic-focus, #005fcc)";function oa({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=na("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"})}else u=na("circle","wedge"===o?{cx:c,cy:l,r:12,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"});else u=na("g",{transform:`translate(${n.left},${n.top})`,children:na("path",{d:a,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"})});return na("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as ia from"react";function sa(e,t){return"touch"===t?Math.max(e,24):e}function aa(e){return Array.isArray(e)?e[0]:e}function ca(e,t,n,r){return{data:aa(e),x:t,y:n,__semioticHoverData:!0,...r}}var la=["name","label","title"],ua=["type","kind","category","group","class","status","role","shape"],ha=["value","amount","total","count","weight","score"],da=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function fa(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function ya(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&da.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>la.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let c=o.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=fa(c,ua),u=fa(c,ha),h=new Set(ua),d=new Set(ha),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as pa,jsxs as ga}from"react/jsx-runtime";var ma={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};import{jsx as va}from"react/jsx-runtime";function xa({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=ia.useRef(null),[u,h]=ia.useState(null);ia.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,r,c]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!ia.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:ma;return c?va("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}import*as ba from"react";import{useCallback as ka,useEffect as wa,useLayoutEffect as Aa,useMemo as Sa,useRef as _a}from"react";import{useState as Ma,useEffect as Ca}from"react";import{useRef as Pa,useState as Ta,useEffect as Ra}from"react";var Da=()=>"undefined"!=typeof performance?performance.now():Date.now();function Na(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function La(e,t){const n=e();return Number.isFinite(n)?n:t}var Ea=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Da,this.lastWallTime=La(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=La(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Da;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=La(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Na(n)))}},Ia="undefined"==typeof window?wa:Aa,Wa={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function $a(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function za(e){const t=function(){const[e,t]=Ma(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Ca(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=_a(t);n.current=t;const[r,o]=function(e,t,n){const r=Pa(null),[o,i]=Ta(null);return Ra(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=Sa(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),c=o[0]-a.left-a.right,l=o[1]-a.top-a.bottom,u=$a(e.foregroundGraphics,o,a),h=$a(e.backgroundGraphics,o,a),d=H(e=>e.theme),{transition:f,introEnabled:y}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+ba.useId(),g=_a(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Ea({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const v=_a(null),x=_a(e.frameScheduler??Wa);x.current=e.frameScheduler??Wa;const b=_a(null),k=_a(!1),w=_a(()=>{}),A=ka(()=>{if(null!==v.current||k.current)return;const e=x.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),v.current=null,b.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(v.current=r,b.current=e)},[]),S=ka(()=>{null!==v.current&&((b.current??x.current).cancelAnimationFrame(v.current),v.current=null,b.current=null)},[]);Ia(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),wa(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),wa(()=>()=>{S()},[S]);const _=_a(()=>{}),M=_a(()=>{}),C=_a(null),P=_a(null),T=_a(null),R=ka(()=>{const e=C.current;C.current=null,e&&_.current(e)},[]),D=ka(e=>{if(C.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=x.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,T.current=null,R()});t||(P.current=n,T.current=e)}},[R]),N=ka(()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null),M.current()},[]);wa(()=>()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null)},[]);const L=e.themeDirtyRef;return Ia(()=>{L&&(Xn++,L.current=!0,A())},[d,A,L]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:y,tableId:p,frameRuntime:m,rafRef:v,renderFnRef:w,scheduleRender:A,cancelRender:S,hoverHandlerRef:_,hoverLeaveRef:M,onPointerMove:D,onPointerLeave:N}}import{useEffect as Oa,useRef as Fa}from"react";import{jsx as Ba}from"react/jsx-runtime";function Ya(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=Fa(null),a=Fa(null),c=Fa(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;us(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[t,n]);const c=as(a);c.current=a,is(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),Oa(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),Oa(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function ja({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?Ba("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:Ba("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Ha(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Xa(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,c,0,0),o.translate(n.left,n.top),o}function Ga(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}import{useCallback as Va,useRef as qa}from"react";function Ua(e,t,n,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}var Ka=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qa=3156e7;function Za(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Ja(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:ft(n.size)});else if("glyph"===n.type){const e=Fn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as ec}from"d3-shape";function tc(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function nc(e,t,n,r,o,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;c>r&&(i*=r/c),c>a-r&&(i*=(a-r)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var rc=(e,t,n,r)=>{const o=t.filter(e=>"line"===e.type);for(const t of o){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const o=t.style.stroke||"#007bff",i=Un(e,o)||o,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){nc(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=fr(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},o=null,s=null,l=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=c[h],p=tc(y,a,i);if(null!==o&&null!==u&&null!==l){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>y)&&(n>l||y>n)||l===n||y===n||t.push({t:(n-l)/(y-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=o+(d-o)*c.t,u=s+(f-s)*c.t,h=tc(l+(y-l)*Math.min(c.t+1e-4,1),a,i);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}o=d,s=f,l=y,u=p}else n(p,d,f),o=d,s=f,l=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?gr(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=yr(e,t.style.fill,t.style.fill),l&&!u)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function oc(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ic(e,t,n=.3){oc(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function sc(e,t,n=.6){if(!oc(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function ac(e,t,n,r=.35){oc(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as cc,line as lc}from"d3-shape";function uc(e,t){const n=fr(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=cc().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var hc=(e,t,n,r)=>{const o=t.filter(e=>"area"===e.type);for(const t of o){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const i=yr(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(uc(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const o=pr(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);e.fillStyle=o||i,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(uc(e,t),ac(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?gr(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=fr(t.curve);if(e.beginPath(),r)lc().x(e=>e[0]).y(e=>e[1]).curve(r).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==o&&1>o&&e.restore(),n&&e.restore(),e.globalAlpha=1}},dc=(e,t,n,r)=>{const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{const t=e.globalAlpha;for(const n of o)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=yr(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=yr(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),sc(e,n)}finally{e.restore()}}},fc=new Map;function yc(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=fc.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),fc.size>256&&fc.clear(),fc.set(t,n)),n}catch{return null}}var pc=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=yc(t);if(!o)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#4e79a7"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=yr(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}e.globalAlpha=n};function gc(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=In(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=yr(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=On(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Bn(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Bn(e,i,l,t.accent,void 0,c),e.restore()}function mc(e,t){const{x:n,y:r,w:o,h:i}=t,{tl:s,tr:a,br:c,bl:l}=function(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+o-a,r),a>0&&e.arcTo(n+o,r,n+o,r+a,a),e.lineTo(n+o,r+i-c),c>0&&e.arcTo(n+o,r+i,n+o-c,r+i,c),e.lineTo(n+l,r+i),l>0&&e.arcTo(n,r+i,n,r+i-l,l),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function vc(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var xc=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)bc(e,t);else if(t.cornerRadii&&Zi(t.cornerRadii)){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,mc(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+l-i),e.arcTo(s,a+l,s+i,a+l,i),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s+i,a+l),e.arcTo(s,a+l,s,a+l-i,i);break;default:e.moveTo(s,a+l),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}ic(e,t),e.globalAlpha=1}};function bc(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=o+r,s=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,s,r,o,o)}else{const i=o+r,s=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,s,o,o)}e.restore()}function kc(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function wc(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ac=(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Un(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),ic(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):wc(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=kc(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}},Sc=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);const i=Un(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,i=Un(e,o)||o;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&c(),e.restore()}},_c={line:[hc,rc,dc],area:[hc,dc],stackedarea:[hc,dc],scatter:[dc,pc],bubble:[dc,pc],heatmap:[Ac],bar:[xc],swarm:[dc],waterfall:[(e,t,n,r)=>{xc(e,t);const o=t.filter(e=>"rect"===e.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=Un(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){const r=o[t],i=o[t+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Sc],mixed:[hc,rc,dc],custom:[hc,xc,Ac,rc,dc,pc,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.x,r.y,n);e.globalAlpha=n},Sc]},Mc=new Set;function Cc(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Pc(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Mc.has(n)||(Mc.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Tc(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=Cc(r,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}c||(Pc(n.id,e.type??"unknown"),i([e]))}a()}function Rc(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=Cc(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Pc(i.id,t.type??"unknown"),o())}import{jsx as Dc,jsxs as Nc}from"react/jsx-runtime";import{jsx as Lc,jsxs as Ec}from"react/jsx-runtime";function Ic(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Wc({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=ya(t);if(null!=e.title||e.entries.length>0)return Ec("div",{className:"semiotic-tooltip",style:ma,children:[null!=e.title&&Lc("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>Ec("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",Lc("span",{style:{fontWeight:600},children:Ic(e.value)})]},e.key))]})}return Ec("div",{className:"semiotic-tooltip",style:ma,children:[Lc("div",{style:{fontWeight:600,marginBottom:2},children:Ic(n)}),Lc("div",{style:{opacity:.7,fontSize:11},children:Ic(r)})]})}function $c(e){return"touch"===e?"touch":"pointer"}function zc(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function Oc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function Fc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}Wc.ownsChrome=!0;import{useCallback as Bc}from"react";import{useCallback as Yc,useRef as jc}from"react";function Hc(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}function Xc(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Gc(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Vc(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Vc(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Vc(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function qc(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=Fn(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:o});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function Uc(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as Kc,jsxs as Qc}from"react/jsx-runtime";var Zc={top:20,right:20,bottom:30,left:40},Jc=ws;function el(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var tl=l(c(function(c,l){const{chartType:u,runtimeMode:h,data:d,chunkThreshold:f,chunkSize:y,xAccessor:p,yAccessor:g,accessorRevision:m,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w,lineDataAccessor:S,curve:C,normalize:P,baseline:T,stackOrder:R,binSize:D,valueAccessor:N,arrowOfTime:L="right",windowMode:E="sliding",windowSize:I=200,timeAccessor:$,xExtent:z,yExtent:O,extentPadding:F=.1,scalePadding:B,sizeRange:Y,size:j=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,renderMode:U,lineStyle:K,pointStyle:Q,areaStyle:Z,barStyle:J,waterfallStyle:ee,swarmStyle:te,barColors:ne,colorScheme:re,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:ce,lineGradient:le,areaGroups:ue,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,showAxes:ge=!0,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ke,yFormat:we,axisExtent:Ae,tickFormatTime:Se,tickFormatValue:_e,hoverAnnotation:Me,tooltipContent:Ce,customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,annotationObservationCallback:De,chartId:Ne,enableHover:Le,hoverRadius:Ee=30,tooltipMode:Ie,annotations:We,onAnnotationActivate:$e,autoPlaceAnnotations:ze,svgAnnotationRules:Oe,showGrid:Fe,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,legendCategoryAccessor:qe,onCategoriesChange:Ue,backgroundGraphics:Ke,foregroundGraphics:Ze,canvasPreRenderers:Je,svgPreRenderers:et,title:tt,categoryAccessor:nt,brush:rt,onBrush:ot,decay:it,pulse:st,transition:at,animate:ct,staleness:lt,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt=!1,suspendWhenHidden:gt=!0,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,marginalGraphics:wt,pointIdAccessor:At,xScaleType:St,yScaleType:_t,accessibleTable:Mt=!0,description:Ct,summary:Pt,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt,customLayout:Dt,onLayoutError:Nt,layoutConfig:Lt,layoutSelection:Et}=c,{customHoverBehavior:It,customClickBehavior:Wt,hasClickBehavior:$t}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:o}){return{customHoverBehavior:Bc((t,i)=>{e?.(t,i),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:o,chartId:r,context:i})},[r,o,e,n]),customClickBehavior:Bc((e,i)=>{t?.(e,i),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:o,chartId:r,context:i})},[r,o,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,chartId:Ne,chartType:"StreamXYFrame"}),zt=a().replace(/:/g,""),Ot=t(!1),Ft=t({w:-1,h:-1}),Bt=t(!1),Yt=za({sizeProp:j,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:Zc,title:tt,legend:Be,legendPosition:Ge,animate:ct,transitionProp:at,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt,suspendWhenHidden:gt,themeDirtyRef:Ot}),jt=hs(),Ht=ps(),{reducedMotionRef:Xt,responsiveRef:Gt,size:Vt,currentTheme:qt,transition:Ut,introEnabled:Kt,tableId:Qt,rafRef:Zt,renderFnRef:Jt,scheduleRender:en,frameRuntime:tn}=Yt;let nn=Yt.margin;if(wt){const e=60,t={...Yt.margin};wt.top&&e>t.top&&(t.top=e),wt.bottom&&e>t.bottom&&(t.bottom=e),wt.left&&e>t.left&&(t.left=e),wt.right&&e>t.right&&(t.right=e),nn=t}const rn=Vt[0]-nn.left-nn.right,sn=Vt[1]-nn.top-nn.bottom,an=o(()=>_(d),[d]),cn=Me??Le,[ln,un]=n(0),hn=t(0),[dn,fn]=n(null),yn=Ha(Ze,Vt,nn,dn),mn=Ha(Ke,Vt,nn,dn),xn=t(null),bn=t(null),kn=t(void 0),[wn,Sn]=n(null),_n=t(Jc.primary),Pn=t(function(){let e=-1,t=ws;return{resolve(n){if(!n)return ws;const r=Xn;return r===e||(t=function(e){if(!e)return ws;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=o||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||ws.axisStroke,tickText:s||ws.tickText,crosshair:s?As(s,"66"):ws.crosshair,hoverFill:l?As(l,"4D"):ws.hoverFill,hoverStroke:s?As(s,"99"):ws.hoverStroke,pointRing:l||ws.pointRing,primary:i||ws.primary,background:l||ws.background}:ws}(n),e=r),t},invalidate(){e=-1}}}()),Tn=t(!1),Rn=pn("StreamXYFrame"),[Dn,Nn]=n(!1),[Ln,En]=n([]),[In,Wn]=n([]),$n="streaming"===h||["bar","swarm","waterfall"].includes(u),zn=ms(o(()=>({chartType:u,runtimeMode:$n?"streaming":"bounded",windowSize:I,windowMode:E,arrowOfTime:$n?L:"right",extentPadding:F,scalePadding:B,axisExtent:Ae,xAccessor:p,yAccessor:g,accessorRevision:m,timeAccessor:$n?$:void 0,valueAccessor:N,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w||(S?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:S,xScaleType:St,yScaleType:_t,xExtent:z,yExtent:O,sizeRange:Y,binSize:D,normalize:P,baseline:T,stackOrder:R,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:ue?new Set(ue):void 0,lineGradient:le,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,lineStyle:K,pointStyle:Q,areaStyle:Z,swarmStyle:te,waterfallStyle:ee,colorScheme:re,barColors:ne,barStyle:J,annotations:We,decay:it,pulse:st,transition:Ut,introAnimation:Kt,staleness:lt,clock:tn.now,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,pointIdAccessor:At,curve:C,themeCategorical:qt?.colors?.categorical,themeSemantic:W(qt),themeSequential:qt?.colors?.sequential,themeDiverging:qt?.colors?.diverging,customLayout:Dt,onLayoutError:Nt,layoutConfig:Lt,layoutMargin:nn}),[u,$n,I,E,L,F,B,Ae,p,g,m,$,N,v,x,b,k,w,S,nt,St,_t,z,O,Y,D,P,T,R,oe,ie,se,ae,ce,ue,le,he,de,fe,ye,pe,K,Q,Z,te,ee,re,ne,J,We,it,st,Ut,Kt,lt,tn.now,mt,vt,xt,bt,kt,At,C,qt,Dt,Nt,Lt,nn])),On=t(null);On.current||(On.current=new on(zn));const Fn=function(e,t,n,r){const o=qa({accessor:t,onChange:n,readData:r}),i=qa([]);return o.current={accessor:t,onChange:n,readData:r},Va(()=>{const{accessor:t,onChange:n,readData:r}=o.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),r.push(i))}return r}(e.current?r(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,n(s))},[e])}(On,qe,Ue,e=>e.getData());Mn(On,zn,Ot,en),Cn(On,Et,Ot,en);const Bn=t(null);Bn.current||(Bn.current=new M(e=>{const t=On.current;t&&t.ingest(e)&&(Ot.current=!0,en())},{chunkThreshold:f,chunkSize:y})),r(()=>{Bn.current?.updateChunkOptions({chunkThreshold:f,chunkSize:y})},[f,y]);const Yn=i(e=>{Bn.current?.push(e)},[]),jn=i(e=>{Bn.current?.pushMany(e)},[]),Hn=i(()=>{Bn.current?.clear(),On.current?.clear(),Ot.current=!0,en()},[en]);s(l,()=>({push:Yn,pushMany:jn,remove:e=>{Bn.current?.flush();const t=On.current?.remove(e)??[];return t.length>0&&(xn.current&&t.some(e=>e===xn.current?.data)&&(xn.current=null,Sn(null)),Ot.current=!0,en()),t},update:(e,t)=>{Bn.current?.flush();const n=On.current?.update(e,t)??[];return n.length>0&&(Ot.current=!0,en()),n},clear:Hn,getData:()=>(Bn.current?.flush(),On.current?.getData()??[]),getScales:()=>On.current?.scales??null,getExtents:()=>On.current?.getExtents()??null,getCustomLayout:()=>On.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>On.current?.lastCustomLayoutFailure??null}),[Yn,jn,Hn,en]),r(()=>{if(d){if(S&&an.length>0&&"object"==typeof an[0]&&null!==an[0]){const e="string"==typeof S?S:"coordinates";if(Array.isArray(an[0][e])){const t=[];for(const n of an){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void Bn.current?.setBoundedData(t)}}Bn.current?.setBoundedData(an)}},[d,an,S]);const{canvasRef:Gn,interactionCanvasRef:Vn}=Ya(Yt,{storeRef:On,dirtyRef:Ot,hydrated:jt,wasHydratingFromSSR:Ht,cleanup:()=>Bn.current?.clear(),canvasPaintDependencies:[u,rn,sn,ge,q,Ke,K,U,Je,en]}),{hoverHandlerRef:qn,hoverLeaveRef:Un,onPointerMove:Kn,onPointerLeave:Qn}=Yt;qn.current=e=>{if(!cn)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void(xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en()));const i=On.current;if(!i||0===i.scene.length)return;const s=sa(Ee,e.pointerType),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius),c="multi"===Ie,l=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&It(null),en())};if(!a&&!c)return void l();const h=c||!a?r:a.x,d=c||!a?o:a.y,f=a?.datum?Qe(a.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=ca(f,h,d,null!=g?{xValue:g,xPx:h}:void 0);if(c&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=kr(xr(e.path,e.curve),t,n);if(null===i)continue;const s=Dr(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=xr(e.topPath,e.curve),s=xr(e.bottomPath,e.curve),a=kr(i,t,n);if(null===a)continue;const c=kr(s,t,n),l=Dr(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(i.scene,h,Math.max(s,rn));if(e.length>0){const t=i.scales.y.invert,n=_n.current,r=y?y(h):h;if(a)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof p&&(e[p]=r),m=ca(e,h,d,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===u&&null!=o?r-o:r,valuePx:e.y,color:e.color||n,datum:Qe(e.datum,i.resolvedRibbons)}})}}a||m.allSeries?.length?(xn.current=m,bn.current=a?.node??null,Sn(m),It&&(It(m),Ot.current=!0),en()):l()},Un.current=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en())};const Zn=t(()=>{});Zn.current=e=>{if(Qo(e.target))return;if(!Wt)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void Wt(null);const i=On.current;if(!i||0===i.scene.length)return void Wt(null);const s=sa(Ee,kn.current),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void Wt(null);const c=a.datum||{},l=i.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Wt(ca(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:$c(kn.current)})};const er=i(e=>Zn.current(e),[]),{kbFocusIndexRef:tr,focusedNavPointRef:rr,onKeyDown:or}=(cr={storeRef:On,hoverRef:xn,hoveredNodeRef:bn,setHoverPoint:Sn,customHoverBehavior:It,customClickBehavior:Wt,scheduleRender:en},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:o,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=jc(-1),u=jc(null),h=jc(null),d=Yc(d=>{if(zc(d))return;const f=e.current;if(!f)return;const y=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),o(null),s()};if(0===f.scene.length)return void(0>l.current||y());let p;if(h.current?.version===f.version)p=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||y());p=Hc(e),h.current={version:f.version,graph:p}}let g=l.current;if(p.flat.length>g||(y(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void i(c(p.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),l.current=0;const e=p.flat[0];u.current=e;const n=c(e,f);return t.current=n,r(n),o(n,{type:"focus",inputType:"keyboard"}),void s()}const m=Gc(d.key,Xc(p,g),p);if(null===m)return;if(d.preventDefault(),0>m)return void y();l.current=m;const v=p.flat[m];u.current=v;const x=c(v,f);t.current=x,r(x),o(x,{type:"focus",inputType:"keyboard"}),s()},[i,o,a,t,n,s,r,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:d}}({...cr,extractPoints:qc,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:Qe(e.datum,t.resolvedRibbons)})})),ir=i(e=>{kn.current=e.pointerType,tr.current=-1,rr.current=null,Kn(e)},[rr,tr,Kn]),sr=i(e=>{kn.current="mouse",tr.current=-1,rr.current=null,Kn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[rr,tr,Kn]),ar=i(e=>{kn.current=e.pointerType},[]);var cr;Jt.current=()=>{if(Zt.current=null,!tn.isActive)return;const e=Gn.current,t=Vn.current;if(!e||!t)return;const n=On.current;if(!n)return;const r=tn.now(),o=n.advanceTransition(Xt.current?r+1e6:r),i=!Xt.current&&o,s=Ft.current.w!==rn||Ft.current.h!==sn,a=Ot.current||o||s,c=n.consumeStylePaintPending();let l=!1;const h=n.getLastUpdateResult(),d=Rn.current.beforeCompute(h,i);!a||i&&!s||(n.computeScene({width:rn,height:sn}),Ft.current={w:rn,h:sn},l=!0,Fn()),Rn.current.afterCompute(d,l,s);const f=function(e,t,n,r){const o=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!o)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(n,r,l,Bt),y=Ga(),m=Pn.current.resolve(e);_n.current=m.primary;const v=Wr(lt,n.lastIngestTime>0?r-n.lastIngestTime:0),x=lt&&v.isStale;if(a||c||f.changed){const t=Xa(e,Vt,nn,y);if(t){if(t.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),lt&&1>v.alpha&&(t.globalAlpha=v.alpha),ks(t,{background:q,hasBackgroundGraphics:!!Ke,themeBackground:m.background,x:-nn.left,y:-nn.top,width:Vt[0],height:Vt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,rn,sn),t.clip()),Je&&n.scales)for(const e of Je)t.save(),e(t,n.scene,n.scales,{width:rn,height:sn}),t.restore();const e=Dt?_c.custom:_c[u];Tc({context:t,nodes:n.scene,renderMode:U,pixelRatio:y,paintBuiltIn:r=>{if(e&&n.scales)for(const o of e)o(t,r,n.scales,{width:rn,height:sn})}}),t.restore(),lt&&1>v.alpha&&(t.globalAlpha=1)}}const b=!!(cn&&xn.current&&n.scales),k=!!(bn.current&&Array.isArray(Me)&&Me.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||Tn.current){const e=Xa(t,Vt,nn,y);if(e&&(e.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),b&&xn.current&&function(e,t,n,r,o,i,s){if(!1===o.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,r),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,xn.current,rn,sn,"object"==typeof cn?cn:{},bn.current,m),k&&bn.current&&Array.isArray(Me))){const t=Me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||o.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,n.scene,bn.current,t,m)}Tn.current=w}a&&e&&e.setAttribute("aria-label",$s(n.scene,u+" chart"));const A=Ot.current;if(Ot.current=A&&i&&!l,A&&n.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!dn||e(dn.x.domain()[0])!==e(n.scales.x.domain()[0])||e(dn.x.domain()[1])!==e(n.scales.x.domain()[1])||e(dn.y.domain()[0])!==e(n.scales.y.domain()[0])||e(dn.y.domain()[1])!==e(n.scales.y.domain()[1])||dn.x.range()[0]!==n.scales.x.range()[0]||dn.x.range()[1]!==n.scales.x.range()[1]||dn.y.range()[0]!==n.scales.y.range()[0]||dn.y.range()[1]!==n.scales.y.range()[1])&&fn(n.scales),wt){const e=n.getData(),t="function"==typeof p?p:e=>e[p||"x"],r="function"==typeof g?g:e=>e[g||"y"];En(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wn(e.map(e=>r(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((We&&We.length>0||Dt)&&(l||i))||!l&&33>r-hn.current||(un(e=>e+1),hn.current=r),lt?.showBadge&&Nn(!!x),(i||null!=n.activeTransition||f.pending)&&en()},$r(lt,On,Ot,en,Dn,Nn);const lr=o(()=>{if(ke||Se)return;const e=On.current;return e?.xIsDate&&dn?Za(dn.x.domain()):void 0},[ke,Se,dn]),ur=ke||Se||lr,hr=cn&&wn?Ce?Ce(wn):Kc(Wc,{hover:wn}):null,dr=hr?Kc(xa,{x:wn.x,y:wn.y,containerWidth:rn,containerHeight:sn,margin:nn,className:"stream-frame-tooltip",children:hr}):null,fr=rr.current,yr=Kc(oa,{active:tr.current>=0,hoverPoint:wn,margin:nn,size:Vt,shape:fr?.shape,width:fr?.w,height:fr?.h}),pr=Ua(p,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),gr=Ua(g,N,"__semiotic_resolvedY","__semiotic_resolvedValue"),mr=pr.key,vr=gr.key,wr=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let o=!1;const i=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return o?i:r}}(pr,gr,We&&We.length>0||!1);if(os||!jt&&Ht){const t=On.current;t&&d&&(t.ingest({inserts:an,bounded:!0}),t.computeScene({width:rn,height:sn}));const n=t?.scene??[],r=t?.scales??null,o=Ha(Ze,Vt,nn,r),i=Ha(Ke,Vt,nn,r),s=ur||(()=>{if(t?.xIsDate&&r)return Za(r.x.domain())})();return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1]},children:[Kc(ea,{summary:Pt}),Qc("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vt[0],height:Vt[1],style:{position:"absolute",left:0,top:0},children:[Kc("g",{transform:`translate(${nn.left},${nn.top})`,children:i}),Qc("g",{transform:`translate(${nn.left},${nn.top})`,children:[q&&Kc("rect",{x:0,y:0,width:rn,height:sn,fill:q}),et&&r&&et.map((t,o)=>Kc(e.Fragment,{children:t(n,r,{width:rn,height:sn})},"svgpre-"+o)),n.map((e,t)=>Rc({node:e,index:t,renderMode:U,fallback:()=>function(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return Ji("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,i=`${n?n+"-":""}area-${t}-hatch`,s=Jn(r.style.fill)?nr(r.style.fill,i):void 0,a=s?`url(#${i})`:ns(r.style.fill);if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return es("g",{children:[es("defs",{children:[s,Ji("clipPath",{id:e,children:Ji("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return es(Ki.Fragment,{children:[s&&Ji("defs",{children:s}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("circle",{cx:r.x,cy:r.y,r:r.r,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return function(e,t){const n=dt(e.symbolType,e.size,e.path);return Ji("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?ns(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return rs(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return es("g",{children:[Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),Ji("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return es("g",{children:[Ji("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Ji("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,zt)})).filter(Boolean)]})]}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:r,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:s,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(o,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:[],yValues:[],annotations:We,onAnnotationActivate:$e,onObservation:De??Re,chartId:Ne,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:0,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt})]})}return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1],overflow:"visible",touchAction:el(rt)},onKeyDown:or,children:["production"!==process.env.NODE_ENV&&On.current&&Kc(gn,{store:On.current,diagnostics:Rn.current}),Mt&&Kc(ta,{tableId:Qt}),Mt&&Kc(Zs,{scene:On.current?.scene??[],chartType:u+" chart",tableId:Qt,chartTitle:"string"==typeof tt?tt:void 0}),Kc(ea,{summary:Pt}),Kc(Ds,{hoverPoint:wn}),Qc("div",{role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:cn?ir:void 0,onMouseMove:cn?sr:void 0,onPointerLeave:cn?Qn:void 0,onMouseLeave:cn?Qn:void 0,onPointerDown:cn||$t?ar:void 0,onClick:$t?er:void 0,children:[Kc(ja,{size:Vt,margin:nn,children:mn}),Kc(Gi,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,showGrid:Fe,xFormat:ur,yFormat:we||_e,axisExtent:Ae}),Kc("canvas",{ref:Gn,"aria-label":$s(On.current?.scene??[],u+" chart"),style:{position:"absolute",left:0,top:0}}),Kc("canvas",{ref:Vn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ur,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(yn,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:Ln,yValues:In,annotations:We,onAnnotationActivate:$e,onObservation:De??Re,chartId:Ne,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:ln,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==q&&!Ke,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt}),(rt||ot)&&Kc(A,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,dimension:rt?.dimension??"xy",scales:dn,onBrush:ot??(()=>{}),binSize:D,snap:rt?.snap,binBoundaries:rt?.binBoundaries??("bar"===u?On.current?.getBinBoundaries():void 0),snapDuring:rt?.snapDuring,streaming:"streaming"===h}),lt?.showBadge&&Kc(Or,{isStale:Dn,position:lt.badgePosition}),yr,dr]})]})}));tl.displayName="StreamXYFrame";var nl=tl;import{useRef as rl,useState as ol,useEffect as il,useMemo as sl,useCallback as al,useImperativeHandle as cl,forwardRef as ll,memo as ul}from"react";var hl={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},dl={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},fl=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?yl(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function yl(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),c=s-a,[l,u,h,d]=e[a];pl(l,u,h,d,c,o);const f=d.x-l.x,y=d.y-l.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;o.x+=-y/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,s,a]=e.points;pl(o,i,s,a,t,r);const c=a.x-o.x,l=a.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;r.x+=-l/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function pl(e,t,n,r,o,i){const s=1-o,a=s*s,c=a*s,l=o*o,u=l*o;i.x=c*e.x+3*a*o*t.x+3*s*l*n.x+u*r.x,i.y=c*e.y+3*a*o*t.y+3*s*l*n.y+u*r.y}function gl(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function ml(e,t){var n,r=[],o=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,r,h=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),h=!0):i[r]||(h=l(r));if(h)c(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function h(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,r[c]=0,o[c]=!1,i[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(t){var c=[t],l=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,c.push(p),l.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}i[t]=y}else{if(r[t]===n[t]){var g=[],m=[],v=0;for(y=c.length-1;y>=0;--y){var x=c[y];if(o[x]=!1,g.push(x),m.push(a[x]),v+=a[x].length,s[x]=h.length,x===t){c.length=y;break}}h.push(g);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;d.length>c;c++){var y=d[c];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&l.push(y[p]);d[c]=l}}return{components:h,adjacencyList:d}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var c=o[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}l(n),n+=1}else n=d}return t?void 0:r}function vl(e){return e.y0-e.y1>0?"up":"down"}function xl(e,t){return t(e.source)==t(e.target)}function bl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function kl(e){return e.target.x0-e.source.x1}function wl(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1-r:e.y1+r}function Al(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1+r:e.y1-r}function Sl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function _l(e,t){return t(e)}function Ml(e){return Pl(e.source)}function Cl(e){return Pl(e.target)}function Pl(e){return(e.y0+e.y1)/2}function Tl(e){return e.virtual?0:e.value}function Rl(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!xl(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!xl(e,t)?r+1:r}),n+r}function Dl(e){return e.target.depth}function Nl(e,t){return e.sourceLinks.length?e.depth:t-1}function Ll(e,t){return e.y0-t.y0}function El(e,t){return t.y0-e.y0}function Il(e,t){return e.y1-t.y1}function Wl(e,t){return t.y1-e.y1}function $l(e,t){return Ol(e.source,t.source)||e.index-t.index}function zl(e,t){return Ol(e.target,t.target)||e.index-t.index}function Ol(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fl(e,t){return Bl(e)==Bl(t)?"bottom"==e.circularLinkType?El(e,t):Ll(e,t):Bl(t)-Bl(e)}function Bl(e){return e.target.column-e.source.column}function Yl(e,t){return jl(e)==jl(t)}function jl(e){return e.y0-e.y1>0?"up":"down"}import{min as Hl}from"d3-array";function Xl(e,t,n,r,o){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=Hl(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Gl(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Gl(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,xl(e,t)&&bl(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?El:Ll);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Wl:Il),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Gl(e,t,n){e.sort(Fl);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xl(e,t)&&bl(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Vl(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Vl(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as ql,max as Ul,sum as Kl,mean as Ql,group as Zl,groups as Jl}from"d3-array";function eu(e){return function(){return e}}function tu(e){return e.index}function nu(e){return e.nodes}function ru(e){return e.links}function ou(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Rl(t,n)-Rl(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Rl(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function iu(e,t,n,r,o,i){var s=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rl(o,n)>0){var c=Ql(o.sourceLinks,Cl),l=Ql(o.targetLinks,Ml),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Pl(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=Ql(o.sourceLinks,Cl),f=Ql(o.targetLinks,Ml),y=((d&&f?(d+f)/2:d||f)-Pl(o))*t;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||Ol),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+r;if((s=c-r-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+o-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function su(e){e.nodes.forEach(function(e){e.sourceLinks.sort(zl),e.targetLinks.sort($l)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function au(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=tu,c=Nl,l=void 0,u=32,h=2,d=nu,f=ru;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return Zl(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=gl(n,r)),"object"!=typeof o&&(o=e.target=gl(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var c=ml(r);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||l[r]&&l[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(d,l),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){_l(e,t)!=_l(o.source,t)&&_l(e,t)!=_l(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xl(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Kl(e.sourceLinks,Tl),Kl(e.targetLinks,Tl)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(d),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(d,l,c);var f=i;if(null!==s){var y=Jl(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=Ul(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=ql(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Kl(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=Ul(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,o),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return _l(n.source,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Yl(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=wl(t,e);return e.y1-n}if(t.target.column>e.target.column)return wl(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return _l(n.target,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Yl(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Al(t,e);return e.y0-n}if(t.source.column>e.source.column)return Al(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=ql(t,function(e){return e.y0}),s=Ul(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(d),Xl(d,a,h,10,8)}(y),y}return y.update=function(e){return su(e),Xl(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(o=+e,y):o},y.nodePadding=function(e){return arguments.length?(i=+e,y):i},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:eu(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:eu(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:eu(e),y):a},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:eu(e),y):c},y.nodeSort=function(e){return arguments.length?(l=e,y):l},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}import{interpolateNumber as cu}from"d3-interpolate";import{line as lu,curveLinearClosed as uu}from"d3-shape";var hu=e=>{let t,n,r,o,i,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=cu(i,s),c=a(.5),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${r},${s}C${r},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,h=cu(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${o},${i}`,`L${o},${s}`,`C${c},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function du(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,c=r.rightFullExtent,l=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*t}L${c},${i-h*t}L${c+n},${i-h*t+h*d}L${c+n},${u+h*n-h*d}L${c+n-d},${u+h*n}L${l-n+d},${u+h*n}L${l-n},${u+h*n-h*d}L${l-n},${a-h*t+h*d}L${l-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${l+n},${a+h*t}L${l+n},${u-h*n}L${c-n},${u-h*n}L${c-n},${i+h*t}L${o},${i+h*t}Z`}var fu=new Set,yu=new WeakMap;function pu(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=yu.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,yu.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;fu.has(e)||(fu.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var gu={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Dl))-1:0},justify:Nl};function mu(e){return"string"==typeof e?e:e.id}var vu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=au().extent(h).links(u).nodes(l).nodeAlign(gu[i]||Nl).nodeId(e=>e.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of l)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],c=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>c)){const t=Math.min(a/i,c/s),r=-e*t+(a-i*t)/2,o=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const y=new Map;for(const e of t)y.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=mu(e.source),n=mu(e.target),r=y.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const h=[],d=[],f=[],y=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(pu(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?y.get(r.id)||u.get(r.id)||o:y.get(t.id)||u.get(t.id)||o;const i=s?s(pu(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?du(e):hu(e),l)&&d.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===o?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),f.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as xu,forceCenter as bu,forceX as ku,forceY as wu,forceLink as Au,forceManyBody as Su,forceCollide as _u}from"d3-force";import{scaleLinear as Mu}from"d3-scale";var Cu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const r=Pu(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Tu(e.id),i=o%360*(Math.PI/180),s=10+o%20;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=Tu(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),d=Ru(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const r=new Map,a=new Map;for(const t of e)r.set(t.id,0),a.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;r.set(t,(r.get(t)??0)+1),r.set(n,(r.get(n)??0)+1)}const c=Au().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(r.get("string"==typeof e.source?e.source:e.source.id)??1,r.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?a.get(e.source):e.source,n="string"==typeof e.target?a.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),l=xu();if(void 0===n.random&&void 0===n.seed||l.randomSource(n.random??Na(n.seed)),l.force("charge",Su().strength(e=>{const t=r.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",_u(e=>f(e)+3).strength(.9).iterations(2)).force("center",bu(i,s).strength(.8)).force("x",ku(i).strength(.06)).force("y",wu(s).strength(.06)),l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));c.links(e),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;h>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=Ru(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{},i={fill:r.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(pu(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(pu(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Pu(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Tu(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Ru(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=oo(o);if(i===s)return()=>(r[0]+r[1])/2;const a=Mu().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}import{chord as Du,ribbon as Nu}from"d3-chord";import{arc as Lu}from"d3-shape";var Eu=ie,Iu={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,c=a-i,l=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=h(e);p[n][r]=o}const g=Du().padAngle(o);s&&g.sortGroups(s);const m=g(p),v=m.groups,x=Lu().innerRadius(c).outerRadius(a);for(const t of v){const n=e[t.index],r=x.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+l,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=b.get("string"==typeof e.source?e.source:e.source.id),r=b.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,c=r[0]/2,l=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Eu,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=Nu().radius(a),g=[],m=[],v=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(pu(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const i=u?u(pu(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=Wu(r,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(pu(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=y.get(n.id)||s:t&&(s=y.get(t.id)||s)}const a=h?h(pu(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;v.push({x:c+Math.cos(s)*r,y:l+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:g,sceneEdges:m,labels:v}}};function Wu(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as $u,tree as zu,cluster as Ou,treemap as Fu,pack as Bu,partition as Yu,treemapBinary as ju}from"d3-hierarchy";var Hu=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xu(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Gu(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Vu(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function qu(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Hu}function Uu(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ku(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Qu={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=$u(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=zu();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=Ou();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=Fu().size([n,r]).tile(ju).padding(o);i>0&&s.paddingTop(i),s(e)}(l,n,u,h);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;Bu().size([n,r]).padding(o)(e)}(l,n,u,h);break;case"partition":!function(e,t,n,r){Yu().size([n,r]).padding(t.padding??1)(e)}(l,n,u,h)}const d=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],o={id:Gu(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Zu(o,r,n):"treemap"===i||"partition"===i?Ju(o,r):"circlepack"===i&&eh(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const i=o(pu(t,"nodeStyle"));let a=i.fill||Uu(n);if(n.colorByDepth&&void 0!==t.depth){const e=qu(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,c=r.x,f=r.y;u&&(o+=h,s+=d,c+=h,f+=d);const y=Ku(o,s,c,f,l),g=i(pu(e,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:e})}if(!1!==n.showLabels){const t=Vu(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");c.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=r(pu(n,"nodeStyle"));let a=s.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);a=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let h=r(pu(a,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==a.depth){const e=qu(t);h=e[a.depth%e.length]}const d="string"==typeof h?Xu(h):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(pu(n,"nodeStyle"));let s=i.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);s=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=r(pu(o,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==o.depth){const e=qu(t);c=e[o.depth%e.length]}if(a){const n="string"==typeof c?Xu(c):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Zu(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ju(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function eh(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}import{pie as th}from"d3-shape";function nh(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rh={sankey:vu,force:Cu,chord:Iu,tree:Qu,cluster:Qu,treemap:Qu,circlepack:Qu,partition:Qu,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=nh(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=y(s(e));r.push({id:v,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),d.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,p,g){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=a[Math.min(k,a.length-1)],k++,x++;let w=0;for(let v=0;x>v;v++){const b=a[Math.min(v,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(v+1)/x,S={id:n,depth:p,data:t,parentId:n},_=g?f/u(S)*A:f*A,M=th().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const i=(M[t].startAngle+M[t].endAngle)/2,a=k[t],u=y(s(a)),h=c+_*Math.sin(i),f=l+_*Math.cos(i)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:i,depth:p,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,_,p+1,!0)}w+=b}}(e,v,p,g,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=nh(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(pu(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=nh(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const c=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(c),t.y=r.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function oh(e){return rh[e]}import{quadtree as ih}from"d3-quadtree";function sh(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ah(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!ch(e))return!1;return!0}return ch(t.points)}function ch(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as lh}from"d3-interpolate";var uh="rgba(34, 197, 94, 0.7)",hh=2e3,dh=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fh=["scene-style","data-paint","accessibility","evidence"],yh=(e,t)=>({retainedData:e,invalidations:t}),ph=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gh=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mh=["scene-geometry","data-paint","overlay","accessibility","evidence"],vh=["scene-style","data-paint","accessibility","evidence"],xh=["scene-geometry","data-paint","overlay","accessibility","evidence"],bh=[],kh={chartType:yh("rebuild",ph),nodeIDAccessor:yh("rebuild",ph),sourceAccessor:yh("rebuild",ph),targetAccessor:yh("rebuild",ph),valueAccessor:yh("rebuild",ph),edgeIdAccessor:yh("rebuild",ph),childrenAccessor:yh("rebuild",ph),hierarchySum:yh("rebuild",ph),orientation:yh("preserve",gh),nodeAlign:yh("preserve",gh),nodePaddingRatio:yh("preserve",gh),nodeWidth:yh("preserve",gh),edgeSort:yh("preserve",gh),iterations:yh("preserve",gh),forceStrength:yh("preserve",gh),padAngle:yh("preserve",gh),groupWidth:yh("preserve",gh),sortGroups:yh("preserve",gh),treeOrientation:yh("preserve",gh),edgeType:yh("preserve",gh),padding:yh("preserve",gh),paddingTop:yh("preserve",gh),orbitMode:yh("preserve",gh),orbitSize:yh("preserve",gh),orbitSpeed:yh("preserve",gh),orbitRevolution:yh("preserve",gh),orbitRevolutionStyle:yh("preserve",gh),orbitEccentricity:yh("preserve",gh),orbitShowRings:yh("preserve",gh),orbitAnimated:yh("preserve",gh),customNetworkLayout:yh("preserve",gh),layoutConfig:yh("preserve",gh),nodeSize:yh("preserve",mh),nodeSizeRange:yh("preserve",mh),colorByDepth:yh("preserve",mh),nodeLabel:yh("preserve",xh),showLabels:yh("preserve",xh),labelMode:yh("preserve",xh),nodeStyle:yh("preserve",vh),edgeStyle:yh("preserve",vh),colorBy:yh("preserve",vh),colorScheme:yh("preserve",vh),themeCategorical:yh("preserve",vh),themeSemantic:yh("preserve",vh),edgeColorBy:yh("preserve",vh),edgeOpacity:yh("preserve",vh),showParticles:yh("preserve",vh),particleStyle:yh("preserve",vh),decay:yh("preserve",vh),pulse:yh("preserve",vh),thresholds:yh("preserve",vh),staleness:yh("preserve",vh),layoutSelection:yh("preserve",vh),clock:yh("preserve",bh),random:yh("preserve",bh),seed:yh("preserve",bh),tensionConfig:yh("preserve",bh),transition:yh("preserve",bh),introAnimation:yh("preserve",bh),onLayoutError:yh("preserve",bh),__skipForceSimulation:yh("preserve",bh),__hierarchyRoot:yh("preserve",bh),__orbitState:yh("preserve",bh),__previousPositions:yh("preserve",bh)},wh=yh("preserve",gh),Ah=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},dh)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},fh):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=kh[r]??wh;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};function Sh(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&we(n,e)||"#4e79a7":t=>{if(n){const e=we(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var _h=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Ah,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...hl,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new fl(2e3))}currentTime(){return this.config.clock?.()??Me()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...hl,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new fl(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],h="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...sh(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=l(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...sh(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...sh(o),data:n});const c=`${r}\0${o}\0${e}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&ah(n.bezier)&&(d.bezier=n.bezier),this.edges.set(c,d)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,sh(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,sh(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),c=this.edges.get(a);let l=!1;c?(c.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=oh(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const s=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return s}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:s}){const a=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=xe[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(e.colorScheme,e.themeCategorical,ie),c={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:Sh(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==i,r=bt("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void mt({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=oh(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=ih().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=oh(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=oh(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Se(e,this.transition),n=Ae(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=_e(e._prevX0,e._targetX0,n),e.x1=_e(e._prevX1,e._targetX1,n),e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n),e.sankeyWidth=_e(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,s=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:o}}const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const c=i-a;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const c=e.edgeTimestamps.get(`${s}\0${a}`);if(!c)continue;const l=i-c;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const s=Ee(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===uh&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=hh)return;const n=1-t/hh;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=uh,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&hh>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const s=i.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const c=t.metric(a);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=n):l=r,l&&(i.style={...i.style,fill:l},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};_h.QUADTREE_THRESHOLD=500;var Mh=_h;$t(Mh);import*as Ch from"react";import{Fragment as Ph,jsx as Th,jsxs as Rh}from"react/jsx-runtime";function Dh(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=e,S=Uo({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k}),_=Ch.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=Fn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,ft(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),M=Ch.useMemo(()=>m&&w?_i({annotations:m,context:_,..."object"==typeof w?w:{}}):m,[m,w,_]),C=Ch.useMemo(()=>si(),[]),P=M?ii(M.filter(e=>"widget"!==e.type),C,A,_):null,T=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Rh(Ph,{children:[T&&Th("style",{children:Bo},"annotation-widget-disclosure-style"),Rh("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Th("title",{children:"string"==typeof a?a:"Network Chart"}),Th("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),Rh("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>Th("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),P,p]}),a&&"string"==typeof a?Th("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Th("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,to({legend:c,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,r=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,h=e.content??Th("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return Th("div",{...Ko(e,S),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+a-l/2,top:s+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:h},"widget-"+t)})]})}Dh.displayName="NetworkSVGOverlay";import*as Nh from"react";import{jsx as Lh}from"react/jsx-runtime";var Eh={position:"absolute",top:0,left:0,pointerEvents:"none"};function Ih({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=Nh.useRef(null),i=function(e,t,n){const[r,o]=Nh.useState(null);return Nh.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Nh.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,s=t.left-n,a=t.right+n,c=t.top-n,l=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(s>t+e.width||t>a||c>n+e.height||n>l)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const s=Lh("div",{className:"semiotic-network-html-marks",ref:o,style:{...Eh,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>Lh("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?Lh(wn,{value:n,children:s}):s}import{jsx as Wh,jsxs as $h}from"react/jsx-runtime";function zh({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:c}){const{chartType:l,nodes:u,edges:h,data:d,className:f,description:y,title:p,responsiveWidth:g,responsiveHeight:m,summary:v,background:x,renderMode:b,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,layoutSelection:T,annotations:R,onAnnotationActivate:D,annotationObservationCallback:N,onObservation:L,chartId:E,autoPlaceAnnotations:I,svgAnnotationRules:W}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?d||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=_(u),n=Array.isArray(h)?_(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const $=t?.sceneNodes??[],z=t?.sceneEdges??[],O=t?.labels??[];return $h("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:g?"100%":r[0],height:m?"100%":r[1]},children:[Wh(ea,{summary:v}),$h("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&Wh("g",{transform:`translate(${o.left},${o.top})`,children:a}),$h("g",{transform:`translate(${o.left},${o.top})`,children:[x&&Wh("rect",{x:0,y:0,width:i,height:s,fill:x}),z.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"line":return Ji("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-circle-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-rect-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=Qi().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ts)||"",o=Jn(n.style.fill)?nr(n.style.fill,`net-arc-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[o&&Ji("defs",{children:o}),Ji("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=dt(n.symbolType,n.size,n.path);return Ji("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ns(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return rs(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),O.map((e,t)=>function(e,t){return Ji("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),Wh(Dh,{width:i,height:s,totalWidth:r[0],totalHeight:r[1],margin:o,labels:O,sceneNodes:$,title:p,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,foregroundGraphics:vn(c,An(t?.customLayoutOverlays,T??null)),annotations:R,onAnnotationActivate:D,onObservation:N??L,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:I,svgAnnotationRules:W,annotationFrame:0}),Wh(Ih,{marks:t?.customLayoutHtmlMarks,margin:o,selection:T??null})]})}import{jsx as Oh}from"react/jsx-runtime";"undefined"!=typeof process&&process;var Fh={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Bh={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Yh(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?Oh("div",{style:{...Fh,width:t,height:n},children:r||"No data available"}):null}function jh(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return Oh("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return Oh("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>Oh("div",{className:"semiotic-loading-bar",style:{...Bh,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Hh(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Xh(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Gh=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(Xh());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Xh())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Vh=null;import{jsx as qh,jsxs as Uh}from"react/jsx-runtime";var Kh=/^(value|amount|total|count|weight|score)$/i;function Qh({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?Uh("div",{className:"semiotic-tooltip",style:ma,children:[Uh("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{children:e.map((e,t)=>Uh("span",{children:[t>0&&qh("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?qh("strong",{children:e}):qh("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&qh("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=ya(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>Kh.test(e.key));return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>{return Uh("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Zh(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Jh(e,t){if(!t.pathD)return;e.save();const n=Zh(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=Un(e,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function ed(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Un(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function td(e,t){if(!t.pathD)return;e.save();const n=Zh(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function nd(e,t){if(!t.pathD)return;e.save();const n=Zh(t),r=t.style.stroke||"#999";e.strokeStyle=Un(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}Qh.ownsChrome=!0;var rd=new Map;function od(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=rd.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),rd.size>256&&rd.clear(),rd.set(t,n)),n}catch{return null}}function id(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:be,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return s.length}function sd(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=Pn(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const s=Nn(Math.atan2(o,r)),a=Nn(e.startAngle),c=Nn(e.endAngle);if(a>c?s>=a||c>=s:s>=a&&c>=s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.cx+o.centerDx,s=e.cy+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:s,distance:l}}(e,t,n,r);default:return null}}var ad=null,cd=null;function ld(){return cd||((ad=document.createElement("canvas")).width=1,ad.height=1,cd=ad.getContext("2d")),cd}function ud(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function hd(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let s=((t-e.x1)*r+(n-e.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,c=e.y1+s*o,l=Math.sqrt((t-a)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:a,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function dd(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,s=0){let a=null,c=o,l=1/0;if(i){const e=Yn(i,n,r,o,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=sd(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(a=e,l=n)}else c>e.distance&&(a=e,c=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=hd(e,n,r);t&&c>t.distance&&(a=t,c=t.distance)}return a}(a,c,d,f,h,l,u);return y?{kind:"hit",hover:ca(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{useCallback as fd}from"react";var yd="StreamNetworkFrame";import{jsx as pd,jsxs as gd}from"react/jsx-runtime";var md={top:20,right:80,bottom:20,left:80},vd={top:40,right:40,bottom:40,left:40},xd=new Set(["chord","force","circlepack","orbit"]),bd=[800,600],kd=ul(ll(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:v=300,forceStrength:x=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:C,treeOrientation:P="vertical",edgeType:T="curve",padding:R,paddingTop:D,tensionConfig:N,showParticles:L=!1,particleStyle:E,renderMode:I,nodeStyle:$,edgeStyle:z,colorBy:O,colorScheme:F="category10",edgeColorBy:B="source",edgeOpacity:Y=.5,colorByDepth:j=!1,nodeSize:H=8,nodeSizeRange:X=[5,20],nodeLabel:G,showLabels:V=!0,labelMode:q,size:U=bd,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,annotationObservationCallback:se,chartId:ae,onTopologyChange:ce,annotations:le,onAnnotationActivate:ue,autoPlaceAnnotations:he,svgAnnotationRules:de,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,title:ke,foregroundGraphics:we,backgroundGraphics:Ae,decay:Se,pulse:_e,transition:Me,animate:Ce,staleness:Pe,frameScheduler:Te,clock:Re,random:De,seed:Ne,paused:Le=!1,suspendWhenHidden:Ee=!0,thresholds:Ie,accessibleTable:We=!0,description:$e,summary:ze,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=xd.has(n)?vd:md,Ze=rl(!0),Je=za({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:ke,legend:fe,legendPosition:ye,foregroundGraphics:we,backgroundGraphics:Ae,animate:Ce,transitionProp:Me,frameScheduler:Te,clock:Re,random:De,seed:Ne,paused:Le,suspendWhenHidden:Ee,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedForeground:st,resolvedBackground:at,transition:ct,introEnabled:lt,tableId:ut,rafRef:ht,renderFnRef:dt,scheduleRender:ft,frameRuntime:yt,currentTheme:pt}=Je,gt=hs(),mt=ps(),vt=sl(()=>_(r),[r]),xt=sl(()=>Array.isArray(o)?_(o):o,[o]),bt=sl(()=>({...hl,...N}),[N]),kt=sl(()=>({...dl,...E}),[E]),wt=sl(()=>{return{chartType:(e={chartType:n,clock:yt.now,random:De,seed:Ne,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:D,tensionConfig:bt,showParticles:L,particleStyle:kt,nodeStyle:$,edgeStyle:z,nodeLabel:G,showLabels:V,labelMode:q,colorBy:O,colorScheme:F,edgeColorBy:B,edgeOpacity:Y,colorByDepth:j,nodeSize:H,nodeSizeRange:X,decay:Se,pulse:_e,transition:ct,introAnimation:lt,staleness:Pe,thresholds:Ie,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,currentTheme:pt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:W(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,yt.now,De,Ne,a,c,l,u,h,d,f,y,p,g,m,v,x,A,S,M,C,P,T,R,D,bt,L,kt,$,z,G,V,q,O,F,B,Y,j,H,X,Se,_e,ct,lt,Pe,Ie,Oe,Fe,Be,Ye,je,He,Xe,Ge,Ve,qe,Ue,pt]),At=ms(wt),St=ms({chartType:(_t={chartType:n,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:D,random:De,seed:Ne,tensionConfig:bt,customNetworkLayout:Ve,orbitMode:Oe,orbitSize:Fe,orbitEccentricity:He}).chartType,nodeIDAccessor:_t.nodeIDAccessor,sourceAccessor:_t.sourceAccessor,targetAccessor:_t.targetAccessor,valueAccessor:_t.valueAccessor,edgeIdAccessor:_t.edgeIdAccessor,childrenAccessor:_t.childrenAccessor,hierarchySum:_t.hierarchySum,orientation:_t.orientation,nodeAlign:_t.nodeAlign,nodePaddingRatio:_t.nodePaddingRatio,nodeWidth:_t.nodeWidth,iterations:_t.iterations,forceStrength:_t.forceStrength,padAngle:_t.padAngle,groupWidth:_t.groupWidth,sortGroups:_t.sortGroups,edgeSort:_t.edgeSort,treeOrientation:_t.treeOrientation,edgeType:_t.edgeType,padding:_t.padding,paddingTop:_t.paddingTop,random:_t.random,seed:_t.seed,tensionConfig:_t.tensionConfig,customNetworkLayout:_t.customNetworkLayout,orbitMode:_t.orbitMode,orbitSize:_t.orbitSize,orbitEccentricity:_t.orbitEccentricity});var _t;const Mt=rl(0),Ct=rl(0),Pt=rl(!1),Tt=rl(null);Tt.current||(Tt.current=new Mh(At));const Rt=pn("StreamNetworkFrame"),Dt=al((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(Rt.current,e,()=>e.buildScene(t),n),[Rt]),[Nt,Lt]=ol(null),[Et,It]=ol(0),[Wt,$t]=ol(0),[zt,Ot]=ol(!1),[Ft,Bt]=ol(!1),Yt=rl(0),jt=rl(null),Ht=rl(!1),Xt=rl(w);Xt.current=w;const Gt=rl(At);Gt.current=At;const Vt=rl(null),qt=rl(new Map),Ut=rl(0),Kt=al(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:be;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const s=Array.isArray(r)?r:be,a=n?s[i.current++%s.length]:s[0];return o.set(t.id,a),a}({node:e,colorBy:O,colorScheme:F,nodeColorMap:qt.current,colorIndexRef:Ut}),[O,F]),Qt=(Zt=pt,Zt?.colors?.border||Zt?.colors?.secondary||Zt?.colors?.primary||"#999");var Zt;const Jt=al(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Tt.current?.nodes),[]),en=al(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const s=o(t.source),a=o(t.target);return"target"===n&&a?r(a):s?r(s):i}({edge:e,edgeColorBy:B,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[B,Kt,Qt,Jt]),tn=al(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:c}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):c}if(!o)return i(t);const l=r,u=a(t.source),h=a(t.target);return"target"===l&&h?s(h):u?s(u):c}({edge:e,particleStyleColor:kt.color,particleColorBy:kt.colorBy,hasExplicitParticleColorBy:!!E?.colorBy,getEdgeColor:en,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[E?.colorBy,kt.color,kt.colorBy,Kt,en,Qt,Jt]),nn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ve,L,!!_e,Tt.current?.isAnimating??!1);Mn(Tt,At,Ze,ft),Cn(Tt,Ke,Ze,ft),il(()=>{const e=Tt.current;e&&(Dt(e,[ot,it]),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft())},[pt,ot,it,Dt,ft,F]);const rn=al(()=>{const e=Tt.current;if(e&&(e.runLayout([ot,it]),Dt(e,[ot,it]),Ze.current=!0,Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),It(e.layoutVersion),ce)){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[ot,it,Dt,ce,F]),on=al(e=>{if(null==e||"object"!=typeof e)return;const t=Tt.current;t&&(t.ingestEdge(e)&&rn(),ft())},[rn,ft]),sn=al(e=>{const t=Tt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&rn(),ft()},[rn,ft]),an=al(()=>{Tt.current?.clear(),qt.current.clear(),Ut.current=0,It(Tt.current?.layoutVersion??0),Lt(null),Vt.current=null,Ze.current=!0,ft()},[ft]),cn=al(()=>{const e=Tt.current;e&&(e.tension+=999,rn(),ft())},[rn,ft]);cl(t,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Tt.current?.removeNode(e)??!1;if(t){const t=Vt.current?.data?"function"==typeof a?a(Vt.current.data):Vt.current.data[a]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Lt(null)),qt.current.delete(e),rn(),Ze.current=!0,ft()}return t},removeEdge:(e,t)=>{const n=Tt.current?.removeEdge(e,t)??!1;if(n){if(Vt.current&&"edge"===Vt.current.nodeOrEdge){const n=Vt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,r&&(Vt.current=null,Lt(null))}rn(),Ze.current=!0,ft()}return n},updateNode:(e,t)=>{const n=Tt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,ft()),n},updateEdge:(e,t,n)=>{const r=Tt.current?.updateEdge(e,t,n)??[];return r.length>0&&(rn(),Ze.current=!0,ft()),r},clear:an,getTopology:()=>Tt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Tt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Tt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Tt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:cn,getTension:()=>Tt.current?.tension??0}),[on,sn,an,cn,a,rn,ft,h]);const ln=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),un=ln?i||(Array.isArray(o)?void 0:o):void 0;il(()=>{const e=Tt.current;if(!e)return;const t=++Yt.current;if(jt.current?.abort(),jt.current=null,ln&&un)e.ingestHierarchy(un,[ot,it]),Dt(e,[ot,it]),Bt(!1),Xt.current?.("ready"),Ze.current=!0,ft();else{const i=vt,s=Array.isArray(xt)?xt:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||an(),Bt(!1),void Xt.current?.("ready");const a=[ot,it],c="force"===n&&!Ve&&Hh()&&!De&&function(e,t,n,r,o=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}(b,i.length,s.length,v);if(c&&mt&&!Ht.current&&e.sceneNodes.length>0)return Ht.current=!0,Bt(!1),Xt.current?.("ready"),Ze.current=!0,void ft();if(c){const n=new AbortController;jt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const o=e.getLayoutData(),c=function(e,t,n,r,o){const i=Ru(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Gt.current,a,r);return Bt(!0),Xt.current?.("pending"),function(e,t){return Hh()?t?.aborted?Promise.reject(Xh()):(Vh&&!Vh.isDead||(Vh=new Gh),Vh).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Yt.current&&(e.applyForceLayoutPositions(n,a),Dt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("ready"),It(e.layoutVersion),Ze.current=!0,ft())}).catch(n=>{"AbortError"!==n.name&&t===Yt.current&&(e.runLayout(a),Dt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("error"),It(e.layoutVersion),Ze.current=!0,ft())}),()=>n.abort()}e.ingestBounded(i,s,a),Dt(e,a),Bt(!1),Xt.current?.("ready"),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft()}},[vt,xt,r,o,i,un,ln,ot,it,St,b,v,mt,n,Ve,De,ft,an,F,Dt]),il(()=>{s&&s.length>0&&sn(s)},[s,sn]);const{customHoverBehavior:hn,customClickBehavior:dn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:fd((t,o)=>{e?.(t,o),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:yd,chartId:r,context:o})},[e,n,r]),customClickBehavior:fd((e,o)=>{t?.(e,o),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:yd,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,chartId:ae}),{hoverHandlerRef:fn,hoverLeaveRef:yn,onPointerMove:mn,onPointerLeave:xn}=Je,bn=()=>!Ve||(Tt.current?.hasCustomRestyle??!1);fn.current=e=>{if(!te)return;const t=bn(),n=Dn.current;if(!n)return;const r=Tt.current;if(!r)return;const o=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Vt.current=o.hover,Lt(o.hover),hn&&(hn(o.hover),t&&(Ze.current=!0)),t&&ft()):Vt.current&&(Vt.current=null,Lt(null),hn&&(hn(null),t&&(Ze.current=!0)),t&&ft())},yn.current=()=>{if(Vt.current){const e=bn();Vt.current=null,Lt(null),hn&&(hn(null),e&&(Ze.current=!0)),e&&ft()}};const kn=rl(()=>{});kn.current=e=>{if(Qo(e.target))return;if(!oe&&!ie)return;const t=Dn.current;if(!t)return;const n=Tt.current;if(!n)return;const r=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?dn(r.hover,{type:"activate",inputType:$c(e.nativeEvent.pointerType)}):"miss"===r.kind&&dn(null)};const wn=al(e=>kn.current(e),[]),Sn=rl(-1),_n=rl(null),Pn=rl(-1),Tn=al(e=>{if(zc(e))return;const t=Tt.current;if(!t)return;const n=()=>{Sn.current=-1,_n.current=null,Pn.current=-1,Vt.current=null,Lt(null),hn&&(hn(null),Ze.current=!0),ft()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=Fn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Sn.current||n());const o=Hc(r);let i=Sn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void dn(ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Sn.current=0,Pn.current=-1;const t=o.flat[0];_n.current={shape:t.shape,w:t.w,h:t.h};const n=ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=n,Lt(n),hn&&(hn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void ft()}const s=Xc(o,i),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Gc(e,t,n);const s=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,c=s.y-t.y;let l=!1;switch(n){case"right":l=a>0&&Math.abs(a)>=Math.abs(c);break;case"left":l=0>a&&Math.abs(a)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(a);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(a)}if(!l)continue;const u=a*a+c*c;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Uc(t.source),i=Uc(t.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Gc(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,s,o,t.sceneEdges??[],Pn);if(null===a)return;if(e.preventDefault(),0>a)return void n();Sn.current=a;const c=o.flat[a];_n.current={shape:c.shape,w:c.w,h:c.h};const l={data:c.datum||{},x:c.x,y:c.y,__semioticHoverData:!0,nodeOrEdge:"node"};Vt.current=l,Lt(l),hn&&(hn(l,{type:"focus",inputType:"keyboard"}),Ze.current=!0),ft()},[dn,hn,ft]),Rn=al(e=>{Sn.current=-1,_n.current=null,mn(e)},[mn]);dt.current=()=>{if(ht.current=null,!yt.isActive)return;const e=Dn.current;if(!e)return;const t=Tt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:h,lastFrameTimeRef:d,now:f,random:y,reducedMotion:p,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:b,thresholds:k,staleness:w,particleStyle:A,getParticleColor:S,pendingAnnotationFrameRef:_,lastAnnotationFrameTimeRef:M,setAnnotationFrame:C,scheduleNextFrame:P}=e,T=t.getContext("2d");if(!T)return;const R=d.current?Math.min((f-d.current)/1e3,.1):.016;d.current=f;const D=n.advanceTransition(p?f+1e6:f),N=!p&&D,L=!p&&n.tickAnimation([s,a],R),E=h.current,I=r?.beforeCompute(n.getLastUpdateResult(),N),W=D||E||L;W&&n.buildScene([s,a]),I&&r?.afterCompute(I,W,!1);const $=g&&!p&&!!n.particlePool,z=!!((O={dirtyOrRebuilt:E,transitioning:N,animationTicked:L,continuous:$||m,liveEncoding:!!x||!!b||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||O.transitioning||O.animationTicked||O.continuous||O.liveEncoding||O.forced);var O;const F=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(z){const e=Ga();if(!Xa(t,o,i,e))return;if(T.clearRect(-i.left,-i.top,o[0],o[1]),ks(T,{background:c,hasBackgroundGraphics:u,width:s,height:a}),x&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),F&&(T.globalAlpha=w?.dimOpacity??.5),Tc({context:T,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Jh(e,n);break;case"line":ed(e,n);break;case"ribbon":td(e,n);break;case"curved":nd(e,n)}}(T,e)}),Tc({context:T,nodes:n.sceneNodes,renderMode:l,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),ic(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),sc(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=od(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.cx,r.cy,n);e.globalAlpha=n}(T,t)}}),$&&!F){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const c=a.value*i*n*(a.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let h=l;o()<u&&h++;for(let t=0;h>t&&e.countForEdge(r)<s;t++)e.spawn(r,o)}}(n.particlePool,e,R,A,y);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(R,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const c=n[a.edgeIndex];if(!c)continue;let l;l="string"==typeof r.color&&"inherit"!==r.color?r.color:o(c),e.fillStyle=Un(e,l)||l,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(T,n.particlePool,e,A,S)}}F&&(T.globalAlpha=1)}h.current=!1,(E||N||L)&&t.setAttribute("aria-label",zs(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const B=E||N||L||_.current;B&&f-M.current>=33?(C(e=>e+1),M.current=f,_.current=!1):_.current=!!B,(m||N||null!=n.transition||L||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||_.current)&&P()}({canvas:e,store:t,sceneRevisionDiagnostics:Rt.current,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,background:ee,renderMode:I,hasBackgroundGraphics:!!Ae,dirtyRef:Ze,lastFrameTimeRef:Mt,now:yt.now(),random:yt.random,reducedMotion:!!et.current,showParticles:L,isContinuous:nn,animate:Ce,decay:Se,pulse:_e,thresholds:Ie,staleness:Pe,particleStyle:kt,getParticleColor:tn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:$t,scheduleNextFrame:()=>{ft()}})};const{canvasRef:Dn}=Ya(Je,{hydrated:gt,wasHydratingFromSSR:mt,storeRef:Tt,dirtyRef:Ze,canvasPaintDependencies:[n,ot,it,ee,Ae,I,ft]});$r(Pe,Tt,Ze,ft,zt,Ot);const Nn=te&&Nt?pd(xa,{x:Nt.x,y:Nt.y,containerWidth:ot,containerHeight:it,margin:rt,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Nt):pd(Qh,{data:Nt})}):null;if(os||!gt&&mt)return pd(zh,{props:e,store:Tt.current,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedBackground:at,resolvedForeground:st});const Ln=Tt.current;return gd("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":$e||("string"==typeof ke?ke:"Network chart"),tabIndex:0,"aria-busy":Ft||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Tn,children:["production"!==process.env.NODE_ENV&&Tt.current&&pd(gn,{store:Tt.current,diagnostics:Rt.current}),We&&pd(ta,{tableId:ut}),We&&pd(Js,{nodes:Ln?.sceneNodes??[],edges:Ln?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof ke?ke:void 0}),pd(ea,{summary:ze}),pd(Ds,{hoverPoint:Nt}),gd("div",{role:"img","aria-label":$e||("string"==typeof ke?ke:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?Rn:void 0,onMouseLeave:te?xn:void 0,onClick:oe||ie?wn:void 0,children:[Ft&&!1!==k&&pd("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:jh(!0,nt[0],nt[1],k)}),pd(ja,{size:nt,margin:rt,overflowVisible:!0,children:at}),pd("canvas",{ref:Dn,"aria-label":zs(Ln?.sceneNodes?.length??0,Ln?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),pd(Dh,{width:ot,height:it,totalWidth:nt[0],totalHeight:nt[1],margin:rt,labels:Ln?.labels||[],sceneNodes:Ln?.sceneNodes,title:ke,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,foregroundGraphics:vn(st,An(Tt.current?.customLayoutOverlays,Ke??null)),annotations:le,onAnnotationActivate:ue,onObservation:se??ie,chartId:ae,chartType:"StreamNetworkFrame",autoPlaceAnnotations:he,svgAnnotationRules:de,annotationFrame:Wt}),pd(Ih,{marks:Ln?.customLayoutHtmlMarks,margin:rt,selection:Ke??null}),pd(oa,{active:Sn.current>=0,hoverPoint:Nt,margin:rt,size:nt,shape:_n.current?.shape,width:_n.current?.w,height:_n.current?.h}),Nn,Pe?.showBadge&&pd(Or,{isStale:zt,position:Pe.badgePosition})]})]})}));kd.displayName="StreamNetworkFrame";var wd=kd,Ad=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Sd=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,r=Math.floor(e/n);for(let o=Math.floor((e-this.size)/n)+1;r>=o;o++)this.bump(o*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Ad,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new Ad;r.push(t);let o=e,i=e;const s=[],a={start:o,end:i,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),o>t.start&&(o=t.start),t.end>i&&(i=t.end));a.start=o,a.end=i,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const r=t+this.size;e.push(this.row(t,r,n,r>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,r){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function _d(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function Md(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=_d(e,n),i=e.stddev*r;return[o-i,o+i]}var Cd={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Pd=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Td(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Pd.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Pd.exec(t));){const e=parseFloat(n[1]),t=Cd[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=n[0].length}return o!==t.length?null:r>0?r:null}var Rd=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const r of this.held)this.getTime(r)>e?n.push(r):t.push(r);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Dd,useImperativeHandle as Nd,forwardRef as Ld,useCallback as Ed,useState as Id,useEffect as Wd}from"react";import{useMemo as $d,useCallback as zd,useState as Od,useId as Fd,useEffect as Bd,useRef as Yd}from"react";function jd(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Hd(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Xd(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Gd,Vd]=E(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!Xd(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=Hd(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Hd(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}}));import{useId as qd,useMemo as Ud,useCallback as Kd}from"react";function Qd(e){const t=qd(),n=e.clientId||t,{name:r}=e,o=Vd(e=>e.selections.get(r)),i=Vd(e=>e.setClause),s=Vd(e=>e.clearClause),a=Ud(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Ud(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(jd(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:Kd(()=>{s(r,n)},[s,r,n]),clientId:n}}function Zd(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Jd(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function ef(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function tf(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function nf(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}var rf=[],of={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function sf(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return of;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function af({selection:e,linkedHover:t,fallbackFields:n=rf,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const h=Fd(),d=$d(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=$d(()=>"series"===d?.mode?[d.seriesField||l||n[0]].filter(e=>!!e):d?.fields||n,[d,l,n]),y=Qd({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=Qd({name:t,fields:n});return{onHover:Kd(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Jd(t)&&i(t)},[n,i,s]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=qo(e=>e.pushObservation),m=zd(e=>{o?.(e),g?.(e)},[o,g]),v=e?{isActive:y.isActive,predicate:y.predicate}:null,[x,b]=Od(null),k=Yd(!1),w=l||n[0],A=$d(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=zd((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===d?.mode&&d.xField){const n=tf(e,t,d.xField);null!=n&&function(e,t,n){const r=Ci.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n})},Ti())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||r||Ri(d.name||"hover",h),"x-position"===d?.mode||r||p.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else r||b(null);(o||g)&&Oc({onObservation:m,datum:e?nf(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,p,d,h,o,i,s,g,m,c,w,u]),_=zd((n=!0)=>{k.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&c&&b(null),"x-position"===d?.mode&&(Di(d.name||"hover",h),Ri(d.name||"hover",h))},[t,d,p,e,u,y,c,h]),M=zd((n,r)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),v=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=tf(n,e,d.xField);null!=t&&function(e,t,n){const r=Ci.positions.get(e);if(r?.locked){const t=new Map(Ci.positions);return t.delete(e),Ci={positions:t},Ti(),!1}Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ti()}(d.name||"hover",t,h)}if(l)if(n){k.current=!0;const r=nf(n);if(t&&"x-position"!==d?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}(function(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(e)&&y.selectPoints(e)}if(c&&w){const e=r?.[w];b(null!=e?e+"":null)}}else v&&_();if(n||v){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(o||g)&&Fc({onObservation:m,datum:n?nf(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,g,m,i,s,d,h,u,t,p,e,y,f,c,w,_]);return Bd(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&_()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,_]),Bd(()=>()=>{k.current&&_(!1)},[_]),Bd(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{Di(e,h),Ri(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:v,hoverSelectionHook:A,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:h}}var cf={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function lf(e,t,n){const r=cf[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])ef(e[r])&&ef(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e,c=cf[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:uf(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:sf(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function uf(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as hf,jsxs as df}from"react/jsx-runtime";var ff={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},yf={opacity:.7,marginRight:4};function pf(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function gf(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function mf(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=pf(i,t,"time"),a=pf(i,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]})]})}}function vf(e,t){return null!=e?e:Math.max(t?.length??0,200)}var xf="time",bf="value",kf="__aggLower",wf="__aggUpper",Af="__aggPartial",Sf="count",_f="__aggStart",Mf="__aggEnd";function Cf(e,t){const n=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[xf]:(e.start+e.end)/2,[bf]:_d(e,n),[Sf]:e.count,[Af]:e.partial,[_f]:e.start,[Mf]:e.end},i=Md(e,r,n,o);return i&&(t[kf]=i[0],t[wf]=i[1]),t})}function Pf(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const y=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),h&&(c||(d?r||o||t:r||o)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}import{jsx as Tf}from"react/jsx-runtime";function Rf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var Df=Ld(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:D,linkedHover:N,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F,aggregate:B,eventTime:Y}=e,j=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,G=r??[n.width,n.height],V=b??k??mf({timeAccessor:u,valueAccessor:h}),q=Dd(null),{customHoverBehavior:U}=af({selection:L,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeLineChart",chartId:I}),K=Ed(e=>{w&&w(e),U(e)},[w,U]),Q=null!=B,[Z,J]=Id([]),ee=Dd(null),te=Dd(B);te.current=B;const ne=Dd(Q);ne.current=Q;const re=Dd(Z);re.current=Z;const oe=Dd({timeAccessor:u,valueAccessor:h});oe.current={timeAccessor:u,valueAccessor:h},Wd(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=Td("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?Td(e.hop):void 0,o=null!=e.gap?Td(e.gap):void 0;return new Sd({window:t,size:n,hop:r??void 0,gap:o??void 0,retain:e.retain})}(e);if(ee.current=t,t&&l){const{timeAccessor:e,valueAccessor:n}=oe.current;for(const r of l){const o=Rf(r,e,"time"),i=Rf(r,n,"value");null!=o&&null!=i&&t.push(o,i)}}J(t?Cf(t,e):[])},[Q?[B.window??"tumbling",B.size,B.hop??"",B.gap??"",B.retain??""].join("|"):"",Q,l]),Wd(()=>{Q&&ee.current&&J(Cf(ee.current,te.current))},[B?.stat,B?.band,B?.sigma]);const ie=Ed(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:o}=oe.current;for(const n of e){const e=Rf(n,r,"time"),i=Rf(n,o,"value");null!=e&&null!=i&&t.push(e,i)}J(Cf(t,n))},[]),se=null!=Y,ae=Dd(null),ce=Dd(Y);ce.current=Y;const le=Dd(se);le.current=se;const ue=Dd(E);ue.current=E;const he=Dd(I);he.current=I,Wd(()=>{ae.current=se?function(e){const t=Td(e.lateness);return null==t?null:new Rd({lateness:t,getTime:e=>Rf(e,oe.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",se]);const de=Ed(e=>{0!==e.length&&(ne.current?ie(e):q.current?.pushMany(e))},[ie]),fe=Ed(e=>{const t=ae.current;if(!le.current||!t)return void de(e);const n=[];for(const r of e){const e=t.push(r);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:r}=oe.current,o=ce.current?.latePolicy??"drop";for(const i of e.late)n({type:"late-data",datum:i,eventTime:Rf(i,r,"time")??NaN,watermark:t.watermark,policy:o,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);Nd(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:q.current?.remove(e)??[],update:(e,t)=>ne.current?[]:q.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):q.current?.clear()},getData:()=>ne.current?re.current:q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[fe]);const ye=jh(W,G[0],G[1],$),pe=ye?null:Yh(Q?void 0:l,G[0],G[1],z),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=v&&(ge.opacity=v);const me=vf(c,l),ve=Q?Z:l,xe=Q?xf:u,be=Q?bf:h,ke=Q&&B&&"none"!==(B.band??"none")?{y0Accessor:kf,y1Accessor:wf,perSeries:!1}:void 0;return ye||pe||Tf(nl,{ref:q,chartType:"line",runtimeMode:"streaming",size:G,margin:X,className:O?`${i||""} semiotic-emphasis-${O}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,B?.retain??Math.max(Z.length,600)):me,data:ve,timeAccessor:xe,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:j,background:x,hoverAnnotation:H,tooltipContent:V,...Pf({linkedHover:N,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:D,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});Df.displayName="RealtimeLineChart";import{useRef as Nf,useImperativeHandle as Lf,forwardRef as Ef,useCallback as If,useMemo as Wf}from"react";import{jsx as $f}from"react/jsx-runtime";function zf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var Of=Ef(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,linkedHover:L,selection:E,decay:I,pulse:W,staleness:$,transition:z,onObservation:O,chartId:F,loading:B,loadingContent:Y,emptyContent:j,emphasis:H,legendPosition:X,brush:G,onBrush:V,linkedBrush:q}=e,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=o??[n.width,n.height],J=_??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=pf(r,t,"time"),o=pf(r,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(e)]}),df("div",{children:[hf("span",{style:yf,children:"y:"}),gf(o)]})]})}return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"range:"}),gf(r.binStart),"–",gf(r.binEnd)]}),null!=r.total&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(r.total)]}),null!=r.category&&df("div",{children:[hf("span",{style:yf,children:"category:"}),gf(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),ee=Nf(null),{customHoverBehavior:te}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:O,chartType:"RealtimeHistogram",chartId:F}),ne=If(e=>{C&&C(e),te(e)},[C,te]),re=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,oe=(ie=q)?"string"==typeof ie?{name:ie}:ie:null;var ie;const se="string"==typeof h?h:"time",ae=function(e){const{name:t,xField:n,yField:r}=e,{predicate:o,isActive:i,selectInterval:s,clear:a}=Qd({name:t,fields:[n,r].filter(Boolean)}),c=n&&r?"xyBrush":n?"xBrush":"yBrush",l=Kd(e=>{if(!e)return void a();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Zd(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&Zd(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Jd(t)&&s(t)},[c,n,r,s,a]);return{brushInteraction:Ud(()=>({brush:c,during:l,end:l}),[c,l]),predicate:o,isActive:i,clear:a}}({name:oe?.name||"__unused_hist_brush__",xField:oe?.xField||se,...oe?.yField?{yField:oe.yField}:{}}),ce=Nf(ae.brushInteraction);ce.current=ae.brushInteraction;const le=If(e=>{if(V&&V(e),O&&O(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}),oe){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[V,O,F,oe]);Lf(t,()=>({push:e=>ee.current?.push(e),pushMany:e=>ee.current?.pushMany(e),remove:e=>ee.current?.remove(e)??[],update:(e,t)=>ee.current?.update(e,t)??[],clear:()=>ee.current?.clear(),getData:()=>ee.current?.getData()??[],getScales:()=>ee.current?.getScales()??null}),[]);const ue=jh(B,Z[0],Z[1],Y),he=ue?null:Yh(u,Z[0],Z[1],j),de={};null!=x&&(de.fill=x),null!=b&&(de.stroke=b),null!=k&&(de.strokeWidth=k),null!=w&&(de.opacity=w),null!=A&&(de.gap=A);const fe=H?`${s||""} semiotic-emphasis-${H}`.trim():s,ye=vf(l,u),pe=Wf(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!e||0===e.length)return;const s=new Map;for(const o of e){const e=zf(o,n,"time"),i=zf(o,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())e>a&&(a=e);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ue||he||$f(nl,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:fe,arrowOfTime:a,windowMode:c,windowSize:ye,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pe,extentPadding:g,binSize:r,categoryAccessor:m,barColors:v,barStyle:de,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Pf({linkedHover:L,selection:E,onObservation:O,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,decay:I,pulse:W,staleness:$,transition:z,pointIdAccessor:e.pointIdAccessor,legendPosition:X,brush:re||(q?{dimension:"x"}:void 0),onBrush:re||q?le:void 0})});function Ff(e){return $f(Of,{...e,windowMode:"growing"})}Of.displayName="RealtimeHistogram",Ff.displayName="TemporalHistogram";import{useRef as Bf,useImperativeHandle as Yf,forwardRef as jf,useCallback as Hf}from"react";import{jsx as Xf}from"react/jsx-runtime";var Gf=jf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,linkedHover:L,selection:E,onObservation:I,chartId:W,loading:$,loadingContent:z,emptyContent:O,emphasis:F,legendPosition:B}=e,Y=n.showAxes,j=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],G=_??M??mf({timeAccessor:u,valueAccessor:h}),V=Bf(null),{customHoverBehavior:q}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:W}),U=Hf(e=>{C&&C(e),q(e)},[C,q]);Yf(t,()=>({push:e=>V.current?.push(e),pushMany:e=>V.current?.pushMany(e),remove:e=>V.current?.remove(e)??[],update:(e,t)=>V.current?.update(e,t)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=jh($,X[0],X[1],z),Q=K?null:Yh(l,X[0],X[1],O),Z={};null!=v&&(Z.radius=v),null!=x&&(Z.fill=x),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=F?`${i||""} semiotic-emphasis-${F}`.trim():i,te=vf(c,l);return K||Q||Xf(nl,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:Y,background:S,hoverAnnotation:j,tooltipContent:G,...Pf({linkedHover:L,selection:E,onObservation:I,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,legendPosition:B,pointIdAccessor:e.pointIdAccessor})});Gf.displayName="RealtimeSwarmChart";import{useRef as Vf,useImperativeHandle as qf,forwardRef as Uf,useCallback as Kf}from"react";import{jsx as Qf}from"react/jsx-runtime";var Zf=Uf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:D,linkedHover:N,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F}=e,B=n.showAxes,Y=n.enableHover,j=o??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null,o=pf(r,t,"time"),i=r?.delta??pf(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?gf(i):"+"+gf(i):gf(i);return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(o)]}),df("div",{children:[hf("span",{style:yf,children:"Δ:"}),a]}),null!=s&&df("div",{children:[hf("span",{style:yf,children:"total:"}),gf(s)]})]})}}({timeAccessor:u,valueAccessor:h}),G=Vf(null),{customHoverBehavior:V}=af({selection:L,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeWaterfallChart",chartId:I}),q=Kf(e=>{M&&M(e),V(e)},[M,V]);qf(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const U=jh(W,H[0],H[1],$),K=U?null:Yh(l,H[0],H[1],z),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=v&&(Q.connectorWidth=v),null!=x&&(Q.gap=x),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=O?`${i||""} semiotic-emphasis-${O}`.trim():i,J=vf(c,l);return U||K||Qf(nl,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:j,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:B,background:A,hoverAnnotation:Y,tooltipContent:X,...Pf({linkedHover:N,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:q}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:D,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Zf.displayName="RealtimeWaterfallChart";import{useRef as Jf,useImperativeHandle as ey,forwardRef as ty,useCallback as ny}from"react";import{jsx as ry}from"react/jsx-runtime";var oy=ty(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,linkedHover:D,selection:N,onObservation:L,chartId:E,loading:I,loadingContent:W,emptyContent:$,emphasis:z,legendPosition:O}=e,F=n.showAxes,B=n.enableHover,Y=o??n.marginDefaults,j=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=i?.xCenter??pf(i,t,"time"),a=i?.yCenter??pf(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,h=i?.agg??"count";return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]}),null!=c&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(c)]}),"sum"===h&&null!=l&&df("div",{children:[hf("span",{style:yf,children:"sum:"}),gf(l)]}),"mean"===h&&null!=u&&df("div",{children:[hf("span",{style:yf,children:"mean:"}),gf(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=Jf(null),{customHoverBehavior:G}=af({selection:N,linkedHover:D,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:E}),V=ny(e=>{w&&w(e),G(e)},[w,G]);ey(t,()=>({push:e=>X.current?.push(e),pushMany:e=>X.current?.pushMany(e),remove:e=>X.current?.remove(e)??[],update:(e,t)=>X.current?.update(e,t)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const q=jh(I,j[0],j[1],W),U=q?null:Yh(l,j[0],j[1],$),K=z?`${i||""} semiotic-emphasis-${z}`.trim():i,Q=vf(c,l);return q||U||ry(nl,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:Y,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:F,background:x,hoverAnnotation:B,tooltipContent:H,...Pf({linkedHover:D,selection:N,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});oy.displayName="RealtimeHeatmap";import{useCallback as iy,useEffect as sy,useMemo as ay,useRef as cy,useState as ly}from"react";var uy=Symbol("semiotic.useStreamStatus.wrapped");function hy(e={}){const{staleThresholdMs:t=5e3,pollIntervalMs:n=1e3}=e,r=cy(null),[o,i]=ly("idle"),[s,a]=ly(null),c=iy(()=>{const e="undefined"!=typeof performance?performance.now():Date.now();r.current=e,a(e),i(e=>"active"===e?e:"active")},[]),l=ay(()=>{const e={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return e._frame},set current(t){const n=e._frame;if(n&&n!==t&&e._origPush&&e._origPushMany&&(n.push=e._origPush,n.pushMany=e._origPushMany,delete n[uy]),e._frame=t,!t)return e._origPush=null,void(e._origPushMany=null);if(t[uy])return;t[uy]=!0;const r=t.push,o=t.pushMany,i=r.bind(t),s=o.bind(t);e._origPush=r,e._origPushMany=o,t.push=e=>(c(),i(e)),t.pushMany=e=>(e&&e.length>0&&c(),s(e))}}},[c]);return sy(()=>{const e=setInterval(()=>{const e=r.current;if(null==e)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-e>t;i(e=>{const t=n?"stale":"active";return e===t?e:t})},n);return()=>clearInterval(e)},[t,n]),{ref:l,status:o,lastPushTime:s}}import{useEffect as dy,useMemo as fy,useRef as yy}from"react";function py(e,t,n,r){const o=new Map;n.forEach((e,t)=>{o.set(r?r(e,t):t+"",e)});const i=[];t.forEach((e,t)=>{o.has(t)||i.push(t)}),i.length>0&&e.remove?.(i);const s=[];if(o.forEach((n,r)=>{const o=t.get(r);void 0===o?s.push(n):o!==n&&(e.update?e.update(r,()=>n):(e.remove?.(r),s.push(n)))}),s.length>0)if(e.pushMany)e.pushMany(s);else if(e.push)for(const t of s)e.push(t);return o}function gy(e,t,n={}){const{id:r,resetKey:o}=n,i=fy(()=>function(e){return null==e?null:"function"==typeof e?(t,n)=>{const r=e(t,n);return null==r?n+"":r+""}:(t,n)=>{const r=t[e];return null==r?n+"":r+""}}(r),[r]),s=yy({map:new Map,handle:null,resetKey:void 0});dy(()=>{const n=e.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===o||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=o),r.map=py(n,r.map,t,i)},[e,t,i,o])}export{Ce as DEFAULT_LIFECYCLE_THRESHOLDS,G as IncrementalExtent,oy as RealtimeHeatmap,Of as RealtimeHistogram,Df as RealtimeLineChart,Gf as RealtimeSwarmChart,Zf as RealtimeWaterfallChart,Rd as ReorderBuffer,X as RingBuffer,Ad as RunningStats,wd as StreamNetworkFrame,nl as StreamXYFrame,Ff as TemporalHistogram,Sd as WindowAccumulator,Md as bandBounds,Pe as bandFromAge,Re as compileMotionEncoding,Le as deriveMotionVector,De as opacityFromAge,Td as parseWindowDuration,Te as resolveMotionAccessor,Ne as resolveMotionVector,_d as statValue,py as syncPushBuffer,hy as useStreamStatus,gy as useSyncedPushData};
|