semiotic 3.7.5 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +54 -12
- 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 +1651 -154
- package/ai/examples.md +174 -0
- package/ai/schema.json +2733 -536
- package/ai/surface-manifest.json +200 -0
- package/ai/system-prompt.md +18 -3
- 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/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/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/DistanceCartogram.d.ts +1 -1
- package/dist/components/charts/geo/FlowMap.d.ts +1 -1
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +1 -1
- package/dist/components/charts/geo/index.d.ts +2 -0
- package/dist/components/charts/index.d.ts +29 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +1 -1
- package/dist/components/charts/network/CirclePack.d.ts +1 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +15 -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 +1 -1
- 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 +1 -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 +1 -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 +1 -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 +47 -0
- package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +53 -0
- package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +66 -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 +120 -0
- package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +53 -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 +41 -0
- package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -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/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/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/diagnoseAnnotationChecks.d.ts +4 -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/hooks.d.ts +28 -5
- 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/streamPropsHelpers.d.ts +12 -2
- package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
- package/dist/components/charts/shared/types.d.ts +49 -1
- package/dist/components/charts/shared/useChartSetup.d.ts +9 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +14 -5
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +1 -1
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
- package/dist/components/charts/shared/validationMap.d.ts +0 -11
- package/dist/components/charts/xy/AreaChart.d.ts +1 -1
- package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
- package/dist/components/charts/xy/LineChart.d.ts +1 -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 +1 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +1 -1
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
- package/dist/components/charts/xy/StackedAreaChart.d.ts +9 -4
- 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 +27 -0
- 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/semiotic-ai-core.d.ts +47 -0
- package/dist/components/semiotic-ai.d.ts +50 -8
- package/dist/components/semiotic-controls.d.ts +18 -0
- package/dist/components/semiotic-experimental.d.ts +38 -9
- package/dist/components/semiotic-geo.d.ts +11 -0
- package/dist/components/semiotic-network.d.ts +11 -0
- package/dist/components/semiotic-ordinal.d.ts +8 -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 +56 -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-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 +46 -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 +8 -0
- package/dist/components/semiotic.d.ts +35 -7
- package/dist/components/server/animatedGif.d.ts +36 -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 +17 -0
- package/dist/components/server/serverChartConfigs.d.ts +19 -9
- 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/staticGeo.d.ts +4 -0
- package/dist/components/server/staticLegend.d.ts +1 -1
- 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 +3 -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 +3 -13
- package/dist/components/stream/FocusRing.d.ts +4 -2
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +28 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +31 -26
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +46 -2
- package/dist/components/stream/PipelineStore.d.ts +81 -170
- package/dist/components/stream/SceneGraph.d.ts +9 -1
- 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 +23 -10
- 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/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/geoTypes.d.ts +56 -7
- package/dist/components/stream/glyphDef.d.ts +98 -0
- package/dist/components/stream/hitTarget.d.ts +170 -0
- package/dist/components/stream/hoverUtils.d.ts +3 -0
- 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 +57 -0
- package/dist/components/stream/networkBezier.d.ts +10 -0
- package/dist/components/stream/networkColorAccessors.d.ts +49 -0
- package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
- package/dist/components/stream/networkFramePaint.d.ts +43 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
- package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
- package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
- package/dist/components/stream/networkTypes.d.ts +76 -5
- 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 +12 -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/ordinalSpatialIndex.d.ts +9 -0
- package/dist/components/stream/ordinalTypes.d.ts +40 -8
- 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 +84 -0
- package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +72 -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 +302 -0
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -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 +9 -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 +16 -0
- package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
- package/dist/components/stream/pipelineConfig.d.ts +177 -0
- package/dist/components/stream/pipelineDecay.d.ts +20 -2
- 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 +16 -2
- 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 +12 -0
- package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
- package/dist/components/stream/pipelineTransitions.d.ts +2 -0
- package/dist/components/stream/pipelineUpdateContract.d.ts +62 -0
- package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
- package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +18 -0
- package/dist/components/stream/streamStoreSync.d.ts +37 -0
- package/dist/components/stream/types.d.ts +135 -7
- package/dist/components/stream/useFrame.d.ts +21 -2
- package/dist/components/stream/useHydration.d.ts +6 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -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/xySceneBuilders/types.d.ts +4 -4
- 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/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 +50 -8
- 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 +18 -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 +11 -0
- package/dist/semiotic-network.d.ts +11 -0
- package/dist/semiotic-ordinal.d.ts +8 -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 +56 -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-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 +46 -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 +8 -0
- package/dist/semiotic.d.ts +35 -7
- 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/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 +239 -87
- 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
package/dist/realtime.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("d3-selection"),i=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-shape"),l=require("d3-array"),a=require("d3-hierarchy"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const g=y(e),p=f(c);function v(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 m(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 x({width:o,height:r,totalWidth:s,totalHeight:l,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:y,snapDuring:g,streaming:p}){const x=e.useRef(null),b=e.useRef(null),k=e.useRef(d);k.current=d;const w=e.useRef(u);w.current=u;const A=e.useMemo(()=>y?[...y].sort((t,e)=>t-e):void 0,[y]),_=e.useRef(A);_.current=A;const S=e.useRef(!1),M=e.useRef(null);return e.useEffect(()=>{if(!x.current)return;const t=n.select(x.current).select(".brush-g"),e="x"===c?i.brushX():"y"===c?i.brushY():i.brush();return e.extent([[0,0],[o,r]]),e.on("brush end",n=>{if(S.current)return;const i=w.current;if(!i)return;if(!n.selection)return M.current=null,void k.current(null);let s,l;if("x"===c){const[t,e]=n.selection;s=[i.x.invert(t),i.x.invert(e)],l=[i.y.invert(r),i.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;s=[i.x.invert(0),i.x.invert(o)],l=[i.y.invert(e),i.y.invert(t)]}else{const[[t,e],[o,r]]=n.selection;s=[i.x.invert(t),i.x.invert(o)],l=[i.y.invert(r),i.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===n.type||"brush"===n.type&&g)){const o=_.current;o&&o.length>0?s=function(t,e){return 0===e.length?t:[v(t[0],e),m(t[1],e)]}(s,o):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=i.x(s[0]),l=i.x(s[1]);if(S.current=!0,"x"===c)t.call(e.move,[r,l]);else if("xy"===c){const i=n.selection;t.call(e.move,[[r,i[0][1]],[l,i[1][1]]])}S.current=!1}const a={x:s,y:l};M.current=a,k.current(a)}),t.call(e),b.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),b.current=null}},[o,r,c,f,h,g]),e.useEffect(()=>{if(!(p&&u&&b.current&&M.current))return;if(!x.current)return;if("y"===c)return;const t=M.current,e=u.x.domain()[0],i=n.select(x.current).select(".brush-g");if(e>=t.x[1])return S.current=!0,i.call(b.current.move,null),S.current=!1,M.current=null,void k.current(null);let o=t.x[0],r=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=_.current;t&&t.length>0?o=m(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return S.current=!0,i.call(b.current.move,null),S.current=!1,M.current=null,void k.current(null);r=!0}const s=u.x(o),l=u.x(t.x[1]);if(S.current=!0,"x"===c)i.call(b.current.move,[s,l]);else{const e=u.y(t.y[1]),n=u.y(t.y[0]);i.call(b.current.move,[[s,e],[l,n]])}if(S.current=!1,r){const e={x:[o,t.x[1]],y:t.y};M.current=e,k.current(e)}},[u,p,c,f,h]),t.jsx("svg",{ref:x,width:s,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}const b=Object.freeze([]);function k(t){if(!t)return b;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 w{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=k(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=k(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 A(n){let i=null;const o=()=>(i||(i=e.createContext(null)),i),r=_(n);return[function({children:i,initialState:r}){const s=e.useRef(r),l=e.useMemo(()=>_(n,s.current),[]),a=o();return t.jsx(a.Provider,{value:l,children:i})},(t,n)=>{var i;const s=o(),l=null!==(i=e.useContext(s))&&void 0!==i?i:r,a=e.useRef(t);a.current=t;const c=e.useRef({hasValue:!1,value:void 0}),u=e.useCallback(()=>{const t=a.current(l.getState()),e=c.current;return e.hasValue&&n&&n(e.value,t)?e.value:(c.current={hasValue:!0,value:t},t)},[l,n]),d=e.useCallback(()=>a.current(l.getState()),[l]);return e.useSyncExternalStore(l.subscribe,u,d)}]}function _(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 S(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 M(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:j})})),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 j=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],P={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}},C={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}},E={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:j,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 O(t,e){if("light"===e)return P;if("dark"===e)return C;if("high-contrast"===e)return E;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?C:P;return M(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 M(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[T,D]=A(t=>({theme:P,setTheme(e){t(t=>({theme:O(t.theme,e)}))}}));class N{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 L{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 R(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 $(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 I(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 W(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 z(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 F(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 Y(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 B(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 H(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function X(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function G(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function V(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}function q(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function U(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function K(t){const e=t.map(q),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return U(t,n,i)}if(t>=1){const[t,i,o]=e[n];return U(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 U(Math.round(s+(c-s)*r),Math.round(l+(u-l)*r),Math.round(a+(d-a)*r))}}const Q=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Z=K(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),J=K(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),tt=K(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),et=K(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),nt=K(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),it=K(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ot=K(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),rt=K(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),st=K(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),lt=K(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),at=K(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),ct=K(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ut={blues:Z,reds:J,greens:tt,viridis:ot,oranges:et,purples:nt,greys:it,plasma:rt,inferno:st,magma:lt,cividis:at,turbo:ct};K(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),K(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),K(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),K(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),K(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const dt=Object.assign({category10:Q,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},ut),ht=Q,ft=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function yt(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 gt(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 pt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function vt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function mt(t,e,n){return t+(e-t)*n}function xt(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 bt(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 kt(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:bt(t,i,n,e[0]),datum:e,group:n,interactive:i.interactive}}function wt(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 At(t,e,n){const i=[];for(const o of n){const n=kt(t,e,"__ribbon_aggregate",o);n&&i.push(n)}return i}function _t(t,e,n,i){const o=[];for(const r of i){const i=kt(t,e,n,r);i&&o.push(i)}return o}function St(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 Mt(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=z(s,t.scales,t.getX,r,l,i,a);c&&n.push(c)}}}const jt={topOpacity:.8,bottomOpacity:.05};function Pt(t){var e,n;if(t)return!0===t?jt:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:jt.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:jt.bottomOpacity}}const Ct={circle:s.symbolCircle,square:s.symbolSquare,triangle:s.symbolTriangle,diamond:s.symbolDiamond,star:s.symbolStar,cross:s.symbolCross,wye:s.symbolWye},Et=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Ot(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*Tt(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 l=null!==(i=Ct[r])&&void 0!==i?i:s.symbolCircle;return null!==(o=s.symbol(l,Math.max(1,e))())&&void 0!==o?o:""}function Tt(t){return Math.sqrt(Math.max(1,t)/Math.PI)}const Dt=new Map;function Nt(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=X(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 x=1/0,b=-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]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||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-x)/k;M.push(B(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=X(t.config.valueAccessor,"value"),o=G(t.config.xAccessor,"x"),r=G(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),x=new Map;let b=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=x.get(h);let y;void 0!==f?y=f:(y=b++,x.set(h,y)),p[y]=h,v[y]=d,m[y]=n}let k=1/0,w=-1/0;for(let t=0;b>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 ut?t:"blues";let n=Dt.get(e);if(n)return n;n=Array(256);const i=(o=e)&&ut[o]||Z;var o;for(let t=0;256>t;t++)n[t]=i(t/255);return Dt.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,j=t.config.showValues,P=t.config.heatmapValueFormat,C=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;C.push(B(i*S,(d-1-(n-i)/u)*M,S,M,A[Math.min((e-k)*_+.5|0,255)],m[t],j?{value:e,showValues:!0,valueFormat:P}:void 0))}return C}function Lt(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:i,warned:o}=t;Rt(i)&&0===n.length&&$t(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)&&$t(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 Rt(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Rt))}function $t(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function It(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Wt(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=It(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=X(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:It(t.y1Accessor,"y1"),getBottom:It(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class zt{constructor(t){if(this.xExtent=new L,this.yExtent=new L,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 N(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=X(t.timeAccessor||t.xAccessor,"time"),this.getY=X(t.valueAccessor||t.yAccessor,"value")):(this.getX=X(t.xAccessor,"x"),this.getY=X(t.yAccessor,"y")),this.getGroup=V(t.groupAccessor),this.getCategory=V(t.categoryAccessor),this.getSize=t.sizeAccessor?X(t.sizeAccessor,"size"):void 0,this.getColor=V(t.colorAccessor),this.getSymbol=V(t.symbolAccessor),this.getY0=t.y0Accessor?X(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Wt(t),this.getPointId=V(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?X(t.openAccessor,"open"):void 0,this.getHigh=X(t.highAccessor,"high"),this.getLow=X(t.lowAccessor,"low"),this.getClose=n?X(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new N(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?X(this.config.timeAccessor||this.config.xAccessor,"time"):X(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,r,s,l,a,c,u,d,h,f,y,g;const{config:p,buffer:v}=this;if(!this.needsFullRebuild&&!p.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(v,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),x=this.xExtent.extent,b=this.yExtent.extent;let k=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:x[0],null!==(i=p.xExtent[1])&&void 0!==i?i:x[1]]:x,w=p.yExtent?[null!==(r=p.yExtent[0])&&void 0!==r?r:b[0],null!==(s=p.yExtent[1])&&void 0!==s?s:b[1]]:b;const A=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1],_="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!A&&v.size>0)if(p.normalize)w=[0,_?1:1+p.extentPadding];else{const t=`${v.size}:${this._ingestVersion}:${null!==(l=p.baseline)&&void 0!==l?l:"zero"}:${null!==(a=p.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)w=this._stackExtentCache.yDomain;else{const e=this.groupData(m),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!==(c=p.stackOrder)&&void 0!==c?c:"key",a=(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:a(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(u=s.get(e))&&void 0!==u?u:0):(i.push(e),r+=null!==(d=s.get(e))&&void 0!==d?d: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:a(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:a(t,e)}):e.map(t=>t.key).sort(a);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=W(t,y,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},p.baseline);let o=1/0,s=-1/0;for(const n of t){const t=null!==(h=e.get(n))&&void 0!==h?h:0,i=null!==(f=r.get(n))&&void 0!==f?f: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=_?0:l>0?l*p.extentPadding:1;w=[o-a,s+a]}else w=[0,o+(_?0:o>0?o*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:w}}}else if("bar"===p.chartType&&p.binSize&&!A&&v.size>0){const[,t]=function(t,e,n,i,o){const r=R(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]}(v,this.getX,this.getY,p.binSize,this.getCategory);w=[0,_?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!A&&v.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]}(v,this.getY),n=e-t,i=_?0:n>0?n*p.extentPadding:1;w=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!A&&w[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of m)for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(w[0]>n&&(w[0]=n),n>w[1]&&(w[1]=n)),Number.isFinite(i)&&(w[0]>i&&(w[0]=i),i>w[1]&&(w[1]=i))}const t=w[1]-w[0],e=_?0:t>0?t*p.extentPadding:1,n=null===(y=p.yExtent)||void 0===y?void 0:y[0],i=null===(g=p.yExtent)||void 0===g?void 0:g[1];w=[null!=n?w[0]:w[0]-e,null!=i?w[1]:w[1]+e],"log"!==p.yScaleType||w[0]>0||0>=b[0]||_||(w[0]=null!=n?w[0]:b[0]/(1+p.extentPadding))}if(p.yExtent&&!A){const t=p.yExtent[0],e=p.yExtent[1];null==t&&null==e||(w=[null!=t?t:w[0],null!=e?e:w[1]])}if(k[0]===1/0||k[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();k=[t-864e5,t]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const S="streaming"===p.runtimeMode,M=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(S)if("x"==("up"===(j=p.arrowOfTime)||"down"===j?"y":"x")){const e="right"===p.arrowOfTime?[M,t.width-M]:[t.width-M,M];this.scales={x:o.scaleLinear().domain(k).range(e),y:o.scaleLinear().domain(w).range([t.height-M,M])}}else{const e="down"===p.arrowOfTime?[M,t.height-M]:[t.height-M,M];this.scales={x:o.scaleLinear().domain(w).range([M,t.width-M]),y:o.scaleLinear().domain(k).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 o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(p.xScaleType,k,[M,t.width-M]),y:e(p.yScaleType,w,[t.height-M,M])}}var j;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),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,zt.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=r.quadtree().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(),r=this.scales.y.domain(),s=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=l[1]>l[0];this.scales={x:a(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},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:ft},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 Lt({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}=wt(t.ribbons);if(r.length>0&&o.push(...At(t,e,r)),n.length>0)for(const e of i)o.push(..._t(t,e.data,e.key,n))}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=$(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 Mt(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}=wt(t.ribbons);if(r.length>0&&i.push(...At(t,e,r)),o.length>0)for(const e of n)i.push(..._t(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=I(e.data,t.scales,t.getX,t.getY,o,n,e.key,r),l=Pt(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 Mt(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}=wt(t.ribbons);if(r.length>0&&i.push(...At(t,e,r)),o.length>0)for(const e of n)i.push(..._t(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=I(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),l=Pt(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=$(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 Mt(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=W(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)};Mt(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=Et[h%Et.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=F(n,t.scales,t.getX,t.getY,Math.PI*r*r,o,e,u);s&&i.push(s)}else{const o=z(n,t.scales,t.getX,t.getY,r,e,u);o&&i.push(o)}}return i}(f,e);case"heatmap":return Nt(f,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=R(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,x=Math.max(p-v,1);if(x>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(Y(m,Math.min(a,c),x,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(Y(m,Math.min(t,n),x,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,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=b+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){b=s;continue}const A=d.y(b),_=d.y(s),S=Math.min(A,_),M=Math.abs(A-_),j={fill:0>r?g:y,stroke:v,strokeWidth:m};null!=x&&(j.opacity=x),u.push(Y(k,S,w,M,j,Object.assign(Object.assign({},i),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=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?yt(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]=yt(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]=yt(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=yt(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=yt(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=gt(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=gt(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=xt(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=xt(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,x,b,k,w,A,_,S,M,j,P,C,E,O,T,D,N,L,R,$,I,W,z,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],E=xt(t,r,e);if(!E)continue;if(r._transitionKey=E,"line"===r.type||"area"===r.type){const t=o.get(E);if(t){if(U.add(E),"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 O=i.get(E);if("point"===r.type)if(O){q.add(E);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,O.x===t.x&&O.y===t.y&&O.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=O.x,r.y=O.y,r.r=null!==(d=O.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(O){q.add(E);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,O.x===t.x&&O.y===t.y&&O.w===t.w&&O.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=O.x,r.y=O.y,r.w=null!==(y=O.w)&&void 0!==y?y:r.w,r.h=null!==(g=O.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(O){q.add(E);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,O.x===t.x&&O.y===t.y&&O.w===t.w&&O.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=O.x,r.y=O.y,r.w=null!==(x=O.w)&&void 0!==x?x:r.w,r.h=null!==(b=O.h)&&void 0!==b?b: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(O&&null!=O.openY){q.add(E);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,(O.x!==t.x||O.openY!==t.openY||O.closeY!==t.closeY||O.highY!==t.highY||O.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=O.x,r.openY=O.openY,r.closeY=null!==(S=O.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(M=O.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(j=O.lowY)&&void 0!==j?j:r.lowY,V=!0)}else r._targetOpacity=null!==(C=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==C?C: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!==(E=e.opacity)&&void 0!==E?E: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!==(O=e.opacity)&&void 0!==O?O: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!==(T=e.r)&&void 0!==T?T:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D: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!==(N=e.w)&&void 0!==N?N:0,h:null!==(L=e.h)&&void 0!==L?L:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R: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!==($=e.w)&&void 0!==$?$:0,h:null!==(I=e.h)&&void 0!==I?I:0,fill:"#999",datum:null,style:{opacity:null!==(W=e.opacity)&&void 0!==W?W:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(z=e.openY)&&void 0!==z?z: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=vt(t,n.activeTransition),d=pt(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=mt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=mt(n.x,t._targetX,d),t.y=mt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=mt(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=mt(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=mt(n.x,t._targetX,d),t.y=mt(n.y,t._targetY,d),void 0!==n.w&&(t.w=mt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=mt(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:mt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=mt(n.x,t._targetX,d),t.y=mt(n.y,t._targetY,d),void 0!==n.w&&(t.w=mt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=mt(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:mt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=mt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=mt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=mt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=mt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=mt(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:mt(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]=mt(e[i][0],n[i][0],d),t.path[i][1]=mt(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:mt(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]=mt(e[n][0],i[n][0],d),t.topPath[n][1]=mt(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]=mt(n[e][0],o[e][0],d),t.bottomPath[e][1]=mt(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||ft,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)||ft;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>zt.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||!H(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=a||!H(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=X(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=X(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=X(this.config.xAccessor,"x"),this.getY=X(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Wt(this.config)),s=!0,l=!0)}if("groupAccessor"in t&&!H(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?V(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!H(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?V(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!H(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?X(this.config.sizeAccessor,"size"):void 0,s=!0),"symbolAccessor"in t&&!H(t.symbolAccessor,r.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?V(this.config.symbolAccessor):void 0,s=!0),"colorAccessor"in t&&!H(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?V(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!H(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?X(this.config.y0Accessor,"y0"):void 0,s=!0,l=!0),("boundsAccessor"in t&&!H(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Wt(this.config),s=!0,l=!0),"pointIdAccessor"in t&&!H(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?V(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in t&&!H(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!H(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!H(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!H(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?X(this.config.openAccessor,"open"):void 0,this.getHigh=X(this.config.highAccessor,"high"),this.getLow=X(this.config.lowAccessor,"low"),this.getClose=e?X(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 Ft(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:g.createElement(g.Fragment,null,...e)}zt.GROUP_COLOR_MAP_CAP=1e3,zt.QUADTREE_THRESHOLD=500;const Yt=g.createContext(null);function Bt({value:e,children:n}){return t.jsx(Yt.Provider,{value:e,children:n})}function Ht(e,n){return null!=e?t.jsx(Bt,{value:n,children:e}):e}function Xt(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 Gt(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Vt(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function qt(t,e){const n=Vt(t);if(!n)return!1;const i=Vt(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function Ut(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Kt(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);Gt(l(t),i)>=u&&y>u&&(f=t,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}const Qt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Zt=new WeakMap;let Jt=0,te=!1,ee=null,ne=null,ie=null;function oe(t,e){var n,i;if(!e)return e;const o=Qt.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(te)return;if("undefined"==typeof window||"undefined"==typeof document)return;te=!0;const t=()=>{Jt++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(ee=new MutationObserver(t),ee.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{ne=window.matchMedia("(prefers-color-scheme: dark)"),ie=t,"function"==typeof ne.addEventListener?ne.addEventListener("change",ie):"function"==typeof ne.addListener&&ne.addListener(ie)}catch(t){}}();let s=Zt.get(r);s&&s.version===Jt||(s={version:Jt,map:new Map},Zt.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 re(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function se(t,e,n){return null==e?n:"string"!=typeof e?e:oe(t,e)||n}function le(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 ae(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 ce=new WeakMap;function ue(t,e){const n=re(e);if(!n)return t;const i=ce.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 s.line().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return ce.set(t,o),o}function de(t,e,n,i=30,o,r=0){let s=null;if(o){const t=Kt(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=fe(r,e,n,i);break;case"symbol":t=ye(r,e,n,i);break;case"line":t=ge(r,e,n,i);break;case"rect":if(null==r.datum)break;t=ve(r,e,n);break;case"heatcell":t=me(r,e,n);break;case"area":if(!1===r.interactive)break;t=be(r,e,n);break;case"candlestick":t=xe(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function he(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=ke(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 fe(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>Gt(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function ye(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>Gt(Tt(t.size),i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function ge(t,e,n,i=30){var o,r;if(0===t.path.length)return null;const s=ke(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=pe(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 pe(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 ve(t,e,n){const i=Xt(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function me(t,e,n){const i=Xt(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function xe(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 be(t,e,n){if(0===t.topPath.length)return null;const i=ke(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 ke(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 we(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 Ae(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 _e(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?Se(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Se(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 Se(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 Me(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function je(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const Pe={fresh:1,aging:1.5,stale:3};function Ce(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:Pe.fresh,l=null!==(o=n.aging)&&void 0!==o?o:Pe.aging,a=null!==(r=n.stale)&&void 0!==r?r:Pe.stale;return e*s>t?"fresh":e*l>t?"aging":e*a>t?"stale":"expired"}const Ee={fresh:1,aging:.7,stale:.45,expired:.25},Oe={alpha:1,band:"fresh",isStale:!1};function Te(t,e){var n,i;if(!t||0>=e)return Oe;const o=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},i=Ce(e,o,t.thresholds);return{alpha:Object.assign(Object.assign({},Ee),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}:Oe}function De(t,n,i,o,r,s){const l=e.useRef("fresh");e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{const e=n.current;if(!e||0===e.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=Te(t,a-e.lastIngestTime);c.band===l.current&&c.isStale===r||(l.current=c.band,c.isStale!==r&&s(c.isStale),i.current=!0,o())},1e3);return()=>clearInterval(e)},[t,r,o])}function Ne({isStale:e,position:n}){return t.jsx("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 Le={fill:(e,n)=>t.jsx("rect",{style:e,width:n,height:n}),line:(e,n)=>t.jsx("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function Re(t,e,n,i,o){let r;return r="function"==typeof n?n(t):(0,Le[n])(i(t,e),o),r}function $e({swatchSize:e}){return t.jsx("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 Ie(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const We=(e,n,i,o,r,s,l,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:y}=e,g=[];let p=0;const v=!(!n&&!i),m="isolate"===u||void 0===u&&null!=r,{swatchSize:x,labelGap:b,rowHeight:k}=d;return y.forEach((e,u)=>{const d=Re(e,u,h,f,x),w=Ie(e,o,r),A=r&&r.size>0&&r.has(e.label);g.push(t.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:v?a===s&&u===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&m?A||!1:void 0,"aria-current":v&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+y.length)%y.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:v?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),d,A&&t.jsx($e,{swatchSize:x}),t.jsx("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=k}),g};function ze({config:e,orientation:n="vertical",width:i=100}){const{colorFn:o,domain:r,label:s,format:l}=e,a=l||(t=>Math.round(100*t)/100+""),c="grad-legend-"+g.useId();if("horizontal"===n){const e=12,n=Math.min(i,200),l=Math.max(0,(i-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:l+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:l,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),t.jsx("text",{x:l+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function Fe(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,legendInteraction:l,title:a="Legend",width:c=100,height:u=20,orientation:d="vertical",legendLayout:h}=e,f=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}}(h),[y,p]=g.useState(0),[v,m]=g.useState(0),x=g.useCallback((t,e)=>{p(t),m(e)},[]),b="vertical"===d?(({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.jsx("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.jsx("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.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:We(e,i,o,r,s,l,a,y,c,u,d)},"legend-group-"+y)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:l,metrics:f}):(({legendGroups:e,height:n,width:i,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var f;let y=0;const g=[];e.forEach((e,n)=>{var f;let p=0;e.label&&(p+=16);const v=((e,n,i,o,r,s,l,a,c,u,d,h)=>{const{type:f="fill",styleFn:y,items:g}=e,p=[],{swatchSize:v,labelGap:m,itemGap:x,rowHeight:b,align:k}=d,w=!(!n&&!i),A="isolate"===u||void 0===u&&null!=r,_=g.map(t=>v+m+7*t.label.length),S=[];let M=0,j=0;_.forEach((t,e)=>{const n=0===j?t:j+x+t;h&&h>0&&j>0&&n>h?(S.push({start:M,end:e,width:j}),M=e,j=t):j=n}),g.length>0&&S.push({start:M,end:g.length,width:j}),S.forEach((e,u)=>{let d="center"===k?Math.max(0,((null!=h?h:e.width)-e.width)/2):"end"===k?Math.max(0,(null!=h?h:e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=g[h],k=Re(e,h,f,y,v),S=Ie(e,o,r),M=r&&r.size>0&&r.has(e.label);p.push(t.jsxs("g",{transform:`translate(${d},${u*b})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:w?a===s&&h===l?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&A?M||!1:void 0,"aria-current":w&&!A&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:w?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(h+("ArrowRight"===t.key?1:-1)+g.length)%g.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:w?t=>{c(a,h),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:w?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+m+2+7*e.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,M&&t.jsx($e,{swatchSize:v}),t.jsx("text",{y:v/2,x:v+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),d+=_[h]+x}});const P=Math.max(0,...S.map(t=>t.width)),C=S.length;return{items:p,offset:P,totalRows:C,totalHeight:C*b}})(e,o,r,s,l,a,c,n,u,d,h,null!==(f=h.maxWidth)&&void 0!==f?f:i);p+=v.offset+5,g.push(Object.assign(Object.assign({label:e.label},v),{offset:p,totalRows:v.totalRows,totalHeight:v.totalHeight})),y+=p+12});const p=null!==(f=h.maxWidth)&&void 0!==f?f:i;let v=y>p?0:"center"===h.align?Math.max(0,(p-y)/2):"end"===h.align?Math.max(0,p-y):0;const m=[];return g.forEach((i,o)=>{const r=e[o];r.label&&(m.push(t.jsx("text",{transform:`translate(${v},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)),v+=16),m.push(t.jsx("g",{className:"legend-item",transform:`translate(${v},0)`,children:i.items},"legend-group-"+o)),v+=i.offset+5,e[o+1]&&m.push(t.jsx("line",{stroke:"gray",x1:v,y1:-8,x2:v,y2:(i.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+o)),v+=12}),t.jsx("g",{children:m})})({legendGroups:n||[],title:a,height:u,width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:l,metrics:f}),k=!(!i&&!o);return t.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"isolate"!==l&&(void 0!==l||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&t.jsx("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}),b]})}function Ye(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Be(t){return"object"==typeof t&&null!==t&&"gradient"in t}function He(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,x;return"left"===l?(m=Math.max(4,s.left-v-10),x=s.top):"top"===l?(m=s.left,x=p?32:8):"bottom"===l?(m=s.left,x=r-s.bottom+38):(m=o-s.right+10,x=s.top),t.jsx("g",{transform:`translate(${m}, ${x})`,children:Be(i)?t.jsx(ze,{config:i.gradient,orientation:g?"horizontal":"vertical",width:v}):Ye(i)?t.jsx(Fe,{legendGroups:i.legendGroups,title:"",width:v,orientation:g?"horizontal":"vertical",legendLayout:a,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:y}):i})}function Xe(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 Ge(t){return"string"==typeof t?{type:t}:t}function Ve({orient:n,config:i,values:o,scale:r,size:s,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=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),i=s-8;if("boxplot"===c.type){const e=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(!e)return null;const{q1:s,median:l,q3:a,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*i,20),y=(i-f)/2+4;if(u){const e=r(s),i=r(a),o=r(l),u=r(d),g=r(h),p="top"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:v+p*(y+f/2),x2:g,y2:v+p*(y+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:v+p*y,x2:u,y2:v+p*(y+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:g,y1:v+p*y,x2:g,y2:v+p*(y+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,i),y:"top"===n?v-y-f:v+y,width:Math.abs(i-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:o,y1:"top"===n?v-y-f:v+y,x2:o,y2:"top"===n?v-y:v+y+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),i=r(a),o=r(l),u=r(d),g=r(h),p="left"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:v+p*(y+f/2),y1:u,x2:v+p*(y+f/2),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*y,y1:u,x2:v+p*(y+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*y,y1:g,x2:v+p*(y+f),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?v-y-f:v+y,y:Math.min(e,i),width:f,height:Math.abs(i-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?v-y-f:v+y,y1:o,x2:"left"===n?v-y:v+y+f,y2:o,stroke:c.fill,strokeWidth:2})]})}}const d=l.bin().domain(e).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.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*i;if(u){const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:i,y:"top"===n?-4-s:4,width:Math.max(l,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(i,i+l),width:s,height:Math.abs(l),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=i/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(i/2),l=r((t.x0+t.x1)/2);o.push(u?`${l},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${l}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const l=s.length/h*(i/2),a=r((s.x0+s.x1)/2);o.push(u?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:o.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,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-o-4:o+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${t},${s}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,r,c,s,a,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function qe(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 Ue(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 Ke(e,n,i,o){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:l,align:a,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=l;d||(d=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>i?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const y=16,g=s?u?[s]:qe(s,c):[],p=r?u?[r]:qe(r,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?(x.push(t.jsx("foreignObject",{className:"annotation-note-html",x:"end"===f?v-c:"middle"===f?v-c/2:v,y:-16,width:c,height:Math.max(y,(g.length+p.length)*y+(s&&r?2:0))+y,style:{overflow:"visible"},children:t.jsxs("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===f?"right":"middle"===f?"center":"left",whiteSpace:u?"nowrap":"normal",wordBreak:"break-word"},children:[s&&t.jsx("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:s}),r&&t.jsx("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")),m=g.length*y):(g.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:g.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:y,children:e},n))},"annotation-note-title")),m=g.length*y),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:m,children:p.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:y,children:e},n))},"annotation-note-label")));let k=null;if((s||r)&&(0!==n||0!==i))if("topBottom"===d){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,i=e;"bottom"===h?(n=-e,i=0):"middle"===h&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,g.length+p.length-1)*y;let A=0;return"topBottom"===d?A=0>i?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${i})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function Qe(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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("path",{d:Ue((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.jsx("g",{className:"annotation-subject",children:l})}function Ze(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.jsx("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.jsx("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.jsx("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.jsx("g",{className:"annotation-connector",children:a})}function Je(e){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:x={},"data-testid":b}=e,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 t.jsxs("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${k},${w})`,"data-testid":b},null!=v&&{opacity:v},m&&{strokeDasharray:m},x,{children:[!A.has("connector")&&Ze(_,S,d,y,M,h),!A.has("subject")&&Qe(M,h,y,k,w),!A.has("note")&&Ke(u,_,S,y)]}))}function tn(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.jsx(Je,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t.jsx("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t.jsx(Je,Object.assign({"data-testid":"semiotic-annotation",events:l},o,{type:s}),c)}function en(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 nn(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 on(t){return null==t?null:t+""}function rn(t,e,n){var i;return null===(i=e.stickyPositionCache)||void 0===i||i.set(t,n),n}function sn(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 rn(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?rn(e,n,i):null}if("semantic"===r){const i=function(t,e,n){var i,o;const r=function(t){var e,n;return on(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=>on(t.pointId)===r);if(s)return rn(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 on(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=en(l,n),c=nn(l,n);return null==a||null==c?null:rn(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=en(t,n),l=nn(t,n)),null!=s&&null!=l)return rn(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 ln(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const an={secondary:0,primary:3},cn=".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 un(t){return!0===(null==t?void 0:t._annotationDeferred)}function dn(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function hn(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 fn(t){return Math.max(.72,.95-.06*t)}function yn(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:hn(t.annotation),readingOrder:null,rank:1};var n}),i=n.some(t=>null!=t.emphasis||null!=t.confidence),o=e.some(t=>un(t.annotation)),r=e.some(t=>null!=dn(t.annotation)),s=e.some(t=>"layer"===dn(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=an[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=un(n.annotation);let l=n.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;l=t.jsx("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o},"secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:fn(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+i)}const a=dn(n.annotation);return a&&(l=t.jsx("g",{className:"annotation-cohesion--"+a,children:l},"annotation-cohesion-"+i)),s&&(l=t.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:l},"annotation-deferred-"+i)),l});return o&&a.unshift(t.jsx("style",{children:cn},"annotation-disclosure-style")),s&&a.unshift(t.jsx("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 gn={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};const pn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function vn(t){return!!t&&"object"==typeof t&&pn.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function mn(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function xn(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 bn(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 kn=32,wn=6,An=4,_n=8,Sn=72;const Mn={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function jn(t){return vn(t)}function Pn(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 Cn(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 En(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function On(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 Tn(t,e,n,i,o,r,s,l){const a=En(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*On(a,t);for(const t of i)c+=4*On(a,t);return c}function Dn(t){var e;const{annotations:n,context:i,defaultOffset:o=kn,notePadding:r=wn,markPadding:s=An,edgePadding:l=_n,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:u=Sn,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 x=[],b=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(!jn(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?sn(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=[...Pn("string"==typeof t.title?t.title:void 0,e),...Pn("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 x.push(En(Cn(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=Tn(Cn(n.x,n.y,t.dx,t.dy,s),t,x,b,v,m,r,l);f>e&&(h=t,f=e)}if(!h)return t;const y=En(Cn(n.x,n.y,h.dx,h.dy,s),r);x.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=Mn[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:xn(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=xn(i,o,t),l=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,vn(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=>mn(t.annotation)),u=a.filter(t=>!mn(t.annotation)).sort((t,e)=>bn(e.annotation)-bn(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 _)jn(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=>jn(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 Nn={positions:new Map};const Ln=new Set;function Rn(){for(const t of Ln)t()}function $n(t,e){const n=Nn.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Nn.positions);i.delete(t),Nn={positions:i},Rn()}function In(t,e){const n=Nn.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Nn.positions);i.delete(t),Nn={positions:i},Rn()}function Wn(){return Nn}function zn(t){return Ln.add(t),()=>Ln.delete(t)}const Fn={positions:new Map};function Yn(){return()=>{}}function Bn(){return Fn}function Hn(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 Xn(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function Gn(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Vn(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 qn(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Un(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 Kn(n){const{width:i,height:o,totalWidth:r,totalHeight:s,margin:l,scales:a,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f,axisExtent:y}=n,g=e.useMemo(()=>{var t,e;if(!a)return[];const n=null==u?void 0:u.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||h||Qn,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:Hn(a.x,"exact"===y?Math.max(2,s):Math.min(s,r),y),c=l.map(t=>t.valueOf()),d=l.map((t,e)=>({value:t,pixel:a.x(t),label:o(t,e,c)})),f=d.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 Zn(d,Math.max(55,f+8))},[a,u,h,i,y]),p=e.useMemo(()=>{var t,e;if(!a)return[];const n=null==u?void 0:u.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||f||Qn,r=Math.max(2,Math.floor(o/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return Zn((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hn(a.y,"exact"===y?Math.max(2,s):Math.min(s,r),y)).map(t=>({value:t,pixel:a.y(t),label:i(t)})),22)},[a,u,f,o,y]),v=d&&a,m=c&&a;if(!v&&!m)return null;const x=null==u?void 0:u.find(t=>"bottom"===t.orient),b=null==u?void 0:u.find(t=>"left"===t.orient),k=m&&(!x||!1!==x.baseline),w=m&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,_=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[v&&(()=>{var e,n;const r=qn(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=qn(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[g.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),p.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t.jsx("line",{x1:0,y1:o,x2:i,y2:o,stroke:S,strokeWidth:1}),A&&t.jsx("path",{d:Un("bottom",i,o),fill:"none",stroke:S,strokeWidth:1}),w&&!_&&t.jsx("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),_&&t.jsx("path",{d:Un("left",i,o),fill:"none",stroke:S,strokeWidth:1})]})})}function Qn(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Zn(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 Jn(n){var i,o;const{width:r,height:l,totalWidth:c,totalHeight:u,margin:d,scales:h,showAxes:f,axes:y,xLabel:v,yLabel:m,yLabelRight:x,xFormat:b,yFormat:k,axisExtent:w,showGrid:A,title:_,legend:S,legendHoverBehavior:M,legendClickBehavior:j,legendHighlightedCategory:P,legendIsolatedCategories:C,legendPosition:E="right",legendLayout:O,foregroundGraphics:T,marginalGraphics:D,xValues:N,yValues:L,annotations:R,autoPlaceAnnotations:$,svgAnnotationRules:I,xAccessor:W,yAccessor:z,annotationData:F,pointNodes:Y,curve:B,underlayRendered:H,canvasObscuresUnderlay:X=!0,linkedCrosshairName:G,linkedCrosshairSourceId:V,children:q}=n,U=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==y?void 0:y.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||b||Qn,o=Math.max(2,Math.floor(r/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:Hn(h.x,"exact"===w?Math.max(2,s):Math.min(s,o),w),a=l.map(t=>t.valueOf()),c=l.map((t,e)=>({value:t,pixel:h.x(t),label:i(t,e,a)})),u=c.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),d=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(u+8,55)):Math.max(55,u+8);let g=Zn(c,d);if(g.length>1&&(g=g.filter((t,e)=>0===e||t.label+""!=g[e-1].label+"")),(null==n?void 0:n.includeMax)&&g.length>0&&"exact"!==w&&!(null==n?void 0:n.tickValues)){const t=h.x.domain()[1],e=h.x(t),n=g[g.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t,g.length,a);d>e-n&&g.length>1&&(g=g.slice(0,-1)),g.push({value:t,pixel:e,label:o})}}return g},[f,h,y,b,r,w]),K=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==y?void 0:y.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||k||Qn,o=Math.max(2,Math.floor(l/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=Zn((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Hn(h.y,"exact"===w?Math.max(2,r):Math.min(r,o),w)).map(t=>({value:t,pixel:h.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"!==w&&!(null==n?void 0:n.tickValues)){const t=h.y.domain()[1],e=h.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},[f,h,y,k,l,w]),Q=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==y?void 0:y.find(t=>"right"===t.orient);if(!n)return[];const i=n.tickFormat||k||Qn,o=Math.max(2,Math.floor(l/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return Zn((null!==(e=n.tickValues)&&void 0!==e?e:Hn(h.y,"exact"===w?Math.max(2,r):Math.min(r,o),w)).map(t=>({value:t,pixel:h.y(t),label:i(t)})),22)},[f,h,y,k,l,w]),Z=e.useRef(new Map),J=e.useRef(null!==(i=null==R?void 0:R.length)&&void 0!==i?i:0),tt=null!==(o=null==R?void 0:R.length)&&void 0!==o?o:0;J.current!==tt&&(J.current=tt,Z.current=new Map);const et=e.useMemo(()=>{if(!R||0===R.length)return null;const e=function(e,n,i){var o,r,l,c,u,d,h,f,y,v,m,x,b,k,w,A,_,S,M,j,P,C,E,O,T,D,N,L,R,$,I,W,z,F,Y,B,H,X,G,V,q,U,K,Q,Z,J,tt,et,nt,it,ot;switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const s=sn(e,n,i);if(!s)return null;const{x:a,y:c}=s;if(!ln(a,c,i))return null;const u="callout"===e.type?"callout-circle":e.type,d="callout-circle"===u?{radius:null!==(o=e.radius)&&void 0!==o?o:12,radiusPadding:e.radiusPadding}:"callout-rect"===u?{width:e.width,height:e.height}:void 0;return t.jsx(tn,{noteData:Object.assign(Object.assign({x:a,y:c,dx:null!==(r=e.dx)&&void 0!==r?r:30,dy:null!==(l=e.dy)&&void 0!==l?l:-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:u},d?{subject:d}:{}),{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 o=en(null!=e.value?Object.assign(Object.assign({},e),{x:e.value}):e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let l;l="bottom"===s?(i.height||0)-4:"center"===s?(i.height||0)/2:12;const a=o>.6*(i.width||0),c=a?o-4:o+4,u=a?"end":"start";return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:i.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:c,y:l,textAnchor:u,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"y-threshold":{const o=nn(null!=e.value?Object.assign(Object.assign({},e),{y:e.value}):e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let l,a;return"left"===s?(l=4,a="start"):"center"===s?(l=(i.width||0)/2,a="middle"):(l=(i.width||0)-4,a="end"),t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:0,y1:o,x2:i.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:l,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:en(Object.assign(Object.assign({},t),{type:"point"}),i),y:nn(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=a.packEnclose(o),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:en(Object.assign(Object.assign({},t),{type:"point"}),i),y:nn(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=e.padding||10,s=o.map(t=>t.x),l=o.map(t=>t.y),[a,c]=Xe(s),[u,d]=Xe(l),h=a-r,f=c+r,y=u-r;return t.jsxs("g",{children:[t.jsx("rect",{x:h,y:y,width:f-h,height:d+r-y,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(h+f)/2,y:y-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const o=i.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,o)=>{const r=en(n,i),l=nn(n,i);if(null==r||null==l)return null;const a="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:l,r:a},c),"hl-"+o)})},"ann-"+n)}case"bracket":{const o=en(e,i),r=nn(e,i);return t.jsx(tn,{noteData:{x:null!=o?o:0,y:null!=r?r: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 o=i.data||[];if(2>o.length)return null;const r=i.xAccessor||"x",s=i.yAccessor||"y",l="ordinal"===i.frameType,a="horizontal"===i.projection,g=l?r:null,m=l?s:null;let x;const b=[],k=new Map;if(l&&g&&m){for(const t of o){const e=t[g];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,b.length),b.push(n))}x=o.map(t=>{const e=t[g],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 x=o.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>x.length)return null;const w=null!==(u=null===(c=i.scales)||void 0===c?void 0:c.x)&&void 0!==u?u:null===(d=i.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=i.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=i.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(b.length-1,n+1),o=e-n,r=t(b[n]);return r+(t(b[i])-r)*o},S=w,M=A;let j;if(l)if(a){const t=_(M);j=(e,n)=>[S(n),t(e)]}else{const t=_(S);j=(e,n)=>[t(e),M(n)]}else j=(t,e)=>[S(t),M(e)];const P=e.method||"linear";let C;C="loess"===P?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}(x,null!==(v=e.bandwidth)&&void 0!==v?v:.3):("polynomial"===P?p.default.polynomial(x,{order:e.order||2}):p.default.linear(x)).points;const E=C.map(([t,e])=>{const[n,i]=j(t,e);return`${n},${i}`}).join(" "),O=e.color||"#6366f1",T=C[C.length-1],[D,N]=j(T[0],T[1]);return t.jsxs("g",{children:[t.jsx("polyline",{points:E,fill:"none",stroke:O,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:D+4,y:N-4,fill:O,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const o=null!==(x=null===(m=i.scales)||void 0===m?void 0:m.y)&&void 0!==x?x:null===(b=i.scales)||void 0===b?void 0:b.value,r=null!==(k=null==o?void 0:o(e.y0))&&void 0!==k?k:0,s=null!==(w=null==o?void 0:o(e.y1))&&void 0!==w?w:i.height||0;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:i.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.max(Math.min(r,s),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"envelope":{const o=i.data||[];if(2>o.length)return null;const r=i.xAccessor||"x",l=null!==(_=null===(A=i.scales)||void 0===A?void 0:A.x)&&void 0!==_?_:null===(S=i.scales)||void 0===S?void 0:S.time,a=null!==(j=null===(M=i.scales)||void 0===M?void 0:M.y)&&void 0!==j?j:null===(P=i.scales)||void 0===P?void 0:P.value;if(!l||!a)return null;const c=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=o.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const f=gn[i.curve||"linear"]||s.curveLinear,y=s.area().x(t=>l(t[r])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!y)return null;const g=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:y,fill:g,fillOpacity:null!==(C=e.fillOpacity)&&void 0!==C?C:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:l(h[h.length-1][r])+4,y:a(h[h.length-1][c])-4,fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const o=i.data||[];if(2>o.length)return null;const r=i.yAccessor||"y",s=null!==(O=null===(E=i.scales)||void 0===E?void 0:E.x)&&void 0!==O?O:null===(T=i.scales)||void 0===T?void 0:T.time,l=null!==(N=null===(D=i.scales)||void 0===D?void 0:D.y)&&void 0!==N?N:null===(L=i.scales)||void 0===L?void 0:L.value;if(!s||!l)return null;const a=o.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,u=a.reduce((t,e)=>t+Math.pow(e-c,2),0)/a.length,d=Math.sqrt(u),h=null!==(R=e.threshold)&&void 0!==R?R:2,f=c-h*d,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==($=e.fillOpacity)&&void 0!==$?$:.1,v=e.anomalyColor||"#ef4444",m=null!==(I=e.anomalyRadius)&&void 0!==I?I:6,x=l(c+h*d),b=l(f),k=o.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[y&&t.jsx("rect",{x:0,y:Math.min(x,b),width:i.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const o=en(e,i),r=nn(e,i);return null==o||null==r?null:t.jsx("circle",{cx:o,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const o=i.data||[];if(3>o.length)return null;const r=i.xAccessor||"x",s=i.yAccessor||"y",l=null!==(z=null===(W=i.scales)||void 0===W?void 0:W.x)&&void 0!==z?z:null===(F=i.scales)||void 0===F?void 0:F.time,a=null!==(B=null===(Y=i.scales)||void 0===Y?void 0:Y.y)&&void 0!==B?B:null===(H=i.scales)||void 0===H?void 0:H.value;if(!l||!a)return null;const c=o.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=p.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,o=0;for(const[t,r]of c)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;u=t=>l+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),y=c.reduce((t,e)=>t+e[0],0)/d,g=c.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),v=null!==(X=e.confidence)&&void 0!==X?X:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(G=e.steps)&&void 0!==G?G:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(g>0?Math.pow(t-y,2)/g:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const _=`M${A.map(t=>`${l(t.x)},${a(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${a(t.yLower)}`).join(" L")} Z`,S=A.map(t=>`${l(t.x)},${a(t.yCenter)}`).join(" "),M=`${l(b)},${a(u(b))}`,j=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:_,fill:e.fill||"#6366f1",fillOpacity:null!==(V=e.fillOpacity)&&void 0!==V?V:.15,stroke:"none"}),t.jsx("polyline",{points:`${M} ${S}`,fill:"none",stroke:j,strokeWidth:null!==(q=e.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(U=e.strokeDasharray)&&void 0!==U?U:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:l(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:j,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const t=sn(e,n,i);if(!t)return null;o=t.x,r=t.y}if(null==o||null==r)return null;if(!ln(o,r,i))return null;const s=null!==(K=e.dx)&&void 0!==K?K:0,l=null!==(Q=e.dy)&&void 0!==Q?Q:0,a=null!==(Z=e.width)&&void 0!==Z?Z:32,c=null!==(J=e.height)&&void 0!==J?J:32,u=null!==(tt=e.content)&&void 0!==tt?tt:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:o+s-a/2,y:r+l-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const o=sn(e,n,i);if(!o)return null;const{x:r,y:s}=o,l=r+(e.dx||0),a=s+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",u=t.jsx("text",{x:l,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?g.cloneElement(u,{key:"ann-text-"+n}):t.jsxs("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[t.jsx("line",{x1:r,y1:s,x2:l,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),g.cloneElement(u,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=t=>"function"==typeof t&&"function"==typeof t.bandwidth,s=null===(et=i.scales)||void 0===et?void 0:et.o,l=null===(nt=i.scales)||void 0===nt?void 0:nt.x,a=null===(it=i.scales)||void 0===it?void 0:it.y,c=r(s)?s:r(l)?l:r(a)?a:null;if(!c)return null;const u=c(o+"");if(null==u)return null;const d=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",f=null!==(ot=e.opacity)&&void 0!==ot?ot:.15,y=e.label;return t.jsxs("g",(i.projection?"vertical"===i.projection:c===l)?{children:[t.jsx("rect",{x:u,y:0,width:d,height:i.height||0,fill:h,fillOpacity:f}),y&&t.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:y})]}:{children:[t.jsx("rect",{x:0,y:u,width:i.width||0,height:d,fill:h,fillOpacity:f}),y&&t.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:y})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:W,yAccessor:z,width:r,height:l,data:F,frameType:"xy",pointNodes:Y,curve:B,stickyPositionCache:Z.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})}),yn(o)}($?Dn(Object.assign({annotations:R,context:n},"object"==typeof $?$:{})):R,e,I,n)},[R,$,I,r,l,W,z,F,h,Y,B]),nt=function(t){var n;const i=e.useSyncExternalStore(t?zn:Yn,t?Wn:Bn,t?Wn:Bn);return t&&null!==(n=i.positions.get(t))&&void 0!==n?n:null}(G);return e.useEffect(()=>{if(!(null==nt?void 0:nt.locked)||!G)return;const t=t=>{"Escape"===t.key&&In(G)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==nt?void 0:nt.locked,G]),f||_||S||T||D||et&&et.length>0||A||q||nt?t.jsxs("svg",{role:"img",width:c,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof _?_:"XY Chart"}),t.jsx("desc",{children:"string"==typeof _?_+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[A&&h&&(!H||X)&&(()=>{var e,n;const i=qn(null===(e=null==y?void 0:y.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),o=qn(null===(n=null==y?void 0:y.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[U.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:l,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),K.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==y?void 0:y.find(t=>"left"===t.orient),n=null==y?void 0:y.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,o=!n||!1!==n.baseline,s=(null==e?void 0:e.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",p=!!(null==n?void 0:n.autoRotate)&&U.length>1&&(()=>{const t=r/Math.max(U.length-1,1);return U.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),b={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},w={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=null==n?void 0:n.tickAnchor,_=null==e?void 0:e.tickAnchor,S=Vn(U),M=Vn(K);return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[t.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!H||X)&&o&&!a&&t.jsx("line",{x1:0,y1:l,x2:r,y2:l,stroke:h,strokeWidth:1}),(!H||X)&&a&&t.jsx("path",{d:Un("bottom",r,l),fill:"none",stroke:h,strokeWidth:1}),U.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):qt(e.value,n>0?U[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${l})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:p?10:18,textAnchor:p?"end":Xn(A,e.pixel===S.min,e.pixel===S.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?k:b),transform:p?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"center",userSelect:"none"},b),children:e.label})})]},"xtick-"+n)}),v&&t.jsx("text",{x:r/2,y:l+40,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:v})]}),t.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!H||X)&&i&&!s&&t.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:h,strokeWidth:1}),(!H||X)&&s&&t.jsx("path",{d:Un("left",r,l),fill:"none",stroke:h,strokeWidth:1}),K.map((e,n)=>{const i=!!u&&("function"==typeof u?u(e.value,n):qt(e.value,n>0?K[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:Gn(_,e.pixel===M.min,e.pixel===M.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?k:b),children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},b),children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||m;return n?t.jsx("text",{x:15-d.left,y:l/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-d.left}, ${l/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:n}):null})()]}),(()=>{const e=null==y?void 0:y.find(t=>"right"===t.orient);if(!e||0===Q.length)return null;const n=!1!==e.baseline,i=e.landmarkTicks,o=e.label||x,s=e.tickAnchor,a=Vn(Q);return t.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[n&&t.jsx("line",{x1:r,y1:0,x2:r,y2:l,stroke:h,strokeWidth:1}),Q.map((e,n)=>{const o=!!i&&("function"==typeof i?i(e.value,n):qt(e.value,n>0?Q[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${r},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:Gn(s,e.pixel===a.min,e.pixel===a.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?k:b),children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"left",userSelect:"none"},b),children:e.label})})]},"ytick-r-"+n)}),o&&t.jsx("text",{x:r+d.right-15,y:l/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${r+d.right-15}, ${l/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:o})]})})()]})})(),et,D&&h&&N&&L&&t.jsxs(t.Fragment,{children:[D.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Ve,{orient:"top",config:Ge(D.top),values:N,scale:h.x,size:d.top,length:r})}),D.bottom&&t.jsx("g",{transform:`translate(0, ${l})`,children:t.jsx(Ve,{orient:"bottom",config:Ge(D.bottom),values:N,scale:h.x,size:d.bottom,length:r})}),D.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Ve,{orient:"left",config:Ge(D.left),values:L,scale:h.y,size:d.left,length:l})}),D.right&&t.jsx("g",{transform:`translate(${r}, 0)`,children:t.jsx(Ve,{orient:"right",config:Ge(D.right),values:L,scale:h.y,size:d.right,length:l})})]}),T,nt&&nt.sourceId!==V&&(null==h?void 0:h.x)&&(()=>{const e=h.x(nt.xValue);if(null==e||0>e||e>r)return null;const n=nt.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:l,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"})})(),q]}),_&&t.jsx("text",{x:c/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 _?_:null}),He({legend:S,totalWidth:c,totalHeight:u,margin:d,legendPosition:E,title:_,legendLayout:O,legendHoverBehavior:M,legendClickBehavior:j,legendHighlightedCategory:P,legendIsolatedCategories:C})]}):null}function ti(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 ei={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ni(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const ii="undefined"==typeof window||"undefined"==typeof document,oi="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function ri(){const[t,n]=e.useState(!1);return oi(()=>{n(!0)},[]),t}const si=()=>()=>{},li=()=>!1,ai=()=>!0;function ci(){const t=e.useSyncExternalStore(si,li,ai);return e.useRef(t).current}function ui(t){const{hydrated:n,wasHydratingFromSSR:i,storeRef:o,dirtyRef:r,renderFnRef:s,cleanup:l}=t;oi(()=>{var t,e;n&&i&&(null===(e=null===(t=o.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===e||e.call(t)),r.current=!0,s.current()},[n,i]);const a=e.useRef(l);a.current=l,e.useEffect(()=>()=>{var t;return null===(t=a.current)||void 0===t?void 0:t.call(a)},[])}function di(t){const n=e.useRef(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return fi(t,e);if(!yi(t)||!yi(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(!fi(n,o))return!1}else{if(!yi(n)||!yi(o))return!1;if(!hi(n,o))return!1}}return!0}(n.current,t)||(n.current=t),n.current}function hi(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 fi(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 yi(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 gi=g.createContext(null);function pi(){return g.useContext(gi)}const vi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function mi(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 xi(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 bi=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function ki(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 wi="semiotic-accessible-data-table",Ai=wi+" semiotic-accessible-data-table-hidden",_i=wi+" semiotic-accessible-data-table-visible",Si=_i+" semiotic-accessible-data-table-network",Mi={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"},ji={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Pi={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)"},Ci={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ei={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))"},Oi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Ti={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Di={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 Ni({scene:e,chartType:n,tableId:i,chartTitle:o}){var r;const[s,l]=g.useState(!1),[a,c]=g.useState(5),u=pi(),d=null!==(r=null==u?void 0:u.visible)&&void 0!==r&&r,h=s||d,f=g.useRef(null),y=o?"Data summary for "+o:i?`Data summary for ${n} ${i}`:"Data summary for "+n;g.useEffect(()=>{h||c(5)},[h]);const p=g.useCallback(t=>{t.target===t.currentTarget&&(s||d||l(!0))},[s,d]),v=g.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||l(!1)},[d]);if(!e||0===e.length)return i?t.jsx("span",{id:i,tabIndex:-1,style:vi}):null;if(!h)return t.jsx("div",{id:i,className:Ai,tabIndex:-1,onFocus:p,style:vi,role:"region","aria-label":y,children:t.jsxs("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," elements)"]})});const m=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 x=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const b of t)if(b&&"object"==typeof b&&null!==b.datum)try{switch(b.type){case"point":if(x)break;m.push({label:"Point",values:ki(b.datum)});break;case"line":case"area":{const t=Array.isArray(b.datum)?b.datum:[],e="line"===b.type?"Line point":"Area point";for(const n of t)m.push({label:e,values:ki(n)});break}case"rect":{const t=null!=b.datum&&"object"==typeof b.datum?b.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:b.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=ki(b.datum);null==t.value&&"number"==typeof b.value&&Number.isFinite(b.value)&&(t.value=b.value),m.push({label:"Cell",values:t});break}case"wedge":m.push({label:"Wedge",values:{category:null!==(a=null!==(s=null===(r=b.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(l=b.datum)||void 0===l?void 0:l.label)&&void 0!==a?a:"",value:null!==(u=null===(c=b.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":m.push({label:"Node",values:ki(b.datum)});break;case"arc":m.push({label:"Arc",values:ki(b.datum)});break;case"candlestick":m.push({label:"Candlestick",values:ki(b.datum)});break;case"geoarea":m.push({label:"Region",values:{name:null!==(g=null!==(f=null===(h=null===(d=b.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(y=b.datum)||void 0===y?void 0:y.name)&&void 0!==g?g:"",value:null!==(v=null===(p=b.datum)||void 0===p?void 0:p.value)&&void 0!==v?v:""}})}}catch(t){}return m}(e),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}(m),b=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${bi(t.min)} to ${bi(t.max)}, mean ${bi(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(" ")}(m.length,x),k=Math.min(a,m.length),w=m.slice(0,k),A=m.length-k,_=new Set;for(const t of w)for(const e of Object.keys(t.values))_.add(e);const S=Array.from(_);return t.jsxs("div",{ref:f,id:i,className:_i,tabIndex:-1,onBlur:v,style:Mi,role:"region","aria-label":y,children:[t.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&u&&u.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:Pi,children:"×"}),t.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ji,children:b}),t.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+n,style:Ci,children:[t.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:Ti,children:A>0?`First ${k} of ${m.length} data points`:`All ${m.length} data points`}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:Ei,children:"type"}),S.map(e=>t.jsx("th",{style:Ei,children:e},e))]})}),t.jsx("tbody",{children:w.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Oi,children:e.label}),S.map(n=>{return t.jsx("td",{style:Oi,children:(i=e.values[n],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":bi(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},n);var i})]},n))})]}),A>0&&t.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(t=>t+25),style:Di,children:["Show ",Math.min(25,A)," more"," ",1===A?"row":"rows"," (",A," remaining)"]})]})}function Li({nodes:e,edges:n,chartType:i,tableId:o,chartTitle:r}){var s,l,a,c,u,d,h,f,y,p,v,m,x,b;const[k,w]=g.useState(!1),[A,_]=g.useState(5),S=pi(),M=null!==(s=null==S?void 0:S.visible)&&void 0!==s&&s,j=k||M,P=r?"Data summary for "+r:o?`Data summary for ${i} ${o}`:"Data summary for "+i,C=g.useRef(null);g.useEffect(()=>{j||_(5)},[j]);const E=g.useCallback(t=>{t.target===t.currentTarget&&(k||M||w(!0))},[k,M]),O=g.useCallback(t=>{var e;M||(null===(e=C.current)||void 0===e?void 0:e.contains(t.relatedTarget))||w(!1)},[M]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:vi}):null;if(!j)return t.jsx("div",{id:o,className:Ai,tabIndex:-1,onFocus:E,style:vi,role:"region","aria-label":P,children:t.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",e.length," nodes, ",n.length," edges)"]})});const T=Array.isArray(e)?e:[],D=Array.isArray(n)?n:[],N=new Map,L=new Map,R=new Map,$=new Map;for(const t of D){if(!t||"object"!=typeof t)continue;const e=null!==(l=t.datum)&&void 0!==l?l:t,n="object"==typeof e.source?null===(a=e.source)||void 0===a?void 0:a.id:e.source,i="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";L.set(t,(null!==(u=L.get(t))&&void 0!==u?u:0)+1),$.set(t,(null!==(d=$.get(t))&&void 0!==d?d:0)+o)}if(null!=i&&""!==i){const t=i+"";N.set(t,(null!==(h=N.get(t))&&void 0!==h?h:0)+1),R.set(t,(null!==(f=R.get(t))&&void 0!==f?f:0)+o)}}const I=[];for(let t=0;T.length>t;t++){const e=T[t];if(!e||"object"!=typeof e)continue;const n=null!==(p=null===(y=e.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:e.id,i=null!=n?n+"":"node-"+t,o=null!==(v=N.get(i))&&void 0!==v?v:0,r=null!==(m=L.get(i))&&void 0!==m?m:0,s=null!==(x=R.get(i))&&void 0!==x?x:0,l=null!==(b=$.get(i))&&void 0!==b?b:0;I.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:s+l,wInDeg:s,wOutDeg:l})}I.sort((t,e)=>e.degree-t.degree);let W=0,z=0;if(I.length>0){let t=0;for(const e of I)t+=e.degree,e.degree>z&&(z=e.degree);W=t/I.length}const F=D.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)}),Y=[`${I.length} nodes, ${D.length} edges.`];I.length>0&&Y.push(`Mean degree: ${bi(W)}, max degree: ${z}.`);const B=Math.min(A,I.length),H=I.slice(0,B),X=I.length-B;return t.jsxs("div",{ref:C,id:o,className:Si,tabIndex:-1,onBlur:O,style:Mi,role:"region","aria-label":P,children:[t.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{M&&S&&S.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:Pi,children:"×"}),t.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ji,children:Y.join(" ")}),t.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+i,style:Ci,children:[t.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:Ti,children:X>0?`Top ${B} of ${I.length} nodes by degree`:`All ${I.length} nodes by degree`}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:Ei,children:"id"}),t.jsx("th",{style:Ei,children:"degree"}),t.jsx("th",{style:Ei,children:"in"}),t.jsx("th",{style:Ei,children:"out"}),F&&t.jsx("th",{style:Ei,children:"w. degree"}),F&&t.jsx("th",{style:Ei,children:"w. in"}),F&&t.jsx("th",{style:Ei,children:"w. out"})]})}),t.jsx("tbody",{children:H.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Oi,children:e.id}),t.jsx("td",{style:Oi,children:e.degree}),t.jsx("td",{style:Oi,children:e.inDeg}),t.jsx("td",{style:Oi,children:e.outDeg}),F&&t.jsx("td",{style:Oi,children:bi(e.wDegree)}),F&&t.jsx("td",{style:Oi,children:bi(e.wInDeg)}),F&&t.jsx("td",{style:Oi,children:bi(e.wOutDeg)})]},n))})]}),X>0&&t.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>_(t=>t+25),style:Di,children:["Show ",Math.min(25,X)," more"," ",1===X?"node":"nodes"," (",X," remaining)"]})]})}function Ri({summary:e}){return e?t.jsx("div",{role:"note",style:vi,children:e}):null}function $i({tableId:e}){return t.jsx("a",{href:"#"+e,style:vi,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,vi)},children:"Skip to data table"})}function Ii({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.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:vi,children:n})}const Wi="var(--semiotic-focus, #005fcc)";function zi({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.jsx("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Wi,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Wi,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Wi,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Fi(t){return Array.isArray(t)?t[0]:t}function Yi(t,e,n,i){return Object.assign({data:Fi(t),x:e,y:n,__semioticHoverData:!0},i)}const Bi=["name","label","title"],Hi=["type","kind","category","group","class","status","role","shape"],Xi=["value","amount","total","count","weight","score"],Gi=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 Vi(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}const qi={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 Ui({x:e,y:n,containerWidth:i,containerHeight:o,margin:r,children:s,className:l="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(n),u=g.useRef(null),[d,h]=g.useState(null);g.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,l,i,o]);let f;f=d?`translate(${d.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`;const y=function(t){if(!g.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 i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor)return!0}return!1}(s),p=y?null:qi;return c?t.jsx("div",{ref:u,className:y?l:(l+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:r.left+e,top:r.top+n,transform:f,pointerEvents:"none",zIndex:a,width:"max-content"}),children:s}):null}const Ki="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function Qi(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Zi(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(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=>n(t.matches))},[]),t}(),i=e.useRef(n);i.current=n;const[o,r]=function(t,n,i){const o=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!i)return;const t=o.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[o,[n&&r?r.w:t[0],i&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),l=r[0]-s.left-s.right,a=r[1]-s.top-s.bottom,c=Qi(t.foregroundGraphics,r,s),u=Qi(t.backgroundGraphics,r,s),d=D(t=>t.theme),{transition:h,introEnabled:f}=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),y="semiotic-table-"+g.useId(),p=e.useRef(0),v=e.useRef(()=>{}),m=e.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);e.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),_=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),S=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const M=t.themeDirtyRef;return Ki(()=>{M&&(Jt++,M.current=!0,m())},[d,m,M]),{reducedMotion:n,reducedMotionRef:i,responsiveRef:o,size:r,margin:s,adjustedWidth:l,adjustedHeight:a,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:y,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:_,onPointerLeave:S}}function Ji(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 to(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function eo(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 no(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 io=(t,e,n,i)=>{var o,r;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const c=a._introClipFraction;void 0!==c&&1>c&&(t.save(),t.beginPath(),t.rect(0,0,i.width*c,i.height),t.clip());const u=a.style.stroke||"#007bff",d=oe(t,u)||u,h=a.style.strokeWidth||2,f=a.colorThresholds,y=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=h,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(o=a.style.opacity)&&void 0!==o?o:1;no(t,a.path,d,h,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=re(a.curve),p=f&&f.length>0&&y&&y.length===a.path.length,v=a._decayOpacities;if(v&&v.length===a.path.length&&!p){t.strokeStyle=d;const x=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(v[b]+v[b+1])*x,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,_=null,S=!1;function M(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),S=!0}function j(){S&&(t.stroke(),S=!1)}for(let P=0;a.path.length>P;P++){const[C,E]=a.path[P],O=y[P],T=eo(O,f,d);if(null!==k&&null!==_&&null!==A){if(T===_)t.lineTo(C,E);else{const D=[];for(const N of f){const L=N.value;(A>L||L>O)&&(L>A||O>L)||A===L||O===L||D.push({t:(L-A)/(O-A)})}D.sort((t,e)=>t.t-e.t);for(const R of D){const $=k+(C-k)*R.t,I=w+(E-w)*R.t,W=eo(A+(O-A)*Math.min(R.t+1e-4,1),f,d);t.lineTo($,I),j(),M(W,$,I)}t.lineTo(C,E)}k=C,w=E,A=O,_=T}else M(T,C,E),k=C,w=E,A=O,_=T}j()}else{t.beginPath();const z=a.strokeGradient&&a.path.length>=2?ae(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=z||d,g)s.line().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[F,Y]=a.path[0];t.moveTo(F,Y);for(let B=1;a.path.length>B;B++)t.lineTo(a.path[B][0],a.path[B][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=se(t,a.style.fill,a.style.fill),g&&!p)s.line().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[X,G]=a.path[0];t.moveTo(X,G);for(let V=1;a.path.length>V;V++)t.lineTo(a.path[V][0],a.path[V][1])}const H=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==c&&1>c&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function oo(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ro(t,e,n=.3){oo(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 so(t,e,n=.6){var i,o,r,s,l;if(!oo(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 lo(t,e,n,i=.35){oo(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ao(t,e){const n=re(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=s.area().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 co=(t,e,n,i)=>{var o,r,l;const a=e.filter(t=>"area"===t.type);for(const e of a){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 a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=se(t,e.style.fill,"#4e79a7"),u=e._decayOpacities;if(u&&u.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=c;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(u[i]+u[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=oe(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*(u[n]+u[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 d=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(ao(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=le(t,e.fillGradient,"string"==typeof c?c:"#4e79a7",0,n,0,i);t.fillStyle=o||c,t.globalAlpha=d}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*d,t.fillStyle=c}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(ao(t,e),lo(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=d;const n=e.strokeGradient&&e.topPath.length>=2?ae(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||oe(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=re(e.curve);if(t.beginPath(),i)s.line().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!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},uo=(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=se(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=se(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),so(t,n)}}finally{t.restore()}}},ho=new Map;function fo(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=ho.get(n);return i||(i=new Path2D(Ot(t.symbolType,t.size)),ho.size>256&&ho.clear(),ho.set(n,i)),i}catch(t){return null}}const yo=(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=fo(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=se(t,e.style.fill,"#4e79a7"),t.fill(a)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=s*c,t.strokeStyle=se(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 go(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 po(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 vo=(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)mo(t,e);else if(e.cornerRadii&&ti(e.cornerRadii)){const n=se(t,e.style.fill,oe(t,"var(--semiotic-primary, #007bff)")),i=po(e),o=e.fillGradient&&"string"==typeof n?le(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,go(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=oe(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=se(t,e.style.fill,oe(t,"var(--semiotic-primary, #007bff)")),i=po(e),o=e.fillGradient&&"string"==typeof n?le(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=oe(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=se(t,e.style.fill,oe(t,"var(--semiotic-primary, #007bff)")),i=po(e),o=e.fillGradient&&"string"==typeof n?le(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=oe(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ro(t,e),t.globalAlpha=1}};function mo(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 xo(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 bo(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const ko=(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=oe(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ro(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):bo(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=xo(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},wo=(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=oe(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=oe(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 Ao(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 _o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function So(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`${_o[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${_o[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Mo={line:[co,io,uo],area:[co,uo],stackedarea:[co,uo],scatter:[uo,yo],bubble:[uo,yo],heatmap:[ko],bar:[vo],swarm:[uo],waterfall:[(t,e,n,i)=>{var o;vo(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=oe(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:[wo],mixed:[co,io,uo],custom:[co,vo,ko,io,uo,yo,wo]},jo={top:20,right:20,bottom:30,left:40},Po={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 Co(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 Eo={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 Oo({hover:e}){var n,i,o;const r=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",s=null!==(n=e.data)&&void 0!==n?n:{},l=null!==(i=s.y)&&void 0!==i?i:s.value,a=null!==(o=s.x)&&void 0!==o?o:s.time;return t.jsxs("div",{className:"semiotic-tooltip",style:Eo,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(l)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:r(a)})]})}Oo.ownsChrome=!0;const To=e.forwardRef(function(n,i){var o,r,s,l,a,c,u,d,h,f,y,p,v;const{chartType:m,runtimeMode:b,data:A,chunkThreshold:_,chunkSize:M,xAccessor:j,yAccessor:P,colorAccessor:C,sizeAccessor:E,symbolAccessor:O,symbolMap:T,groupAccessor:D,lineDataAccessor:N,curve:L,normalize:R,baseline:$,stackOrder:I,binSize:W,valueAccessor:z,arrowOfTime:F="right",windowMode:Y="sliding",windowSize:B=200,timeAccessor:H,xExtent:X,yExtent:G,extentPadding:V=.1,scalePadding:q,sizeRange:U,size:K=[500,300],responsiveWidth:Q,responsiveHeight:Z,margin:J,className:tt,background:et,lineStyle:nt,pointStyle:it,areaStyle:ot,barStyle:rt,waterfallStyle:st,swarmStyle:lt,barColors:at,colorScheme:ct,boundsAccessor:ut,boundsStyle:dt,y0Accessor:ht,band:ft,gradientFill:yt,lineGradient:gt,areaGroups:pt,openAccessor:vt,highAccessor:mt,lowAccessor:xt,closeAccessor:bt,candlestickStyle:kt,showAxes:wt=!0,axes:At,xLabel:_t,yLabel:Mt,yLabelRight:jt,xFormat:Pt,yFormat:Ct,axisExtent:Et,tickFormatTime:Tt,tickFormatValue:Dt,hoverAnnotation:Nt,tooltipContent:Lt,customHoverBehavior:Rt,customClickBehavior:$t,enableHover:It,hoverRadius:Wt=30,tooltipMode:Yt,annotations:Bt,autoPlaceAnnotations:Xt,svgAnnotationRules:Gt,showGrid:Vt,legend:qt,legendHoverBehavior:Ut,legendClickBehavior:Kt,legendHighlightedCategory:Qt,legendIsolatedCategories:Zt,legendPosition:Jt,legendLayout:te,legendCategoryAccessor:ee,onCategoriesChange:ne,backgroundGraphics:ie,foregroundGraphics:re,canvasPreRenderers:se,svgPreRenderers:le,title:ae,categoryAccessor:ce,brush:fe,onBrush:ye,decay:ge,pulse:pe,transition:ve,animate:me,staleness:xe,heatmapAggregation:be,heatmapXBins:Se,heatmapYBins:Me,showValues:Pe,heatmapValueFormat:Ce,marginalGraphics:Ee,pointIdAccessor:Oe,xScaleType:Le,yScaleType:Re,accessibleTable:$e=!0,description:Ie,summary:We,linkedCrosshairName:ze,linkedCrosshairSourceId:Fe,customLayout:Ye,layoutConfig:Be,layoutSelection:He}=n,Xe=e.useId().replace(/:/g,""),Ge=e.useRef(!1),Ve=e.useRef({w:-1,h:-1}),qe=Zi({sizeProp:K,responsiveWidth:Q,responsiveHeight:Z,userMargin:J,marginDefault:jo,animate:me,transitionProp:ve,themeDirtyRef:Ge}),Ue=ri(),Ke=ci(),{reducedMotionRef:Qe,responsiveRef:Ze,size:Je,currentTheme:tn,transition:en,introEnabled:nn,tableId:on,rafRef:rn,renderFnRef:sn,scheduleRender:ln}=qe;let an=qe.margin;if(Ee){const t=60,e=Object.assign({},qe.margin);Ee.top&&t>e.top&&(e.top=t),Ee.bottom&&t>e.bottom&&(e.bottom=t),Ee.left&&t>e.left&&(e.left=t),Ee.right&&t>e.right&&(e.right=t),an=e}const cn="function"==typeof re?re({size:Je,margin:an}):re,un="function"==typeof ie?ie({size:Je,margin:an}):ie,dn=Je[0]-an.left-an.right,hn=Je[1]-an.top-an.bottom,fn=e.useMemo(()=>k(A),[A]),yn=null!=Nt?Nt:It,gn=e.useRef(null),pn=e.useRef(null),[vn,mn]=e.useState(0),xn=e.useRef(0),[bn,kn]=e.useState(null),wn=e.useRef(null),An=e.useRef(null),[_n,Sn]=e.useState(null),Mn=e.useRef(Po.primary),jn=e.useRef([]),Pn=e.useRef(ee),Cn=e.useRef(ne);Pn.current=ee,Cn.current=ne;const[En,On]=e.useState(!1),[Tn,Dn]=e.useState([]),[Nn,Ln]=e.useState([]),Rn="streaming"===b||["bar","swarm","waterfall"].includes(m),$n=e.useMemo(()=>{var t,e,n;return{chartType:m,runtimeMode:Rn?"streaming":"bounded",windowSize:B,windowMode:Y,arrowOfTime:Rn?F:"right",extentPadding:V,scalePadding:q,axisExtent:Et,xAccessor:j,yAccessor:P,timeAccessor:Rn?H:void 0,valueAccessor:z,colorAccessor:C,sizeAccessor:E,symbolAccessor:O,symbolMap:T,groupAccessor:D||(N?"_lineGroup":void 0),categoryAccessor:ce,lineDataAccessor:N,xScaleType:Le,yScaleType:Re,xExtent:X,yExtent:G,sizeRange:U,binSize:W,normalize:R,baseline:$,stackOrder:I,boundsAccessor:ut,boundsStyle:dt,y0Accessor:ht,band:ft,gradientFill:!0===yt?{topOpacity:.8,bottomOpacity:.05}:!1===yt?void 0:yt,areaGroups:pt?new Set(pt):void 0,lineGradient:gt,openAccessor:vt,highAccessor:mt,lowAccessor:xt,closeAccessor:bt,candlestickStyle:kt,lineStyle:nt,pointStyle:it,areaStyle:ot,swarmStyle:lt,waterfallStyle:st,colorScheme:ct,barColors:at,barStyle:rt,annotations:Bt,decay:ge,pulse:pe,transition:en,introAnimation:nn,staleness:xe,heatmapAggregation:be,heatmapXBins:Se,heatmapYBins:Me,showValues:Pe,heatmapValueFormat:Ce,pointIdAccessor:Oe,curve:L,themeCategorical:null===(t=null==tn?void 0:tn.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(tn),themeSequential:null===(e=null==tn?void 0:tn.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==tn?void 0:tn.colors)||void 0===n?void 0:n.diverging,customLayout:Ye,layoutConfig:Be,layoutMargin:an}},[m,B,Y,F,V,q,Et,j,P,H,z,Le,Re,C,E,O,T,D,ce,N,X,G,U,W,R,$,I,ut,dt,ht,ft,yt,gt,pt,vt,mt,xt,bt,kt,nt,it,ot,lt,st,rt,ct,at,Bt,ge,pe,null==en?void 0:en.duration,null==en?void 0:en.easing,nn,xe,be,Se,Me,Pe,Ce,Rn,Oe,L,tn,Ye,Be,an]),In=di($n),Wn=e.useRef(null);Wn.current||(Wn.current=new zt(In));const zn=e.useCallback(()=>{var t,e;const n=Pn.current,i=Cn.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=Wn.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,jn.current)||(jn.current=o,i(o))},[]);e.useEffect(()=>{var t;null===(t=Wn.current)||void 0===t||t.updateConfig(In),Ge.current=!0,ln()},[In,ln]);const Fn=e.useRef(null);e.useEffect(()=>{const t=Wn.current;if(!t)return;const e=null!=He?He:null;Fn.current!==e&&(Fn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):Ge.current=!0,ln())},[He,ln]);const Yn=e.useRef(null);Yn.current||(Yn.current=new w(t=>{const e=Wn.current;e&&e.ingest(t)&&(Ge.current=!0,ln())},{chunkThreshold:_,chunkSize:M})),e.useEffect(()=>{var t;null===(t=Yn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:_,chunkSize:M})},[_,M]);const Bn=e.useCallback(t=>{var e;null===(e=Yn.current)||void 0===e||e.push(t)},[]),Hn=e.useCallback(t=>{var e;null===(e=Yn.current)||void 0===e||e.pushMany(t)},[]),Xn=e.useCallback(()=>{var t,e;null===(t=Yn.current)||void 0===t||t.clear(),null===(e=Wn.current)||void 0===e||e.clear(),Ge.current=!0,ln()},[ln]);e.useImperativeHandle(i,()=>({push:Bn,pushMany:Hn,remove:t=>{var e,n,i;null===(e=Yn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=Wn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(wn.current&&o.some(t=>{var e;return t===(null===(e=wn.current)||void 0===e?void 0:e.data)})&&(wn.current=null,Sn(null)),Ge.current=!0,ln()),o},update:(t,e)=>{var n,i,o;null===(n=Yn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=Wn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Ge.current=!0,ln()),r},clear:Xn,getData:()=>{var t,e,n;return null===(t=Yn.current)||void 0===t||t.flush(),null!==(n=null===(e=Wn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Wn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Wn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Bn,Hn,Xn,ln]),e.useEffect(()=>{var t,e;if(A){if(N&&fn.length>0&&"object"==typeof fn[0]&&null!==fn[0]){const e="string"==typeof N?N:"coordinates";if(Array.isArray(fn[0][e])){const n=[];for(const t of fn){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=Yn.current)||void 0===t||t.setBoundedData(n))}}null===(e=Yn.current)||void 0===e||e.setBoundedData(fn)}},[A,fn,N]);const{hoverHandlerRef:Gn,hoverLeaveRef:Vn,onPointerMove:qn,onPointerLeave:Un}=qe;Gn.current=t=>{var e,n,i,o;if(!yn)return;const r=gn.current;if(!r)return;const s=r.getBoundingClientRect(),l=t.clientX-s.left-an.left,a=t.clientY-s.top-an.top;if(0>l||l>dn||0>a||a>hn)return void(wn.current&&(wn.current=null,An.current=null,Sn(null),Rt&&(Rt(null),Ge.current=!0),ln()));const c=Wn.current;if(!c||0===c.scene.length)return;const u=de(c.scene,l,a,Wt,c.quadtree,c.maxPointRadius),d="multi"===Yt,h=()=>{wn.current&&(wn.current=null,An.current=null,Sn(null),Rt&&Rt(null),ln())};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)?St(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 x=Yi(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=he(ue(t.path,t.curve),e,n);if(null===r)continue;const s=ke(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=ue(t.topPath,t.curve),s=ue(t.bottomPath,t.curve),l=he(r,e,n);if(null===l)continue;const a=he(s,e,n),c=ke(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(Wt,dn));if(t.length>0){const e=c.scales.y.invert,n=Mn.current,i=p?p(f):f;if(u)x.xValue=i,x.xPx=f;else{const t={xValue:i};"string"==typeof j&&(t[j]=i),x=Yi(t,f,y,{xValue:i,xPx:f})}x.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"===m&&null!=o?i-o:i,valuePx:t.y,color:t.color||n,datum:St(t.datum,c.resolvedRibbons)}})}}u||(null===(i=x.allSeries)||void 0===i?void 0:i.length)?(wn.current=x,An.current=null!==(o=null==u?void 0:u.node)&&void 0!==o?o:null,Sn(x),Rt&&(Rt(x),Ge.current=!0),ln()):h()},Vn.current=()=>{wn.current&&(wn.current=null,An.current=null,Sn(null),Rt&&(Rt(null),Ge.current=!0),ln())};const Qn=e.useRef(()=>{});Qn.current=t=>{var e,n;if(!$t)return;const i=gn.current;if(!i)return;const o=i.getBoundingClientRect(),r=t.clientX-o.left-an.left,s=t.clientY-o.top-an.top;if(0>r||r>dn||0>s||s>hn)return void $t(null);const l=Wn.current;if(!l||0===l.scene.length)return void $t(null);const a=de(l.scene,r,s,Wt,l.quadtree,l.maxPointRadius);if(!a)return void $t(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;$t(Yi(c,a.x,a.y,null!=d?{xValue:d,xPx:a.x}:void 0))};const Zn=e.useCallback(t=>Qn.current(t),[]),ti=e.useRef(-1),ei=e.useRef(null),oi=e.useRef(null),si=e.useCallback(t=>{const e=Wn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(oi.current&&oi.current.version===n)i=oi.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=we(t),oi.current={version:n,graph:i}}const o=ti.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),ti.current=0;const n=i.flat[0];ei.current={shape:n.shape,w:n.w,h:n.h};const o=je(Object.assign(Object.assign({},n),{datum:St(n.datum,e.resolvedRibbons)}));return wn.current=o,Sn(o),Rt&&Rt(o),void ln()}const r=Ae(i,o),s=_e(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return ti.current=-1,ei.current=null,wn.current=null,An.current=null,Sn(null),Rt&&Rt(null),void ln();ti.current=s;const l=i.flat[s];ei.current={shape:l.shape,w:l.w,h:l.h};const a=je(Object.assign(Object.assign({},l),{datum:St(l.datum,e.resolvedRibbons)}));wn.current=a,Sn(a),Rt&&Rt(a),ln()},[Rt,ln]),li=e.useCallback(t=>{ti.current=-1,ei.current=null,qn(t)},[qn]);sn.current=()=>{rn.current=0;const t=gn.current,e=pn.current;if(!t||!e)return;const n=Wn.current;if(!n)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=n.advanceTransition(Qe.current?i+1e6:i),r=!Qe.current&&o,s=Ve.current.w!==dn||Ve.current.h!==hn,l=Ge.current||o||s;let a=!1;!l||r&&!s||(n.computeScene({width:dn,height:hn}),Ve.current={w:dn,h:hn},a=!0,zn());const c=to(),u=function(t){if(!t)return Po;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||Po.axisStroke,tickText:s||Po.tickText,crosshair:s?Co(s,"66"):Po.crosshair,hoverFill:c?Co(c,"4D"):Po.hoverFill,hoverStroke:s?Co(s,"99"):Po.hoverStroke,pointRing:c||Po.pointRing,primary:r||Po.primary}:Po}(t);Mn.current=u.primary;const d=Te(xe,n.lastIngestTime>0?i-n.lastIngestTime:0),h=xe&&d.isStale;if(l){const e=Ji(t,Je,an,c);if(e){if(e.clearRect(-an.left,-an.top,Je[0],Je[1]),xe&&1>d.alpha&&(e.globalAlpha=d.alpha),"transparent"!==et&&!ie){const n=getComputedStyle(t).getPropertyValue("--semiotic-bg").trim(),i=et||(n&&"transparent"!==n?n:null),o=i?oe(e,i):null;o&&(e.fillStyle=o,e.fillRect(-an.left,-an.top,Je[0],Je[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,dn,hn),e.clip()),se&&n.scales)for(const t of se)e.save(),t(e,n.scene,n.scales,{width:dn,height:hn}),e.restore();const i=Ye?Mo.custom:Mo[m];if(i&&n.scales)for(const t of i)t(e,n.scene,n.scales,{width:dn,height:hn});e.restore(),xe&&1>d.alpha&&(e.globalAlpha=1)}}{const t=Ji(e,Je,an,c);if(t&&(t.clearRect(-an.left,-an.top,Je[0],Je[1]),yn&&wn.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,wn.current,dn,hn,"object"==typeof yn?yn:{},An.current,u),An.current&&Array.isArray(Nt))){const e=Nt.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,An.current,e,u)}}l&&t&&t.setAttribute("aria-label",mi(n.scene,m+" chart"));const f=Ge.current;if(Ge.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])&&kn(n.scales),Ee){const t=n.getData(),e="function"==typeof j?j:t=>t[j||"x"],i="function"==typeof P?P:t=>t[P||"y"];Dn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Ln(t.map(t=>i(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Bt&&Bt.length>0||Ye)&&(a||r))||!a&&33>i-xn.current||(mn(t=>t+1),xn.current=i),(null==xe?void 0:xe.showBadge)&&On(!!h),(r||null!=n.activeTransition||n.hasActivePulses)&&(rn.current=requestAnimationFrame(()=>sn.current()))},ui({hydrated:Ue,wasHydratingFromSSR:Ke,storeRef:Wn,dirtyRef:Ge,renderFnRef:sn,cleanup:()=>{var t;return null===(t=Yn.current)||void 0===t?void 0:t.clear()}}),e.useEffect(()=>{Ge.current=!0,ln()},[m,dn,hn,wt,et,nt,se,ln]),De(xe,Wn,Ge,ln,En,On);const ai=e.useMemo(()=>{if(Pt||Tt)return;const t=Wn.current;return(null==t?void 0:t.xIsDate)&&bn?So(bn.x.domain()):void 0},[Pt,Tt,bn]),hi=Pt||Tt||ai,fi=yn&&_n?Lt?Lt(_n):t.jsx(Oo,{hover:_n}):null,yi=fi?t.jsx(Ui,{x:_n.x,y:_n.y,containerWidth:dn,containerHeight:hn,margin:an,className:"stream-frame-tooltip",children:fi}):null,gi=ei.current,pi=t.jsx(zi,{active:ti.current>=0,hoverPoint:_n,margin:an,size:Je,shape:null==gi?void 0:gi.shape,width:null==gi?void 0:gi.w,height:null==gi?void 0:gi.h}),vi=Ao(j,H,"__semiotic_resolvedX","__semiotic_resolvedTime"),xi=Ao(P,z,"__semiotic_resolvedY","__semiotic_resolvedValue"),bi=vi.key,ki=xi.key,wi=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}}(vi,xi,Bt&&Bt.length>0||!1);if(ii||!Ue&&Ke){const e=Wn.current;e&&A&&(e.ingest({inserts:fn,bounded:!0}),e.computeScene({width:dn,height:hn}));const n=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],i=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,l=hi||(()=>{if((null==e?void 0:e.xIsDate)&&i)return So(i.x.domain())})();return t.jsxs("div",{ref:Ze,className:"stream-xy-frame"+(tt?" "+tt:""),role:"img","aria-label":Ie||("string"==typeof ae?ae:"XY chart"),style:{position:"relative",width:Q?"100%":Je[0],height:Z?"100%":Je[1]},children:[t.jsx(Ri,{summary:We}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Je[0],height:Je[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${an.left},${an.top})`,children:un}),t.jsxs("g",{transform:`translate(${an.left},${an.top})`,children:[et&&t.jsx("rect",{x:0,y:0,width:dn,height:hn,fill:et}),le&&i&&le.map((e,o)=>t.jsx(g.Fragment,{children:e(n,i,{width:dn,height:hn})},"svgpre-"+o)),n.map((e,n)=>function(e,n,i){var o,r,s,l,a;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+n)}case"area":{const a=e;if(0===a.topPath.length)return null;const c=`M${a.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...a.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(a.clipRect){const e=`${i?i+"-":""}area-clip-${n}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:a.clipRect.x,y:a.clipRect.y,width:a.clipRect.width,height:a.clipRect.height})})}),t.jsx("path",{d:c,fill:ni(a.style.fill),fillOpacity:null!==(r=null!==(o=a.style.fillOpacity)&&void 0!==o?o:a.style.opacity)&&void 0!==r?r:.7,stroke:a.style.stroke,strokeWidth:a.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+n)}return t.jsx("path",{d:c,fill:ni(a.style.fill),fillOpacity:null!==(l=null!==(s=a.style.fillOpacity)&&void 0!==s?s:a.style.opacity)&&void 0!==l?l:.7,stroke:a.style.stroke,strokeWidth:a.style.strokeWidth},"area-"+n)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:ni(i.style.fill),opacity:null!==(a=i.style.opacity)&&void 0!==a?a:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"point-"+n)}case"symbol":return function(e,n){const i=Ot(e.symbolType,e.size,e.path);return t.jsx("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?ni(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+n)}(e,n);case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ni(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"rect-"+n)}case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,r,s]=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]}(i.fill),l=.299*o+.587*r+.114*s>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.jsx("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+n)}case"candlestick":{const i=e,o=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),s=i.isUp?i.upColor:i.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.jsx("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(e,n,Xe)).filter(Boolean)]})]}),t.jsx(Jn,{width:dn,height:hn,totalWidth:Je[0],totalHeight:Je[1],margin:an,scales:i,showAxes:wt,axes:At,xLabel:_t,yLabel:Mt,yLabelRight:jt,xFormat:l,yFormat:Ct||Dt,axisExtent:Et,showGrid:Vt,title:ae,legend:qt,legendHoverBehavior:Ut,legendClickBehavior:Kt,legendHighlightedCategory:Qt,legendIsolatedCategories:Zt,legendPosition:Jt,legendLayout:te,foregroundGraphics:Ft(cn,Ht(null===(s=Wn.current)||void 0===s?void 0:s.customLayoutOverlays,null!=He?He:null)),marginalGraphics:Ee,xValues:[],yValues:[],annotations:Bt,autoPlaceAnnotations:Xt,svgAnnotationRules:Gt,annotationFrame:0,xAccessor:bi,yAccessor:ki,annotationData:wi(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,linkedCrosshairName:ze,linkedCrosshairSourceId:Fe})]})}return t.jsxs("div",{ref:Ze,className:"stream-xy-frame"+(tt?" "+tt:""),role:"group","aria-label":Ie||("string"==typeof ae?ae:"XY chart"),tabIndex:0,style:{position:"relative",width:Q?"100%":Je[0],height:Z?"100%":Je[1],overflow:"visible"},onKeyDown:si,children:[$e&&t.jsx($i,{tableId:on}),$e&&t.jsx(Ni,{scene:null!==(a=null===(l=Wn.current)||void 0===l?void 0:l.scene)&&void 0!==a?a:[],chartType:m+" chart",tableId:on,chartTitle:"string"==typeof ae?ae:void 0}),t.jsx(Ri,{summary:We}),t.jsx(Ii,{hoverPoint:_n}),t.jsxs("div",{role:"img","aria-label":Ie||("string"==typeof ae?ae:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:yn?li:void 0,onMouseLeave:yn?Un:void 0,onClick:$t?Zn:void 0,children:[un&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Je[0],height:Je[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${an.left},${an.top})`,children:un})}),t.jsx(Kn,{width:dn,height:hn,totalWidth:Je[0],totalHeight:Je[1],margin:an,scales:bn,showAxes:wt,axes:At,showGrid:Vt,xFormat:hi,yFormat:Ct||Dt,axisExtent:Et}),t.jsx("canvas",{ref:gn,"aria-label":mi(null!==(u=null===(c=Wn.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],m+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:pn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Jn,{width:dn,height:hn,totalWidth:Je[0],totalHeight:Je[1],margin:an,scales:bn,showAxes:wt,axes:At,xLabel:_t,yLabel:Mt,yLabelRight:jt,xFormat:hi,yFormat:Ct||Dt,axisExtent:Et,showGrid:Vt,title:ae,legend:qt,legendHoverBehavior:Ut,legendClickBehavior:Kt,legendHighlightedCategory:Qt,legendIsolatedCategories:Zt,legendPosition:Jt,legendLayout:te,foregroundGraphics:Ft(cn,Ht(null===(d=Wn.current)||void 0===d?void 0:d.customLayoutOverlays,null!=He?He:null)),marginalGraphics:Ee,xValues:Tn,yValues:Nn,annotations:Bt,autoPlaceAnnotations:Xt,svgAnnotationRules:Gt,annotationFrame:vn,xAccessor:bi,yAccessor:ki,annotationData:wi(null===(h=Wn.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=Wn.current)||void 0===f?void 0:f.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==et&&!ie,linkedCrosshairName:ze,linkedCrosshairSourceId:Fe}),(fe||ye)&&t.jsx(x,{width:dn,height:hn,totalWidth:Je[0],totalHeight:Je[1],margin:an,dimension:null!==(y=null==fe?void 0:fe.dimension)&&void 0!==y?y:"xy",scales:bn,onBrush:null!=ye?ye:()=>{},binSize:W,snap:null==fe?void 0:fe.snap,binBoundaries:null!==(p=null==fe?void 0:fe.binBoundaries)&&void 0!==p?p:"bar"===m?null===(v=Wn.current)||void 0===v?void 0:v.getBinBoundaries():void 0,snapDuring:null==fe?void 0:fe.snapDuring,streaming:"streaming"===b}),(null==xe?void 0:xe.showBadge)&&t.jsx(Ne,{isStale:En,position:xe.badgePosition}),pi,yi]})]})});To.displayName="StreamXYFrame";const Do={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},No={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Lo{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?Ro(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 Ro(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];$o(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;$o(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 $o(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 Io(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Wo(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 x=a[y];if(o[x]=!1,p.push(x),v.push(l[x]),m+=l[x].length,s[x]=d.length,x===e){a.length=y;break}}d.push(p);var b=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)b[--m]=v[y][k];h.push(b)}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 zo(t){return t.y0-t.y1>0?"up":"down"}function Fo(t,e){return e(t.source)==e(t.target)}function Yo(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 Bo(t){return t.target.x0-t.source.x1}function Ho(t,e){var n=Go(t),i=Bo(e)/Math.tan(n);return"up"==zo(t)?t.y1-i:t.y1+i}function Xo(t,e){var n=Go(t),i=Bo(e)/Math.tan(n);return"up"==zo(t)?t.y1+i:t.y1-i}function Go(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Vo(t,e){return e(t)}function qo(t){return Ko(t.source)}function Uo(t){return Ko(t.target)}function Ko(t){return(t.y0+t.y1)/2}function Qo(t){return t.virtual?0:t.value}function Zo(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Fo(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Fo(t,e)?i+1:i}),n+i}function Jo(t){return t.target.depth}function tr(t,e){return t.sourceLinks.length?t.depth:e-1}function er(t,e){return t.y0-e.y0}function nr(t,e){return e.y0-t.y0}function ir(t,e){return t.y1-e.y1}function or(t,e){return e.y1-t.y1}function rr(t,e){return lr(t.source,e.source)||t.index-e.index}function sr(t,e){return lr(t.target,e.target)||t.index-e.index}function lr(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ar(t,e){return cr(t)==cr(e)?"bottom"==t.circularLinkType?nr(t,e):er(t,e):cr(e)-cr(t)}function cr(t){return t.target.column-t.source.column}function ur(t,e){return dr(t)==dr(e)}function dr(t){return t.y0-t.y1>0?"up":"down"}function hr(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 a=l.min(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),fr(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),fr(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,Fo(t,e)&&Yo(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,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?nr:er);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==l})).sort("bottom"==t.circularLinkType?or:ir),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=a-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 fr(t,e,n){t.sort(ar);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(Fo(t,e)&&Yo(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&&yr(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 yr(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function gr(t){return function(){return t}}function pr(t){return t.index}function vr(t){return t.nodes}function mr(t){return t.links}function xr(t,e,n){var i=l.groups(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+=Ko(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Ko(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?Zo(e,n)-Zo(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==Zo(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 br(t,e,n,i,o,r){var s=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var a=1,c=r;c>0;--c)u(a*=.99,n),d();function u(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Zo(o,n)>0){var c=l.mean(o.sourceLinks,Uo),u=l.mean(o.targetLinks,qo),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ko(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.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 f=l.mean(o.sourceLinks,Uo),y=l.mean(o.targetLinks,qo),g=((f&&y?(f+y)/2:f||y)-Ko(o))*e;o.y0+=g,o.y1+=g}})})}function d(){s.forEach(function(n){var r,s,l,a=t.y0,c=n.length;for(n.sort(e||lr),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 kr(t){t.nodes.forEach(function(t){t.sourceLinks.sort(sr),t.targetLinks.sort(rr)}),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 wr(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=pr,c=tr,u=void 0,d=32,h=2,f=vr,y=mr;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.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 l.group(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=Io(n,i)),"object"!=typeof o&&(o=t.target=Io(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(f,a),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=Wo(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++)})}(f,u),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){Vo(t,e)!=Vo(o.source,e)&&Vo(t,e)!=Vo(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),Fo(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(l.sum(t.sourceLinks,Qo),l.sum(t.targetLinks,Qo)),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)})})}(f),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})}(f,u,c);var y=r;if(null!==s){var g=l.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=l.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=l.groups(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=l.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/l.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=l.max(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})})(f,y,o),xr(f,u,a),br(f,u,a,y,y,d),kr(f),hr(f,a,h,10,8),xr(f,u,a),br(f,u,a,y,y,d),kr(f),hr(f,a,h,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 Vo(n.source,e)==Vo(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(!ur(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Ho(e,t);return t.y1-n}if(e.target.column>t.target.column)return Ho(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}})})}(f,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return Vo(n.target,e)==Vo(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(!ur(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Xo(e,t);return t.y0-n}if(e.source.column>t.source.column)return Xo(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}})})}(f,a),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=l.min(e,function(t){return t.y0}),s=l.max(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function c(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),hr(f,a,h,10,8)}(g),g}return g.update=function(t){return kr(t),hr(t,a,h,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:gr(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:gr(t),g):y},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:gr(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:gr(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(d=+t,g):d},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}const Ar=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=u.interpolateNumber(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 d=t.sankeyWidth/2,h=u.interpolateNumber(t.source.x1,t.target.x0),{pathD:f}=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-d,sBot:t.y0+d,tx:t.target.x0,tTop:t.y1-d,tBot:t.y1+d,cp1X:h(.5),cp2X:h(.5)});return f};function _r(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 Sr=new Set,Mr=new WeakMap;function jr(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Mr.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Mr.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}`;Sr.has(t)||(Sr.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 Pr={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(Jo))-1:0},justify:tr};function Cr(t){return"string"==typeof t?t:t.id}const Er={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 x=wr().extent(m).links(v).nodes(p).nodeAlign(Pr[h]||tr).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.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=Cr(t.source),n=Cr(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=b.get(e),r=b.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:Q,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const v=[],m=[],x=[],b=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(jr(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};b.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?b.get(i.id)||p.get(i.id)||o:b.get(e.id)||p.get(e.id)||o;const u=h?h(jr(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?_r(t):Ar(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),x.push({x:s,y:l,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:x}}},Or={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 h=[];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++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const i=Tr(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=Dr(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=Dr(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 y=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:f?40:y,p=Nr(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t);if(g>0){const n=d.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=d.forceSimulation().force("charge",d.forceManyBody().strength(t=>-25*v(t))).force("center",d.forceCenter(l,a).strength(.8)).force("x",d.forceX(l).strength(.15)).force("y",d.forceY(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)}f?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=v(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 m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.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=Nr(n.nodeSize,n.nodeSizeRange,t),y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Q,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(jr(e,"nodeSize")),i=d?d(jr(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 x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),i="object"==typeof t.target?t.target:x.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(jr(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=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||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(jr(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}};function Tr(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 Dr(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 Nr(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 r=e||[5,20],s=[];for(const e of n){const n=null===(i=e.data)||void 0===i?void 0:i[t];"number"==typeof n&&s.push(n)}if(0===s.length)return()=>r[0];const[l,a]=Xe(s);if(l===a)return()=>(r[0]+r[1])/2;const c=o.scaleLinear().domain([l,a]).range(r).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?r[0]:c(i)}}const Lr=Q,Rr={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:l}=n,a=Math.min(i[0],i[1])/2,c=a-r,u=i[0]/2,d=i[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),i=g.get(e);if(void 0===n||void 0===i)continue;const o=f(t);v[n][i]=o}const m=h.chord().padAngle(o);l&&m.sortGroups(l);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const e of b){const n=t[e.index],i=k.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+u,n.y=i[1]+d,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const A=new Map;for(const t of e)A.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 x){const n=t[e.source.index].id,i=t[e.target.index].id,o=A.get(`${n}\0${i}`)||A.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,f=i[0]/2,y=i[1]/2,g=n.nodeStyle,p=n.edgeStyle,v=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Lr,x=new Map;t.forEach((t,e)=>{x.set(t.id,m[e%m.length])});const b=h.ribbon().radius(d),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=g?g(jr(n,"nodeStyle")).fill||x.get(n.id)||m[e%m.length]:x.get(n.id)||m[e%m.length];const s=g?g(jr(n,"nodeStyle")):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:y,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=$r(i,f,y);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(p)a=p(jr(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===v&&n?a=x.get(n.id)||a:e&&(a=x.get(e.id)||a)}const u=p?p(jr(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};w.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(_=n.nodeLabel)?"function"==typeof _?_:t=>t[_]||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;A.push({x:f+Math.cos(s)*i,y:y+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var _;return{sceneNodes:k,sceneEdges:w,labels:A}}};function $r(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 Ir=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Wr(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 zr(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 Fr(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 Yr(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ir}function Br(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 Hr(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 Xr={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),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?t=>Number(t[c])||0:t=>Number(t.value)||0,d=a.hierarchy(r,l);d.sum(u),d.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[h,f]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.tree();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.cluster();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);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,c=a.treemap().size([n,i]).tile(a.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;a.pack().size([n,i]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,i){var o;a.partition().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(d,n,h,f)}const y=d.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],r={id:zr(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?Gr(r,i,n):"treemap"===s||"partition"===s?Vr(r,i):"circlepack"===s&&qr(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===s||"cluster"===s)for(const t of y)if(t.parent){const n=g.get(t.parent),i=g.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,x=i[0]/2,b=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+=x,i+=b);const r=o(jr(e,"nodeStyle"));let a=r.fill||Br(n);if(n.colorByDepth&&void 0!==e.depth){const t=Yr(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+=x,s+=b,l+=x,a+=b);const f=Hr(o,s,l,a,v),y=r(jr(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=Fr(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+=x,l+=b),m){const t=s-x,e=l-b,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(jr(n,"nodeStyle"));let a=l.fill||Br(e);if(e.colorByDepth&&void 0!==n.depth){const t=Yr(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=Fr(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(jr(c,"nodeStyle")).fill||Br(e);if(e.colorByDepth&&void 0!==c.depth){const t=Yr(e);y=t[c.depth%t.length]}const g="string"==typeof y?Wr(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(jr(n,"nodeStyle"));let c=a.fill||Br(e);if(e.colorByDepth&&void 0!==n.depth){const t=Yr(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=Fr(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(jr(o,"nodeStyle")).fill||Br(e);if(e.colorByDepth&&void 0!==o.depth){const t=Yr(e);l=t[o.depth%t.length]}if(s){const n="string"==typeof l?Wr(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 Gr(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 Vr(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 qr(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 Ur(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Kr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),c=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),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof d?()=>d:d,y="number"==typeof h?()=>h:h,g=Ur(n);g.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(c(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,l,d,h,p){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(A,A+k);if(!w.length)break;const _=(x+1)/b,S={id:n,depth:h,data:e,parentId:n},M=p?d/f(S)*_:d*_,j=s.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=j(w),C=y(S);for(let e=0;w.length>e;e++){const s=(P[e].startAngle+P[e].endAngle)/2,a=w[e],u=v(c(a)),d=r+M*Math.sin(s),f=l+M*Math.cos(s)*C;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:a}),g.metaMap.set(u,{ring:M,angle:s,depth:h,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,d,f,M,h+1,!0)}A+=k}}(t,k,m,x,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=Ur(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(jr(e,"nodeSize")),i=d?d(jr(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(jr(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=Ur(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)},Qr={sankey:Er,force:Or,chord:Rr,tree:Xr,cluster:Xr,treemap:Xr,circlepack:Xr,partition:Xr,orbit:Kr};function Zr(t){return Qr[t]}function Jr(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 ts{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({},Do),t.tensionConfig),t.showParticles&&("sankey"===t.chartType||t.customNetworkLayout)&&(this.particlePool=new Lo(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({},Do),t.tensionConfig),!t.showParticles||"sankey"!==t.chartType&&!t.customNetworkLayout||this.particlePool||(this.particlePool=new Lo(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({},es(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({},es(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},es(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&&ns(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,es(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,es(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=Zr(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=dt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,Q),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:Jr(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 Lt({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=Zr(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,ts.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=r.quadtree().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=Zr(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Zr(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=vt(t,this.transition),n=pt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=mt(t._prevX0,t._targetX0,n),t.x1=mt(t._prevX1,t._targetX1,n),t.y0=mt(t._prevY0,t._targetY0,n),t.y1=mt(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=mt(t._prevY0,t._targetY0,n),t.y1=mt(t._prevY1,t._targetY1,n),t.sankeyWidth=mt(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=u.interpolateNumber(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=u.interpolateNumber(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=yt(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 es(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 ns(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(!is(t))return!1;return!0}return is(e.points)}function is(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 os(t,e,n,i,o=30,r,s=0){let l=null,a=o,c=1/0;if(r){const t=Kt(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=rs(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=us(t,n,i);e&&a>e.distance&&(l=e,a=e.distance)}return l}function rs(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>Gt(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=Xt(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=Ut(Math.atan2(o,i)),l=Ut(t.startAngle),a=Ut(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>Gt(Tt(t.size),i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);default:return null}}ts.QUADTREE_THRESHOLD=500;let ss=null,ls=null;function as(){return ls||(ss=document.createElement("canvas"),ss.width=1,ss.height=1,ls=ss.getContext("2d")),ls}function cs(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 us(t,e,n){switch(t.type){case"bezier":return function(t,e,n){if(!t.pathD)return null;const i=cs(t),o=as();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=cs(t),o=as();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 ds(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,labels:l,title:a,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:y="right",legendLayout:p,foregroundGraphics:v,sceneNodes:m,annotations:x,autoPlaceAnnotations:b,svgAnnotationRules:k}=e,w=g.useMemo(()=>{const t=(m||[]).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,Tt(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:n,height:i,frameType:"network",pointNodes:t,sceneNodes:m}},[i,m,n]),A=g.useMemo(()=>x&&b?Dn(Object.assign({annotations:x,context:w},"object"==typeof b?b:{})):x,[x,b,w]),_=A?yn(A.reduce((e,n,i)=>{if("widget"===n.type||!k)return e;const o=k(n,i,w);return o&&e.push({node:t.jsx(g.Fragment,{children:o},"annotation-"+i),annotation:n}),e},[])):null,S=!0===(null==A?void 0:A.some(t=>"widget"===t.type&&!0===t._annotationDeferred));return t.jsxs(t.Fragment,{children:[S&&t.jsx("style",{children:cn},"annotation-widget-disclosure-style"),t.jsxs("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t.jsx("title",{children:"string"==typeof a?a:"Network Chart"}),t.jsx("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),t.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[l.map((e,n)=>t.jsx("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)),_,v]}),a&&"string"==typeof a?t.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?t.jsx("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,He({legend:c,totalWidth:o,totalHeight:r,margin:s,legendPosition:y,title:a,legendLayout:p,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})]}),null==A?void 0:A.filter(t=>"widget"===t.type&&t.nodeId&&m).map((e,n)=>{var i,o,r,l,a,c,u,d,h;const f=!0===e._annotationDeferred,y=m.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=s.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=s.top+(null!==(r=y.cy)&&void 0!==r?r:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(l=y.y)&&void 0!==l?l:0),v=null!==(a=e.dx)&&void 0!==a?a:0,x=null!==(c=e.dy)&&void 0!==c?c:-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.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t.jsx("div",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:g+v-b/2,top:p+x-k/2,width:b,height:k,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:w},"widget-"+n)})]})}ds.displayName="NetworkSVGOverlay";const hs={position:"absolute",top:0,left:0,pointerEvents:"none"};function fs({marks:e,margin:n,selection:i=null,overscan:o=400}){const r=g.useRef(null),s=function(t,e,n){const[i,o]=g.useState(null);return g.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 o(null);let i=0;const r=()=>{i=0;const e=n.getBoundingClientRect(),r=t.getBoundingClientRect();o(0!==e.width&&0!==e.height?{scroll:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},originX:r.left,originY:r.top}:null)},s=()=>{0===i&&(i=window.requestAnimationFrame(r))};r(),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]),g.useMemo(()=>{if(!t||!i)return t;const{scroll:e,originX:o,originY:r}=i,s=e.left-n,l=e.right+n,a=e.top-n,c=e.bottom+n;return t.filter(t=>{const e=o+t.x,n=r+t.y;return!(s>e+t.width||e>l||a>n+t.height||n>c)})},[t,i,n])}(e,r,o);if(!e||0===e.length)return null;const l=t.jsx("div",{className:"semiotic-network-html-marks",ref:r,style:Object.assign(Object.assign({},hs),{transform:`translate(${n.left}px, ${n.top}px)`}),children:(null!=s?s:e).map(e=>t.jsx("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!=i?t.jsx(Bt,{value:i,children:l}):l}const ys=new Map;function gs(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=ys.get(n);return i||(i=new Path2D(Ot(t.symbolType,t.size)),ys.size>256&&ys.clear(),ys.set(n,i)),i}catch(t){return null}}function ps(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function vs(t,e){var n,i,o,r,s,l;if(!e.pathD)return;t.save();const a=ps(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=oe(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&&oe(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=oe(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 ms(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=oe(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 xs(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=ps(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&oe(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=oe(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 bs(t,e){var n,i;if(!e.pathD)return;t.save();const o=ps(e),r=e.style.stroke||"#999";t.strokeStyle=oe(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&&oe(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 ks={top:20,right:80,bottom:20,left:80},ws={top:40,right:40,bottom:40,left:40},As=new Set(["chord","force","circlepack","orbit"]),_s=[800,600],Ss={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 Ms({data:e}){var n,i,o,r,s,l,a;if("edge"===e.nodeOrEdge){const n=e.data;return n?t.jsxs("div",{className:"semiotic-tooltip",style:Ss,children:[t.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""]})]}):null}const c=e.data;if(!c)return null;const u=c.__hierarchyNode;if(u){const e=[];let s=u;for(;s;){const t=null!==(r=null!==(i=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(o=s.data)||void 0===o?void 0:o.id)&&void 0!==r?r:c.id;null!=t&&e.unshift(t+""),s=s.parent}e.length>1&&e.shift();const l=e.length-1;return t.jsxs("div",{className:"semiotic-tooltip",style:Ss,children:[t.jsx("div",{children:e.map((e,n)=>t.jsxs("span",{children:[n>0&&t.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===l?t.jsx("strong",{children:e}):t.jsx("span",{style:{opacity:.7},children:e})]},n))}),null!=c.value&&c.value>0&&t.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const d=((null===(s=c.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(l=c.targetLinks)||void 0===l?void 0:l.length)||0),h=(c.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(c.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0),f=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&&Gi.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=>Bi.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=Vi(c,Hi),d=Vi(c,Xi),h=new Set(Hi),f=new Set(Xi),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!==(a=c.data)&&void 0!==a?a:c),y=null!=f.title?f.title+"":c.id,g=f.entries.some(t=>js.test(t.key));return t.jsxs("div",{className:"semiotic-tooltip",style:Ss,children:[t.jsx("div",{style:{fontWeight:600},children:y}),f.entries.map(e=>{return t.jsxs("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(n=e.value,null==n?"–":"number"==typeof n?Math.abs(n)>9999?n.toLocaleString():n+"":n instanceof Date?n.toLocaleDateString():n+"")]},e.key);var n}),!g&&null!=c.value&&c.value>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),d>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,h!==d&&` (weighted: ${h.toLocaleString()})`]})]})}const js=/^(value|amount|total|count|weight|score)$/i;Ms.ownsChrome=!0;const Ps=e.forwardRef(function(n,i){var o,r,l,a,c,u,d,h,f,y,g,p,v,m,x,b,w,A,_;const{chartType:M,nodes:j,edges:P,data:C,initialEdges:E,nodeIDAccessor:O="id",sourceAccessor:T="source",targetAccessor:D="target",valueAccessor:N="value",edgeIdAccessor:L,childrenAccessor:R,hierarchySum:$,orientation:I="horizontal",nodeAlign:W="justify",nodePaddingRatio:z=.05,nodeWidth:F=15,iterations:Y=300,forceStrength:B=.1,padAngle:H=.01,groupWidth:X=20,sortGroups:G,edgeSort:V,treeOrientation:q="vertical",edgeType:U="curve",padding:K,paddingTop:Q,tensionConfig:Z,showParticles:J=!1,particleStyle:tt,nodeStyle:et,edgeStyle:nt,colorBy:it,colorScheme:ot="category10",edgeColorBy:rt="source",edgeOpacity:st=.5,colorByDepth:lt=!1,nodeSize:at=8,nodeSizeRange:ct=[5,20],nodeLabel:ut,showLabels:dt=!0,labelMode:ft,size:yt=_s,responsiveWidth:gt,responsiveHeight:pt,margin:vt,className:mt,background:xt,enableHover:bt=!0,tooltipContent:kt,customHoverBehavior:wt,customClickBehavior:At,onObservation:_t,chartId:St,onTopologyChange:Mt,annotations:jt,autoPlaceAnnotations:Pt,svgAnnotationRules:Ct,legend:Et,legendPosition:Tt,legendLayout:Dt,legendHoverBehavior:Nt,legendClickBehavior:Lt,legendHighlightedCategory:Rt,legendIsolatedCategories:$t,title:It,foregroundGraphics:Wt,backgroundGraphics:zt,decay:Yt,pulse:Bt,transition:Xt,animate:Gt,staleness:Vt,thresholds:qt,accessibleTable:Ut=!0,description:Kt,summary:Qt,orbitMode:Zt,orbitSize:Jt,orbitSpeed:te,orbitRevolution:ee,orbitRevolutionStyle:ne,orbitEccentricity:ie,orbitShowRings:re,orbitAnimated:se,customNetworkLayout:le,layoutConfig:ae,layoutSelection:ce}=n,ue=As.has(M)?ws:ks,de=e.useRef(!0),he=Zi({sizeProp:yt,responsiveWidth:gt,responsiveHeight:pt,userMargin:vt,marginDefault:ue,foregroundGraphics:Wt,backgroundGraphics:zt,animate:Gt,transitionProp:Xt,themeDirtyRef:de}),{reducedMotionRef:fe,responsiveRef:ye,size:ge,margin:pe,adjustedWidth:ve,adjustedHeight:me,resolvedForeground:xe,resolvedBackground:be,transition:ke,introEnabled:Se,tableId:je,rafRef:Pe,renderFnRef:Ce,scheduleRender:Ee,currentTheme:Oe}=he,Te=ri(),Le=ci(),Re=e.useMemo(()=>k(j),[j]),$e=e.useMemo(()=>Array.isArray(P)?k(P):P,[P]),Ie=e.useMemo(()=>Object.assign(Object.assign({},Do),Z),[Z]),We=e.useMemo(()=>Object.assign(Object.assign({},No),tt),[tt]),ze=e.useMemo(()=>{var t;return{chartType:M,nodeIDAccessor:O,sourceAccessor:T,targetAccessor:D,valueAccessor:N,edgeIdAccessor:L,childrenAccessor:R,hierarchySum:$,orientation:I,nodeAlign:W,nodePaddingRatio:z,nodeWidth:F,iterations:Y,forceStrength:B,padAngle:H,groupWidth:X,sortGroups:G,edgeSort:V,treeOrientation:q,edgeType:U,padding:K,paddingTop:Q,tensionConfig:Ie,showParticles:J,particleStyle:We,nodeStyle:et,edgeStyle:nt,nodeLabel:ut,showLabels:dt,labelMode:ft,colorBy:it,colorScheme:ot,themeCategorical:null===(t=null==Oe?void 0:Oe.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(Oe),edgeColorBy:rt,edgeOpacity:st,colorByDepth:lt,nodeSize:at,nodeSizeRange:ct,decay:Yt,pulse:Bt,transition:ke,introAnimation:Se,staleness:Vt,thresholds:qt,orbitMode:Zt,orbitSize:Jt,orbitSpeed:te,orbitRevolution:ee,orbitRevolutionStyle:ne,orbitEccentricity:ie,orbitShowRings:re,orbitAnimated:se,customNetworkLayout:le,layoutConfig:ae}},[M,O,T,D,N,R,$,I,W,z,F,Y,B,H,X,G,V,q,U,K,Q,Ie,J,We,et,nt,ut,dt,ft,it,ot,rt,st,lt,at,ct,Yt,Bt,null==ke?void 0:ke.duration,null==ke?void 0:ke.easing,Se,Vt,qt,Zt,Jt,te,ee,ne,ie,re,se,Oe,le,ae]),Fe=di(ze),Ye=di({chartType:M,nodeIDAccessor:O,sourceAccessor:T,targetAccessor:D,valueAccessor:N,childrenAccessor:R,hierarchySum:$,orientation:I,nodeAlign:W,nodePaddingRatio:z,nodeWidth:F,iterations:Y,forceStrength:B,padAngle:H,groupWidth:X,sortGroups:G,edgeSort:V,treeOrientation:q,edgeType:U,padding:K,paddingTop:Q,tensionConfig:Ie,orbitMode:Zt,orbitSize:Jt,orbitEccentricity:ie,customNetworkLayout:le}),Be=e.useRef(null),He=e.useRef(0),Xe=e.useRef(0),Ge=e.useRef(!1),Ve=e.useRef(null);Ve.current||(Ve.current=new ts(Fe));const[qe,Ue]=e.useState(null),[Ke,Qe]=e.useState(0),[Ze,Je]=e.useState(0),[tn,en]=e.useState(!1),nn=e.useRef(null),on=e.useRef(new Map),rn=e.useRef(0),sn=e.useCallback(t=>{if("function"==typeof it)return it(t)+"";if("string"==typeof it&&t.data){const e=t.data[it];if(void 0!==e){if(!on.current.has(e+"")){const t=Array.isArray(ot)?ot:ht;on.current.set(e+"",t[rn.current++%t.length])}return on.current.get(e+"")}}if(on.current.has(t.id))return on.current.get(t.id);const e=Array.isArray(ot)?ot:ht,n=it?e[rn.current++%e.length]:e[0];return on.current.set(t.id,n),n},[it,ot]),ln=(null===(o=null==Oe?void 0:Oe.colors)||void 0===o?void 0:o.border)||(null===(r=null==Oe?void 0:Oe.colors)||void 0===r?void 0:r.secondary)||(null===(l=null==Oe?void 0:Oe.colors)||void 0===l?void 0:l.primary)||"#999",an=e.useCallback(t=>{var e,n;return t?"object"==typeof t?t:null!==(n=null===(e=Ve.current)||void 0===e?void 0:e.nodes.get(t))&&void 0!==n?n:null:null},[]),cn=e.useCallback(t=>{if("function"==typeof rt)return rt(t);const e=an(t.source),n=an(t.target);return"target"===rt&&n?sn(n):e?sn(e):ln},[rt,sn,ln,an]),un=e.useCallback(t=>{if("function"==typeof We.color){const e=an(t.source);return e?We.color(t,e):ln}if(!(null==tt?void 0:tt.colorBy))return cn(t);const e=We.colorBy,n=an(t.source),i=an(t.target);return"target"===e&&i?sn(i):n?sn(n):ln},[null==tt?void 0:tt.colorBy,We.color,We.colorBy,sn,cn,ln,an]),dn=("sankey"===M||!!le)&&J||!!Bt||null!==(c=null===(a=Ve.current)||void 0===a?void 0:a.isAnimating)&&void 0!==c&&c;e.useEffect(()=>{var t;null===(t=Ve.current)||void 0===t||t.updateConfig(Fe),de.current=!0,Ee()},[Fe,Ee]);const hn=e.useRef(null);e.useEffect(()=>{const t=Ve.current;if(!t)return;const e=null!=ce?ce:null;hn.current!==e&&(hn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):de.current=!0,Ee())},[ce,Ee]),e.useEffect(()=>{var t;const e=Ve.current;if(e){e.buildScene([ve,me]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill);de.current=!0,Ee()}},[Oe,ve,me,Ee]);const fn=e.useCallback(()=>{var t;const e=Ve.current;if(!e)return;e.runLayout([ve,me]),e.buildScene([ve,me]),de.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill);const n=Array.isArray(ot)?ot:ht,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];on.current.has(e.id)||on.current.set(e.id,n[t%n.length])}if(rn.current=i.length,Qe(e.layoutVersion),Mt){const{nodes:t,edges:n}=e.getLayoutData();Mt(t,n)}},[ve,me,Mt,ot]),yn=e.useCallback(t=>{if(null==t||"object"!=typeof t)return;const e=Ve.current;e&&(e.ingestEdge(t)&&fn(),Ee())},[fn,Ee]),gn=e.useCallback(t=>{const e=Ve.current;if(!e)return;let n=!1;for(const i of t)null!=i&&"object"==typeof i&&e.ingestEdge(i)&&(n=!0);n&&fn(),Ee()},[fn,Ee]),pn=e.useCallback(()=>{var t,e,n;null===(t=Ve.current)||void 0===t||t.clear(),on.current.clear(),rn.current=0,Qe(null!==(n=null===(e=Ve.current)||void 0===e?void 0:e.layoutVersion)&&void 0!==n?n:0),Ue(null),nn.current=null,de.current=!0,Ee()},[Ee]),vn=e.useCallback(()=>{const t=Ve.current;t&&(t.tension+=999,fn(),Ee())},[fn,Ee]);e.useImperativeHandle(i,()=>({push:yn,pushMany:gn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Ve.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=nn.current)||void 0===i?void 0:i.data)?"function"==typeof O?O(nn.current.data):nn.current.data[O]:void 0;nn.current&&"node"===nn.current.nodeOrEdge&&e===t&&(nn.current=null,Ue(null)),on.current.delete(t),fn(),de.current=!0,Ee()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ve.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(nn.current&&"edge"===nn.current.nodeOrEdge){const n=nn.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:!L||!n||("function"==typeof L?L:t=>null==t?void 0:t[L])(n)===t,i&&(nn.current=null,Ue(null))}fn(),de.current=!0,Ee()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ve.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(de.current=!0,Ee()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Ve.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(fn(),de.current=!0,Ee()),r},clear:pn,getTopology:()=>{var t,e;return null!==(e=null===(t=Ve.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Ve.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=Ve.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[yn,gn,pn,vn,fn,Ee]);const mn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(M),xn=mn?C||(Array.isArray(P)?void 0:P):void 0;e.useEffect(()=>{var t;const e=Ve.current;if(e)if(mn&&xn)e.ingestHierarchy(xn,[ve,me]),e.buildScene([ve,me]),de.current=!0,Ee();else{const n=Re,i=Array.isArray($e)?$e:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[ve,me]),e.buildScene([ve,me]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill+"");const o=Array.isArray(ot)?ot:ht,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];on.current.has(e.id)||on.current.set(e.id,o[t%o.length])}rn.current=r.length,de.current=!0,Ee()}},[Re,$e,C,xn,mn,ve,me,Ye,Ee,ot]),e.useEffect(()=>{E&&E.length>0&&gn(E)},[]);const bn=e.useCallback(t=>{if(wt&&wt(t),_t){const e=Date.now();_t(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:St}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:St})}},[wt,_t,St]),kn=e.useCallback(t=>{if(At&&At(t),_t){const e=Date.now();_t(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:St}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:St})}},[At,_t,St]),{hoverHandlerRef:wn,hoverLeaveRef:An,onPointerMove:_n,onPointerLeave:Sn}=he,Mn=()=>{var t,e;return!le||null!==(e=null===(t=Ve.current)||void 0===t?void 0:t.hasCustomRestyle)&&void 0!==e&&e};wn.current=t=>{if(!bt)return;const e=Mn(),n=Be.current;if(!n)return;const i=n.getBoundingClientRect(),o=t.clientX-i.left-pe.left,r=t.clientY-i.top-pe.top;if(0>o||o>ve||0>r||r>me)return void(nn.current&&(nn.current=null,Ue(null),bn&&(bn(null),e&&(de.current=!0)),e&&Ee()));const s=Ve.current;if(!s)return;const l=os(s.sceneNodes,s.sceneEdges,o,r,30,s.nodeQuadtree,s.maxNodeRadius);if(!l)return void(nn.current&&(nn.current=null,Ue(null),bn&&(bn(null),e&&(de.current=!0)),e&&Ee()));const a=Yi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});nn.current=a,Ue(a),bn&&(bn(a),e&&(de.current=!0)),e&&Ee()},An.current=()=>{if(nn.current){const t=Mn();nn.current=null,Ue(null),bn&&(bn(null),t&&(de.current=!0)),t&&Ee()}};const jn=e.useRef(()=>{});jn.current=t=>{if(!At&&!_t)return;const e=Be.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-pe.left,o=t.clientY-n.top-pe.top;if(0>i||i>ve||0>o||o>me)return;const r=Ve.current;if(!r)return;const s=os(r.sceneNodes,r.sceneEdges,i,o,30,r.nodeQuadtree,r.maxNodeRadius);kn(s?Yi(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const Pn=e.useCallback(t=>jn.current(t),[]),Cn=e.useRef(-1),En=e.useRef(null),On=e.useRef(-1),Tn=e.useCallback(t=>{var e;const n=Ve.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=we(i),r=Cn.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(),Cn.current=0,On.current=-1;const e=o.flat[0];En.current={shape:e.shape,w:e.w,h:e.h};const n=Yi(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return nn.current=n,Ue(n),bn&&(bn(n),de.current=!0),void Ee()}const s=Ae(o,r),l=function(t,e,n,i,o){var r,s,l;const a=n.flat[e.flatIndex];if(!a)return _e(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=Me(e.source),s=Me(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=_e(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:[],On);if(null===l)return;if(t.preventDefault(),0>l)return Cn.current=-1,En.current=null,On.current=-1,nn.current=null,Ue(null),bn&&(bn(null),de.current=!0),void Ee();Cn.current=l;const a=o.flat[l];En.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"};nn.current=c,Ue(c),bn&&(bn(c),de.current=!0),Ee()},[bn,Ee]),Dn=e.useCallback(t=>{Cn.current=-1,En.current=null,_n(t)},[_n]);Ce.current=()=>{var t,e,n,i,o,r,s;Pe.current=0;const l=Be.current;if(!l)return;const a=l.getContext("2d");if(!a)return;const c=Ve.current;if(!c)return;const u=performance.now(),d=He.current?Math.min((u-He.current)/1e3,.1):.016;He.current=u;const h=c.advanceTransition(fe.current?u+1e6:u),f=!fe.current&&h,y=!fe.current&&c.tickAnimation([ve,me],d);(h||de.current||y)&&c.buildScene([ve,me]);const g=to();if(!Ji(l,ge,pe,g))return;if(a.clearRect(-pe.left,-pe.top,ge[0],ge[1]),xt){const t=oe(a,xt);t&&(a.fillStyle=t,a.fillRect(0,0,ve,me))}Yt&&c.applyDecay(),Bt&&c.applyPulse(u),qt&&c.applyThresholds(u),!1!==Gt&&c.applyTopologyDiff(u);const p=null!==(t=null==Vt?void 0:Vt.threshold)&&void 0!==t?t:5e3,v=Vt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Vt?void 0:Vt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":vs(t,n);break;case"line":ms(t,n);break;case"ribbon":xs(t,n);break;case"curved":bs(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&&oe(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=oe(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)),ro(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&&oe(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=oe(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()),so(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&&oe(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=oe(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=gs(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&&oe(t,e.style.fill)||e.style.fill,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=r*a,t.strokeStyle=oe(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),J&&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:No.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:No.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,We);const e=.5*(null!==(n=We.speedMultiplier)&&void 0!==n?n:1);let i;if(We.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:No.radius,a=null!==(s=i.opacity)&&void 0!==s?s:No.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=oe(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,We,un)}}v&&(a.globalAlpha=1);const m=de.current;if(de.current=!1,m||f||y){const t=Be.current;t&&t.setAttribute("aria-label",xi(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 x=m||f||y||Ge.current;x&&u-Xe.current>=33?(Je(t=>t+1),Xe.current=u,Ge.current=!1):Ge.current=!!x,(dn||f||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||!1!==Gt&&c.hasActiveTopologyDiff||Ge.current)&&(Pe.current=requestAnimationFrame(()=>Ce.current()))},ui({hydrated:Te,wasHydratingFromSSR:Le,storeRef:Ve,dirtyRef:de,renderFnRef:Ce}),e.useEffect(()=>{de.current=!0,Ee()},[M,ve,me,xt,Ee]),De(Vt,Ve,de,Ee,tn,en);const Nn=bt&&qe?t.jsx(Ui,{x:qe.x,y:qe.y,containerWidth:ve,containerHeight:me,margin:pe,className:"stream-network-tooltip",zIndex:2,children:kt?kt(qe):t.jsx(Ms,{data:qe})}):null;if(ii||!Te&&Le){const e=Ve.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(M),n=t?C||(Array.isArray(P)?void 0:P):void 0;if(t&&n)e.ingestHierarchy(n,[ve,me]),e.buildScene([ve,me]);else{const t=Re,n=Array.isArray($e)?$e:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[ve,me]),e.buildScene([ve,me]))}}const n=null!==(u=null==e?void 0:e.sceneNodes)&&void 0!==u?u:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],o=null!==(h=null==e?void 0:e.labels)&&void 0!==h?h:[];return t.jsxs("div",{ref:ye,className:"stream-network-frame"+(mt?" "+mt:""),role:"img","aria-label":Kt||("string"==typeof It?It:"Network chart"),style:{position:"relative",width:gt?"100%":ge[0],height:pt?"100%":ge[1]},children:[t.jsx(Ri,{summary:Qt}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ge[0],height:ge[1],style:{position:"absolute",left:0,top:0},children:[be&&t.jsx("g",{transform:`translate(${pe.left},${pe.top})`,children:be}),t.jsxs("g",{transform:`translate(${pe.left},${pe.top})`,children:[xt&&t.jsx("rect",{x:0,y:0,width:ve,height:me,fill:xt}),i.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("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.jsx("path",{d:i.pathD,fill:ni(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.jsx("path",{d:i.pathD,fill:ni(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.jsx("path",{d:i.pathD,fill:ni(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),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t.jsx("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:ni(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.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ni(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=s.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(ei)||"";return t.jsx("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:ni(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}case"symbol":{const i=e,o=Ot(i.symbolType,i.size,i.path);return t.jsx("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?ni(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),o.map((e,n)=>function(e,n){return t.jsx("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.jsx(ds,{width:ve,height:me,totalWidth:ge[0],totalHeight:ge[1],margin:pe,labels:o,sceneNodes:n,title:It,legend:Et,legendPosition:Tt,legendLayout:Dt,legendHoverBehavior:Nt,legendClickBehavior:Lt,legendHighlightedCategory:Rt,legendIsolatedCategories:$t,foregroundGraphics:Ft(xe,Ht(null===(f=Ve.current)||void 0===f?void 0:f.customLayoutOverlays,null!=ce?ce:null)),annotations:jt,autoPlaceAnnotations:Pt,svgAnnotationRules:Ct,annotationFrame:0}),t.jsx(fs,{marks:null==e?void 0:e.customLayoutHtmlMarks,margin:pe,selection:null!=ce?ce:null})]})}const Ln=Ve.current;return t.jsxs("div",{ref:ye,className:"stream-network-frame"+(mt?" "+mt:""),role:"group","aria-label":Kt||("string"==typeof It?It:"Network chart"),tabIndex:0,style:{position:"relative",width:gt?"100%":ge[0],height:pt?"100%":ge[1],overflow:"visible"},onKeyDown:Tn,children:[Ut&&t.jsx($i,{tableId:je}),Ut&&t.jsx(Li,{nodes:null!==(y=null==Ln?void 0:Ln.sceneNodes)&&void 0!==y?y:[],edges:null!==(g=null==Ln?void 0:Ln.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:je,chartTitle:"string"==typeof It?It:void 0}),t.jsx(Ri,{summary:Qt}),t.jsx(Ii,{hoverPoint:qe}),t.jsxs("div",{role:"img","aria-label":Kt||("string"==typeof It?It:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:bt?Dn:void 0,onMouseLeave:bt?Sn:void 0,onClick:At||_t?Pn:void 0,children:[be&&t.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ge[0],height:ge[1],pointerEvents:"none",overflow:"visible"},children:t.jsx("g",{transform:`translate(${pe.left},${pe.top})`,children:be})}),t.jsx("canvas",{ref:Be,"aria-label":xi(null!==(v=null===(p=null==Ln?void 0:Ln.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==v?v:0,null!==(x=null===(m=null==Ln?void 0:Ln.sceneEdges)||void 0===m?void 0:m.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.jsx(ds,{width:ve,height:me,totalWidth:ge[0],totalHeight:ge[1],margin:pe,labels:(null==Ln?void 0:Ln.labels)||[],sceneNodes:null==Ln?void 0:Ln.sceneNodes,title:It,legend:Et,legendPosition:Tt,legendLayout:Dt,legendHoverBehavior:Nt,legendClickBehavior:Lt,legendHighlightedCategory:Rt,legendIsolatedCategories:$t,foregroundGraphics:Ft(xe,Ht(null===(b=Ve.current)||void 0===b?void 0:b.customLayoutOverlays,null!=ce?ce:null)),annotations:jt,autoPlaceAnnotations:Pt,svgAnnotationRules:Ct,annotationFrame:Ze}),t.jsx(fs,{marks:null==Ln?void 0:Ln.customLayoutHtmlMarks,margin:pe,selection:null!=ce?ce:null}),t.jsx(zi,{active:Cn.current>=0,hoverPoint:qe,margin:pe,size:ge,shape:null===(w=En.current)||void 0===w?void 0:w.shape,width:null===(A=En.current)||void 0===A?void 0:A.w,height:null===(_=En.current)||void 0===_?void 0:_.h}),Nn,(null==Vt?void 0:Vt.showBadge)&&t.jsx(Ne,{isStale:tn,position:Vt.badgePosition})]})]})});Ps.displayName="StreamNetworkFrame";class Cs{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 Cs;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 Es{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 Cs,this.windows.set(t,n)),n.push(e)}pushSession(t,e){const n=this.gap,i=new Cs;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 Os(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 Ts(t,e,n,i=1){if("none"===e)return null;if("minmax"===e)return[t.min,t.max];const o=Os(t,n),r=t.stddev*i;return[o-r,o+r]}const Ds={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Ns=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Ls(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;Ns.lastIndex=0;let n,i=0,o=0;for(;null!==(n=Ns.exec(e));){const t=parseFloat(n[1]),e=Ds[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 Rs{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 $s(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 Is(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function Ws(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[zs,Fs]=A(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||!Ws(i,n))return!1}return!0}(o,n))return{};const r=new Map(t.selections),s=Is(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=Is(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}})}})),[Ys,Bs]=A(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 Hs(t){const n=e.useId(),i=t.clientId||n,{name:o}=t,r=Fs(t=>t.selections.get(o)),s=Fs(t=>t.setClause),l=Fs(t=>t.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push($s(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,i):()=>!0,[r,i]),isActive:a,selectPoints:e.useCallback(t=>{const e={};let n=!1;for(const[i,o]of Object.entries(t))e[i]={type:"point",values:new Set(o)},n=!0;n&&s(o,{clientId:i,type:"point",fields:e})},[i,o,s]),selectInterval:e.useCallback(t=>{const e={};let n=!1;for(const[i,o]of Object.entries(t))e[i]={type:"interval",range:o},n=!0;n&&s(o,{clientId:i,type:"interval",fields:e})},[i,o,s]),clear:e.useCallback(()=>{l(o,i)},[l,o,i]),clientId:i}}function Xs(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function Gs(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function Vs(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 qs(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 Us({selection:t,linkedHover:n,fallbackFields:i=[],unwrapData:o=!1,onObservation:r,chartType:s,chartId:l,onClick:a,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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}(n,i),f="series"===(null==h?void 0:h.mode)?[h.seriesField||u||i[0]].filter(t=>!!t):(null==h?void 0:h.fields)||i||[],y=Hs({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const n=t.name||"hover",{fields:i}=t,{predicate:o,isActive:r,selectPoints:s,clear:l}=Hs({name:n});return{onHover:e.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Gs(e)&&s(e)},[i,s,l,n]),predicate:o,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:f}),p=Bs(t=>t.pushObservation),v=t?{isActive:y.isActive,predicate:y.predicate}:null,[m,x]=e.useState(null),b=u||i[0],k=e.useMemo(()=>{if(!c||null==m||!b)return null;const t=m,e=b;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[c,m,b]),w=e.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=Vs(t,e,h.xField);null!=n&&function(t,e,n){const i=Nn.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Nn={positions:new Map(Nn.positions).set(t,{xValue:e,sourceId:n})},Rn())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&$n(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&b)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[b];x(null!=n?n+"":null)}else x(null);if(r||p){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const o=qs(t),s=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),p&&p(t)}}},[n,g,h,d,r,s,l,p,c,b]),A=e.useCallback(t=>{var e,n,i,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=Vs(t,e,h.xField);null!=n&&function(t,e,n){const i=Nn.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Nn.positions);return e.delete(t),Nn={positions:e},Rn(),!1}Nn={positions:new Map(Nn.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Rn()}(h.name||"hover",n,d)}if(t&&a){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),a(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||p){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=qs(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),p&&p(t)}}},[a,r,p,s,l,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{In(t,d),$n(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:v,hoverSelectionHook:k,customHoverBehavior:w,customClickBehavior:A,crosshairSourceId:d}}const Ks={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 Qs(t,e,n){var i,o,r,s,l,a,c;const u=Ks[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:Zs(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function Zs(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 Js={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"},tl={opacity:.7,marginRight:4};function el(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function nl(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function il(e={}){const{timeAccessor:n,valueAccessor:i,xLabel:o="x",yLabel:r="y"}=e;return e=>{var s;const l=null!==(s=null==e?void 0:e.data)&&void 0!==s?s:null,a=el(l,n,"time"),c=el(l,i,"value");return t.jsxs("div",{className:"semiotic-tooltip",style:Js,children:[t.jsxs("div",{children:[t.jsxs("span",{style:tl,children:[o,":"]}),nl(a)]}),t.jsxs("div",{children:[t.jsxs("span",{style:tl,children:[r,":"]}),nl(c)]})]})}}"undefined"!=typeof process&&process;const ol={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"},rl={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function sl(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},ol),{width:n,height:i}),children:o||"No data available"}):null}function ll(e,n,i,o){if(!e)return null;if(!1===o)return null;if(null!=o)return t.jsx("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.jsx("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.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},rl),{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 al(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 cl="time",ul="value",dl="__aggLower",hl="__aggUpper",fl="__aggPartial",yl="count",gl="__aggStart",pl="__aggEnd";function vl(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={[cl]:(t.start+t.end)/2,[ul]:Os(t,r),[yl]:t.count,[fl]:t.partial,[gl]:t.start,[pl]:t.end},n=Ts(t,s,r,l);return n&&(e[dl]=n[0],e[hl]=n[1]),e})}function ml(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 xl=e.forwardRef(function(n,i){var o,r,s,l,a,c,u,d,h,f,y;const g=Qs(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:p,margin:v,className:m,arrowOfTime:x="right",windowMode:b="sliding",windowSize:k,data:w,timeAccessor:A,valueAccessor:_,timeExtent:S,valueExtent:M,extentPadding:j,stroke:P="#007bff",strokeWidth:C=2,strokeDasharray:E,opacity:O,background:T,tooltipContent:D,tooltip:N,onHover:L,annotations:R,autoPlaceAnnotations:$,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,decay:F,pulse:Y,staleness:B,transition:H,linkedHover:X,selection:G,onObservation:V,chartId:q,loading:U,loadingContent:K,emptyContent:Q,emphasis:Z,legendPosition:J,aggregate:tt,eventTime:et}=n,nt=g.showAxes,it=g.enableHover,ot=null!=v?v:g.marginDefaults,rt=null!=p?p:[g.width,g.height],st=null!==(a=null!=D?D:N)&&void 0!==a?a:il({timeAccessor:A,valueAccessor:_}),lt=e.useRef(null),{customHoverBehavior:at}=Us({selection:G,linkedHover:X,unwrapData:!0,onObservation:V,chartType:"RealtimeLineChart",chartId:q}),ct=e.useCallback(t=>{L&&L(t),at(t)},[L,at]),ut=null!=tt,[dt,ht]=e.useState([]),ft=e.useRef(null),yt=e.useRef(tt);yt.current=tt;const gt=e.useRef(ut);gt.current=ut;const pt=e.useRef(dt);pt.current=dt;const vt=e.useRef({timeAccessor:A,valueAccessor:_});vt.current={timeAccessor:A,valueAccessor:_};const mt=ut?[null!==(c=tt.window)&&void 0!==c?c:"tumbling",tt.size,null!==(u=tt.hop)&&void 0!==u?u:"",null!==(d=tt.gap)&&void 0!==d?d:"",null!==(h=tt.retain)&&void 0!==h?h:""].join("|"):"";e.useEffect(()=>{if(!ut)return void(ft.current=null);const t=yt.current,e=function(t){var e,n;const i=null!==(e=t.window)&&void 0!==e?e:"tumbling",o=Ls("session"===i&&null!==(n=t.gap)&&void 0!==n?n:t.size);if(null==o)return null;const r=null!=t.hop?Ls(t.hop):void 0,s=null!=t.gap?Ls(t.gap):void 0;return new Es({window:i,size:o,hop:null!=r?r:void 0,gap:null!=s?s:void 0,retain:t.retain})}(t);if(ft.current=e,e&&w){const{timeAccessor:t,valueAccessor:n}=vt.current;for(const i of w){const o=ml(i,t,"time"),r=ml(i,n,"value");null!=o&&null!=r&&e.push(o,r)}}ht(e?vl(e,t):[])},[mt,ut,w]),e.useEffect(()=>{ut&&ft.current&&ht(vl(ft.current,yt.current))},[null==tt?void 0:tt.stat,null==tt?void 0:tt.band,null==tt?void 0:tt.sigma]);const xt=e.useCallback(t=>{const e=ft.current,n=yt.current;if(!e||!n)return;const{timeAccessor:i,valueAccessor:o}=vt.current;for(const n of t){const t=ml(n,i,"time"),r=ml(n,o,"value");null!=t&&null!=r&&e.push(t,r)}ht(vl(e,n))},[]),bt=null!=et,kt=e.useRef(null),wt=e.useRef(et);wt.current=et;const At=e.useRef(bt);At.current=bt;const _t=e.useRef(V);_t.current=V;const St=e.useRef(q);St.current=q;const Mt=bt?`${et.lateness}|${null!==(f=et.latePolicy)&&void 0!==f?f:"drop"}`:"";e.useEffect(()=>{kt.current=bt?function(t){var e;const n=Ls(t.lateness);return null==n?null:new Rs({lateness:n,getTime:t=>{var e;return null!==(e=ml(t,vt.current.timeAccessor,"time"))&&void 0!==e?e:NaN},latePolicy:null!==(e=t.latePolicy)&&void 0!==e?e:"drop"})}(wt.current):null},[Mt,bt]);const jt=e.useCallback(t=>{var e;0!==t.length&&(gt.current?xt(t):null===(e=lt.current)||void 0===e||e.pushMany(t))},[xt]),Pt=e.useCallback(t=>{var e,n,i;const o=kt.current;if(!At.current||!o)return void jt(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=_t.current;if(r){const{timeAccessor:s}=vt.current,l=null!==(n=null===(e=wt.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=ml(e,s,"time"))&&void 0!==i?i:NaN,watermark:o.watermark,policy:l,lateCount:o.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:St.current})}}}jt(r)},[jt]);e.useImperativeHandle(i,()=>({push:t=>Pt([t]),pushMany:t=>Pt(t),remove:t=>{var e,n;return gt.current?[]:null!==(n=null===(e=lt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return gt.current?[]:null!==(i=null===(n=lt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t,e,n;null===(t=kt.current)||void 0===t||t.clear(),gt.current?(null===(e=ft.current)||void 0===e||e.clear(),ht([])):null===(n=lt.current)||void 0===n||n.clear()},getData:()=>{var t,e;return gt.current?pt.current:null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[Pt]);const Ct=ll(U,rt[0],rt[1],K),Et=Ct?null:sl(ut?void 0:w,rt[0],rt[1],Q),Ot={stroke:P,strokeWidth:C,strokeDasharray:E};null!=O&&(Ot.opacity=O);const Tt=al(k,w),Dt=Z?`${m||""} semiotic-emphasis-${Z}`.trim():m,Nt=ut?dt:w,Lt=ut?cl:A,Rt=ut?ul:_,$t=ut?"growing":b,It=null!==(y=null==tt?void 0:tt.retain)&&void 0!==y?y:Math.max(dt.length,600),Wt=ut?Math.max(1,It):Tt,zt=ut&&tt&&function(t){var e;return"none"!==(null!==(e=t.band)&&void 0!==e?e:"none")}(tt)?{y0Accessor:dl,y1Accessor:hl,perSeries:!1}:void 0;return Ct||Et||t.jsx(To,{ref:lt,chartType:"line",runtimeMode:"streaming",size:rt,margin:ot,className:Dt,arrowOfTime:x,windowMode:$t,windowSize:Wt,data:Nt,timeAccessor:Lt,valueAccessor:Rt,xExtent:S,yExtent:M,extentPadding:j,band:zt,lineStyle:Ot,showAxes:nt,background:T,hoverAnnotation:it,tooltipContent:st,customHoverBehavior:ct,annotations:R,autoPlaceAnnotations:$,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,decay:F,pulse:Y,staleness:B,transition:H,pointIdAccessor:n.pointIdAccessor,legendPosition:J})});function bl(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}xl.displayName="RealtimeLineChart";const kl=e.forwardRef(function(n,i){var o,r,s,l,a;const c=Qs(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:u,size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p,data:v,timeAccessor:m,valueAccessor:x,direction:b="up",timeExtent:k,valueExtent:w,extentPadding:A,categoryAccessor:_,colors:S,fill:M,stroke:j,strokeWidth:P,opacity:C,gap:E,background:O,tooltipContent:T,tooltip:D,onHover:N,annotations:L,autoPlaceAnnotations:R,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:F,decay:Y,pulse:B,staleness:H,transition:X,onObservation:G,chartId:V,loading:q,loadingContent:U,emptyContent:K,emphasis:Q,legendPosition:Z,brush:J,onBrush:tt,linkedBrush:et}=n,nt=c.showAxes,it=c.enableHover,ot=null!=h?h:c.marginDefaults,rt=null!=d?d:[c.width,c.height],st=null!==(a=null!=T?T:D)&&void 0!==a?a:function(e={}){const{timeAccessor:n,valueAccessor:i}=e;return e=>{var o;const r=null!==(o=null==e?void 0:e.data)&&void 0!==o?o:null;if(null==(null==r?void 0:r.binStart)||null==(null==r?void 0:r.binEnd)){const e=el(r,n,"time"),o=el(r,i,"value");return t.jsxs("div",{className:"semiotic-tooltip",style:Js,children:[t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"x:"}),nl(e)]}),t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"y:"}),nl(o)]})]})}return t.jsxs("div",{className:"semiotic-tooltip",style:Js,children:[t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"range:"}),nl(r.binStart),"–",nl(r.binEnd)]}),null!=r.total&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"count:"}),nl(r.total)]}),null!=r.category&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"category:"}),nl(r.category)]})]})}}({timeAccessor:m,valueAccessor:x}),lt=e.useRef(null),{customHoverBehavior:at}=Us({selection:F,linkedHover:z,unwrapData:!0,onObservation:G,chartType:"RealtimeHistogram",chartId:V}),ct=e.useCallback(t=>{N&&N(t),at(t)},[N,at]),ut=!0===J?{dimension:"x",snap:"bin"}:"x"===J?{dimension:"x"}:"object"==typeof J?J:void 0,dt=(ht=et)?"string"==typeof ht?{name:ht}:ht:null;var ht;const ft=function(t){const{name:n,xField:i,yField:o}=t,{predicate:r,isActive:s,selectInterval:l,clear:a}=Hs({name:n}),c=i&&o?"xyBrush":i?"xBrush":"yBrush",u=e.useCallback(t=>{if(!t)return void a();const e={};"xyBrush"===c&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(i&&(e[i]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===c&&Xs(t)?i&&(e[i]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===c&&Xs(t)&&o&&(e[o]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),Gs(e)&&l(e)},[c,i,o,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:a}}(Object.assign({name:(null==dt?void 0:dt.name)||"__unused_hist_brush__",xField:(null==dt?void 0:dt.xField)||("string"==typeof m?m:"time")},(null==dt?void 0:dt.yField)?{yField:dt.yField}:{})),yt=e.useRef(ft.brushInteraction);yt.current=ft.brushInteraction;const gt=e.useCallback(t=>{if(tt&&tt(t),G&&G(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:V}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:V}),dt){const e=yt.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)}},[tt,G,V,dt]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=lt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=lt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=lt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const pt=ll(q,rt[0],rt[1],U),vt=pt?null:sl(v,rt[0],rt[1],K),mt={};null!=M&&(mt.fill=M),null!=j&&(mt.stroke=j),null!=P&&(mt.strokeWidth=P),null!=C&&(mt.opacity=C),null!=E&&(mt.gap=E);const xt=Q?`${f||""} semiotic-emphasis-${Q}`.trim():f,bt=al(p,v),kt=e.useMemo(()=>"down"!==b?w: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=bl(o,n,"time"),r=bl(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:v,valueAccessor:x,timeAccessor:m,binSize:u,valueExtent:w,extentPadding:A}),[b,v,x,m,u,w,A]);return pt||vt||t.jsx(To,{ref:lt,chartType:"bar",runtimeMode:"streaming",size:rt,margin:ot,className:xt,arrowOfTime:y,windowMode:g,windowSize:bt,data:v,timeAccessor:m,valueAccessor:x,xExtent:k,yExtent:kt,extentPadding:A,binSize:u,categoryAccessor:_,barColors:S,barStyle:mt,showAxes:nt,background:O,hoverAnnotation:it,tooltipContent:st,customHoverBehavior:ct,annotations:L,autoPlaceAnnotations:R,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:W,decay:Y,pulse:B,staleness:H,transition:X,pointIdAccessor:n.pointIdAccessor,legendPosition:Z,brush:ut||(et?{dimension:"x"}:void 0),onBrush:ut||et?gt:void 0})});function wl(e){return t.jsx(kl,Object.assign({},e,{windowMode:"growing"}))}kl.displayName="RealtimeHistogram",wl.displayName="TemporalHistogram";const Al=e.forwardRef(function(n,i){var o,r,s,l,a;const c=Qs(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:y="sliding",windowSize:g,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:A,radius:_,fill:S,opacity:M,stroke:j,strokeWidth:P,background:C,tooltipContent:E,tooltip:O,onHover:T,annotations:D,autoPlaceAnnotations:N,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:$,linkedHover:I,selection:W,onObservation:z,chartId:F,loading:Y,loadingContent:B,emptyContent:H,emphasis:X,legendPosition:G}=n,V=c.showAxes,q=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(a=null!=E?E:O)&&void 0!==a?a:il({timeAccessor:v,valueAccessor:m}),Z=e.useRef(null),{customHoverBehavior:J}=Us({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:F}),tt=e.useCallback(t=>{T&&T(t),J(t)},[T,J]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const et=ll(Y,K[0],K[1],B),nt=et?null:sl(p,K[0],K[1],H),it={};null!=_&&(it.radius=_),null!=S&&(it.fill=S),null!=M&&(it.opacity=M),null!=j&&(it.stroke=j),null!=P&&(it.strokeWidth=P);const ot=X?`${h||""} semiotic-emphasis-${X}`.trim():h,rt=al(g,p);return et||nt||t.jsx(To,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:K,margin:U,className:ot,arrowOfTime:f,windowMode:y,windowSize:rt,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,categoryAccessor:w,barColors:A,swarmStyle:it,showAxes:V,background:C,hoverAnnotation:q,tooltipContent:Q,customHoverBehavior:tt,annotations:D,autoPlaceAnnotations:N,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:$,legendPosition:G,pointIdAccessor:n.pointIdAccessor})});Al.displayName="RealtimeSwarmChart";const _l=e.forwardRef(function(n,i){var o,r,s,l,a;const c=Qs(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:y="sliding",windowSize:g,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,positiveColor:w,negativeColor:A,connectorStroke:_,connectorWidth:S,gap:M,stroke:j,strokeWidth:P,opacity:C,background:E,tooltipContent:O,tooltip:T,onHover:D,annotations:N,autoPlaceAnnotations:L,svgAnnotationRules:R,tickFormatTime:$,tickFormatValue:I,linkedHover:W,selection:z,onObservation:F,chartId:Y,loading:B,loadingContent:H,emptyContent:X,emphasis:G,legendPosition:V}=n,q=c.showAxes,U=c.enableHover,K=null!=d?d:c.marginDefaults,Q=null!=u?u:[c.width,c.height],Z=null!==(a=null!=O?O:T)&&void 0!==a?a:function(e={}){const{timeAccessor:n,valueAccessor:i}=e;return e=>{var o,r;const s=null!==(o=null==e?void 0:e.data)&&void 0!==o?o:null,l=el(s,n,"time"),a=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:el(s,i,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof a?0>a?nl(a):"+"+nl(a):nl(a);return t.jsxs("div",{className:"semiotic-tooltip",style:Js,children:[t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"x:"}),nl(l)]}),t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"Δ:"}),u]}),null!=c&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"total:"}),nl(c)]})]})}}({timeAccessor:v,valueAccessor:m}),J=e.useRef(null),{customHoverBehavior:tt}=Us({selection:z,linkedHover:W,unwrapData:!0,onObservation:F,chartType:"RealtimeWaterfallChart",chartId:Y}),et=e.useCallback(t=>{D&&D(t),tt(t)},[D,tt]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=J.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=J.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const nt=ll(B,Q[0],Q[1],H),it=nt?null:sl(p,Q[0],Q[1],X),ot={};null!=w&&(ot.positiveColor=w),null!=A&&(ot.negativeColor=A),null!=_&&(ot.connectorStroke=_),null!=S&&(ot.connectorWidth=S),null!=M&&(ot.gap=M),null!=j&&(ot.stroke=j),null!=P&&(ot.strokeWidth=P),null!=C&&(ot.opacity=C);const rt=G?`${h||""} semiotic-emphasis-${G}`.trim():h,st=al(g,p);return nt||it||t.jsx(To,{ref:J,chartType:"waterfall",runtimeMode:"streaming",size:Q,margin:K,className:rt,arrowOfTime:f,windowMode:y,windowSize:st,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,waterfallStyle:ot,showAxes:q,background:E,hoverAnnotation:U,tooltipContent:Z,customHoverBehavior:et,annotations:N,autoPlaceAnnotations:L,svgAnnotationRules:R,tickFormatTime:$,tickFormatValue:I,legendPosition:V,pointIdAccessor:n.pointIdAccessor})});_l.displayName="RealtimeWaterfallChart";const Sl=e.forwardRef(function(n,i){var o,r,s,l,a;const c=Qs(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:y="sliding",windowSize:g,data:p,timeAccessor:v,valueAccessor:m,categoryAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,heatmapXBins:A=20,heatmapYBins:_=20,aggregation:S="count",background:M,tooltipContent:j,tooltip:P,onHover:C,annotations:E,autoPlaceAnnotations:O,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:N,decay:L,pulse:R,staleness:$,linkedHover:I,selection:W,onObservation:z,chartId:F,loading:Y,loadingContent:B,emptyContent:H,emphasis:X,legendPosition:G}=n,V=c.showAxes,q=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(a=null!=j?j:P)&&void 0!==a?a:function(e={}){const{timeAccessor:n,valueAccessor:i,xLabel:o="x",yLabel:r="y"}=e;return e=>{var s,l,a,c;const u=null!==(s=null==e?void 0:e.data)&&void 0!==s?s:null,d=null!==(l=null==u?void 0:u.xCenter)&&void 0!==l?l:el(u,n,"time"),h=null!==(a=null==u?void 0:u.yCenter)&&void 0!==a?a:el(u,i,"value"),f=null==u?void 0:u.count,y=null==u?void 0:u.sum,g=null==u?void 0:u.value,p=null!==(c=null==u?void 0:u.agg)&&void 0!==c?c:"count";return t.jsxs("div",{className:"semiotic-tooltip",style:Js,children:[t.jsxs("div",{children:[t.jsxs("span",{style:tl,children:[o,":"]}),nl(d)]}),t.jsxs("div",{children:[t.jsxs("span",{style:tl,children:[r,":"]}),nl(h)]}),null!=f&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"count:"}),nl(f)]}),"sum"===p&&null!=y&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"sum:"}),nl(y)]}),"mean"===p&&null!=g&&t.jsxs("div",{children:[t.jsx("span",{style:tl,children:"mean:"}),nl(g)]})]})}}({timeAccessor:v,valueAccessor:m}),Z=e.useRef(null),{customHoverBehavior:J}=Us({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:F}),tt=e.useCallback(t=>{C&&C(t),J(t)},[C,J]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const et=ll(Y,K[0],K[1],B),nt=et?null:sl(p,K[0],K[1],H),it=X?`${h||""} semiotic-emphasis-${X}`.trim():h,ot=al(g,p);return et||nt||t.jsx(To,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:K,margin:U,className:it,arrowOfTime:f,windowMode:y,windowSize:ot,data:p,timeAccessor:v,valueAccessor:m,categoryAccessor:x,xExtent:b,yExtent:k,extentPadding:w,heatmapXBins:A,heatmapYBins:_,heatmapAggregation:S,showAxes:V,background:M,hoverAnnotation:q,tooltipContent:Q,customHoverBehavior:tt,annotations:E,autoPlaceAnnotations:O,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:N,decay:L,pulse:R,staleness:$,legendPosition:G,pointIdAccessor:n.pointIdAccessor})});Sl.displayName="RealtimeHeatmap";const Ml=Symbol("semiotic.useStreamStatus.wrapped");exports.DEFAULT_LIFECYCLE_THRESHOLDS=Pe,exports.IncrementalExtent=L,exports.RealtimeHeatmap=Sl,exports.RealtimeHistogram=kl,exports.RealtimeLineChart=xl,exports.RealtimeSwarmChart=Al,exports.RealtimeWaterfallChart=_l,exports.ReorderBuffer=Rs,exports.RingBuffer=N,exports.RunningStats=Cs,exports.StreamNetworkFrame=Ps,exports.StreamXYFrame=To,exports.TemporalHistogram=wl,exports.WindowAccumulator=Es,exports.bandBounds=Ts,exports.bandFromAge=Ce,exports.parseWindowDuration=Ls,exports.statValue=Os,exports.useStreamStatus=function(t={}){const{staleThresholdMs:n=5e3,pollIntervalMs:i=1e3}=t,o=e.useRef(null),[r,s]=e.useState("idle"),[l,a]=e.useState(null),c=e.useMemo(()=>{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[Ml]),t._frame=e,!e)return t._origPush=null,void(t._origPushMany=null);if(e[Ml])return;e[Ml]=!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=>(u(),r(t)),e.pushMany=t=>(t&&t.length>0&&u(),s(t))}}},[]),u=e.useCallback(()=>{const t="undefined"!=typeof performance?performance.now():Date.now();o.current=t,a(t),s(t=>"active"===t?t:"active")},[]);return e.useEffect(()=>{const t=setInterval(()=>{const t=o.current;if(null==t)return;const e=("undefined"!=typeof performance?performance.now():Date.now())-t>n;s(t=>{const n=e?"stale":"active";return t===n?t:n})},i);return()=>clearInterval(t)},[n,i]),{ref:c,status:r,lastPushTime:l}};
|
|
2
|
+
"use strict";var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of i(t))s.call(e,l)||l===o||n(e,l,{get:()=>t[l],enumerable:!(a=r(t,l))||a.enumerable});return e},l=(e,r,i)=>(i=null!=e?t(o(e)):{},a(!r&&e&&e.__esModule?i:n(i,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{DEFAULT_LIFECYCLE_THRESHOLDS:()=>xe,IncrementalExtent:()=>$,RealtimeHeatmap:()=>du,RealtimeHistogram:()=>nu,RealtimeLineChart:()=>Zc,RealtimeSwarmChart:()=>su,RealtimeWaterfallChart:()=>cu,ReorderBuffer:()=>uc,RingBuffer:()=>z,RunningStats:()=>rc,StreamNetworkFrame:()=>nc,StreamXYFrame:()=>js,TemporalHistogram:()=>ru,WindowAccumulator:()=>ic,bandBounds:()=>sc,bandFromAge:()=>ve,compileMotionEncoding:()=>ke,deriveMotionVector:()=>Se,opacityFromAge:()=>we,parseWindowDuration:()=>cc,resolveMotionAccessor:()=>be,resolveMotionVector:()=>Ae,statValue:()=>oc,syncPushBuffer:()=>mu,useStreamStatus:()=>pu,useSyncedPushData:()=>xu}),module.exports=(e=c,a(n({},"__esModule",{value:!0}),e));var u=l(require("react")),h=require("react"),d=require("react"),f=require("d3-selection"),y=require("d3-brush"),p=l(require("react")),g=require("react/jsx-runtime");function m(e,t,n,r){const[i,o]=[Math.min(...t),Math.max(...t)],s=(o-i)/20;let[a,l]=e;if(r)0>n?a=Math.max(i,a-s):l=Math.min(o,l+s);else{const e=l-a;a=Math.max(i,Math.min(o-e,a+n*s)),l=a+e}return[a,l]}function x(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r+1>>1;t[i]>e?r=i-1:n=i}return t[n]}function v(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r>>1;e>t[i]?n=i+1:r=i}return t[n]}function b({width:e,height:t,totalWidth:n,totalHeight:r,margin:i,dimension:o,scales:s,onBrush:a,binSize:l,snap:c,binBoundaries:u,snapDuring:h,streaming:b}){const k=(0,d.useRef)(null),w=(0,d.useRef)(null),A=(0,d.useRef)(a);A.current=a;const S=(0,d.useRef)(s);S.current=s;const _=(0,d.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),M=(0,d.useRef)(_);M.current=_;const C=(0,d.useRef)(!1),P=(0,d.useRef)(null),j=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=p.useId().replace(/:/g,""),i=p.useRef(n);return i.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:p.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(),i.current?.(t))},[])}}}({label:"xy"===o?"Two-dimensional data range brush":o.toUpperCase()+" data range brush",onAction:e=>{const t=S.current,n=w.current;if(!t||!n||!k.current)return;const r=(0,f.select)(k.current).select(".brush-g");if("clear"===e.type)return C.current=!0,r.call(n.move,null),C.current=!1,P.current=null,void A.current(null);const i=t.x.domain(),s=t.y.domain(),a=P.current;let l=a?.x??[i[0]+.4*(i[1]-i[0]),i[0]+.6*(i[1]-i[0])],c=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"!==o&&(l=m(l,i,h,e.resize)),u||"x"===o||(c=m(c,s,h,e.resize)),u&&"y"===o||!u&&"x"===o)return;const d={x:l,y:c};C.current=!0,r.call(n.move,"x"===o?[t.x(l[0]),t.x(l[1])]:"y"===o?[t.y(c[1]),t.y(c[0])]:[[t.x(l[0]),t.y(c[1])],[t.x(l[1]),t.y(c[0])]]),C.current=!1,P.current=d,A.current(d)}});return(0,d.useEffect)(()=>{if(!k.current)return;const n=(0,f.select)(k.current).select(".brush-g"),r="x"===o?(0,y.brushX)():"y"===o?(0,y.brushY)():(0,y.brush)();return r.extent([[0,0],[e,t]]),r.on("brush end",i=>{if(C.current)return;const s=S.current;if(!s)return;if(!i.selection)return P.current=null,void A.current(null);let a,u;if("x"===o){const[e,n]=i.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===o){const[t,n]=i.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]]=i.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===c&&"y"!==o&&("end"===i.type||"brush"===i.type&&h)){const e=M.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[x(e[0],t),v(e[1],t)]}(a,e):l&&l>0&&(a=[Math.floor(a[0]/l)*l,Math.ceil(a[1]/l)*l]);const t=s.x(a[0]),c=s.x(a[1]);if(C.current=!0,"x"===o)n.call(r.move,[t,c]);else if("xy"===o){const e=i.selection;n.call(r.move,[[t,e[0][1]],[c,e[1][1]]])}C.current=!1}const d={x:a,y:u};P.current=d,A.current(d)}),n.call(r),w.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),w.current=null}},[e,t,o,c,l,h]),(0,d.useEffect)(()=>{if(!(b&&s&&w.current&&P.current))return;if(!k.current)return;if("y"===o)return;const e=P.current,t=s.x.domain()[0],n=(0,f.select)(k.current).select(".brush-g");if(t>=e.x[1])return C.current=!0,n.call(w.current.move,null),C.current=!1,P.current=null,void A.current(null);let r=e.x[0],i=!1;if(t>e.x[0]){if(r=t,"bin"===c){const e=M.current;e&&e.length>0?r=v(t,e):l&&l>0&&(r=Math.ceil(t/l)*l)}if(r>=e.x[1])return C.current=!0,n.call(w.current.move,null),C.current=!1,P.current=null,void A.current(null);i=!0}const a=s.x(r),u=s.x(e.x[1]);if(C.current=!0,"x"===o)n.call(w.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(w.current.move,[[a,t],[u,r]])}if(C.current=!1,i){const t={x:[r,e.x[1]],y:e.y};P.current=t,A.current(t)}},[s,b,o,c,l]),(0,g.jsxs)("svg",{ref:k,width:n,height:r,...j.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,g.jsx)("title",{children:j.svgProps["aria-label"]}),(0,g.jsx)("desc",{id:j.descriptionId,children:j.description}),(0,g.jsx)("g",{className:"brush-g",transform:`translate(${i.left},${i.top})`})]})}var k=Object.freeze([]);function w(e){if(!e)return k;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 A=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=w(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=w(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}},S=require("react"),_=require("react/jsx-runtime");function M(e){let t=null;const n=()=>(t||(t=(0,S.createContext)(null)),t),r=C(e);return[function({children:t,initialState:r}){const i=(0,S.useRef)(r),o=(0,S.useMemo)(()=>C(e,i.current),[]),s=n();return(0,_.jsx)(s.Provider,{value:o,children:t})},(e,t)=>{const i=n(),o=(0,S.useContext)(i)??r,s=(0,S.useRef)(e);s.current=e;const a=(0,S.useRef)({hasValue:!1,value:void 0}),l=(0,S.useCallback)(()=>{const e=s.current(o.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[o,t]),c=(0,S.useCallback)(()=>s.current(o.getState()),[o]);return(0,S.useSyncExternalStore)(o.subscribe,l,c)}]}function C(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 P(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 j(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:R}}),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 R=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],T={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}},L={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}},E={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:R,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 N(e,t){if("light"===t)return T;if("dark"===t)return L;if("high-contrast"===t)return E;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?L:T;return j({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return j({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[D,I]=M(e=>({theme:T,setTheme(t){e(e=>({theme:N(e.theme,t)}))}})),z=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 i=0;this._size>i;i++){const o=(r+i)%this._capacity,s=this.buffer[o];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[o]=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}},$=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 W(e,t){return e===t}function F(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function O(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Y(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var B=/^\d{4}-\d{1,2}$/;function H(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=B.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 X(e){return e instanceof Date?e.getTime():"string"==typeof e?H(e):+e}function q(e){return new Set(Array.isArray(e)?e:[e])}function G(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function U(e){const t=e.map(G),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return V(e,n,r)}if(e>=1){const[e,r,i]=t[n];return V(e,r,i)}const r=e*n,i=Math.floor(r),o=r-i,[s,a,l]=t[i],[c,u,h]=t[i+1];return V(Math.round(s+(c-s)*o),Math.round(a+(u-a)*o),Math.round(l+(h-l)*o))}}require("d3-scale");var K=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Q=U(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Z=U(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=U(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=U(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=U(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ne=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),re=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ie=U(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),oe=U(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),se=U(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ae=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),le=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ce={blues:Q,reds:Z,greens:J,viridis:re,oranges:ee,purples:te,greys:ne,plasma:ie,inferno:oe,magma:se,cividis:ae,turbo:le};U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var ue={category10:K,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ce},he=K,de=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function fe(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 ye(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function pe(e,t){return Math.min((e-t.startTime)/t.duration,1)}function ge(e,t,n){return e+(t-e)*n}function me(){return"undefined"!=typeof performance?performance.now():Date.now()}var xe={fresh:1,aging:1.5,stale:3};function ve(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??xe.fresh)>e?"fresh":t*(n.aging??xe.aging)>e?"aging":t*(n.stale??xe.stale)>e?"stale":"expired":"fresh"}function be(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 ke(e){const{data:t,encoding:n}=e,r=[],i=new Map;return t.forEach((e,t)=>{const o=be(n.id,e,t);if(null==o||""===o)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=o+"";if(i.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=be(n.process?.group,e,t),l=be(n.process?.stage,e,t),c=be(n.accessible?.group,e,t)??(null!=a?a+"":null!=l?l+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=be(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:be(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:be(n.placement?.x,e,t),y:be(n.placement?.y,e,t),lane:be(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:be(n.kinematics?.velocityX,e,t),velocityY:be(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:l,target:be(n.process?.target,e,t),work:be(n.process?.work,e,t)},evidence:u,accessible:{description:be(n.accessible?.description,e,t),group:c,label:be(n.accessible?.label,e,t)??s}};r.push(h),i.set(s,h)}),{rows:r,byId:i}}function we(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 Ae(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 Se(e,t,n){return Number.isFinite(n)&&n>0?Ae((t.x-e.x)/n,(t.y-e.y)/n):Ae(0,0)}function _e(e,t,n){if(1>=n)return 1;const r=n-1;return we({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Me(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Ce(e,t,n){const r=e.duration??500,i=n-t;return r>i?1-i/r:0}function Pe(e,t,n,r){let i=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,i=!0),e._pulseColor!==n&&(e._pulseColor=n,i=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,i=!0),i):(0!==e._pulseIntensity&&(e._pulseIntensity=0,i=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,i=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,i=!0),i)}function je(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 Re(e,t,n,r,i,o){const s=[];for(const i of e){const e=n(i),o=r(i);Number.isFinite(e)&&Number.isFinite(o)&&s.push({px:t.x(e),py:t.y(o),rawY:o,d:i})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:o}}function Te(e,t,n,r,i,o,s,a){const l=[];for(const o of e){const e=n(o),s=r(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const c=t.x(e),u=a?a(o):i;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:o,datum:e,group:s}}function Le(e,t,n,r){const i=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const i of t)e+=n(i,r)||0;i.set(r,-e/2)}else if("wiggle"===r){e.length>0&&i.set(e[0],0);for(let r=1;e.length>r;r++){const o=e[r-1],s=e[r];let a=0,l=0,c=0;for(const e of t){const t=n(e,s)||0;a+=(2*c+t)*(t-(n(e,o)||0)),l+=t,c+=t}const u=i.get(o)??0;i.set(s,u-(l>0?a/(2*l):0))}if(e.length>0){let r=0;for(const o of e){let e=0;for(const r of t)e+=n(r,o)||0;r+=(i.get(o)??0)+e/2}const o=r/e.length;for(const t of e)i.set(t,(i.get(t)??0)-o)}}else for(const t of e)i.set(t,0);return i}function Ee(e,t,n,r,i,o,s){const a=n(e),l=r(e);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:i,style:o,datum:e};return void 0!==s&&(c.pointId=s),c}function Ne(e,t,n,r,i,o,s,a){const l=n(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:t.x(l),y:t.y(c),size:i,symbolType:o,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function De(e,t,n,r,i,o,s){return{type:"rect",x:e,y:t,w:n,h:r,style:i,datum:o,group:s}}function Ie(e,t,n,r,i,o,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:i,datum:o};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function ze(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 $e(e,t,n,r){if(!e.scales)return null;const i=[],o=[];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 l=e.scales.x(t),c=e.scales.y(s),u=e.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),o.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:ze(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function We(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 Fe(e,t,n){const r=[];for(const i of n){const n=$e(e,t,"__ribbon_aggregate",i);n&&r.push(n)}return r}function Oe(e,t,n,r){const i=[];for(const o of r){const r=$e(e,t,n,o);r&&i.push(r)}return i}function Ye(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),i=r.getBottom(e);Number.isFinite(i)&&Number.isFinite(t)&&n.push({y0:i,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function Be(e,t,n,r){if(!e.config.pointStyle)return;const i=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const o of r.data){let r=e.config.pointStyle(o);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(o)+"":void 0,l=Ee(o,e.scales,e.getX,i,s,r,a);l&&n.push(l)}}}var He={topOpacity:.8,bottomOpacity:.05};function Xe(e){if(e)return!0===e?He:"colorStops"in e?e:{topOpacity:e.topOpacity??He.topOpacity,bottomOpacity:e.bottomOpacity??He.bottomOpacity}}var qe=require("d3-shape"),Ge={circle:qe.symbolCircle,square:qe.symbolSquare,triangle:qe.symbolTriangle,diamond:qe.symbolDiamond,star:qe.symbolStar,cross:qe.symbolCross,wye:qe.symbolWye},Ve=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Ue(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*Ke(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):(0,qe.symbol)(Ge[r]??qe.symbolCircle,Math.max(1,t))()??""}function Ke(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var Qe=new Map;function Ze(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),i=Math.max(1,Math.floor(e.config.heatmapYBins??20)),o=e.config.heatmapAggregation??"count",s=F(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),h=(l-a||1)/r,d=(u-c||1)/i,f=r*i;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const o=t[n],l=e.getX(o),u=e.getY(o);if(!isFinite(l)||!isFinite(u))continue;const f=Math.min(Math.floor((l-a)/h),r-1),g=Math.min(Math.floor((u-c)/d),i-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const x=s(o);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(o){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 x=m-g||1,v=n.width/r,b=n.height/i,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;i>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(o){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const l=(s-g)/x;A.push(Ie(n*v,(i-1-e)*b,v,b,`rgb(${220-(180*l+.5)|0},${220-(100*l+.5)|0},${255-(50*l+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:c+(e+.5)*d,agg:o},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=F(e.config.valueAccessor,"value"),i=O(e.config.xAccessor,"x"),o=O(e.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=i(n),u=o(n);l[e]=r,c[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)=>e-t),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>e-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),x=Array(t.length),v=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],i=s.get(l[e]),o=a.get(c[e]);if(void 0===i||void 0===o)continue;const h=r(n),d=o*u+i,f=v.get(d);let y;void 0!==f?y=f:(y=b++,v.set(d,y)),g[y]=d,m[y]=h,x[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 ce?e:"blues";let n=Qe.get(t);if(n)return n;n=Array(256);const r=(i=t)&&ce[i]||Q;var i;for(let e=0;256>e;e++)n[e]=r(e/255);return Qe.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,j=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;j.push(Ie(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((t-k)*S+.5|0,255)],x[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return j}function Je(e,t,n,r,i){const o=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 l=Math.floor(e/r)*r;let c=o.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},o.set(l,c)),c.total+=a,i){const e=i(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return o}function et(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:i}=e;tt(r)&&0===n.length&&nt(i,"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)&&nt(i,"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 tt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(tt))}function nt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function rt(e,t,n,r){const i=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),o="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:o,message:`Semiotic ${e} ${o} failed: ${i.message}`,error:i,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function it(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function ot(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=it(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=F(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t+i:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t-i: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:it(e.y1Accessor,"y1"),getBottom:it(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var st=require("d3-scale");function at(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function lt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,st.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,st.scaleSymlog)().domain(t).range(n):"time"===e?(0,st.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,st.scaleLinear)().domain(t).range(n)}function ct(e,t,n,r){const i=e.push(t);return n&&n.push(r),i}var ut={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 ht(e,t){const n={...e};for(const e of t)n[ut[e]]++;return n}function dt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:ht(n,r)}}var ft=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=dt({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(e,t){const n=dt(e,t,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},yt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pt=["scene-style","data-paint","accessibility","evidence"],gt=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),mt=class{constructor(){this.tracker=new ft}get last(){return this.tracker.last}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"},pt):this.recordNoop("restyle")}recordConfig(e,t,n){return this.tracker.record({kind:"config",keys:e},t?function(e,t){const n=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return t&&n.add("domain"),e.some(e=>gt.has(e))&&n.add("scene-style"),n}(e,n):[])}},xt=require("d3-quadtree"),vt=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 i=Array(n);let o=0;for(const e of t)"point"===e.type&&(i[o++]=e);this.tree=(0,xt.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}},bt=class e{constructor(e){if(this.xExtent=new $,this.yExtent=new $,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 mt,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 vt,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,i,o=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let l=!1;const c=i??(()=>{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 i=0,a=!1;for(const n of t){const t=c.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const l=Ce(e,s,o);l>i&&(i=l)}a&&(l=Pe(n,i,s)||l);continue}const t=c.get(n.datum);if(null==t)continue;const i=r.get(t);l=Pe(n,null==i?0:Ce(e,i,o),s,a)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this._stylePaintPending=!1,this.config=e,this.buffer=new z(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=F(e.timeAccessor||e.xAccessor,"time"),this.getY=F(e.valueAccessor||e.yAccessor,"value")):(this.getX=F(e.xAccessor,"x"),this.getY=F(e.yAccessor,"y")),this.getGroup=Y(e.groupAccessor),this.getCategory=Y(e.categoryAccessor),this.getSize=e.sizeAccessor?F(e.sizeAccessor,"size"):void 0,this.getColor=Y(e.colorAccessor),this.getSymbol=Y(e.symbolAccessor),this.getY0=e.y0Accessor?F(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ot(e),this.getPointId=Y(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?F(e.openAccessor,"open"):void 0,this.getHigh=F(e.highAccessor,"high"),this.getLow=F(e.lowAccessor,"low"),this.getClose=n?F(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new z(e.windowSize))}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 z(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,me())):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=me();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 o=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=o?F(this.config.timeAccessor||this.config.xAccessor,"time"):F(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"],i=r instanceof Date,o="string"==typeof r&&Number.isFinite(H(r));if(this.xIsDate=i||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>X(t[e]):e=>X(n(e))}}i=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),i&&r>i.capacity&&i.resize(r));for(const n of e.inserts)ct(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=ct(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,i;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,i=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 o=this.getBufferArray(),s=this.yExtent.extent;let a=at(this.xExtent.extent,t.xExtent),l=at(s,t.yExtent);const c=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!c&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:i}=e,o="exact"===t.axisExtent;if(t.normalize){const n=[0,o?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,l=new Set;let c=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const o of e.data){const e=r(o),s=i(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),l.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>c&&(c=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 i=0,o=0;for(const n of e)o>i?(t.push(n),i+=h.get(n)??0):(r.push(n),o+=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(l).sort((e,t)=>e-t),n=Le(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,i=-1/0;for(const t of e){const e=n.get(t)??0,o=u.get(t)??0;r>e&&(r=e),e+o>i&&(i=e+o)}Number.isFinite(r)&&Number.isFinite(i)||(r=0,i=0);const s=i-r,c=o?0:s>0?s*t.extentPadding:1;p=[r-c,i+c]}else if("diverging"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,i=0;for(const o of e){let e=0,s=0;for(const r of t){const t=n(r,o)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>i&&(i=e)}return[r,i]}(e,y,(e,t)=>a.get(e)?.get(t)||0),i=r-n,s=o?0:i>0?i*t.extentPadding:1;p=[n-s,r+s]}else p=[0,c+(o?0:c>0?c*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!c&&n.size>0?l=function(e,t,n,r,i,o,s){const[,a]=function(e,t,n,r,i){const o=Je(e,t,n,r,i);if(0===o.size)return[0,0];let s=0;for(const e of o.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,i);return[0,s?a:a+a*o]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!c&&n.size>0?l=function(e,t,n,r){const[i,o]=function(e,t){let n=0,r=0,i=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>r&&(r=i))}return[n,r]}(e,t),s=o-i,a=r?0:s>0?s*n:1;return[Math.min(0,i-Math.abs(a)),Math.max(0,o+Math.abs(a))]}(n,this.getY,t.extentPadding,h):c||l[0]===1/0||(l=function(e,t,n){if(!n.length)return e;let[r,i]=e;for(const e of t)for(const t of n){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>i&&(i=n)),Number.isFinite(o)&&(r>o&&(r=o),o>i&&(i=o))}return[r,i]}(l,o,this.resolvedRibbons),l=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,i=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||i[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(i[0]=t.dataYDomain[0]/(1+t.extentPadding)),i}(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));l=function(e,t,n){if(!t||n)return e;const r=t[0],i=t[1];return null==r&&null==i?e:[null!=r?r:e[0],null!=i?i:e[1]]}(l,t.yExtent,!!c),({xDomain:a,yDomain:l}=function(e,t,n){let r=e,i=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 i[0]!==1/0&&i[1]!==-1/0||(i=[0,1]),{xDomain:r,yDomain:i}}(a,l,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:i}=e,o="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(o){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:(0,st.scaleLinear)().domain(r).range(e),y:lt(t.yScaleType,i,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:lt(t.yScaleType,i,[s,n.width-s]),y:(0,st.scaleLinear)().domain(r).range(e)}}var a;return{x:lt(t.xScaleType,r,[s,n.width-s]),y:lt(t.yScaleType,i,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=i):(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,o),this.config.pulse&&this.applyPulse(this.scene,o),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(),i=this.scales.y.domain(),o=this.scales.x.range(),s=this.scales.y.range(),a=lt,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,o[0]>o[1]?[e.width-l,l]:[l,e.width-l]),y:a(this.config.yScaleType,i,c?[l,e.height-l]:[e.height-l,l])},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 i={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??de},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const i=this.resolveLineStyle(e,t);return i.stroke?i.stroke:"string"==typeof i.fill?i.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let o;try{o=n.customLayout(i)}catch(e){const t=null!==this.lastCustomLayoutResult,r=rt("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=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const s=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.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 et({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 i={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=[],i=e.config.annotations?.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=We(e.ribbons);if(o.length>0&&r.push(...Fe(e,t,o)),i.length>0)for(const t of n)r.push(...Oe(e,t.data,t.key,i))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),o=Re(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return Be(e,n,r),r}(i,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=We(e.ribbons);if(o.length>0&&r.push(...Fe(e,t,o)),i.length>0)for(const t of n)r.push(...Oe(e,t.data,t.key,i))}const i=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Te(t.data,e.scales,e.getX,e.getY,i,n,t.key,o),a=Xe(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 Be(e,n,r),r}(i,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],i=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=We(e.ribbons);if(o.length>0&&r.push(...Fe(e,t,o)),i.length>0)for(const t of n)r.push(...Oe(e,t.data,t.key,i))}const o=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n)if(i.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),i=Te(t.data,e.scales,e.getX,e.getY,o,n,t.key,s),a=Xe(e.config.gradientFill);a&&(i.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}else{const n=e.resolveLineStyle(t.key,t.data[0]),i=Re(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return Be(e,n,r),r}(i,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",i=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)i();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),i=e.getY(t);Number.isFinite(r)&&Number.isFinite(i)&&(n+=i)}t.set(r.key,n)}const i=(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:i(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:i(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:i(e.key,n.key)}),r=[],o=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(o.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...o.reverse(),...r)}}else i();const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:l}=function(e,t,n,r,i,o,s,a="zero"){const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),o=r(i);Number.isFinite(t)&&Number.isFinite(o)&&e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let h;if(o){h=new Map;for(const t of c){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Le(c,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!o,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const e of c)g.set(e,d.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:l,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],l=[]};for(const n of c){const i=e.has(n);let s,c,u=i?e.get(n):0;if(o&&i&&(u/=h.get(n)),!i||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const y=t.x(n);l.push([y,t.y(s)]),a.push([y,t.y(c)]),r.set(n,c)}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,o,s),c=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=l.get(r.key);if(n)for(const i of r.data){const r=e.getX(i),o=e.getY(i);null==r||Number.isNaN(r)||null==o||Number.isNaN(o)||!n.has(r)||t.set(i,n.get(r))}}const r=n=>t.get(n)??e.getY(n);Be(e,n,c,r)}return c}(i,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,i=e.config.sizeRange||[3,15];let o=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);o=n=>e===t?(i[0]+i[1])/2:i[0]+(n-e)/(t-e)*(i[1]-i[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=c?.[e];if(t)return t;let n=u.get(e);return n||(n=Ve[h%Ve.length],h++,u.set(e,n)),n};for(const i of t){let t=e.config.pointStyle?e.config.pointStyle(i):{fill:a,opacity:.8},c=t.r||r;if(o&&e.getSize){const t=e.getSize(i);null==t||Number.isNaN(t)||(c=o(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(i);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(i)+"":void 0;if(l){const r=d(l(i)+""),o=Ne(i,e.scales,e.getX,e.getY,Math.PI*c*c,r,t,u);o&&n.push(o)}else{const r=Ee(i,e.scales,e.getX,e.getY,c,t,u);r&&n.push(r)}}return n}(i,t);case"heatmap":return Ze(i,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=Je(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 i=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(i),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=i.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const i=[],o=e.scales,[s,a]=o.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.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=o.x(n),y=o.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,x=Math.max(p-g,1);if(x>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=o.y(n),u=o.y(n+r);i.push(De(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=o.y(0),n=o.y(t.total);i.push(De(m,Math.min(e,n),x,Math.abs(e-n),{fill:l?.fill||c||"#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:i,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(i,t);return this._barCategoryCache=i.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},i=r.radius??3,o=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,l=r.strokeWidth;for(const r of t){const t=e.getX(r),c=e.getY(r);if(null==c||Number.isNaN(c))continue;const u=e.scales.x(t),h=e.scales.y(c);let d=o;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??i,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(i,t);case"waterfall":return function(e,t,n){const r=[],i=e.scales,o=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=o?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=o?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=o?.gap??1,u=o?.stroke,h=o?.strokeWidth,d=o?.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 x;x=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const v=i.x(p),b=0!==x?i.x(p+x):v+n.width/10,k=Math.min(v,b)+c/2,w=Math.max(v,b)-c/2-k;if(0>=w){f=m;continue}const A=i.y(f),S=i.y(m),_=Math.min(A,S),M=Math.abs(A-S),C={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(De(k,_,w,M,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),f=m}return r}(i,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=[],i=e.config.candlestickStyle||{},o=i.rangeColor||"#6366f1",s=n?o:i.upColor||"#28a745",a=n?o:i.downColor||"#dc3545",l=n?o:i.wickColor||"#333",c=i.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=i.bodyWidth??0;if(null==i.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 i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(i),u=e.getLow(i);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const d=n?o:e.getOpen(i),f=n?u:e.getClose(i);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(o),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:l,wickWidth:c,isUp:y,datum:i};n&&(p.isRange=!0),r.push(p)}return r}(i,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const i=e.boundsStyle;return"function"==typeof i?i(n||{},t):i&&"object"==typeof i?i:{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?_e(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Me(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Me(n)){const i=n.length;if(i>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(o[n]=_e(e,a,i),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const s=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=r.get(t[n]);null!=o?(s[n]=_e(e,o,i),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=_e(e,t,i);s>n&&(s=n)}}if(1>s){const e=Array(o);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const o=_e(e,t,i);"heatcell"===n.type?n.style={opacity:o}:"candlestick"===n.type?n._decayOpacity=o:n.style={...n.style,opacity:(n.style?.opacity??1)*o}}}(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,i=t.peek();return null!=i&&r>n-i}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(me())}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 i=0;t.length>i;i++){const o=t[i],s=je(e,o,i);s&&("point"===o.type?n.set(s,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?n.set(s,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?n.set(s,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?r.set(s,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}):"area"===o.type&&r.set(s,{topPath:o.topPath.map(e=>[e[0],e[1]]),bottomPath:o.bottomPath.map(e=>[e[0],e[1]]),opacity:o.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=je(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,i){if(0===r.size&&0===i.size)return n;const o=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 s=!1;const a=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],c=je(e,o,t);if(!c)continue;if(o._transitionKey=c,"line"===o.type||"area"===o.type){const e=i.get(c);if(e){if(l.add(c),"line"===o.type&&e.path&&e.path.length===o.path.length){o._targetPath=o.path.map(e=>[e[0],e[1]]),o._prevPath=e.path;for(let t=0;o.path.length>t;t++)o.path[t]=[e.path[t][0],e.path[t][1]];s=!0}else if("area"===o.type&&e.topPath&&e.bottomPath&&e.topPath.length===o.topPath.length&&e.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(e=>[e[0],e[1]]),o._targetBottomPath=o.bottomPath.map(e=>[e[0],e[1]]),o._prevTopPath=e.topPath,o._prevBottomPath=e.bottomPath;for(let t=0;o.topPath.length>t;t++)o.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;o.bottomPath.length>t;t++)o.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];s=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=e.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},s=!0;continue}const u=r.get(c);if("point"===o.type)if(u){a.add(c);const e={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.r,o.x=u.x,o.y=u.y,o.r=u.r??o.r,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("glyph"===o.type)if(u){a.add(c);const e={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.size,o.x=u.x,o.y=u.y,o.size=u.r??o.size,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("rect"===o.type)if(u){a.add(c);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("heatcell"===o.type)if(u){a.add(c);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0;else if("candlestick"===o.type)if(u&&null!=u.openY){a.add(c);const e={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(o._targetX=e.x,o._targetOpenY=e.openY,o._targetCloseY=e.closeY,o._targetHighY=e.highY,o._targetLowY=e.lowY,o.x=u.x,o.openY=u.openY,o.closeY=u.closeY??o.closeY,o.highY=u.highY??o.highY,o.lowY=u.lowY??o.lowY,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0}for(const[e,t]of i)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),s=!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),s=!0}for(const[e,t]of r)if(!a.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})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:me(),duration:o}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);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 i=pe(e,n.activeTransition),o=ye(i,"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=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.r=ge(n.r,e._targetR,o))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.size=ge(n.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==n.w&&(e.w=ge(n.w,e._targetW,o)),void 0!==n.h&&(e.h=ge(n.h,e._targetH,o))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:ge(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==n.w&&(e.w=ge(n.w,e._targetW,o)),void 0!==n.h&&(e.h=ge(n.h,e._targetH,o))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:ge(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),void 0!==n.openY&&(e.openY=ge(n.openY,e._targetOpenY,o)),void 0!==n.closeY&&(e.closeY=ge(n.closeY,e._targetCloseY,o)),void 0!==n.highY&&(e.highY=ge(n.highY,e._targetHighY,o)),void 0!==n.lowY&&(e.lowY=ge(n.lowY,e._targetLowY,o))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:ge(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);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]=ge(t[r][0],n[r][0],o),e.path[r][1]=ge(t[r][1],n[r][1],o)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:ge(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,i=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=ge(t[n][0],r[n][0],o),e.topPath[n][1]=ge(t[n][1],r[n][1],o);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=ge(n[t][0],i[t][0],o),e.bottomPath[t][1]=ge(n[t][1],i[t][1],o)}}if(i>=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 i;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)}i=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else i=[{key:"_default",data:e}];return{result:i,cache:{version:n,group:t,data:e,result:i}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,i){if(i&&i.version===r)return{map:i.map,cache:i};const o=new Set;if(t)for(const n of e){const e=t(n);e&&o.add(e)}const s=Array.from(o).sort(),a=s.join("\0");if(i&&i.key===a){const e={...i,version:r};return{map:e.map,cache:e}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||de,c=new Map;for(let e=0;s.length>e;e++)c.set(s[e],l[e%l.length]);return{map:c,cache:{key:a,map:c,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 i=e.lineStyle;if("function"==typeof i){const e=i(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const o=e.themeSemantic?.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:r(t)||o||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const i=e.areaStyle(n||{});if(i&&!i.fill&&t){const e=r(t);if(e)return{...i,fill:e,stroke:i.stroke||e}}return i}const i=e.lineStyle;if("function"==typeof i){const e=i(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const o=e.themeSemantic?.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||o||"#4e79a7",fillOpacity:i.fillOpacity??.7,stroke:i.stroke||o||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=r(t)||o||"#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:i,config:o}=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 l=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||de;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,r.set(t,c),r.size>i){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:c,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()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=q(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 i=t.toArray();t.clear();for(let e=0;i.length>e;e++)r.has(e)||t.push(i[e])}(this.buffer,this.timestampBuffer,r);const i=this.buffer.remove(r);if(0===i.length)return this.updateResults.recordNoop("remove"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=me(),this.updateResults.recordData("remove",i.length),i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=q(e),r=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&i.add(t)});const o=this.buffer.update(e=>n.has(r(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=me(),this.updateResults.recordData("update",o.length),o}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}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},i=n(r,t);r.style=i?{...e,...i}:e}}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this._stylePaintPending=!0,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,i=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const o="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(o||"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=o||!W(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=o||!W(n,s);(a||l)&&(e?(this.getX=F(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=F(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=F(this.config.xAccessor,"x"),this.getY=F(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ot(this.config)),r=!0,i=!0)}if("groupAccessor"in e&&!W(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Y(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!W(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Y(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!W(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?F(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!W(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Y(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!W(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Y(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!W(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?F(this.config.y0Accessor,"y0"):void 0,r=!0,i=!0),("boundsAccessor"in e&&!W(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=ot(this.config),r=!0,i=!0),"pointIdAccessor"in e&&!W(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Y(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in e&&!W(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!W(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!W(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!W(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?F(this.config.openAccessor,"open"):void 0,this.getHigh=F(this.config.highAccessor,"high"),this.getLow=F(this.config.lowAccessor,"low"),this.getClose=t?F(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,i=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,i=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const i of n)if(e[i]!==t[i]){r=!0;break}}r&&(i&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,r,i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};bt.GROUP_COLOR_MAP_CAP=1e3;var kt=bt,wt={sceneGeometry:0,layout:0,domain:0},At="production"!==process.env.NODE_ENV,St={revisions:wt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},_t=class{constructor(){this.lastConsumed=wt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(e,t){if(!At)return St;const n=function(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}(e),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),i=!((o=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&o.layout===s.layout&&o.domain===s.domain);var o,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:i,warnUnconsumed:!t&&i&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(At){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] StreamXYFrame 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] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},Mt=l(require("react"));function Ct(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:Mt.createElement(Mt.Fragment,null,...t)}var Pt=l(require("react")),jt=require("react/jsx-runtime"),Rt=Pt.createContext(null);function Tt({value:e,children:t}){return(0,jt.jsx)(Rt.Provider,{value:e,children:t})}function Lt(e,t){return null!=e?(0,jt.jsx)(Tt,{value:t,children:e}):e}var Et=require("react");function Nt(e,t,n,r){(0,Et.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function Dt(e,t,n,r){const i=(0,Et.useRef)(null);(0,Et.useEffect)(()=>{const o=e.current;if(!o)return;const s=t??null;i.current!==s&&(i.current=s,o.setLayoutSelection(s),o.hasCustomRestyle?o.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function It(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 zt(e,t=30){return Math.max((e??4)+5,12,t)}function $t(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Wt(e,t){const n=$t(e);if(!n)return!1;const r=$t(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Ft(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Ot=[40,40],Yt=[.5,.5];function Bt(e,t){const[n,r]=e.viewBox??Ot,[i,o]=e.anchor??Yt,s=r>0?r:1,a=Math.max(0,t)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-i*l,offsetY:-o*c}}function Ht(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var Xt=null;function qt(e){if("undefined"==typeof Path2D)return null;Xt||(Xt=new Map);const t=Xt.get(e);if(t)return t;const n=new Path2D(e);return Xt.size>1024&&Xt.clear(),Xt.set(e,n),n}function Gt(e,t,n=0,r="horizontal"){const[i,o]=e.viewBox??Ot,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:o*(1-a),width:i,height:o*(a-s)}:{x:i*s,y:0,width:i*(a-s),height:o}:null:{x:0,y:0,width:0,height:0}}function Vt(e,t){const n=Bt(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 Ut(e,t,n,r,i,o=e=>e){for(const s of t.parts){const t=qt(s.d);if(!t)continue;const a=s.opacity??1,l=e.globalAlpha;1!==a&&(e.globalAlpha=l*a);const c=i?"none"===s.fill?void 0:i:Ht(s.fill,n,r);c&&(e.fillStyle=o(c),e.fill(t));const u=i?s.stroke&&"none"!==s.stroke?i:void 0:Ht(s.stroke??"none",n,r);u&&(e.strokeStyle=o(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=l)}}function Kt(e,t,n,r,i,o=e=>e.x,s=e=>e.y,a=e=>e.r){const l=Math.max(r,i+5,12),c=t-l,u=t+l,h=n-l,d=n+l;let f=null,y=1/0;return e.visit((e,i,l,p,g)=>{if(i>u||c>p||l>d||h>g)return!0;if(!e.length){let i=e;do{const e=i.data,l=o(e)-t,c=s(e)-n,u=Math.sqrt(l*l+c*c);zt(a(e),r)>=u&&y>u&&(f=e,y=u),i=i.next}while(i)}return!1}),f?{node:f,distance:y}:null}var Qt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Zt=new WeakMap,Jt=0,en=!1,tn=null,nn=null;function rn(e,t){if(!t)return t;const n=Qt.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(en)return;if("undefined"==typeof window||"undefined"==typeof document)return;en=!0;const e=()=>{Jt++};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{tn=window.matchMedia("(prefers-color-scheme: dark)"),nn=e,"function"==typeof tn.addEventListener?tn.addEventListener("change",nn):"function"==typeof tn.addListener&&tn.addListener(nn)}catch{}}();let i=Zt.get(r);i&&i.version===Jt||(i={version:Jt,map:new Map},Zt.set(r,i));const o=i.map.get(t);if(void 0!==o)return o;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return i.map.set(t,s),s}var on=require("d3-shape");function sn(e){switch(e){case"monotoneX":return on.curveMonotoneX;case"monotoneY":return on.curveMonotoneY;case"cardinal":return on.curveCardinal;case"catmullRom":return on.curveCatmullRom;case"step":return on.curveStep;case"stepBefore":return on.curveStepBefore;case"stepAfter":return on.curveStepAfter;case"basis":return on.curveBasis;case"natural":return on.curveNatural;default:return null}}function an(e,t,n){return null==t?n:"string"!=typeof t?t:rn(e,t)||n}function ln(e,t,n,r,i,o,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,i,o,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:l}=t;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),h=e.createLinearGradient(r,i,o,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 i=e.fillStyle;if(e.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const o=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${c})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function cn(e,t,n,r,i,o){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,i,o);for(const e of s)a.addColorStop(e.offset,e.color);return a}var un=require("d3-shape"),hn=new WeakMap;function dn(e,t){const n=sn(t);if(!n)return e;const r=hn.get(e);if(r)return r;const i=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let i=null;const o={moveTo(e,t){i=[e,t],r.push([e,t])},lineTo(e,t){i=[e,t],r.push([e,t])},bezierCurveTo(e,t,o,s,a,l){if(!i)return i=[a,l],void r.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const h=i/n,d=1-h;r.push([d*d*d*c+3*d*d*h*e+3*d*h*h*o+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,o){i=[n,o],r.push([n,o])}};return(0,un.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(o)(e),r}(e,n);return hn.set(e,i),i}function fn(e,t,n,r=30,i,o=0){let s=null;if(i){const e=Kt(i,t,n,r,o);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const o of e){let e=null;switch(o.type){case"point":if(i)break;e=pn(o,t,n,r);break;case"symbol":e=gn(o,t,n,r);break;case"glyph":e=mn(o,t,n,r);break;case"line":e=xn(o,t,n,r);break;case"rect":if(null==o.datum)break;e=bn(o,t,n);break;case"heatcell":e=kn(o,t,n);break;case"area":if(!1===o.interactive)break;e=An(o,t,n);break;case"candlestick":e=wn(o,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function yn(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=Sn(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let i=r,o=r;r>0&&e[r][0]>=t?(i=r-1,o=r):e.length-1>r&&(i=r,o=r+1);const[s,a]=e[i],[l,c]=e[o];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function pn(e,t,n,r=30){const i=t-e.x,o=n-e.y,s=Math.sqrt(i*i+o*o);return s>zt(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function gn(e,t,n,r=30){const i=t-e.x,o=n-e.y,s=Math.sqrt(i*i+o*o);return s>zt(Ke(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function mn(e,t,n,r=30){if(null==e.datum)return null;const i=Vt(e.glyph,e.size),o=e.x+i.centerDx,s=e.y+i.centerDy,a=t-o,l=n-s,c=Math.sqrt(a*a+l*l);return c>zt(i.radius,r)?null:{node:e,datum:e.datum,x:o,y:s,distance:c}}function xn(e,t,n,r=30){if(0===e.path.length)return null;const i=Sn(e.path,t);if(0>i)return null;const[o,s]=e.path[i];let a;if(e.path.length>1){let r=1/0;const o=Math.max(0,i-1),s=Math.min(e.path.length-2,i);for(let i=o;s>=i;i++){const[o,s]=e.path[i],[a,l]=e.path[i+1],c=vn(t,n,o,s,a,l);r>c&&(r=c)}a=r}else{const e=t-o,r=n-s;a=Math.sqrt(e*e+r*r)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:o,y:s,distance:a}}function vn(e,t,n,r,i,o){const s=i-n,a=o-r,l=s*s+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-r)**2);let c=((e-n)*s+(t-r)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*s))**2+(t-(r+c*a))**2)}function bn(e,t,n){const r=It(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function kn(e,t,n){const r=It(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function wn(e,t,n){const r=e.bodyWidth/2,i=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=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,o=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(o*o+s*s)}}return null}function An(e,t,n){if(0===e.topPath.length)return null;const r=Sn(e.topPath,t);if(0>r)return null;const[i,o]=e.topPath[r],s=t-i,a=n-o,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:o,distance:l}}function Sn(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const i=n+r>>1;t>e[i][0]?n=i+1:r=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function _n(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),i=t.get(n);return(r.length>0?r[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const i=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&i.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:i}}function Mn(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 Cn(e,t,n){const{group:r,indexInGroup:i}=t,o=n.byGroup.get(r);switch(e){case"ArrowRight":return o.length-1>i?o[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?o[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Pn(n,n.groups[e+1],o[i]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Pn(n,n.groups[e-1],o[i]):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 Pn(e,t,n){const r=e.byGroup.get(t);let i=0,o=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);o>t&&(o=t,i=e)}return r[i]._flatIndex}function jn(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Rn(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}var Tn=require("react"),Ln={fresh:1,aging:.7,stale:.45,expired:.25},En={alpha:1,band:"fresh",isStale:!1};function Nn(e,t){if(!e||0>=t)return En;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},i=ve(t,n,e.thresholds);return{alpha:{...Ln,...e.opacities??{}}[i],band:i,isStale:"fresh"!==i}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:En}function Dn(e,t,n,r,i,o){const s=(0,Tn.useRef)("fresh");(0,Tn.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Nn(e,l-a.lastIngestTime);c.band===s.current&&c.isStale===i||(s.current=c.band,c.isStale!==i&&o(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,i,r])}var In=require("react/jsx-runtime");function zn({isStale:e,position:t}){return(0,In.jsx)("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"})}var $n=require("react"),Wn=l(require("react")),Fn=require("react/jsx-runtime"),On={fill:(e,t)=>(0,Fn.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Fn.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Yn(e,t,n,r,i){let o;return o="function"==typeof n?n(e):(0,On[n])(r(e,t),i),o}function Bn({swatchSize:e}){return(0,Fn.jsx)("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 Hn(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Xn=(e,t,n,r,i,o,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===c||void 0===c&&null!=i,{swatchSize:x,labelGap:v,rowHeight:b}=u;return f.forEach((e,c)=>{const u=Yn(e,c,h,d,x),k=Hn(e,r,i),w=i&&i.size>0&&i.has(e.label);y.push((0,Fn.jsxs)("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===o&&c===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=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{l(a,c),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&&(0,Fn.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+v+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,Fn.jsx)(Bn,{swatchSize:x}),(0,Fn.jsx)("text",{y:x/2,x:x+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),p+=b}),y};function qn({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:i,label:o,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Wn.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Fn.jsx)("stop",{offset:100*t+"%",stopColor:r(i[0]+t*(i[1]-i[0]))},e))}return(0,Fn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[(0,Fn.jsx)("defs",{children:(0,Fn.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),o&&(0,Fn.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Fn.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,Fn.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])}),(0,Fn.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Fn.jsx)("stop",{offset:100*t+"%",stopColor:r(i[1]-t*(i[1]-i[0]))},e))}return(0,Fn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[o&&(0,Fn.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Fn.jsx)("defs",{children:(0,Fn.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,Fn.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,Fn.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])}),(0,Fn.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])})]})}function Gn(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,legendInteraction:s,title:a="Legend",width:l=100,height:c=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]=Wn.useState(0),[p,g]=Wn.useState(0),m=Wn.useCallback((e,t)=>{y(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push((0,Fn.jsx)("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((0,Fn.jsx)("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((0,Fn.jsx)("g",{className:"legend-item",transform:`translate(0,${h})`,children:Xn(e,n,r,i,o,s,a,f,l,c,u)},"legend-group-"+f)),h+=e.items.length*u.rowHeight+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,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,i,o,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:v,align:b}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=i,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+x+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,c)=>{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=Yn(e,h,d,f,g),S=Hn(e,r,i),_=i&&i.size>0&&i.has(e.label);p.push((0,Fn.jsxs)("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===o&&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;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(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&&(0,Fn.jsx)("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,_&&(0,Fn.jsx)(Bn,{swatchSize:g}),(0,Fn.jsx)("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]+x}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*v}})(e,r,i,o,s,a,l,t,c,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 i=e[r];i.label&&(g.push((0,Fn.jsx)("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:i.label},"legend-text-"+r)),p+=16),g.push((0,Fn.jsx)("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push((0,Fn.jsx)("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),(0,Fn.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),v=!(!n&&!r);return(0,Fn.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Fn.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Vn(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}var Un=require("react/jsx-runtime");function Kn(e){const{legend:t,totalWidth:n,totalHeight:r,margin:i,legendPosition:o="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===o||"bottom"===o,y=!!a,p=Math.max(0,n-i.left-i.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,x;return"left"===o?(m=Math.max(4,i.left-g-10),x=i.top):"top"===o?(m=i.left,x=y?32:8):"bottom"===o?(m=i.left,x=r-i.bottom+38):(m=n-i.right+10,x=i.top),(0,Un.jsx)("g",{transform:`translate(${m}, ${x})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?(0,Un.jsx)(qn,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Vn(t)?(0,Un.jsx)(Gn,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var v}var Qn=require("react"),Zn=require("d3-array");function Jn(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var er=require("react/jsx-runtime");function tr(e){return"string"==typeof e?{type:e}:e}function nr({orient:e,config:t,values:n,scale:r,size:i,length:o}){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,l=(0,Qn.useMemo)(()=>{if(0===n.length)return null;const t=r.domain(),l=i-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)],i=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],s=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],o+1.5*s)}}(n);if(!t)return null;const{q1:i,median:o,q3:c,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const t=r(i),n=r(c),a=r(o),l=r(u),y=r(h),p="top"===e?-1:1,g=0;return(0,er.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,er.jsx)("line",{x1:l,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("line",{x1:l,y1:g+p*f,x2:l,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("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}),(0,er.jsx)("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(i),n=r(c),a=r(o),l=r(u),y=r(h),p="left"===e?-1:1,g=0;return(0,er.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,er.jsx)("line",{x1:g+p*(f+d/2),y1:l,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("line",{x1:g+p*f,y1:l,x2:g+p*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,er.jsx)("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}),(0,er.jsx)("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 c=(0,Zn.bin)().domain(t).thresholds(s.bins)(n);if(0===c.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(c.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,er.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/u*l;if(a){const o=r(t.x0),a=r(t.x1)-r(t.x0);return(0,er.jsx)("rect",{x:o,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const o=r(t.x0),a=r(t.x1)-r(t.x0);return(0,er.jsx)("rect",{x:"left"===e?-4-i:4,y:Math.min(o,o+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=l/2+4,n=[];for(const i of c){if(null==i.x0||null==i.x1)continue;const o=i.length/u*(l/2),s=r((i.x0+i.x1)/2);n.push(a?`${s},${"top"===e?-(t-o):t-o}`:`${"left"===e?-(t-o):t-o},${s}`)}for(let i=c.length-1;i>=0;i--){const o=c[i];if(null==o.x0||null==o.x1)continue;const s=o.length/u*(l/2),h=r((o.x0+o.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return(0,er.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,er.jsx)("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,i=null!=c[0].x0?r(c[0].x0):0;t.push(`M${i},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const i=n.length/u*l,o=r((n.x0+n.x1)/2);t.push(`L${o},${"top"===e?-i-4:i+4}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):o;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,i=null!=c[0].x0?r(c[0].x0):0;t.push(`M${n},${i}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const i=n.length/u*l,o=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${o}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):o;t.push(`L${n},${s}`),t.push("Z")}return(0,er.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,er.jsx)("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,i,o,e,a,4]);return l?(0,er.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}var rr=l(require("react")),ir=require("react/jsx-runtime");function or(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),o=[];let s="";for(const e of i)s&&s.length+1+e.length>r?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function sr(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 ar(e,t,n,r){if(!e)return(0,ir.jsx)("g",{className:"annotation-note"});const{label:i,title:o,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!i&&!o)return(0,ir.jsx)("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=o?c?[o]:or(o,l):[],p=i?c?[i]:or(i,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,ir.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(y.length+p.length)*f+(o&&i?2:0))+f,style:{overflow:"visible"},children:(0,ir.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[o&&(0,ir.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:o}),i&&(0,ir.jsx)("div",{className:"annotation-note-label",children:i})]})},"annotation-note-html")):(y.length>0&&(x.push((0,ir.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>(0,ir.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&x.push((0,ir.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:d,y:m,children:p.map((e,t)=>(0,ir.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((o||i)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=(0,ir.jsx)("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=(0,ir.jsx)("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),(0,ir.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,ir.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:x}),b]})}function lr(e,t,n,r,i){const o=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&o.push((0,ir.jsx)("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)&&o.push((0,ir.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&o.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=i||0;if(void 0!==t?.x){const r=(t.x||0)-e;o.push((0,ir.jsx)("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;o.push((0,ir.jsx)("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?o.push((0,ir.jsx)("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||o.push((0,ir.jsx)("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&&o.push((0,ir.jsx)("path",{d:sr(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,ir.jsx)("g",{className:"annotation-subject",children:o})}function cr(e,t,n,r,i,o){const s=[];let a=0,l=0;if("callout-circle"!==i&&"label"!==i||!o?.radius){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,s=e-i,c=t-o;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=i+s*d,l=o+c*d}}}else if("bracket"===i&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-a)**2+(t-l)**2);if(c>.5){const i=r||"var(--semiotic-text-secondary, currentColor)",o="curve"===n?.type;let u=Math.atan2(t-l,e-a);if(o){const r=(a+e)/2,o=(l+t)/2,h=-(t-l)/c,d=(e-a)/c,f=(n?.curve??.25)*c,y=r+h*f,p=o+d*f;s.push((0,ir.jsx)("path",{className:"connector-curve",d:`M${a},${l}Q${y},${p} ${e},${t}`,fill:"none",stroke:i},"connector-line")),u=Math.atan2(p-l,y-a)}else s.push((0,ir.jsx)("line",{x1:a,y1:l,x2:e,y2:t,stroke:i},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,ir.jsx)("path",{d:`M${a},${l}L${a+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:i,stroke:"none"},"connector-arrow"))}}return(0,ir.jsx)("g",{className:"annotation-connector",children:s})}function ur(e){const{x:t=0,y:n=0,dx:r,dy:i,nx:o,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=i||0;null!=o&&(k=o-x),null!=s&&(w=s-v);const A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,ir.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${v})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&cr(k,w,l,h,A,c),!b.has("subject")&&lr(A,c,h,x,v),!b.has("note")&&ar(a,k,w,h)]})}function hr(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",i=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),i=t.ny||n[0][1]+(t.dy??0),o=n.map((n,o)=>{const s=Object.assign({},t,{note:0===o?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:i});return(0,ir.jsx)(ur,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+o)});return(0,ir.jsx)("g",{children:o})}const o=t.note||{title:"none",label:t.label},s=`${o.label}-${o.title}-${t.i}`;return(0,ir.jsx)(ur,{"data-testid":"semiotic-annotation",events:i,...t,type:r},s)}var dr=require("d3-hierarchy"),fr=require("d3-shape"),yr=l(require("regression"));function pr(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 gr(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 mr(e){return null==e?null:e+""}function xr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function vr(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 i=n.pointNodes[r];if(i.pointId===e.pointId)return xr(t,n,{x:i.x,y:i.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,i=e.scales?.y??e.scales?.value;if(!r||!i)return null;const o=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==o||null==s?null:{x:r(o),y:i(s)}}(n);return r?xr(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return mr(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const i=n.pointNodes?.find(e=>mr(e.pointId)===r);if(i)return xr(t,n,{x:i.x,y:i.y});const o=n.data?.find(e=>function(e){return mr(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!o)return null;const s=pr(o,n),a=gr(o,n);return null==s||null==a?null:xr(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let i=null,o=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(i=t.x,o=t.y)}if(null!=i&&null!=o||(i=pr(e,n),o=gr(e,n)),null!=i&&null!=o)return xr(t,n,{x:i,y:o});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function br(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var kr=require("react/jsx-runtime"),wr={secondary:0,primary:3},Ar=".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 Sr(e){return!0===e?._annotationDeferred}function _r(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Mr(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Cr(e){return Math.max(.72,.95-.06*e)}var Pr=require("react/jsx-runtime"),jr={linear:fr.curveLinear,monotoneX:fr.curveMonotoneX,monotoneY:fr.curveMonotoneY,step:fr.curveStep,stepAfter:fr.curveStepAfter,stepBefore:fr.curveStepBefore,basis:fr.curveBasis,cardinal:fr.curveCardinal,catmullRom:fr.curveCatmullRom};function Rr(e,t,n,r){const i=[];return e.forEach((e,o)=>{let s;if(n){const i=n(e,o,r);s=null!=i?i:t(e,o,r)}else s=t(e,o,r);s&&i.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:Mr(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Sr(e.annotation)),i=e.some(e=>null!=_r(e.annotation)),o=e.some(e=>"layer"===_r(e.annotation));if(!n&&!r&&!i)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=wr[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:i}=e,o=Sr(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=i){const e=null==r&&null!=i;s=(0,kr.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Cr(i),"data-annotation-reading-order":i}:{},children:t.node},"annotation-emphasis-"+n)}const a=_r(t.annotation);return a&&(s=(0,kr.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),o&&(s=(0,kr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift((0,kr.jsx)("style",{children:Ar},"annotation-disclosure-style")),o&&a.unshift((0,kr.jsx)("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}(i)}function Tr(e){return function(e,t,n){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=vr(e,t,n);if(!r)return null;const{x:i,y:o}=r;if(!br(i,o,n))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(0,Pr.jsx)(hr,{noteData:{x:i,y:o,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-"+t)}case"x-threshold":{const r=pr(null!=e.value?{...e,x:e.value}:e,n);if(null==r)return null;const i=e.color||"#f97316",o=e.labelPosition||"top";let s;s="bottom"===o?(n.height||0)-4:"center"===o?(n.height||0)/2:12;const a=r>.6*(n.width||0),l=a?r-4:r+4,c=a?"end":"start";return(0,Pr.jsxs)("g",{opacity:e.opacity,children:[(0,Pr.jsx)("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Pr.jsx)("text",{x:l,y:s,textAnchor:c,fill:i,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const r=gr(null!=e.value?{...e,y:e.value}:e,n);if(null==r)return null;const i=e.color||"#f97316",o=e.labelPosition||"right";let s,a;return"left"===o?(s=4,a="start"):"center"===o?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),(0,Pr.jsxs)("g",{opacity:e.opacity,children:[(0,Pr.jsx)("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Pr.jsx)("text",{x:s,y:r-4,textAnchor:a,fill:i,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const r=(e.coordinates||[]).map(e=>({x:pr({...e,type:"point"},n),y:gr({...e,type:"point"},n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=(0,dr.packEnclose)(r),o=e.padding||10;return(0,Pr.jsxs)("g",{children:[(0,Pr.jsx)("circle",{cx:i.x,cy:i.y,r:i.r+o,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Pr.jsx)("text",{x:i.x,y:i.y-i.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const r=(e.coordinates||[]).map(e=>({x:pr({...e,type:"point"},n),y:gr({...e,type:"point"},n)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=e.padding||10,o=r.map(e=>e.x),s=r.map(e=>e.y),[a,l]=Jn(o),[c,u]=Jn(s),h=a-i,d=l+i,f=c-i;return(0,Pr.jsxs)("g",{children:[(0,Pr.jsx)("rect",{x:h,y:f,width:d-h,height:u+i-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&&(0,Pr.jsx)("text",{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const r=n.data||[],i="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Pr.jsx)("g",{children:i.map((t,r)=>{const i=pr(t,n),s=gr(t,n);if(null==i||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||o;return(0,Pr.jsx)("circle",{cx:i,cy:s,r:a,...l},"hl-"+r)})},"ann-"+t)}case"bracket":{const r=pr(e,n),i=gr(e,n);return(0,Pr.jsx)(hr,{noteData:{x:r??0,y:i??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-"+t)}case"trend":{const r=n.data||[];if(2>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,l=s?i:null,c=s?o:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const e of r){const t=e[l];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=r.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=r.map(e=>[e[i],e[o]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,y=n.scales?.y??n.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),i=t-n,o=e(h[n]);return o+(e(h[r])-o)*i},g=f,m=y;let x;if(s)if(a){const e=p(m);x=(t,n)=>[g(n),e(t)]}else{const e=p(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const v=e.method||"linear";let b;b="loess"===v?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]),i=r.map(e=>e[0]),o=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],r=i.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[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=c[e];0!==t&&(u+=t,h+=t*i[e],d+=t*o[e],f+=t*i[e]*i[e],y+=t*i[e]*o[e])}if(0===u){a.push([t,o[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):("polynomial"===v?yr.default.polynomial(u,{order:e.order||2}):yr.default.linear(u)).points;const k=b.map(([e,t])=>{const[n,r]=x(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,_]=x(A[0],A[1]);return(0,Pr.jsxs)("g",{children:[(0,Pr.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Pr.jsx)("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const r=n.scales?.y??n.scales?.value,i=r?.(e.y0)??0,o=r?.(e.y1)??(n.height||0);return(0,Pr.jsxs)("g",{opacity:e.opacity,children:[(0,Pr.jsx)("rect",{x:0,y:Math.min(i,o),width:n.width||0,height:Math.abs(o-i),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&(0,Pr.jsx)("text",{x:(n.width||0)-4,y:Math.max(Math.min(i,o),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"x-band":{const r=n.scales?.x??n.scales?.time,i=null!=e.x0&&r?r(e.x0):null,o=null!=e.x1&&r?r(e.x1):null;return null==i||null==o?null:(0,Pr.jsxs)("g",{opacity:e.opacity,children:[(0,Pr.jsx)("rect",{x:Math.min(i,o),y:0,width:Math.abs(o-i),height:n.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&(0,Pr.jsx)("text",{x:Math.min(i,o)+4,y:13,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"envelope":{const r=n.data||[];if(2>r.length)return null;const i=n.xAccessor||"x",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[a]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[i]-t[i]);if(2>u.length)return null;const h=jr[n.curve||"linear"]||fr.curveLinear,d=(0,fr.area)().x(e=>o(e[i])).y0(e=>s(e[l])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return(0,Pr.jsxs)("g",{children:[(0,Pr.jsx)("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Pr.jsx)("text",{x:o(u[u.length-1][i])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const i=n.yAccessor||"y",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+(t-l)**2,0)/a.length,u=Math.sqrt(c),h=e.threshold??2,d=l-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(l+h*u),v=s(d),b=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-l)>h*u});return(0,Pr.jsxs)("g",{children:[f&&(0,Pr.jsx)("rect",{x:0,y:Math.min(x,v),width:n.width||0,height:Math.abs(v-x),fill:y,fillOpacity:p}),b.map((e,t)=>{const r=pr(e,n),i=gr(e,n);return null==r||null==i?null:(0,Pr.jsx)("circle",{cx:r,cy:i,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Pr.jsx)("text",{x:(n.width||0)-4,y:Math.min(x,v)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const r=n.data||[];if(3>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const l=r.map(e=>[e[i],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=yr.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,i=0;for(const[e,o]of l)t+=e,n+=o,r+=e*e,i+=e*o;const o=e*r-t*t;if(1e-12>Math.abs(o))return null;const s=(e*i-t*n)/o,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),d=Math.sqrt(h/Math.max(u-2,1)),f=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+(t[0]-f)**2,0),p=e.confidence??.95,g=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=e.steps??5,x=l[u-1][0],v=(x-l[0][0])/Math.max(u-1,1),b=[];for(let e=1;m>=e;e++)b.push(x+e*v);const k=[];for(const e of b){const t=c(e),n=d*Math.sqrt(1+1/u+(y>0?(e-f)**2/y:0))*g;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const w=`M${k.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,A=k.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),S=`${s(x)},${a(c(x))}`,_=e.strokeColor||"#6366f1";return(0,Pr.jsxs)("g",{children:[(0,Pr.jsx)("path",{d:w,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Pr.jsx)("polyline",{points:`${S} ${A}`,fill:"none",stroke:_,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&(0,Pr.jsx)("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,i;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const o=vr(e,t,n);if(!o)return null;r=o.x,i=o.y}if(!br(r,i,n))return null;const o=e.width??32,s=e.height??32;return(0,Pr.jsx)("foreignObject",{x:r+(e.dx??0)-o/2,y:i+(e.dy??0)-s/2,width:o,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Pr.jsx)("div",{style:{width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??(0,Pr.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const r=vr(e,t,n);if(!r)return null;const{x:i,y:o}=r,s=i+(e.dx||0),a=o+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,Pr.jsx)("text",{x:s,y:a,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?rr.cloneElement(c,{key:"ann-text-"+t}):(0,Pr.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Pr.jsx)("line",{x1:i,y1:o,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),rr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const r=e.category;if(null==r)return null;const i=e=>"function"==typeof e&&"function"==typeof e.bandwidth,o=n.scales?.o,s=n.scales?.x,a=n.scales?.y,l=i(o)?o:i(s)?s:i(a)?a:null;if(!l)return null;const c=l(r+"");if(null==c)return null;const u=l.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return(0,Pr.jsxs)("g",(n.projection?"vertical"===n.projection:l===s)?{children:[(0,Pr.jsx)("rect",{x:c,y:0,width:u,height:n.height||0,fill:h,fillOpacity:d}),f&&(0,Pr.jsx)("text",{x:c+u/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]}:{children:[(0,Pr.jsx)("rect",{x:0,y:c,width:n.width||0,height:u,fill:h,fillOpacity:d}),f&&(0,Pr.jsx)("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+t)}default:return null}}}var Lr=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Er(e){return!!e&&"object"==typeof e&&Lr.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Nr(e){return"primary"===e?.emphasis||!0===e?.defensive}function Dr(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 Ir(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 zr=32,$r=6,Wr=4,Fr=8,Or=72;var Yr={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Br(e){if(!Hr(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 Hr(e){return Er(e)}function Xr(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),i=[];let o="";for(const e of r)o&&o.length+e.length+1>n?(i.push(o),o=e):o=o?`${o} ${e}`:e;return o&&i.push(o),i}function qr(e,t,n,r,i){const o=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?o-i.width-4:o+4,y:0>r?s-i.height:s,width:i.width,height:i.height}:{x:0>n?o-i.width:o,y:0>r?s-i.height-4:s+4,width:i.width,height:i.height}}function Gr(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Vr(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 Ur(e,t,n,r,i,o,s,a){const l=Gr(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const i=Math.max(0,r-e.x),o=Math.max(0,r-e.y);return(i+Math.max(0,e.x+e.width-(t-r)))*e.height+(o+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,i,o,a);for(const e of n)c+=12*Vr(l,e);for(const e of r)c+=4*Vr(l,e);return c}function Kr(e){const{annotations:t,context:n,defaultOffset:r=zr,notePadding:i=$r,markPadding:o=Wr,edgePadding:s=Fr,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=Or,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,x=n.height||0,v="object"==typeof y?y:{},b=v.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==v.preferShortText?t.map(Br):t,A=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,S=h||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),_=k&&!f?v.responsive??{minWidth:b}:f,M=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=x)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,o);let j=!1;const R=w.map((e,t)=>{if(!Hr(e))return e;const o=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 i=e.coordinates,o=n.scales?.geoProjection;if(Array.isArray(i)&&i.length>=2&&o){const e=i[0],t=i[1];if("number"==typeof e&&"number"==typeof t){const n=o([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?vr(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!o)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=[...Xr("string"==typeof e.title?e.title:void 0,t),...Xr("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(Gr(qr(o.x,o.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),i)),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=Ur(qr(o.x,o.y,e.dx,e.dy,u),e,C,P,m,x,i,s);f>t&&(d=e,f=t)}if(!d)return e;const y=Gr(qr(o.x,o.y,d.dx,d.dy,u),i);C.push(y);const p=Math.hypot(d.dx,d.dy),g=l&&p>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),T=j?R:w.slice();let L=T;if(d){let e=!1;const t=T.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});L=e?t:T}{let e=!1;const t=L.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?Yr[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 i=[n,r].filter(Boolean).join(" · "),o="string"==typeof e.label?e.label:"";return o.includes(`(${i})`)?e:{...e,label:o?`${o} (${i})`:`(${i})`}}(t);return n!==t&&(e=!0),n});L=e?t:L}const E=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??Dr(m,x,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,i=Math.max(0,e.minVisible??1),o=Dr(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Er(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||o>=a.length)return{visible:t.slice(),deferred:[],budget:o};const l=a.filter(e=>Nr(e.annotation)),c=a.filter(e=>!Nr(e.annotation)).sort((e,t)=>Ir(t.annotation)-Ir(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,o-l.length),Math.max(0,i-l.length))),h=new Set([...l.map(e=>e.index),...c.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:o}}({annotations:L,width:m,height:x,...n});for(const e of r)E.add(e)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const e of L)Hr(e)&&"secondary"===e.emphasis&&E.add(e);if(E.size>0)for(const e of L)!0===e?.defensive&&E.delete(e);let N;return N=0===E.size?L:S?L.map(e=>E.has(e)?{...e,_annotationDeferred:!0}:e):L.filter(e=>!E.has(e)),M?function(e,t){let n=!1;const r=e.map(e=>Hr(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(N,M):N}var Qr=require("react"),Zr={positions:new Map},Jr=new Set;function ei(){for(const e of Jr)e()}function ti(e,t){const n=Zr.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Zr.positions);r.delete(e),Zr={positions:r},ei()}function ni(e,t){const n=Zr.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Zr.positions);r.delete(e),Zr={positions:r},ei()}function ri(){return Zr}function ii(e){return Jr.add(e),()=>Jr.delete(e)}var oi={positions:new Map};function si(){return()=>{}}function ai(){return oi}function li(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],i=n[n.length-1],o=r instanceof Date,s=r instanceof Date?r.getTime():r,a=i instanceof Date?i.getTime():i;if(2>t||s===a)return o?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(t-1),c=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*l;c[e]=o?new Date(n):n}return c}(e,t):e.ticks(t)}var ci=require("react/jsx-runtime");function ui(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function hi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function di(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 fi(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,i="left"===e?-1:1,o=Math.ceil(t/8);let s="M0,"+r;for(let e=0;o>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*i}`,s+=`L${Math.min(n,t)},${r}`}return s}{const r="bottom"===e?0:t,i="bottom"===e?1:-1,o=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;o>e;e++){const t=8*(e+1);s+=`L${r+4*i},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}}function pi(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=e,f=(0,$n.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||gi,r=Math.max(2,Math.floor(t/70)),i=e?.ticks??5,o="exact"===d?Math.max(2,i):Math.min(i,r),a=e?.tickValues??li(s.x,o,d),c=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,c)})),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 mi(h,Math.max(55,f+8))},[s,l,u,t,d]),y=(0,$n.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||h||gi,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,o="exact"===d?Math.max(2,i):Math.min(i,r);return mi((e?.tickValues??li(s.y,o,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,l,h,n,d]),p=c&&s,g=a&&s;if(!p&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),x=l?.find(e=>"left"===e.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return(0,ci.jsx)("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,ci.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[p&&(()=>{const e=fi(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=fi(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,ci.jsxs)("g",{className:"stream-grid",children:[f.map((t,r)=>(0,ci.jsx)("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)=>(0,ci.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&!k&&(0,ci.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&(0,ci.jsx)("path",{d:yi("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&(0,ci.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&(0,ci.jsx)("path",{d:yi("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function gi(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function mi(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 xi(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,scales:s,showAxes:a,axes:l,xLabel:c,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:C,annotations:P,autoPlaceAnnotations:j,svgAnnotationRules:R,xAccessor:T,yAccessor:L,annotationData:E,pointNodes:N,curve:D,underlayRendered:I,canvasObscuresUnderlay:z=!0,linkedCrosshairName:$,linkedCrosshairSourceId:W,children:F}=e,O=(0,$n.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||gi,r=Math.max(2,Math.floor(t/70)),i=e?.ticks??5,o="exact"===y?Math.max(2,i):Math.min(i,r),c=e?.tickValues??li(s.x,o,y),u=c.map(e=>e.valueOf()),h=c.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=mi(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 i=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:i})}}return g},[a,s,l,d,t,y]),Y=(0,$n.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||f||gi,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,o="exact"===y?Math.max(2,i):Math.min(i,r);let c=mi((e?.tickValues??li(s.y,o,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(c.length>1&&(c=c.filter((e,t)=>0===t||e.label+""!=c[t-1].label+"")),e?.includeMax&&c.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=c[c.length-1].pixel;if(Math.abs(n-r)>1){const i=t(e);22>Math.abs(n-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:e,pixel:n,label:i})}}return c},[a,s,l,f,n,y]),B=(0,$n.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||gi,r=Math.max(2,Math.floor(n/30)),i=e.ticks??5;return mi((e.tickValues??li(s.y,"exact"===y?Math.max(2,i):Math.min(i,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,l,f,n,y]),H=(0,$n.useRef)(new Map),X=(0,$n.useRef)(P?.length??0),q=P?.length??0;X.current!==q&&(X.current=q,H.current=new Map);const G=(0,$n.useMemo)(()=>{if(!P||0===P.length)return null;const e=Tr(),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:T,yAccessor:L,width:t,height:n,data:E,frameType:"xy",pointNodes:N,curve:D,stickyPositionCache:H.current};return Rr(j?Kr({annotations:P,context:r,..."object"==typeof j?j:{}}):P,e,R,r)},[P,j,R,t,n,T,L,E,s,N,D]),V=function(e){const t=(0,Qr.useSyncExternalStore)(e?ii:si,e?ri:ai,e?ri:ai);return e?t.positions.get(e)??null:null}($);return(0,$n.useEffect)(()=>{if(!V?.locked||!$)return;const e=e=>{"Escape"===e.key&&ni($)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[V?.locked,$]),a||g||m||S||_||G&&G.length>0||p||F||V?(0,ci.jsxs)("svg",{role:"img",width:r,height:i,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,ci.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,ci.jsx)("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),(0,ci.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[p&&s&&(!I||z)&&(()=>{const e=fi(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=fi(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,ci.jsxs)("g",{className:"stream-grid",children:[O.map((t,r)=>(0,ci.jsx)("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)=>(0,ci.jsx)("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=l?.find(e=>"left"===e.orient),r=l?.find(e=>"bottom"===e.orient),i=!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)",x=!!r?.autoRotate&&O.length>1&&(()=>{const e=t/Math.max(O.length-1,1);return O.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),v=x?12:18,b=n+(x?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=di(O),C=di(Y);return(0,ci.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,ci.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!I||z)&&s&&!d&&(0,ci.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!I||z)&&d&&(0,ci.jsx)("path",{d:yi("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),O.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):Wt(e.value,t>0?O[t-1].value:void 0));return(0,ci.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,ci.jsx)("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,ci.jsx)("text",{y:v,textAnchor:x?"end":ui(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:x?"rotate(-45)":void 0,children:e.label}):(0,ci.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,ci.jsx)("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),c&&(0,ci.jsx)("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:c})]}),(0,ci.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!I||z)&&i&&!a&&(0,ci.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!I||z)&&a&&(0,ci.jsx)("path",{d:yi("left",t,n),fill:"none",stroke:p,strokeWidth:1}),Y.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):Wt(e.value,t>0?Y[t-1].value:void 0));return(0,ci.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,ci.jsx)("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,ci.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:hi(_,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}):(0,ci.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,ci.jsx)("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,ci.jsx)("text",{x:15-o.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-o.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=l?.find(e=>"right"===e.orient);if(!e||0===B.length)return null;const r=!1!==e.baseline,i=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,c=di(B);return(0,ci.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&(0,ci.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),B.map((e,n)=>{const r=!!i&&("function"==typeof i?i(e.value,n):Wt(e.value,n>0?B[n-1].value:void 0));return(0,ci.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,ci.jsx)("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,ci.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:hi(a,e.pixel===c.min,e.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):(0,ci.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,ci.jsx)("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&(0,ci.jsx)("text",{x:t+o.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+o.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),G,_&&s&&M&&C&&(0,ci.jsxs)(ci.Fragment,{children:[_.top&&(0,ci.jsx)("g",{transform:"translate(0, 0)",children:(0,ci.jsx)(nr,{orient:"top",config:tr(_.top),values:M,scale:s.x,size:o.top,length:t})}),_.bottom&&(0,ci.jsx)("g",{transform:`translate(0, ${n})`,children:(0,ci.jsx)(nr,{orient:"bottom",config:tr(_.bottom),values:M,scale:s.x,size:o.bottom,length:t})}),_.left&&(0,ci.jsx)("g",{transform:"translate(0, 0)",children:(0,ci.jsx)(nr,{orient:"left",config:tr(_.left),values:C,scale:s.y,size:o.left,length:n})}),_.right&&(0,ci.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,ci.jsx)(nr,{orient:"right",config:tr(_.right),values:C,scale:s.y,size:o.right,length:n})})]}),S,V&&V.sourceId!==W&&s?.x&&(()=>{const e=s.x(V.xValue);if(null==e||0>e||e>t)return null;const r=V.locked;return(0,ci.jsx)("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"})})(),F]}),g&&(0,ci.jsx)("text",{x:r/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 g?g:null}),Kn({legend:m,totalWidth:r,totalHeight:i,margin:o,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}l(require("react"));var vi=require("d3-shape");function bi(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}var ki=require("react/jsx-runtime"),wi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ai(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function Si(e,t,n,r){const i=e.glyph;if(!i?.parts?.length||0>=e.size)return null;const o=Bt(i,e.size);if(0>=o.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${o.offsetX},${o.offsetY}) scale(${o.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Gt(i,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?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=>i.parts.map((n,r)=>{const i=t?"none"===n.fill?void 0:t:Ht(n.fill,a,e.accent),o=t?n.stroke&&"none"!==n.stroke?t:void 0:Ht(n.stroke??"none",a,e.accent);return i||o?(0,ki.jsx)("path",{d:n.d,fill:i??"none",stroke:o,strokeWidth:o?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,ki.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&(0,ki.jsx)("clipPath",{id:c,children:(0,ki.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,ki.jsx)("g",{children:h(e.ghostColor)}):null,l&&c?(0,ki.jsx)("g",{clipPath:`url(#${c})`,children:h()}):h()]},r)}var _i="undefined"==typeof window||"undefined"==typeof document,Mi=require("react"),Ci="undefined"!=typeof window?Mi.useLayoutEffect:Mi.useEffect;function Pi(){const[e,t]=(0,Mi.useState)(!1);return Ci(()=>{t(!0)},[]),e}var ji=()=>()=>{},Ri=()=>!1,Ti=()=>!0;function Li(){const e=(0,Mi.useSyncExternalStore)(ji,Ri,Ti);return(0,Mi.useRef)(e).current}function Ei(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:i,renderFnRef:o,cancelRender:s,cleanup:a}=e;Ci(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),i.current=!0,s?.(),o.current()},[t,n]);const l=(0,Mi.useRef)(a);l.current=a,(0,Mi.useEffect)(()=>()=>l.current?.(),[])}var Ni=require("react");function Di(e){const t=(0,Ni.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return zi(e,t);if(!$i(e)||!$i(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],i=t[r];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!zi(n,i))return!1}else{if(!$i(n)||!$i(i))return!1;if(!Ii(n,i))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function Ii(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 zi(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 $i(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 Wi(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:i="",x:o=0,y:s=0,width:a,height:l}=t;if("transparent"===n)return!1;if(r)return!1;const c=n||(i&&"transparent"!==i?i:"")||null;if(!c)return!1;const u=rn(e,c);return!!u&&(e.fillStyle=u,e.fillRect(o,s,a,l),!0)}var Fi={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 Oi(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],i=n[3];return`#${e}${e}${r}${r}${i}${i}${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}var Yi=l(require("react")),Bi=l(require("react")),Hi=(require("react/jsx-runtime"),Bi.createContext(null));function Xi(){return Bi.useContext(Hi)}function qi(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 Gi(e){return e&&"object"==typeof e?e:{}}function Vi(e){return Gi(e.accessibility).tableFields??e.accessibleDatum??e.datum}var Ui=require("react/jsx-runtime"),Ki={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Qi(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=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),r=o.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${i[e]||e}`);return`${t}, ${r.join(", ")}`}function Zi(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 Ji=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},eo="semiotic-accessible-data-table",to=eo+" semiotic-accessible-data-table-hidden",no=eo+" semiotic-accessible-data-table-visible",ro=no+" semiotic-accessible-data-table-network",io={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"},oo={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},so={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)"},ao={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},lo={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))"},co={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},uo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ho={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 fo({scene:e,chartType:t,tableId:n,chartTitle:r}){const[i,o]=Yi.useState(!1),[s,a]=Yi.useState(5),l=Xi(),c=l?.visible??!1,u=i||c,h=Yi.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Yi.useEffect(()=>{u||a(5)},[u]);const f=Yi.useCallback(e=>{e.target===e.currentTarget&&(i||c||o(!0))},[i,c]),y=Yi.useCallback(e=>{c||h.current?.contains(e.relatedTarget)||o(!1)},[c]);if(!e||0===e.length)return n?(0,Ui.jsx)("span",{id:n,tabIndex:-1,style:Ki}):null;if(!u)return(0,Ui.jsx)("div",{id:n,className:to,tabIndex:-1,onFocus:f,style:Ki,role:"region","aria-label":d,children:(0,Ui.jsxs)("button",{type:"button",onClick:()=>o(!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:qi(Vi(r))});break;case"line":case"area":{const e=Vi(r),n=Array.isArray(e)?e:[],i="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:i,values:qi(e)});break}case"rect":{const e=Vi(r),n=null!=e&&"object"==typeof e?e:{},i=n.category??r.group??"",o=n.value??n.__aggregateValue??n.total,s=qi(n);null==s.category&&""!==i&&(s.category=i+""),null==s.value&&null!=o&&(s.value="number"==typeof o||"string"==typeof o?o:o+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=qi(Vi(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=Vi(r),n=qi(e);if(null==n.category){const t=Gi(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:qi(Vi(r))});break;case"arc":t.push({label:"Arc",values:qi(Vi(r))});break;case"candlestick":t.push({label:"Candlestick",values:qi(Vi(r))});break;case"geoarea":{const e=Gi(Vi(r)),n=qi(e);if(null==n.name){const t=Gi(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=[],i=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&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],o=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),o+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:i,mean:o/t.length})}else if(i.size>0){const e=Array.from(i);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}: ${Ji(e.min)} to ${Ji(e.max)}, mean ${Ji(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),x=Math.min(s,p.length),v=p.slice(0,x),b=p.length-x,k=new Set;for(const e of v)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return(0,Ui.jsxs)("div",{ref:h,id:n,className:no,tabIndex:-1,onBlur:y,style:io,role:"region","aria-label":d,children:[(0,Ui.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),o(!1)},"aria-label":"Close data summary",style:so,children:"×"}),(0,Ui.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:oo,children:m}),(0,Ui.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:ao,children:[(0,Ui.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:uo,children:b>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),(0,Ui.jsx)("thead",{children:(0,Ui.jsxs)("tr",{children:[(0,Ui.jsx)("th",{style:lo,children:"type"}),w.map(e=>(0,Ui.jsx)("th",{style:lo,children:e},e))]})}),(0,Ui.jsx)("tbody",{children:v.map((e,t)=>(0,Ui.jsxs)("tr",{children:[(0,Ui.jsx)("td",{style:co,children:e.label}),w.map(t=>{return(0,Ui.jsx)("td",{style:co,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ji(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&(0,Ui.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:ho,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function yo({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:i}){const[o,s]=Yi.useState(!1),[a,l]=Yi.useState(5),c=Xi(),u=c?.visible??!1,h=o||u,d=i?"Data summary for "+i:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Yi.useRef(null);Yi.useEffect(()=>{h||l(5)},[h]);const y=Yi.useCallback(e=>{e.target===e.currentTarget&&(o||u||s(!0))},[o,u]),p=Yi.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?(0,Ui.jsx)("span",{id:r,tabIndex:-1,style:Ki}):null;if(!h)return(0,Ui.jsx)("div",{id:r,className:to,tabIndex:-1,onFocus:y,style:Ki,role:"region","aria-label":d,children:(0,Ui.jsxs)("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:[],x=new Map,v=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??e,n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+i)}if(null!=r&&""!==r){const e=r+"";x.set(e,(x.get(e)??0)+1),b.set(e,(b.get(e)??0)+i)}}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,i=x.get(r)??0,o=v.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:i+o,inDeg:i,outDeg:o,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??e;return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${Ji(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),j=w.length-C;return(0,Ui.jsxs)("div",{ref:f,id:r,className:ro,tabIndex:-1,onBlur:p,style:io,role:"region","aria-label":d,children:[(0,Ui.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:so,children:"×"}),(0,Ui.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:oo,children:M.join(" ")}),(0,Ui.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:ao,children:[(0,Ui.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:uo,children:j>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,Ui.jsx)("thead",{children:(0,Ui.jsxs)("tr",{children:[(0,Ui.jsx)("th",{style:lo,children:"id"}),(0,Ui.jsx)("th",{style:lo,children:"degree"}),(0,Ui.jsx)("th",{style:lo,children:"in"}),(0,Ui.jsx)("th",{style:lo,children:"out"}),_&&(0,Ui.jsx)("th",{style:lo,children:"w. degree"}),_&&(0,Ui.jsx)("th",{style:lo,children:"w. in"}),_&&(0,Ui.jsx)("th",{style:lo,children:"w. out"})]})}),(0,Ui.jsx)("tbody",{children:P.map((e,t)=>(0,Ui.jsxs)("tr",{children:[(0,Ui.jsx)("td",{style:co,children:e.id}),(0,Ui.jsx)("td",{style:co,children:e.degree}),(0,Ui.jsx)("td",{style:co,children:e.inDeg}),(0,Ui.jsx)("td",{style:co,children:e.outDeg}),_&&(0,Ui.jsx)("td",{style:co,children:Ji(e.wDegree)}),_&&(0,Ui.jsx)("td",{style:co,children:Ji(e.wInDeg)}),_&&(0,Ui.jsx)("td",{style:co,children:Ji(e.wOutDeg)})]},t))})]}),j>0&&(0,Ui.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:ho,children:["Show ",Math.min(25,j)," more"," ",1===j?"node":"nodes"," (",j," remaining)"]})]})}function po({summary:e}){return e?(0,Ui.jsx)("div",{role:"note",style:Ki,children:e}):null}function go({tableId:e}){return(0,Ui.jsx)("a",{href:"#"+e,style:Ki,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,Ki)},children:"Skip to data table"})}function mo({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(0,Ui.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ki,children:t})}var xo=require("react/jsx-runtime"),vo="var(--semiotic-focus, #005fcc)";function bo({active:e,hoverPoint:t,margin:n,size:r,shape:i="circle",width:o,height:s,pathData:a}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==i&&"path"!==i||!a)if("rect"===i&&null!=o&&null!=s){const e=Math.max(o,4),t=Math.max(s,4);u=(0,xo.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:vo,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,xo.jsx)("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:vo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:vo,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,xo.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,xo.jsx)("path",{d:a,fill:"none",stroke:vo,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,xo.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var ko=l(require("react"));function wo(e,t){return"touch"===t?Math.max(e,24):e}function Ao(e){return Array.isArray(e)?e[0]:e}function So(e,t,n,r){return{data:Ao(e),x:t,y:n,__semioticHoverData:!0,...r}}var _o=["name","label","title"],Mo=["type","kind","category","group","class","status","role","shape"],Co=["value","amount","total","count","weight","score"],Po=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 jo(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Ro(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,i=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&Po.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&i.push({key:t,lower:t.toLowerCase(),value:n})}if(0===i.length)return{entries:[]};let o=i.findIndex(e=>_o.includes(e.lower));const s=o>=0;0>o&&(o=i.findIndex(e=>"id"===e.lower)),0>o&&(o=i.findIndex(e=>"string"==typeof e.value));const a=0>o?void 0:i[o];let l=i.filter((e,t)=>t!==o);s&&(l=l.filter(e=>"id"!==e.lower));const c=jo(l,Mo),u=jo(l,Co),h=new Set(Mo),d=new Set(Co),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&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}}require("react/jsx-runtime");var To={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"},Lo=require("react/jsx-runtime");function Eo({x:e,y:t,containerWidth:n,containerHeight:r,margin:i,children:o,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=ko.useRef(null),[u,h]=ko.useState(null);ko.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();h(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[o,s,n,r]);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(!ko.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}(o),y=f?null:To;return l?(0,Lo.jsx)("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:i.left+e,top:i.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:o}):null}var No=l(require("react")),Do=require("react"),Io=require("react");var zo=require("react"),$o="undefined"==typeof window?Do.useEffect:Do.useLayoutEffect,Wo={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Fo(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Oo(e){const t=function(){const[e,t]=(0,Io.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,Io.useEffect)(()=>{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=(0,Do.useRef)(t);n.current=t;const[r,i]=function(e,t,n){const r=(0,zo.useRef)(null),[i,o]=(0,zo.useState)(null);return(0,zo.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const i=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;o(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return i.observe(e),()=>i.disconnect()},[t,n]),[r,[t&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=(0,Do.useMemo)(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),s=i[0]-o.left-o.right,a=i[1]-o.top-o.bottom,l=Fo(e.foregroundGraphics,i,o),c=Fo(e.backgroundGraphics,i,o),u=I(e=>e.theme),{transition:h,introEnabled:d}=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),f="semiotic-table-"+No.useId(),y=(0,Do.useRef)(null),p=(0,Do.useRef)(e.frameScheduler??Wo);p.current=e.frameScheduler??Wo;const g=(0,Do.useRef)(null),m=(0,Do.useRef)(!1),x=(0,Do.useRef)(()=>{}),v=(0,Do.useCallback)(()=>{if(null!==y.current||m.current)return;const e=p.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(m.current=!0),y.current=null,g.current=null;try{x.current()}finally{e&&(m.current=!1)}});n=!0,t||(y.current=r,g.current=e)},[]),b=(0,Do.useCallback)(()=>{null!==y.current&&((g.current??p.current).cancelAnimationFrame(y.current),y.current=null,g.current=null)},[]);(0,Do.useEffect)(()=>()=>{b()},[b]);const k=(0,Do.useRef)(()=>{}),w=(0,Do.useRef)(()=>{}),A=(0,Do.useRef)(null),S=(0,Do.useRef)(null),_=(0,Do.useRef)(null),M=(0,Do.useCallback)(()=>{const e=A.current;A.current=null,e&&k.current(e)},[]),C=(0,Do.useCallback)(e=>{if(A.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===S.current){const e=p.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,S.current=null,_.current=null,M()});t||(S.current=n,_.current=e)}},[M]),P=(0,Do.useCallback)(()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null),w.current()},[]);(0,Do.useEffect)(()=>()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null)},[]);const j=e.themeDirtyRef;return $o(()=>{j&&(Jt++,j.current=!0,v())},[u,v,j]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:i,margin:o,adjustedWidth:s,adjustedHeight:a,resolvedForeground:l,resolvedBackground:c,currentTheme:u,transition:h,introEnabled:d,tableId:f,rafRef:y,renderFnRef:x,scheduleRender:v,cancelRender:b,hoverHandlerRef:k,hoverLeaveRef:w,onPointerMove:C,onPointerLeave:P}}function Yo(e,t,n,r){const i=e.getContext("2d");if(!i)return null;const o=Math.round(t[0]*r),s=Math.round(t[1]*r),a=o/t[0],l=s/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===o&&e.height===s||(e.width=o,e.height=s),i.setTransform(a,0,0,l,0,0),i.translate(n.left,n.top),i}function Bo(){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))}var Ho=require("react");function Xo(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 qo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Go=3156e7;function Vo(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")}`}:Go>t?e=>{const t=new Date(e);return`${qo[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Go>t?e=>{const t=new Date(e);return`${qo[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Uo(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:Ke(n.size)});else if("glyph"===n.type){const e=Vt(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var Ko=require("d3-shape");function Qo(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 Zo(e,t,n,r,i,o){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 l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=o;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let o=i;l>r&&(o*=r/l),l>a-r&&(o*=(a-r)/l),e.globalAlpha=Math.max(0,o),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Jo=(e,t,n,r)=>{const i=t.filter(e=>"line"===e.type);for(const t of i){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 i=t.style.stroke||"#007bff",o=rn(e,i)||i,s=t.style.strokeWidth||2,a=t.colorThresholds,l=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){Zo(e,t.path,o,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=sn(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=o;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)},i=null,s=null,c=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=l[h],p=Qo(y,a,o);if(null!==i&&null!==u&&null!==c){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(c>n||n>y)&&(n>c||y>n)||c===n||y===n||t.push({t:(n-c)/(y-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=i+(d-i)*l.t,u=s+(f-s)*l.t,h=Qo(c+(y-c)*Math.min(l.t+1e-4,1),a,o);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}i=d,s=f,c=y,u=p}else n(p,d,f),i=d,s=f,c=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?cn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||o,c)(0,Ko.line)().x(e=>e[0]).y(e=>e[1]).curve(c).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=an(e,t.style.fill,t.style.fill),c&&!u)(0,Ko.line)().x(e=>e[0]).y(e=>e[1]).curve(c).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 es(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ts(e,t,n=.3){es(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 ns(e,t,n=.6){if(!es(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,i=t.cx??t.x??0,o=t.cy??t.y??0;e.beginPath(),e.arc(i,o,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 rs(e,t,n,r=.35){es(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var is=require("d3-shape");function os(e,t){const n=sn(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=(0,is.area)().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 ss=(e,t,n,r)=>{const i=t.filter(e=>"area"===e.type);for(const t of i){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 i=t._introClipFraction;void 0!==i&&1>i&&(e.save(),e.beginPath(),e.rect(0,0,r.width*i,r.height),e.clip());const o=an(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=o;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=rn(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(os(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 i=ln(e,t.fillGradient,"string"==typeof o?o:"#4e79a7",0,n,0,r);e.fillStyle=i||o,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=o;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(os(e,t),rs(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?cn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=sn(t.curve);if(e.beginPath(),r)(0,is.line)().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!==i&&1>i&&e.restore(),n&&e.restore(),e.globalAlpha=1}},as=(e,t,n,r)=>{const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{const t=e.globalAlpha;for(const n of i)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=an(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=an(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),ns(e,n)}finally{e.restore()}}},ls=new Map;function cs(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=ls.get(t);return n||(n=new Path2D(Ue(e.symbolType,e.size)),ls.size>256&&ls.clear(),ls.set(t,n)),n}catch{return null}}var us=(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 i=cs(t);if(!i)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const o=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle=an(e,t.style.fill,"#4e79a7"),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=an(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(i)),e.restore()}e.globalAlpha=n};function hs(e,t,n,r,i){if(0>=t.size)return;const o=t.glyph;if(!o||!o.parts?.length)return;const s=Bt(o,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=an(e,t,t);return"string"==typeof n?n:t},c=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=i*a*(t.style.fillOpacity??1);const u=Gt(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Ut(e,o,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Ut(e,o,c,t.accent,void 0,l),e.restore()}function ds(e,t){const{x:n,y:r,w:i,h:o}=t,{tl:s,tr:a,br:l,bl:c}=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+i-a,r),a>0&&e.arcTo(n+i,r,n+i,r+a,a),e.lineTo(n+i,r+o-l),l>0&&e.arcTo(n+i,r+o,n+i-l,r+o,l),e.lineTo(n+c,r+o),c>0&&e.arcTo(n,r+o,n,r+o-c,c),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function fs(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 ys=(e,t,n,r)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)ps(e,t);else if(t.cornerRadii&&bi(t.cornerRadii)){const n=an(e,t.style.fill,rn(e,"var(--semiotic-primary, #007bff)")),r=fs(t),i=t.fillGradient&&"string"==typeof n?ln(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n,ds(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=an(e,t.style.fill,rn(e,"var(--semiotic-primary, #007bff)")),r=fs(t),i=t.fillGradient&&"string"==typeof n?ln(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n;const o=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+l-o,a),e.arcTo(s+l,a,s+l,a+o,o),e.lineTo(s+l,a+c-o),e.arcTo(s+l,a+c,s+l-o,a+c,o),e.lineTo(s,a+c);break;case"left":e.moveTo(s+l,a),e.lineTo(s+o,a),e.arcTo(s,a,s,a+o,o),e.lineTo(s,a+c-o),e.arcTo(s,a+c,s+o,a+c,o),e.lineTo(s+l,a+c);break;case"bottom":e.moveTo(s,a),e.lineTo(s+l,a),e.lineTo(s+l,a+c-o),e.arcTo(s+l,a+c,s+l-o,a+c,o),e.lineTo(s+o,a+c),e.arcTo(s,a+c,s,a+c-o,o);break;default:e.moveTo(s,a+c),e.lineTo(s,a+o),e.arcTo(s,a,s+o,a,o),e.lineTo(s+l-o,a),e.arcTo(s+l,a,s+l,a+o,o),e.lineTo(s+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=an(e,t.style.fill,rn(e,"var(--semiotic-primary, #007bff)")),r=fs(t),i=t.fillGradient&&"string"==typeof n?ln(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}ts(e,t),e.globalAlpha=1}};function ps(e,t){const n=t.style.icon,r=t.style.iconPadding||2,i=Math.min(t.w,t.h)-r;if(0>=i)return;const o=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),o){const o=i+r,s=t.x+(t.w-i)/2;for(let r=t.y+t.h-i;r>=t.y-i;r-=o)e.drawImage(n,s,r,i,i)}else{const o=i+r,s=t.y+(t.h-i)/2;for(let r=t.x;t.x+t.w>r;r+=o)e.drawImage(n,r,s,i,i)}e.restore()}function gs(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 ms(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var xs=(e,t,n,r)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){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=rn(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),ts(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):ms(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=gs(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,o)}}}finally{e.restore()}},vs=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const i=(t._decayOpacity??1)*(t.style?.opacity??1);1!==i&&(e.globalAlpha=i);const o=rn(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=o,e.lineWidth=a,e.stroke()};if(s||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=o,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),i=t.isUp?t.upColor:t.downColor,o=rn(e,i)||i;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&l(),e.restore()}},bs={line:[ss,Jo,as],area:[ss,as],stackedarea:[ss,as],scatter:[as,us],bubble:[as,us],heatmap:[xs],bar:[ys],swarm:[as],waterfall:[(e,t,n,r)=>{ys(e,t);const i=t.filter(e=>"rect"===e.type);if(2>i.length)return;const o=i[0].datum,s=o?._connectorStroke;if(s){e.save(),e.strokeStyle=rn(e,s)||s,e.lineWidth=o?._connectorWidth??1,e.setLineDash([]);for(let t=0;i.length-1>t;t++){const r=i[t],o=i[t+1],s=r.datum,a=o.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=r.x+r.w,u=o.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[vs],mixed:[ss,Jo,as],custom:[ss,ys,xs,Jo,as,us,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&hs(e,r,r.x,r.y,n);e.globalAlpha=n},vs]};require("react/jsx-runtime");var ks=require("react/jsx-runtime");function ws(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function As({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=Ro(t);if(null!=e.title||e.entries.length>0)return(0,ks.jsxs)("div",{className:"semiotic-tooltip",style:To,children:[null!=e.title&&(0,ks.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,ks.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,ks.jsx)("span",{style:{fontWeight:600},children:ws(e.value)})]},e.key))]})}return(0,ks.jsxs)("div",{className:"semiotic-tooltip",style:To,children:[(0,ks.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:ws(n)}),(0,ks.jsx)("div",{style:{opacity:.7,fontSize:11},children:ws(r)})]})}As.ownsChrome=!0;var Ss=require("react/jsx-runtime"),_s={top:20,right:20,bottom:30,left:40},Ms=Fi;function Cs(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Ps=(0,h.memo)((0,h.forwardRef)(function(e,t){const{chartType:n,runtimeMode:r,data:i,chunkThreshold:o,chunkSize:s,xAccessor:a,yAccessor:l,accessorRevision:c,colorAccessor:d,sizeAccessor:f,symbolAccessor:y,symbolMap:p,groupAccessor:g,lineDataAccessor:m,curve:x,normalize:v,baseline:k,stackOrder:S,binSize:_,valueAccessor:M,arrowOfTime:C="right",windowMode:j="sliding",windowSize:R=200,timeAccessor:T,xExtent:L,yExtent:E,extentPadding:N=.1,scalePadding:D,sizeRange:I,size:z=[500,300],responsiveWidth:$,responsiveHeight:W,margin:F,className:O,background:Y,lineStyle:B,pointStyle:H,areaStyle:X,barStyle:q,waterfallStyle:G,swarmStyle:V,barColors:U,colorScheme:K,boundsAccessor:Q,boundsStyle:Z,y0Accessor:J,band:ee,gradientFill:te,lineGradient:ne,areaGroups:re,openAccessor:ie,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:le,showAxes:ce=!0,axes:ue,xLabel:he,yLabel:de,yLabelRight:fe,xFormat:ye,yFormat:pe,axisExtent:ge,tickFormatTime:me,tickFormatValue:xe,hoverAnnotation:ve,tooltipContent:be,customHoverBehavior:ke,customClickBehavior:we,enableHover:Ae,hoverRadius:Se=30,tooltipMode:_e,annotations:Me,autoPlaceAnnotations:Ce,svgAnnotationRules:Pe,showGrid:je,legend:Re,legendHoverBehavior:Te,legendClickBehavior:Le,legendHighlightedCategory:Ee,legendIsolatedCategories:Ne,legendPosition:De,legendLayout:Ie,legendCategoryAccessor:ze,onCategoriesChange:$e,backgroundGraphics:We,foregroundGraphics:Fe,canvasPreRenderers:Oe,svgPreRenderers:Be,title:He,categoryAccessor:Xe,brush:qe,onBrush:Ge,decay:Ve,pulse:Ke,transition:Qe,animate:Ze,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:rt,heatmapValueFormat:it,marginalGraphics:ot,pointIdAccessor:st,xScaleType:at,yScaleType:lt,accessibleTable:ct=!0,description:ut,summary:ht,linkedCrosshairName:dt,linkedCrosshairSourceId:ft,customLayout:yt,onLayoutError:pt,layoutConfig:gt,layoutSelection:mt}=e,xt=(0,h.useId)().replace(/:/g,""),vt=(0,h.useRef)(!1),bt=(0,h.useRef)({w:-1,h:-1}),wt=(0,h.useRef)(!1),At=Oo({sizeProp:z,responsiveWidth:$,responsiveHeight:W,userMargin:F,marginDefault:_s,animate:Ze,transitionProp:Qe,themeDirtyRef:vt}),St=Pi(),Mt=Li(),{reducedMotionRef:Pt,responsiveRef:jt,size:Rt,currentTheme:Tt,transition:Et,introEnabled:It,tableId:zt,rafRef:$t,renderFnRef:Wt,scheduleRender:Ft,cancelRender:Ot}=At;let Yt=At.margin;if(ot){const e=60,t={...At.margin};ot.top&&e>t.top&&(t.top=e),ot.bottom&&e>t.bottom&&(t.bottom=e),ot.left&&e>t.left&&(t.left=e),ot.right&&e>t.right&&(t.right=e),Yt=t}const Bt=Rt[0]-Yt.left-Yt.right,Ht=Rt[1]-Yt.top-Yt.bottom,Xt=(0,h.useMemo)(()=>w(i),[i]),qt=ve??Ae,Gt=(0,h.useRef)(null),Ut=(0,h.useRef)(null),[Kt,Qt]=(0,h.useState)(0),Zt=(0,h.useRef)(0),[en,tn]=(0,h.useState)(null),nn=(e,t)=>"function"==typeof e?e({size:Rt,margin:Yt,scales:t}):e,rn=nn(Fe,en),on=nn(We,en),sn=(0,h.useRef)(null),an=(0,h.useRef)(null),ln=(0,h.useRef)(void 0),[cn,un]=(0,h.useState)(null),hn=(0,h.useRef)(Ms.primary),pn=(0,h.useRef)(function(){let e=-1,t=Fi;return{resolve(n){if(!n)return Fi;const r=Jt;return r===e||(t=function(e){if(!e)return Fi;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),o=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||n||o?{axisStroke:l||Fi.axisStroke,tickText:s||Fi.tickText,crosshair:s?Oi(s,"66"):Fi.crosshair,hoverFill:c?Oi(c,"4D"):Fi.hoverFill,hoverStroke:s?Oi(s,"99"):Fi.hoverStroke,pointRing:c||Fi.pointRing,primary:o||Fi.primary,background:c||Fi.background}:Fi}(n),e=r),t},invalidate(){e=-1}}}()),gn=(0,h.useRef)(!1),mn=(0,h.useRef)(new _t),xn=(0,h.useRef)([]),vn=(0,h.useRef)(ze),bn=(0,h.useRef)($e);vn.current=ze,bn.current=$e;const[kn,wn]=(0,h.useState)(!1),[An,Pn]=(0,h.useState)([]),[jn,Tn]=(0,h.useState)([]),Ln="streaming"===r||["bar","swarm","waterfall"].includes(n),En=Di((0,h.useMemo)(()=>({chartType:n,runtimeMode:Ln?"streaming":"bounded",windowSize:R,windowMode:j,arrowOfTime:Ln?C:"right",extentPadding:N,scalePadding:D,axisExtent:ge,xAccessor:a,yAccessor:l,accessorRevision:c,timeAccessor:Ln?T:void 0,valueAccessor:M,colorAccessor:d,sizeAccessor:f,symbolAccessor:y,symbolMap:p,groupAccessor:g||(m?"_lineGroup":void 0),categoryAccessor:Xe,lineDataAccessor:m,xScaleType:at,yScaleType:lt,xExtent:L,yExtent:E,sizeRange:I,binSize:_,normalize:v,baseline:k,stackOrder:S,boundsAccessor:Q,boundsStyle:Z,y0Accessor:J,band:ee,gradientFill:!0===te?{topOpacity:.8,bottomOpacity:.05}:!1===te?void 0:te,areaGroups:re?new Set(re):void 0,lineGradient:ne,openAccessor:ie,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:le,lineStyle:B,pointStyle:H,areaStyle:X,swarmStyle:V,waterfallStyle:G,colorScheme:K,barColors:U,barStyle:q,annotations:Me,decay:Ve,pulse:Ke,transition:Et,introAnimation:It,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:rt,heatmapValueFormat:it,pointIdAccessor:st,curve:x,themeCategorical:Tt?.colors?.categorical,themeSemantic:P(Tt),themeSequential:Tt?.colors?.sequential,themeDiverging:Tt?.colors?.diverging,customLayout:yt,onLayoutError:pt,layoutConfig:gt,layoutMargin:Yt}),[n,R,j,C,N,D,ge,a,l,c,T,M,at,lt,d,f,y,p,g,Xe,m,L,E,I,_,v,k,S,Q,Z,J,ee,te,ne,re,ie,oe,se,ae,le,B,H,X,V,G,q,K,U,Me,Ve,Ke,Et?.duration,Et?.easing,It,Je,et,tt,nt,rt,it,Ln,st,x,Tt,yt,pt,gt,Yt])),In=(0,h.useRef)(null);In.current||(In.current=new kt(En));const $n=function(e,t,n,r){return(0,Ho.useCallback)(()=>{const i=t.current,o=n.current;if(!o||!i)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const i of e){if(!i||"object"!=typeof i)continue;const e="function"==typeof t?t(i):i[t];if(null==e)continue;const o=e+"";n.has(o)||(n.add(o),r.push(o))}return r}(e.current?.getData()??[],i);(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,r.current)||(r.current=s,o(s))},[t,n,r,e])}(In,vn,bn,xn);Nt(In,En,vt,Ft),Dt(In,mt,vt,Ft);const Wn=(0,h.useRef)(null);Wn.current||(Wn.current=new A(e=>{const t=In.current;t&&t.ingest(e)&&(vt.current=!0,Ft())},{chunkThreshold:o,chunkSize:s})),(0,h.useEffect)(()=>{Wn.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const Fn=(0,h.useCallback)(e=>{Wn.current?.push(e)},[]),On=(0,h.useCallback)(e=>{Wn.current?.pushMany(e)},[]),Yn=(0,h.useCallback)(()=>{Wn.current?.clear(),In.current?.clear(),vt.current=!0,Ft()},[Ft]);(0,h.useImperativeHandle)(t,()=>({push:Fn,pushMany:On,remove:e=>{Wn.current?.flush();const t=In.current?.remove(e)??[];return t.length>0&&(sn.current&&t.some(e=>e===sn.current?.data)&&(sn.current=null,un(null)),vt.current=!0,Ft()),t},update:(e,t)=>{Wn.current?.flush();const n=In.current?.update(e,t)??[];return n.length>0&&(vt.current=!0,Ft()),n},clear:Yn,getData:()=>(Wn.current?.flush(),In.current?.getData()??[]),getScales:()=>In.current?.scales??null,getExtents:()=>In.current?.getExtents()??null,getCustomLayout:()=>In.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>In.current?.lastCustomLayoutFailure??null}),[Fn,On,Yn,Ft]),(0,h.useEffect)(()=>{if(i){if(m&&Xt.length>0&&"object"==typeof Xt[0]&&null!==Xt[0]){const e="string"==typeof m?m:"coordinates";if(Array.isArray(Xt[0][e])){const t=[];for(const n of Xt){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 Wn.current?.setBoundedData(t)}}Wn.current?.setBoundedData(Xt)}},[i,Xt,m]);const{hoverHandlerRef:Bn,hoverLeaveRef:Hn,onPointerMove:Xn,onPointerLeave:qn}=At;Bn.current=e=>{if(!qt)return;const t=Gt.current;if(!t)return;const r=t.getBoundingClientRect(),i=e.clientX-r.left-Yt.left,o=e.clientY-r.top-Yt.top;if(0>i||i>Bt||0>o||o>Ht)return void(sn.current&&(sn.current=null,an.current=null,un(null),ke&&(ke(null),vt.current=!0),Ft()));const s=In.current;if(!s||0===s.scene.length)return;const l=wo(Se,e.pointerType),c=fn(s.scene,i,o,l,s.quadtree,s.maxPointRadius),u="multi"===_e,h=()=>{sn.current&&(sn.current=null,an.current=null,un(null),ke&&ke(null),Ft())};if(!c&&!u)return void h();const d=u||!c?i:c.x,f=u||!c?o:c.y,y=c?.datum?Ye(c.datum,s.resolvedRibbons):{},p=s.scales?.x?.invert,g="function"==typeof p?p(d):void 0;let m=So(y,d,f,null!=g?{xValue:g,xPx:d}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const r=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const o=yn(dn(e.path,e.curve),t,n);if(null===o)continue;const s=Sn(e.path,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:o,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const o=dn(e.topPath,e.curve),s=dn(e.bottomPath,e.curve),a=yn(o,t,n);if(null===a)continue;const l=yn(s,t,n),c=Sn(e.topPath,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??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}(s.scene,d,Math.max(l,Bt));if(e.length>0){const t=s.scales.y.invert,r=hn.current,i=p?p(d):d;if(c)m.xValue=i,m.xPx=d;else{const e={xValue:i};"string"==typeof a&&(e[a]=i),m=So(e,d,f,{xValue:i,xPx:d})}m.allSeries=e.map(e=>{const i=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=o?i-o:i,valuePx:e.y,color:e.color||r,datum:Ye(e.datum,s.resolvedRibbons)}})}}c||m.allSeries?.length?(sn.current=m,an.current=c?.node??null,un(m),ke&&(ke(m),vt.current=!0),Ft()):h()},Hn.current=()=>{sn.current&&(sn.current=null,an.current=null,un(null),ke&&(ke(null),vt.current=!0),Ft())};const Gn=(0,h.useRef)(()=>{});Gn.current=e=>{if(!we)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-Yt.left,i=e.clientY-n.top-Yt.top;if(0>r||r>Bt||0>i||i>Ht)return void we(null);const o=In.current;if(!o||0===o.scene.length)return void we(null);const s=wo(Se,ln.current),a=fn(o.scene,r,i,s,o.quadtree,o.maxPointRadius);if(!a)return void we(null);const l=a.datum||{},c=o.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;we(So(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Vn=(0,h.useCallback)(e=>Gn.current(e),[]),Un=(0,h.useRef)(-1),Kn=(0,h.useRef)(null),Qn=(0,h.useRef)(null),Zn=(0,h.useCallback)(e=>{const t=In.current;if(!t||0===t.scene.length)return;const n=t.version;let r;if(Qn.current&&Qn.current.version===n)r=Qn.current.graph;else{const e=function(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=Vt(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:[],i=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:i});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],i=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:i});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}(t.scene);if(0===e.length)return;r=_n(e),Qn.current={version:n,graph:r}}const i=Un.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Un.current=0;const n=r.flat[0];Kn.current={shape:n.shape,w:n.w,h:n.h};const i=Rn({...n,datum:Ye(n.datum,t.resolvedRibbons)});return sn.current=i,un(i),ke&&ke(i),void Ft()}const o=Mn(r,i),s=Cn(e.key,o,r);if(null===s)return;if(e.preventDefault(),0>s)return Un.current=-1,Kn.current=null,sn.current=null,an.current=null,un(null),ke&&ke(null),void Ft();Un.current=s;const a=r.flat[s];Kn.current={shape:a.shape,w:a.w,h:a.h};const l=Rn({...a,datum:Ye(a.datum,t.resolvedRibbons)});sn.current=l,un(l),ke&&ke(l),Ft()},[ke,Ft]),Jn=(0,h.useCallback)(e=>{ln.current=e.pointerType,Un.current=-1,Kn.current=null,Xn(e)},[Xn]),er=(0,h.useCallback)(e=>{ln.current="mouse",Un.current=-1,Kn.current=null,Xn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Xn]),tr=(0,h.useCallback)(e=>{ln.current=e.pointerType},[]);Wt.current=()=>{$t.current=null;const e=Gt.current,t=Ut.current;if(!e||!t)return;const r=In.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=r.advanceTransition(Pt.current?i+1e6:i),s=!Pt.current&&o,c=bt.current.w!==Bt||bt.current.h!==Ht,u=vt.current||o||c,h=r.consumeStylePaintPending();let d=!1;const f=r.getLastUpdateResult(),y=mn.current.beforeCompute(f,s);!u||s&&!c||(r.computeScene({width:Bt,height:Ht}),bt.current={w:Bt,h:Ht},d=!0,$n()),mn.current.afterCompute(y,d,c);const p=function(e,t,n,r){const i=r.current,o=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!o&&e.hasActivePulsesAt(t),a=!(n||o||!s&&!i)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(r,i,d,wt),g=Bo(),m=pn.current.resolve(e);hn.current=m.primary;const x=Nn(Je,r.lastIngestTime>0?i-r.lastIngestTime:0),v=Je&&x.isStale;if(u||h||p.changed){const t=Yo(e,Rt,Yt,g);if(t){if(t.clearRect(-Yt.left,-Yt.top,Rt[0],Rt[1]),Je&&1>x.alpha&&(t.globalAlpha=x.alpha),Wi(t,{background:Y,hasBackgroundGraphics:!!We,themeBackground:m.background,x:-Yt.left,y:-Yt.top,width:Rt[0],height:Rt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Bt,Ht),t.clip()),Oe&&r.scales)for(const e of Oe)t.save(),e(t,r.scene,r.scales,{width:Bt,height:Ht}),t.restore();const e=yt?bs.custom:bs[n];if(e&&r.scales)for(const n of e)n(t,r.scene,r.scales,{width:Bt,height:Ht});t.restore(),Je&&1>x.alpha&&(t.globalAlpha=1)}}const b=!!(qt&&sn.current&&r.scales),k=!!(an.current&&Array.isArray(ve)&&ve.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||gn.current){const e=Yo(t,Rt,Yt,g);if(e&&(e.clearRect(-Yt.left,-Yt.top,Rt[0],Rt[1]),b&&sn.current&&function(e,t,n,r,i,o,s){if(!1===i.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof i.crosshair?i.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(l?c:t.x,0),e.lineTo(l?c:t.x,r),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=i.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}(o)||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,sn.current,Bt,Ht,"object"==typeof qt?qt:{},an.current,m),k&&an.current&&Array.isArray(ve))){const t=ve.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,i){if(!n)return;const o="group"in n?n.group:void 0;if(void 0!==o)for(const n of t){if("line"!==n.type)continue;if(n.group!==o)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||i.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,r.scene,an.current,t,m)}gn.current=w}u&&e&&e.setAttribute("aria-label",Qi(r.scene,n+" chart"));const A=vt.current;if(vt.current=A&&s&&!d,A&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!en||e(en.x.domain()[0])!==e(r.scales.x.domain()[0])||e(en.x.domain()[1])!==e(r.scales.x.domain()[1])||e(en.y.domain()[0])!==e(r.scales.y.domain()[0])||e(en.y.domain()[1])!==e(r.scales.y.domain()[1])||en.x.range()[0]!==r.scales.x.range()[0]||en.x.range()[1]!==r.scales.x.range()[1]||en.y.range()[0]!==r.scales.y.range()[0]||en.y.range()[1]!==r.scales.y.range()[1])&&tn(r.scales),ot){const e=r.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Pn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Tn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((Me&&Me.length>0||yt)&&(d||s))||!d&&33>i-Zt.current||(Qt(e=>e+1),Zt.current=i),Je?.showBadge&&wn(!!v),(s||null!=r.activeTransition||p.pending)&&Ft()},Ei({hydrated:St,wasHydratingFromSSR:Mt,storeRef:In,dirtyRef:vt,renderFnRef:Wt,cancelRender:Ot,cleanup:()=>Wn.current?.clear()}),(0,h.useEffect)(()=>{vt.current=!0,Ft()},[n,Bt,Ht,ce,Y,We,B,Oe,Ft]),Dn(Je,In,vt,Ft,kn,wn);const nr=(0,h.useMemo)(()=>{if(ye||me)return;const e=In.current;return e?.xIsDate&&en?Vo(en.x.domain()):void 0},[ye,me,en]),rr=ye||me||nr,ir=qt&&cn?be?be(cn):(0,Ss.jsx)(As,{hover:cn}):null,or=ir?(0,Ss.jsx)(Eo,{x:cn.x,y:cn.y,containerWidth:Bt,containerHeight:Ht,margin:Yt,className:"stream-frame-tooltip",children:ir}):null,sr=Kn.current,ar=(0,Ss.jsx)(bo,{active:Un.current>=0,hoverPoint:cn,margin:Yt,size:Rt,shape:sr?.shape,width:sr?.w,height:sr?.h}),lr=Xo(a,T,"__semiotic_resolvedX","__semiotic_resolvedTime"),cr=Xo(l,M,"__semiotic_resolvedY","__semiotic_resolvedValue"),ur=lr.key,hr=cr.key,dr=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let i=!1;const o=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),o=t.fn&&t.key&&!(t.key in n);if(!r&&!o)return n;i=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),o&&(s[t.key]=t.fn(n)),s});return i?o:r}}(lr,cr,Me&&Me.length>0||!1);if(_i||!St&&Mt){const e=In.current;e&&i&&(e.ingest({inserts:Xt,bounded:!0}),e.computeScene({width:Bt,height:Ht}));const t=e?.scene??[],n=e?.scales??null,r=nn(Fe,n),o=nn(We,n),s=rr||(()=>{if(e?.xIsDate&&n)return Vo(n.x.domain())})();return(0,Ss.jsxs)("div",{ref:jt,className:"stream-xy-frame"+(O?" "+O:""),role:"img","aria-label":ut||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:$?"100%":Rt[0],height:W?"100%":Rt[1]},children:[(0,Ss.jsx)(po,{summary:ht}),(0,Ss.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Rt[0],height:Rt[1],style:{position:"absolute",left:0,top:0},children:[(0,Ss.jsx)("g",{transform:`translate(${Yt.left},${Yt.top})`,children:o}),(0,Ss.jsxs)("g",{transform:`translate(${Yt.left},${Yt.top})`,children:[Y&&(0,Ss.jsx)("rect",{x:0,y:0,width:Bt,height:Ht,fill:Y}),Be&&n&&Be.map((e,r)=>(0,Ss.jsx)(u.Fragment,{children:e(t,n,{width:Bt,height:Ht})},"svgpre-"+r)),t.map((e,t)=>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(0,ki.jsx)("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 i=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,ki.jsxs)("g",{children:[(0,ki.jsx)("defs",{children:(0,ki.jsx)("clipPath",{id:e,children:(0,ki.jsx)("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})}),(0,ki.jsx)("path",{d:i,fill:Ai(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return(0,ki.jsx)("path",{d:i,fill:Ai(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+t)}case"point":{const n=e;return(0,ki.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:Ai(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+t)}case"symbol":return function(e,t){const n=Ue(e.symbolType,e.size,e.path);return(0,ki.jsx)("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?Ai(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return Si(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const n=e;return(0,ki.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Ai(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.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,i,o]=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*i+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,ki.jsxs)("g",{children:[(0,ki.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,ki.jsx)("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(0,ki.jsx)("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),i=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return(0,ki.jsxs)("g",{children:[(0,ki.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,ki.jsx)("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:i,fill:o,stroke:o,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,xt)).filter(Boolean)]})]}),(0,Ss.jsx)(xi,{width:Bt,height:Ht,totalWidth:Rt[0],totalHeight:Rt[1],margin:Yt,scales:n,showAxes:ce,axes:ue,xLabel:he,yLabel:de,yLabelRight:fe,xFormat:s,yFormat:pe||xe,axisExtent:ge,showGrid:je,title:He,legend:Re,legendHoverBehavior:Te,legendClickBehavior:Le,legendHighlightedCategory:Ee,legendIsolatedCategories:Ne,legendPosition:De,legendLayout:Ie,foregroundGraphics:Ct(r,Lt(In.current?.customLayoutOverlays,mt??null)),marginalGraphics:ot,xValues:[],yValues:[],annotations:Me,autoPlaceAnnotations:Ce,svgAnnotationRules:Pe,annotationFrame:0,xAccessor:ur,yAccessor:hr,annotationData:dr(e?.getData()),pointNodes:Uo(e?.scene),curve:"string"==typeof x?x:void 0,linkedCrosshairName:dt,linkedCrosshairSourceId:ft})]})}return(0,Ss.jsxs)("div",{ref:jt,className:"stream-xy-frame"+(O?" "+O:""),role:"group","aria-label":ut||("string"==typeof He?He:"XY chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Rt[0],height:W?"100%":Rt[1],overflow:"visible",touchAction:Cs(qe)},onKeyDown:Zn,children:[ct&&(0,Ss.jsx)(go,{tableId:zt}),ct&&(0,Ss.jsx)(fo,{scene:In.current?.scene??[],chartType:n+" chart",tableId:zt,chartTitle:"string"==typeof He?He:void 0}),(0,Ss.jsx)(po,{summary:ht}),(0,Ss.jsx)(mo,{hoverPoint:cn}),(0,Ss.jsxs)("div",{role:"img","aria-label":ut||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:qt?Jn:void 0,onMouseMove:qt?er:void 0,onPointerLeave:qt?qn:void 0,onMouseLeave:qt?qn:void 0,onPointerDown:qt||we?tr:void 0,onClick:we?Vn:void 0,children:[on&&(0,Ss.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:Rt[0],height:Rt[1],pointerEvents:"none"},children:(0,Ss.jsx)("g",{transform:`translate(${Yt.left},${Yt.top})`,children:on})}),(0,Ss.jsx)(pi,{width:Bt,height:Ht,totalWidth:Rt[0],totalHeight:Rt[1],margin:Yt,scales:en,showAxes:ce,axes:ue,showGrid:je,xFormat:rr,yFormat:pe||xe,axisExtent:ge}),(0,Ss.jsx)("canvas",{ref:Gt,"aria-label":Qi(In.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Ss.jsx)("canvas",{ref:Ut,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Ss.jsx)(xi,{width:Bt,height:Ht,totalWidth:Rt[0],totalHeight:Rt[1],margin:Yt,scales:en,showAxes:ce,axes:ue,xLabel:he,yLabel:de,yLabelRight:fe,xFormat:rr,yFormat:pe||xe,axisExtent:ge,showGrid:je,title:He,legend:Re,legendHoverBehavior:Te,legendClickBehavior:Le,legendHighlightedCategory:Ee,legendIsolatedCategories:Ne,legendPosition:De,legendLayout:Ie,foregroundGraphics:Ct(rn,Lt(In.current?.customLayoutOverlays,mt??null)),marginalGraphics:ot,xValues:An,yValues:jn,annotations:Me,autoPlaceAnnotations:Ce,svgAnnotationRules:Pe,annotationFrame:Kt,xAccessor:ur,yAccessor:hr,annotationData:dr(In.current?.getData()),pointNodes:Uo(In.current?.scene),curve:"string"==typeof x?x:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==Y&&!We,linkedCrosshairName:dt,linkedCrosshairSourceId:ft}),(qe||Ge)&&(0,Ss.jsx)(b,{width:Bt,height:Ht,totalWidth:Rt[0],totalHeight:Rt[1],margin:Yt,dimension:qe?.dimension??"xy",scales:en,onBrush:Ge??(()=>{}),binSize:_,snap:qe?.snap,binBoundaries:qe?.binBoundaries??("bar"===n?In.current?.getBinBoundaries():void 0),snapDuring:qe?.snapDuring,streaming:"streaming"===r}),Je?.showBadge&&(0,Ss.jsx)(zn,{isStale:kn,position:Je.badgePosition}),ar,or]})]})}));Ps.displayName="StreamXYFrame";var js=Ps,Rs=require("react"),Ts={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ls={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Es=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){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,r){for(let i=0;this.capacity>i;i++){const o=this.particles[i];if(!o.active)continue;const s=n[o.edgeIndex];s&&s.bezier?(o.t+=e*t*(r?r[o.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>o.t?Ns(s.bezier,o.t,o.offset,o):(o.active=!1,this._freeIndices.push(i))):(o.active=!1,this._freeIndices.push(i))}}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 Ns(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,i){const o=e.length,s=t*o,a=Math.min(Math.floor(s),o-1),l=s-a,[c,u,h,d]=e[a];Ds(c,u,h,d,l,i);const f=d.x-c.x,y=d.y-c.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;i.x+=-y/p*n*r*2,i.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[i,o,s,a]=e.points;Ds(i,o,s,a,t,r);const l=a.x-i.x,c=a.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function Ds(e,t,n,r,i,o){const s=1-i,a=s*s,l=a*s,c=i*i,u=c*i;o.x=l*e.x+3*a*i*t.x+3*s*c*n.x+u*r.x,o.y=l*e.y+3*a*i*t.y+3*s*c*n.y+u*r.y}function Is(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function zs(e,t){var n,r=[],i=[],o=[],s={},a=[];function l(e){o[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],o[t]&&l(t)})}function c(e){var t,r,h=!1;for(i.push(e),o[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,i),h=!0):o[r]||(h=c(r));if(h)l(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 i.pop(),h}function u(e,n){var i=[].concat(n).concat(e);t?t(i):r.push(i)}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),i=Array(t),o=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,i[l]=!1,o[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,i[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>o[t]){for(var y=o[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}o[t]=y}else{if(r[t]===n[t]){var g=[],m=[],x=0;for(y=l.length-1;y>=0;--y){var v=l[y];if(i[v]=!1,g.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===t){l.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];d.push(b)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var y=d[l];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&c.push(y[p]);d[l]=c}}return{components:h,adjacencyList:d}}(e),i=r.components.filter(function(e){return e.length>1}),o=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)o>i[s][a]&&(o=i[s][a],n=s);var l=i[n];return!!l&&{leastVertex:o,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.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];o[+g]=!1,s[g]={}}c(n),n+=1}else n=d}return t?void 0:r}function $s(e){return e.y0-e.y1>0?"up":"down"}function Ws(e,t){return t(e.source)==t(e.target)}function Fs(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 Os(e){return e.target.x0-e.source.x1}function Ys(e,t){var n=Hs(e),r=Os(t)/Math.tan(n);return"up"==$s(e)?e.y1-r:e.y1+r}function Bs(e,t){var n=Hs(e),r=Os(t)/Math.tan(n);return"up"==$s(e)?e.y1+r:e.y1-r}function Hs(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Xs(e,t){return t(e)}function qs(e){return Vs(e.source)}function Gs(e){return Vs(e.target)}function Vs(e){return(e.y0+e.y1)/2}function Us(e){return e.virtual?0:e.value}function Ks(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Ws(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!Ws(e,t)?r+1:r}),n+r}function Qs(e){return e.target.depth}function Zs(e,t){return e.sourceLinks.length?e.depth:t-1}function Js(e,t){return e.y0-t.y0}function ea(e,t){return t.y0-e.y0}function ta(e,t){return e.y1-t.y1}function na(e,t){return t.y1-e.y1}function ra(e,t){return oa(e.source,t.source)||e.index-t.index}function ia(e,t){return oa(e.target,t.target)||e.index-t.index}function oa(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function sa(e,t){return aa(e)==aa(t)?"bottom"==e.circularLinkType?ea(e,t):Js(e,t):aa(t)-aa(e)}function aa(e){return e.target.column-e.source.column}function la(e,t){return ca(e)==ca(t)}function ca(e){return e.y0-e.y1>0?"up":"down"}var ua=require("d3-array");function ha(e,t,n,r,i){let o=e;var s=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,ua.min)(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=o.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),da(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),da(o.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),o.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,Ws(e,t)&&Fs(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+i+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-i-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,l=e.circularLinkType,c=o.links.filter(function(e){return e.source.column==s&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?ea:Js);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=o.links.filter(function(e){return e.target.column==s&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?na:ta),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+i+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-i-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,i=e.y1,o=(t+r)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(e)}),o}function da(e,t,n){e.sort(sa);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Ws(e,t)&&Fs(e))e.circularPathData.verticalBuffer=o+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&&fa(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=l>o?l:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function fa(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var ya=require("d3-array");function pa(e){return function(){return e}}function ga(e){return e.index}function ma(e){return e.nodes}function xa(e){return e.links}function va(e,t,n){var r=(0,ya.groups)(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(i,o){var s=i.length;if(t)i.sort(t);else if(o>0){var a=new Map;i.forEach(function(e,t){var n,r,i,o=(r=0,i=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Vs(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Vs(e.target)*t,r+=t}}),r>0?i/r:NaN);a.set(e,{bc:o,idx:t})}),i.sort(function(e,t){var n=a.get(e),r=a.get(t),i=n.bc,o=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(i)||isNaN(o)?isNaN(i)?isNaN(o)?n.idx-r.idx:1:-1:i-o})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Ks(t,n)-Ks(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){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==Ks(t,n)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function ba(e,t,n,r,i,o){var s=(0,ya.groups)(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,l=o;l>0;--l)c(a*=.99,n),u();function c(t,n){var r=s.length;s.forEach(function(i){var o=i.length,s=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ks(i,n)>0){var l=(0,ya.mean)(i.sourceLinks,Gs),c=(0,ya.mean)(i.targetLinks,qs),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-Vs(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==o)i.y0=e.y1/2-(a=i.y1-i.y0)/2,i.y1=e.y1/2+a/2;else if(s==r-1&&1==o)i.y0=e.y1/2-(a=i.y1-i.y0)/2,i.y1=e.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var d=(0,ya.mean)(i.sourceLinks,Gs),f=(0,ya.mean)(i.targetLinks,qs),y=((d&&f?(d+f)/2:d||f)-Vs(i))*t;i.y0+=y,i.y1+=y}})})}function u(){s.forEach(function(n){var o,s,a,l=e.y0,c=n.length;for(n.sort(t||oa),a=0;c>a;++a)(s=l-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),l=o.y1+r;if((s=l-r-e.y1)>0)for(l=o.y0-=s,o.y1-=s,a=c-2;a>=0;--a)(s=(o=n[a]).y1+i-l)>0&&(o.y0-=s,o.y1-=s),l=o.y0})}}function ka(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ia),e.targetLinks.sort(ra)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,i=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=i-e.width/2,i-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function wa(){var e=0,t=0,n=1,r=1,i=24,o=8,s=null,a=ga,l=Zs,c=void 0,u=32,h=2,d=ma,f=xa;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(0,ya.group)(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,i=e.target;"object"!=typeof r&&(r=e.source=Is(n,r)),"object"!=typeof i&&(i=e.target=Is(n,i)),r.sourceLinks.push(e),i.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],i=0;e.links.length>i;i++){var o=e.links[i],s=o.source.index,a=o.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=zs(r);l.sort(function(e,t){return e.length-t.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[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,c),function(e,t){var n=0,r=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:r>n?"top":"bottom","top"==i.circularLinkType?n++:r++,e.nodes.forEach(function(e){Xs(e,t)!=Xs(i.source,t)&&Xs(e,t)!=Xs(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Ws(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,ya.sum)(e.sourceLinks,Us),(0,ya.sum)(e.targetLinks,Us)),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,i,o;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,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(r=e.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(d,c,l);var f=o;if(null!==s){var y=(0,ya.groups)(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=(0,ya.max)(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=(0,ya.groups)(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 i=(0,ya.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,ya.sum)(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var o=(0,ya.max)(e.nodes,function(e){return e.column});e.nodes.forEach(o>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/o),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,i),va(d,c,a),ba(d,c,a,f,f,u),ka(d),ha(d,a,h,10,8),va(d,c,a),ba(d,c,a,f,f,u),ka(d),ha(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 Xs(n.source,t)==Xs(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!la(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Ys(t,e);return e.y1-n}if(t.target.column>e.target.column)return Ys(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 o=e.y0;r.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;i>o;o++)s+=r[o].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 Xs(n.target,t)==Xs(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!la(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Bs(t,e);return e.y0-n}if(t.source.column>e.source.column)return Bs(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 o=e.y0;r.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;i>o;o++)s+=r[o].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==r||0==i){let r=function(t){return(t-o)/(s-o)*(e.y1-e.y0)+e.y0};var o=(0,ya.min)(t,function(e){return e.y0}),s=(0,ya.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-o);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),ha(d,a,h,10,8)}(y),y}return y.update=function(e){return ka(e),ha(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(o=+e,y):o},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:pa(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:pa(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:pa(e),y):a},y.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:pa(e),y):l},y.nodeSort=function(e){return arguments.length?(c=e,y):c},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(i){return arguments.length?(e=+i[0][0],t=+i[0][1],n=+i[1][0],r=+i[1][1],y):[[e,t],[n,r]]},y.size=function(i){return arguments.length?(e=t=0,n=+i[0],r=+i[1],y):[n-e,r-t]},y}var Aa=require("d3-interpolate");require("d3-shape");var Sa=e=>{let t,n,r,i,o,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,o=e.source.x1,s=e.target.x0,a=(0,Aa.interpolateNumber)(o,s),l=a(.5),c=a(.5),`M${t},${o}C${t},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${i},${l} ${i},${o}Z`;const u=e.sankeyWidth/2,h=(0,Aa.interpolateNumber)(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:i,tTop:o,tBot:s,cp1X:a,cp2X:l}=e,c=(n+r)/2,u=(o+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${o} ${i},${o}`,`L${i},${s}`,`C${l},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:i,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 _a(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,i=r.sourceY,o=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))),l=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${n},${i-t}L${n+a},${i-t}L${n+a},${i+t}L${n},${i+t}ZM${o},${s-t}L${o-l},${s-t}L${o-l},${s+t}L${o},${s+t}Z`}const i=r.sourceX,o=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${i},${o-h*t}L${l},${o-h*t}L${l+n},${o-h*t+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*t+h*d}L${c-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${c+n},${a+h*t}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${o+h*t}L${i},${o+h*t}Z`}var Ma=new Set,Ca=new WeakMap;function Pa(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Ca.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Ca.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}`;Ma.has(e)||(Ma.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 ja={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(Qs))-1:0},justify:Zs};function Ra(e){return"string"==typeof e?e:e.id}var Ta={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const i="vertical"===n.orientation?"down":"right",o=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=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"===i?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=wa().extent(h).links(u).nodes(c).nodeAlign(ja[o]||Zs).nodeId(e=>e.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,i=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>i&&(i=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>o.leftFullExtent-s&&(e=o.leftFullExtent-s),o.rightFullExtent+s>t&&(t=o.rightFullExtent+s),n>o.verticalFullExtent-s&&(n=o.verticalFullExtent-s),o.verticalFullExtent+s>i&&(i=o.verticalFullExtent+s)}const o=t-e,s=i-n,a=r[0],l=r[1];if(o>0&&s>0&&(0>e||0>n||t>a||i>l)){const t=Math.min(a/o,l/s),r=-e*t+(a-o*t)/2,i=-n*t+(l-s*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of u)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,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+i,n.targetY=n.targetY*t+i,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+i,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+i,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 c){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=Ra(e.source),n=Ra(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=i;const o=f.get(t),s=f.get(n);o&&(r.source=o),s&&(r.target=s)}}},buildScene(e,t,n,r){const i="vertical"===n.orientation?"down":"right",o=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.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=o?o(Pa(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"===i?{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 i=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";i="function"==typeof l?l(e)||i:"target"===l?y.get(r.id)||u.get(r.id)||i:y.get(t.id)||u.get(t.id)||i;const o=s?s(Pa(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))),l=o.fill||i;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:l,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.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:l,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?_a(e):Sa(e),c)&&d.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:o.fill||i,fillOpacity:o.fillOpacity??a,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.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,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=t?t(n):n.id;if(!s)continue;let a,l,c;"down"===i?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+o/2),f.push({x:a,y:l,text:s+"",anchor:"down"===i?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}},La=require("d3-force"),Ea=require("d3-scale"),Na={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const i=n.forceStrength??.1,o=r[0]/2,s=r[1]/2,a=n.__previousPositions;let l=0;const c=[];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?l++:n?(t.x=n.x,t.y=n.y,l++):c.push(t)}const u=l>0&&.3>=(e.length>0?c.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of c){const r=Da(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 i=Ia(e.id),o=i%360*(Math.PI/180),s=10+i%20;e.x=t/r.length+s*Math.cos(o),e.y=n/r.length+s*Math.sin(o)}else{const t=Ia(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=o+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),i=n*t;r.x=o+e*Math.cos(i),r.y=s+e*Math.sin(i)}}}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=za(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const n=new Map,r=new Map;for(const t of e)n.set(t.id,0),r.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(r,(n.get(r)??0)+1)}const a=(0,La.forceLink)().strength(e=>{const t=e.weight,r="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(n.get("string"==typeof e.source?e.source:e.source.id)??1,n.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*i/(.1*o))}).distance(e=>{const t="string"==typeof e.source?r.get(e.source):e.source,n="string"==typeof e.target?r.get(e.target):e.target,i=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,i)}).id(e=>e.id),l=(0,La.forceSimulation)().force("charge",(0,La.forceManyBody)().strength(e=>{const t=n.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,La.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,La.forceCenter)(o,s).strength(.8)).force("x",(0,La.forceX)(o).strength(.06)).force("y",(0,La.forceY)(s).strength(.06));if(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}));a.links(e),l.force("link",a)}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 i=n.nodeStyle,o=n.edgeStyle,s=za(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,l=new Map;e.forEach((e,t)=>{l.set(e.id,a[t%a.length])});const c=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Pa(t,"nodeSize")),r=i?i(Pa(t,"nodeStyle")):{},o={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,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 i=o?o(Pa(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:i.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:i.strokeWidth??1,opacity:i.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(Pa(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function Da(e,t,n){const r=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,o="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=o:o===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 Ia(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 za(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],i=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>r[0];const[o,s]=Jn(i);if(o===s)return()=>(r[0]+r[1])/2;const a=(0,Ea.scaleLinear)().domain([o,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}var $a=require("d3-chord"),Wa=require("d3-shape"),Fa=K,Oa={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-o,c=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 i=h(e);p[n][r]=i}const g=(0,$a.chord)().padAngle(i);s&&g.sortGroups(s);const m=g(p),x=m.groups,v=(0,Wa.arc)().innerRadius(l).outerRadius(a);for(const t of x){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,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,i=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);i&&(i.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:i=20,edgeOpacity:o=.5}=n,s=Math.min(r[0],r[1])/2,a=s-i,l=r[0]/2,c=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:Fa,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=(0,$a.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let i;i=u?u(Pa(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const o=u?u(Pa(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:i,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.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 i=Ya(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(Pa(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(Pa(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:i,style:{fill:s,fillOpacity:a.fillOpacity??o,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const i=t?t(n):n.id;if(!i)continue;const o=(e.startAngle+e.endAngle)/2,s=o-Math.PI/2;x.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Ya(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const i=[];let o=0;for(;r.length>o;){const e=r[o];if("M"===e||"L"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("C"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;3>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("Q"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;2>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("A"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&(i.push(Number(r[o])+t+""),o++),r.length>o&&(i.push(Number(r[o])+n+""),o++);else"Z"===e||"z"===e?(i.push(e),o++):(i.push(r[o]),o++)}return i.join(" ")}var Ba=require("d3-hierarchy"),Ha=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xa(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 qa(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 Ga(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 Va(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ha}function Ua(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 Ka(e,t,n,r,i){if("horizontal"===i){const i=(e+n)/2;return`M ${e},${t} C ${i},${t} ${i},${r} ${n},${r}`}if("radial"===i){const i=(e+n)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+r)/2} T ${n},${r}`}{const i=(t+r)/2;return`M ${e},${t} C ${e},${i} ${n},${i} ${n},${r}`}}var Qa={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const i=n.__hierarchyRoot;if(!i)return;const o=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,c=(0,Ba.hierarchy)(i,s);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(o){case"tree":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=(0,Ba.tree)();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(c,n,u,h);break;case"cluster":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=(0,Ba.cluster)();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(c,n,u,h);break;case"treemap":!function(e,t,n,r){const i=t.padding??4,o=t.paddingTop??0,s=(0,Ba.treemap)().size([n,r]).tile(Ba.treemapBinary).padding(i);o>0&&s.paddingTop(o),s(e)}(c,n,u,h);break;case"circlepack":!function(e,t,n,r){const i=t.padding??4;(0,Ba.pack)().size([n,r]).padding(i)(e)}(c,n,u,h);break;case"partition":!function(e,t,n,r){(0,Ba.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,h)}const d=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],i={id:qa(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"===o||"cluster"===o?Za(i,r,n):"treemap"===o||"partition"===o?Ja(i,r):"circlepack"===o&&el(i,r),i.__hierarchyNode=r,e.push(i),f.set(r,i)}if("tree"===o||"cluster"===o)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 i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,i,o){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,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 o=i(Pa(t,"nodeStyle"));let a=o.fill||Ua(n);if(n.colorByDepth&&void 0!==t.depth){const e=Va(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.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 i=t.x,s=t.y,l=r.x,f=r.y;u&&(i+=h,s+=d,l+=h,f+=d);const y=Ka(i,s,l,f,c),g=o(Pa(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=Ga(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,i,o,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,i=a+t/n*10,o=0>e?"end":"start"):(r=s,i=a-12,o="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,o="end"):(r=s+f+6,o="start"),i=a):(r=s,i=a+f+14,o="middle");l.push({x:r,y:i,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(e,t,n,r,i,o);case"treemap":case"partition":return function(e,t,n,r){const i=[],o=[];for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=r(Pa(n,"nodeStyle"));let a=s.fill||Ua(t);if(t.colorByDepth&&void 0!==n.depth){const e=Va(t);a=e[n.depth%e.length]}i.push({type:"rect",x:n.x0,y:n.y0,w:e,h:o,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=Ga(t.nodeLabel),i=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,l=a.y1-a.y0;if(0>=e||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===i&&!c)continue;if("parent"===i&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let h=r(Pa(a,"nodeStyle")).fill||Ua(t);if(t.colorByDepth&&void 0!==a.depth){const e=Va(t);h=e[a.depth%e.length]}const d="string"==typeof h?Xa(h):t.themeSemantic?.text??"#000";o.push(c?{x:a.x0+e/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/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:i,sceneEdges:[],labels:o}}(e,n,0,i);case"circlepack":return function(e,t,n,r){const i=[],o=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const o=r(Pa(n,"nodeStyle"));let s=o.fill||Ua(t);if(t.colorByDepth&&void 0!==n.depth){const e=Va(t);s=e[n.depth%e.length]}i.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:o.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ga(t.nodeLabel);for(const i of e){const e=i.__radius??5,s=n?n(i):i.id;if(!s)continue;if(15>e)continue;const a=!(i.data?.children&&i.data.children.length>0);let l=r(Pa(i,"nodeStyle")).fill||Ua(t);if(t.colorByDepth&&void 0!==i.depth){const e=Va(t);l=e[i.depth%e.length]}if(a){const n="string"==typeof l?Xa(l):t.themeSemantic?.text??"#000";o.push({x:i.x,y:i.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else o.push({x:i.x,y:i.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:i,sceneEdges:[],labels:o}}(e,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Za(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 Ja(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 el(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}var tl=require("d3-shape");function nl(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rl={sankey:Ta,force:Na,chord:Oa,tree:Qa,cluster:Qa,treemap:Qa,circlepack:Qa,partition:Qa,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const i=n.__hierarchyRoot;i&&function(e,t,n,r,i){const o=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),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=nl(n);d.metaMap.clear(),r.length=0,i.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,x=y(s(e));r.push({id:x,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(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,p,g){const m=o(t);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=a[Math.min(k,a.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=a[Math.min(x,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:n,depth:p,data:t,parentId:n},_=g?f/u(S)*A:f*A,M=(0,tl.pie)().value(e=>{const t=o(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const o=(M[t].startAngle+M[t].endAngle)/2,a=k[t],u=y(s(a)),h=l+_*Math.sin(o),f=c+_*Math.cos(o)*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:o,depth:p,parentId:n,eccentricity:C}),i.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,x,p,g,m,1,!1)}(i,r,n,e,t)},buildScene(e,t,n,r){const i=n.nodeStyle,o=n.nodeSize,s="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=nl(n),r=new Map;for(const t of e)r.set(t.id,t);const i=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}`;i.has(n)||i.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of i)for(let i=0;o>i;i++){const a=i/o*Math.PI*2,c=(i+1)/o*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Pa(t,"nodeSize")),r=i?i(Pa(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&&l.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(Pa(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(e,t,n,r,i)=>!1!==n.orbitAnimated&&(function(e,t){const n=nl(t),r=t.orbitSpeed??.25,i=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),o=(("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 l=e.angle+o*s*i({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function il(e){return rl[e]}function ol(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&fe(n,e)||"#4e79a7":t=>{if(n){const e=fe(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 sl=require("d3-quadtree");function al(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 ll(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(!cl(e))return!1;return!0}return cl(t.points)}function cl(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}var ul=require("d3-interpolate");var hl="rgba(34, 197, 94, 0.7)",dl=2e3,fl=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.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._stylePaintPending=!1,this.config=e,this.tensionConfig={...Ts,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Es(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(e.layoutSelection=t.layoutSelection),this.config=e,this.tensionConfig={...Ts,...e.tensionConfig},!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new Es(2e3))}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}ingestBounded(e,t,n,r){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,l="function"==typeof i?i:e=>e[i],c="function"==typeof o?o:e=>e[o],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=l(t)+"";this.nodes.set(e,{...al(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",i=u(n)+"",o=h(n),s=null==o?NaN:Number(o),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...al(r),data:n}),this.nodes.has(i)||this.nodes.set(i,{...al(i),data:n});const l=`${r}\0${i}\0${e}`,d={source:r,target:i,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&ll(n.bezier)&&(d.bezier=n.bezier),this.edges.set(l,d)}r?.deferLayout||this.runLayout(n)}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,i=0===this.nodes.size;let o=!1;const s=me();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,al(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,al(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,o=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!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,o=!0),i||o||c||this.tension>=this.tensionConfig.threshold}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=il(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 i=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||i.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=i,this.saveTargetPositions();const o=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:me(),duration:s}}else o&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:me(),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=me()),this.previousNodeIds=e,this.previousEdgeKeys=t}setLayoutSelection(e){this.config.layoutSelection=e}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const e of this.sceneNodes)this._baseStyles.set(e,e.style);for(const e of this.sceneEdges)this._baseStyles.set(e,e.style)}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){if(this._customRestyle){const t=this._customRestyle;for(const n of this.sceneNodes){const r=this._baseStyles.get(n)??n.style,i=t(n,e);n.style=i?{...r,...i}:r}}if(this._customRestyleEdge){const t=this._customRestyleEdge;for(const n of this.sceneEdges){const r=this._baseStyles.get(n)??n.style,i=t(n,e);n.style=i?{...r,...i}:r}}this._stylePaintPending=!0}buildScene(e){if(this.config.customNetworkLayout){const t=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),r=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=ue[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,K),i={nodes:t,edges:n,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:this.config.themeSemantic??{},categorical:[...r]},resolveColor:ol(r,this.config.colorScheme),config:this.config.layoutConfig??{},selection:this.config.layoutSelection??null};let o;try{o=this.config.customNetworkLayout(i)}catch(e){const t=null!==this.lastCustomLayoutResult,n=rt("network",e,t,this.layoutVersion);this.lastCustomLayoutFailure=n,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e);try{this.config.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return void(t||(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++))}return this.sceneNodes=o.sceneNodes??[],this.sceneEdges=o.sceneEdges??[],this.labels=o.labels??[],this.customLayoutOverlays=o.overlays??null,this.customLayoutHtmlMarks=o.htmlMarks??[],this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=o.restyle,this._customRestyleEdge=o.restyleEdge,this.hasCustomRestyle=!(!o.restyle&&!o.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(this.config.layoutSelection??null)),void et({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=il(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:i,sceneEdges:o,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=i,this.sceneEdges=o,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 i=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[i++]=e);this._nodeQuadtree=(0,sl.quadtree)().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=il(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=il(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,i=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,i,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=pe(e,this.transition),n=ye(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ge(e._prevX0,e._targetX0,n),e.x1=ge(e._prevX1,e._targetX1,n),e.y0=ge(e._prevY0,e._targetY0,n),e.y1=ge(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=ge(e._prevY0,e._targetY0,n),e.y1=ge(e._prevY1,e._targetY1,n),e.sankeyWidth=ge(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,i="string"==typeof e.target?t.get(e.target):e.target;!r||!i||(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 i=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],o=n.x-t.x,s=n.y-t.y;i.push([t,{x:t.x+o/3,y:t.y+s/3},{x:t.x+2*o/3,y:t.y+2*s/3},n])}return{circular:!0,segments:i,halfWidth:t}}(e):function(e,t,n,r=.5){const i=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.x1,s=n.x0,a=(0,ul.interpolateNumber)(o,s);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:i}}const o=t.x1,s=n.x0,a=(0,ul.interpolateNumber)(o,s);return{circular:!1,points:[{x:o,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:i}}(e,r,i,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)",i=t.glowRadius??4,{now:o}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const l=o-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=i)}for(const t of e.sceneEdges){const i=t.datum;if(!i)continue;const s="object"==typeof i.source?i.source?.id:i.source,a="object"==typeof i.target?i.target?.id:i.target;if(!s||!a)continue;const l=e.edgeTimestamps.get(`${s}\0${a}`);if(!l)continue;const c=o-l;n>c&&(t._pulseIntensity=1-c/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 i of e.sceneNodes){const e=i.id;if(!e)continue;const o=r.get(e);if(void 0===o)continue;const s=_e(t,o,n);i.style={...i.style,opacity:(i.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===hl&&(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>=dl)return;const n=1-t/dl;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=hl,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&&dl>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",i=!1!==t.pulse;for(const o of e.sceneNodes){const s=o.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(o.style={...o.style,fill:c},i&&(o._pulseIntensity=.6+.4*Math.sin(e.now/300),o._pulseColor=c,o._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 null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=me(),r}updateEdge(e,t,n){const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,o=[];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){o.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=i(r.data);null!=e&&(r.value=Number(e))}return o.length>0&&(this.layoutVersion++,this.lastIngestTime=me()),o}removeNode(e){if(!this.nodes.has(e))return!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=me(),!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,i]of this.edges)i.data&&r(i.data)===e&&n.push(t)}else for(const[r,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.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=me()),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()}};fl.QUADTREE_THRESHOLD=500;var yl=fl,pl=l(require("react")),gl=require("react/jsx-runtime");function ml(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,labels:s,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,autoPlaceAnnotations:x,svgAnnotationRules:v}=e,b=pl.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=Vt(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,Ke(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]),k=pl.useMemo(()=>m&&x?Kr({annotations:m,context:b,..."object"==typeof x?x:{}}):m,[m,x,b]),w=pl.useMemo(()=>Tr(),[]),A=k?Rr(k.filter(e=>"widget"!==e.type),w,v,b):null,S=!0===k?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,gl.jsxs)(gl.Fragment,{children:[S&&(0,gl.jsx)("style",{children:Ar},"annotation-widget-disclosure-style"),(0,gl.jsxs)("svg",{role:"img",width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,gl.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,gl.jsx)("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),(0,gl.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[s.map((e,t)=>(0,gl.jsx)("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)),A,p]}),a&&"string"==typeof a?(0,gl.jsx)("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,gl.jsx)("foreignObject",{x:0,y:0,width:r,height:o.top,children:a}):null,Kn({legend:l,totalWidth:r,totalHeight:i,margin:o,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),k?.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 i=e.width??32,s=e.height??32;return(0,gl.jsx)("div",{className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0))+(e.dx??0)-i/2,top:o.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0))+(e.dy??-16)-s/2,width:i,height:s,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:e.content??(0,gl.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"})},"widget-"+t)})]})}ml.displayName="NetworkSVGOverlay";var xl=l(require("react")),vl=require("react/jsx-runtime"),bl={position:"absolute",top:0,left:0,pointerEvents:"none"};function kl({marks:e,margin:t,selection:n=null,overscan:r=400}){const i=xl.useRef(null),o=function(e,t,n){const[r,i]=xl.useState(null);return xl.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 i(null);let r=0;const o=()=>{r=0;const t=n.getBoundingClientRect(),o=e.getBoundingClientRect();i(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:o.left,originY:o.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(o))};o(),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]),xl.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:i,originY:o}=r,s=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=i+e.x,n=o+e.y;return!(s>t+e.width||t>a||l>n+e.height||n>c)})},[e,r,n])}(e,i,r);if(!e||0===e.length)return null;const s=(0,vl.jsx)("div",{className:"semiotic-network-html-marks",ref:i,style:{...bl,transform:`translate(${t.left}px, ${t.top}px)`},children:(o??e).map(e=>(0,vl.jsx)("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?(0,vl.jsx)(Tt,{value:n,children:s}):s}var wl=require("react/jsx-runtime"),Al=("undefined"!=typeof process&&process,{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"}),Sl={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function _l(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,wl.jsx)("div",{style:{...Al,width:t,height:n},children:r||"No data available"}):null}function Ml(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,wl.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*i))),s=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(o+s)-s))/2);return(0,wl.jsx)("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:i},(e,n)=>(0,wl.jsx)("div",{className:"semiotic-loading-bar",style:{...Sl,position:"absolute",top:a+n*(o+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2}},n))})}var Cl={};function Pl(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function jl(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Rl=class{constructor(e=function(){const e="string"==typeof Cl.url&&Cl.url?new URL("./forceLayoutWorker.js",Cl.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(jl());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,i)=>{const o=()=>{this.pending.delete(n),t?.removeEventListener("abort",o),i(jl())},s=()=>t?.removeEventListener("abort",o);this.pending.set(n,{cleanup:s,reject:i,resolve:e}),t?.addEventListener("abort",o,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),i(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()}},Tl=null;var Ll=require("react/jsx-runtime"),El=/^(value|amount|total|count|weight|score)$/i;function Nl({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,Ll.jsxs)("div",{className:"semiotic-tooltip",style:To,children:[(0,Ll.jsxs)("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&&(0,Ll.jsxs)("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 i=e.length-1;return(0,Ll.jsxs)("div",{className:"semiotic-tooltip",style:To,children:[(0,Ll.jsx)("div",{children:e.map((e,t)=>(0,Ll.jsxs)("span",{children:[t>0&&(0,Ll.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===i?(0,Ll.jsx)("strong",{children:e}):(0,Ll.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,Ll.jsx)("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),i=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),o=Ro(t.data??t),s=null!=o.title?o.title+"":t.id,a=o.entries.some(e=>El.test(e.key));return(0,Ll.jsxs)("div",{className:"semiotic-tooltip",style:To,children:[(0,Ll.jsx)("div",{style:{fontWeight:600},children:s}),o.entries.map(e=>{return(0,Ll.jsxs)("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&&(0,Ll.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,Ll.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,i!==r&&` (weighted: ${i.toLocaleString()})`]})]})}function Dl(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Il(e,t){if(!t.pathD)return;e.save();const n=Dl(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),i=t.style.fillOpacity??t.style.opacity??.5,o="string"==typeof t.style.fill?t.style.fill:"#999",s=rn(e,o)||o;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rn(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 zl(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=rn(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 $l(e,t){if(!t.pathD)return;e.save();const n=Dl(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rn(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 Wl(e,t){if(!t.pathD)return;e.save();const n=Dl(t),r=t.style.stroke||"#999";e.strokeStyle=rn(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="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}Nl.ownsChrome=!0;var Fl=new Map;function Ol(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Fl.get(t);return n||(n=new Path2D(Ue(e.symbolType,e.size)),Fl.size>256&&Fl.clear(),Fl.set(t,n)),n}catch{return null}}function Yl(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:i}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const o=Array.isArray(i)?i:he,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,o[e%o.length])}return s.length}function Bl(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const i=t-e.cx,o=n-e.cy,s=Math.sqrt(i*i+o*o);return s>zt(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=It(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,i=n-e.cy,o=Math.sqrt(r*r+i*i);if(e.innerR-2>o||o>e.outerR+2)return null;const s=Ft(Math.atan2(i,r)),a=Ft(e.startAngle),l=Ft(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=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 i=t-e.cx,o=n-e.cy,s=Math.sqrt(i*i+o*o);return s>zt(Ke(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 i=Vt(e.glyph,e.size),o=e.cx+i.centerDx,s=e.cy+i.centerDy,a=t-o,l=n-s,c=Math.sqrt(a*a+l*l);return c>zt(i.radius,r)?null:{type:"node",datum:e.datum,x:o,y:s,distance:c}}(e,t,n,r);default:return null}}var Hl=null,Xl=null;function ql(){return Xl||((Hl=document.createElement("canvas")).width=1,Hl.height=1,Xl=Hl.getContext("2d")),Xl}function Gl(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 Vl(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=Gl(e),i=ql();if(!r||!i)return null;try{if(i.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(r,t,n);if(i.lineWidth=o,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,i=e.y2-e.y1,o=r*r+i*i;if(0===o)return null;let s=((t-e.x1)*r+(n-e.y1)*i)/o;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,l=e.y1+s*i,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=Gl(e),i=ql();if(!r||!i)return null;try{if(i.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(r,t,n);if(i.lineWidth=o,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Ul(e){const{clientX:t,clientY:n,canvasRect:r,margin:i,adjustedWidth:o,adjustedHeight:s,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-i.left,f=n-r.top-i.top;if(0>d||d>o||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,i=30,o,s=0){let a=null,l=i,c=1/0;if(o){const e=Kt(o,n,r,i,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},l=e.distance)}for(const t of e){if(o&&"circle"===t.type)continue;const e=Bl(t,n,r,i);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Vl(e,n,r);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,d,f,h,c,u);return y?{kind:"hit",hover:So(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}var Kl=require("react/jsx-runtime"),Ql={top:20,right:80,bottom:20,left:80},Zl={top:40,right:40,bottom:40,left:40},Jl=new Set(["chord","force","circlepack","orbit"]),ec=[800,600],tc=(0,Rs.memo)((0,Rs.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:i,data:o,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:x=300,forceStrength:v=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:A,padAngle:S=.01,groupWidth:_=20,sortGroups:M,edgeSort:C,treeOrientation:j="vertical",edgeType:R="curve",padding:T,paddingTop:L,tensionConfig:E,showParticles:N=!1,particleStyle:D,nodeStyle:I,edgeStyle:z,colorBy:$,colorScheme:W="category10",edgeColorBy:F="source",edgeOpacity:O=.5,colorByDepth:Y=!1,nodeSize:B=8,nodeSizeRange:H=[5,20],nodeLabel:X,showLabels:q=!0,labelMode:G,size:V=ec,responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,enableHover:ee=!0,tooltipContent:te,customHoverBehavior:ne,customClickBehavior:re,onObservation:ie,chartId:oe,onTopologyChange:se,annotations:ae,autoPlaceAnnotations:le,svgAnnotationRules:ce,legend:ue,legendPosition:de,legendLayout:fe,legendHoverBehavior:ye,legendClickBehavior:pe,legendHighlightedCategory:ge,legendIsolatedCategories:me,title:xe,foregroundGraphics:ve,backgroundGraphics:be,decay:ke,pulse:we,transition:Ae,animate:Se,staleness:_e,thresholds:Me,accessibleTable:Ce=!0,description:Pe,summary:je,orbitMode:Re,orbitSize:Te,orbitSpeed:Le,orbitRevolution:Ee,orbitRevolutionStyle:Ne,orbitEccentricity:De,orbitShowRings:Ie,orbitAnimated:ze,customNetworkLayout:$e,onLayoutError:We,layoutConfig:Fe,layoutSelection:Oe}=e,Ye=Jl.has(n)?Zl:Ql,Be=(0,Rs.useRef)(!0),He=Oo({sizeProp:V,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:Ye,foregroundGraphics:ve,backgroundGraphics:be,animate:Se,transitionProp:Ae,themeDirtyRef:Be}),{reducedMotionRef:Xe,responsiveRef:qe,size:Ge,margin:Ve,adjustedWidth:Ke,adjustedHeight:Qe,resolvedForeground:Ze,resolvedBackground:Je,transition:et,introEnabled:tt,tableId:nt,rafRef:rt,renderFnRef:it,scheduleRender:ot,cancelRender:st,currentTheme:at}=He,lt=Pi(),ct=Li(),ut=(0,Rs.useMemo)(()=>w(r),[r]),ht=(0,Rs.useMemo)(()=>Array.isArray(i)?w(i):i,[i]),dt=(0,Rs.useMemo)(()=>({...Ts,...E}),[E]),ft=(0,Rs.useMemo)(()=>({...Ls,...D}),[D]),yt=(0,Rs.useMemo)(()=>{return{chartType:(e={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:S,groupWidth:_,sortGroups:M,edgeSort:C,treeOrientation:j,edgeType:R,padding:T,paddingTop:L,tensionConfig:dt,showParticles:N,particleStyle:ft,nodeStyle:I,edgeStyle:z,nodeLabel:X,showLabels:q,labelMode:G,colorBy:$,colorScheme:W,edgeColorBy:F,edgeOpacity:O,colorByDepth:Y,nodeSize:B,nodeSizeRange:H,decay:ke,pulse:we,transition:et,introAnimation:tt,staleness:_e,thresholds:Me,orbitMode:Re,orbitSize:Te,orbitSpeed:Le,orbitRevolution:Ee,orbitRevolutionStyle:Ne,orbitEccentricity:De,orbitShowRings:Ie,orbitAnimated:ze,customNetworkLayout:$e,onLayoutError:We,layoutConfig:Fe,currentTheme:at}).chartType,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:P(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,a,l,c,u,d,f,y,p,g,m,x,v,S,_,M,C,j,R,T,L,dt,N,ft,I,z,X,q,G,$,W,F,O,Y,B,H,ke,we,et?.duration,et?.easing,tt,_e,Me,Re,Te,Le,Ee,Ne,De,Ie,ze,at,$e,We,Fe]),pt=Di(yt),gt=Di({chartType:(mt={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:S,groupWidth:_,sortGroups:M,edgeSort:C,treeOrientation:j,edgeType:R,padding:T,paddingTop:L,tensionConfig:dt,customNetworkLayout:$e,orbitMode:Re,orbitSize:Te,orbitEccentricity:De}).chartType,nodeIDAccessor:mt.nodeIDAccessor,sourceAccessor:mt.sourceAccessor,targetAccessor:mt.targetAccessor,valueAccessor:mt.valueAccessor,edgeIdAccessor:mt.edgeIdAccessor,childrenAccessor:mt.childrenAccessor,hierarchySum:mt.hierarchySum,orientation:mt.orientation,nodeAlign:mt.nodeAlign,nodePaddingRatio:mt.nodePaddingRatio,nodeWidth:mt.nodeWidth,iterations:mt.iterations,forceStrength:mt.forceStrength,padAngle:mt.padAngle,groupWidth:mt.groupWidth,sortGroups:mt.sortGroups,edgeSort:mt.edgeSort,treeOrientation:mt.treeOrientation,edgeType:mt.edgeType,padding:mt.padding,paddingTop:mt.paddingTop,tensionConfig:mt.tensionConfig,customNetworkLayout:mt.customNetworkLayout,orbitMode:mt.orbitMode,orbitSize:mt.orbitSize,orbitEccentricity:mt.orbitEccentricity});var mt;const xt=(0,Rs.useRef)(null),vt=(0,Rs.useRef)(0),bt=(0,Rs.useRef)(0),kt=(0,Rs.useRef)(!1),wt=(0,Rs.useRef)(null);wt.current||(wt.current=new yl(pt));const[At,St]=(0,Rs.useState)(null),[_t,Mt]=(0,Rs.useState)(0),[Pt,jt]=(0,Rs.useState)(0),[Rt,Tt]=(0,Rs.useState)(!1),[Et,It]=(0,Rs.useState)(!1),zt=(0,Rs.useRef)(0),$t=(0,Rs.useRef)(null),Wt=(0,Rs.useRef)(!1),Ft=(0,Rs.useRef)(A);Ft.current=A;const Ot=(0,Rs.useRef)(pt);Ot.current=pt;const Yt=(0,Rs.useRef)(null),Bt=(0,Rs.useRef)(new Map),Ht=(0,Rs.useRef)(0),Xt=(0,Rs.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:i,colorIndexRef:o}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!i.has(e+"")){const t=Array.isArray(r)?r:he;i.set(e+"",t[o.current++%t.length])}return i.get(e+"")}}if(i.has(t.id))return i.get(t.id);const s=Array.isArray(r)?r:he,a=n?s[o.current++%s.length]:s[0];return i.set(t.id,a),a}({node:e,colorBy:$,colorScheme:W,nodeColorMap:Bt.current,colorIndexRef:Ht}),[$,W]),qt=(Gt=at,Gt?.colors?.border||Gt?.colors?.secondary||Gt?.colors?.primary||"#999");var Gt;const Ut=(0,Rs.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,wt.current?.nodes),[]),Kt=(0,Rs.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:i,fallback:o}=e;if("function"==typeof n)return n(t);const s=i(t.source),a=i(t.target);return"target"===n&&a?r(a):s?r(s):o}({edge:e,edgeColorBy:F,getNodeColor:Xt,resolveEndpoint:Ut,fallback:qt}),[F,Xt,qt,Ut]),Qt=(0,Rs.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:i,getEdgeColor:o,getNodeColor:s,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!i)return o(t);const c=r,u=a(t.source),h=a(t.target);return"target"===c&&h?s(h):u?s(u):l}({edge:e,particleStyleColor:ft.color,particleColorBy:ft.colorBy,hasExplicitParticleColorBy:!!D?.colorBy,getEdgeColor:Kt,getNodeColor:Xt,resolveEndpoint:Ut,fallback:qt}),[D?.colorBy,ft.color,ft.colorBy,Xt,Kt,qt,Ut]),Zt=("sankey"===n||!!$e)&&N||!!we||(wt.current?.isAnimating??!1);Nt(wt,pt,Be,ot),Dt(wt,Oe,Be,ot),(0,Rs.useEffect)(()=>{const e=wt.current;e&&(e.buildScene([Ke,Qe]),Ht.current=Yl({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Bt.current,colorScheme:W}),Be.current=!0,ot())},[at,Ke,Qe,ot]);const Jt=(0,Rs.useCallback)(()=>{const e=wt.current;if(e&&(e.runLayout([Ke,Qe]),e.buildScene([Ke,Qe]),Be.current=!0,Ht.current=Yl({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Bt.current,colorScheme:W}),Mt(e.layoutVersion),se)){const{nodes:t,edges:n}=e.getLayoutData();se(t,n)}},[Ke,Qe,se,W]),en=(0,Rs.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=wt.current;t&&(t.ingestEdge(e)&&Jt(),ot())},[Jt,ot]),tn=(0,Rs.useCallback)(e=>{const t=wt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&Jt(),ot()},[Jt,ot]),nn=(0,Rs.useCallback)(()=>{wt.current?.clear(),Bt.current.clear(),Ht.current=0,Mt(wt.current?.layoutVersion??0),St(null),Yt.current=null,Be.current=!0,ot()},[ot]),on=(0,Rs.useCallback)(()=>{const e=wt.current;e&&(e.tension+=999,Jt(),ot())},[Jt,ot]);(0,Rs.useImperativeHandle)(t,()=>({push:en,pushMany:tn,removeNode:e=>{const t=wt.current?.removeNode(e)??!1;if(t){const t=Yt.current?.data?"function"==typeof a?a(Yt.current.data):Yt.current.data[a]:void 0;Yt.current&&"node"===Yt.current.nodeOrEdge&&t===e&&(Yt.current=null,St(null)),Bt.current.delete(e),Jt(),Be.current=!0,ot()}return t},removeEdge:(e,t)=>{const n=wt.current?.removeEdge(e,t)??!1;if(n){if(Yt.current&&"edge"===Yt.current.nodeOrEdge){const n=Yt.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&&(Yt.current=null,St(null))}Jt(),Be.current=!0,ot()}return n},updateNode:(e,t)=>{const n=wt.current?.updateNode(e,t)??null;return n&&(Be.current=!0,ot()),n},updateEdge:(e,t,n)=>{const r=wt.current?.updateEdge(e,t,n)??[];return r.length>0&&(Jt(),Be.current=!0,ot()),r},clear:nn,getTopology:()=>wt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>wt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>wt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=wt.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:on,getTension:()=>wt.current?.tension??0}),[en,tn,nn,on,Jt,ot]);const sn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),an=sn?o||(Array.isArray(i)?void 0:i):void 0;(0,Rs.useEffect)(()=>{const e=wt.current;if(!e)return;const t=++zt.current;if($t.current?.abort(),$t.current=null,sn&&an)e.ingestHierarchy(an,[Ke,Qe]),e.buildScene([Ke,Qe]),It(!1),Ft.current?.("ready"),Be.current=!0,ot();else{const o=ut,s=Array.isArray(ht)?ht:[];if(0===o.length&&0===s.length)return null==r&&null==i||0>=e.nodes.size&&0>=e.edges.size||nn(),It(!1),void Ft.current?.("ready");const a=[Ke,Qe],l="force"===n&&!$e&&Pl()&&function(e,t,n,r,i=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=i)}(b,o.length,s.length,x);if(l&&ct&&!Wt.current&&e.sceneNodes.length>0)return Wt.current=!0,It(!1),Ft.current?.("ready"),Be.current=!0,void ot();if(l){const n=new AbortController;$t.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(o,s,a,{deferLayout:!0});const i=e.getLayoutData(),l=function(e,t,n,r,i){const o=za(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=i?.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:o(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,i="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:i}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength},size:r}}(i.nodes,i.edges,Ot.current,a,r);return It(!0),Ft.current?.("pending"),function(e,t){return Pl()?t?.aborted?Promise.reject(jl()):(Tl&&!Tl.isDead||(Tl=new Rl),Tl).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(l,n.signal).then(({positions:n})=>{t===zt.current&&(e.applyForceLayoutPositions(n,a),e.buildScene(a),Ht.current=Yl({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Bt.current,colorScheme:W}),It(!1),Ft.current?.("ready"),Mt(e.layoutVersion),Be.current=!0,ot())}).catch(n=>{"AbortError"!==n.name&&t===zt.current&&(e.runLayout(a),e.buildScene(a),Ht.current=Yl({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Bt.current,colorScheme:W}),It(!1),Ft.current?.("error"),Mt(e.layoutVersion),Be.current=!0,ot())}),()=>n.abort()}e.ingestBounded(o,s,a),e.buildScene(a),It(!1),Ft.current?.("ready"),Ht.current=Yl({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Bt.current,colorScheme:W}),Be.current=!0,ot()}},[ut,ht,r,i,o,an,sn,Ke,Qe,gt,b,x,ct,n,$e,ot,nn,W]),(0,Rs.useEffect)(()=>{s&&s.length>0&&tn(s)},[]);const ln=(0,Rs.useCallback)(e=>{if(ne&&ne(e),ie){const t=Date.now();ie(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:oe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:oe})}},[ne,ie,oe]),cn=(0,Rs.useCallback)(e=>{if(re&&re(e),ie){const t=Date.now();ie(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:oe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:oe})}},[re,ie,oe]),{hoverHandlerRef:un,hoverLeaveRef:hn,onPointerMove:dn,onPointerLeave:fn}=He,yn=()=>!$e||(wt.current?.hasCustomRestyle??!1);un.current=e=>{if(!ee)return;const t=yn(),n=xt.current;if(!n)return;const r=wt.current;if(!r)return;const i=Ul({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:Ve,adjustedWidth:Ke,adjustedHeight:Qe,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===i.kind?(Yt.current=i.hover,St(i.hover),ln&&(ln(i.hover),t&&(Be.current=!0)),t&&ot()):Yt.current&&(Yt.current=null,St(null),ln&&(ln(null),t&&(Be.current=!0)),t&&ot())},hn.current=()=>{if(Yt.current){const e=yn();Yt.current=null,St(null),ln&&(ln(null),e&&(Be.current=!0)),e&&ot()}};const pn=(0,Rs.useRef)(()=>{});pn.current=e=>{if(!re&&!ie)return;const t=xt.current;if(!t)return;const n=wt.current;if(!n)return;const r=Ul({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:Ve,adjustedWidth:Ke,adjustedHeight:Qe,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?cn(r.hover):"miss"===r.kind&&cn(null)};const gn=(0,Rs.useCallback)(e=>pn.current(e),[]),mn=(0,Rs.useRef)(-1),xn=(0,Rs.useRef)(null),vn=(0,Rs.useRef)(-1),bn=(0,Rs.useCallback)(e=>{const t=wt.current;if(!t)return;const n=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=Vt(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===n.length)return;const r=_n(n),i=mn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),mn.current=0,vn.current=-1;const t=r.flat[0];xn.current={shape:t.shape,w:t.w,h:t.h};const n=So(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Yt.current=n,St(n),ln&&(ln(n),Be.current=!0),void ot()}const o=Mn(r,i),s=function(e,t,n,r,i){const o=n.flat[t.flatIndex];if(!o)return Cn(e,t,n);const s=o.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,i=1/0;for(let o=0;e.flat.length>o;o++){const s=e.flat[o];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,r=o)}return r}(n,o,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(i.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,i=jn(t.source),o=jn(t.target),s=null!=i,a=null!=o;s&&i+""===n&&a?r.push(o+""):a&&o+""===n&&s&&r.push(i+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const o=n.idToIdx.get(e[(i.current+1)%e.length])??-1;return 0>o?t.flatIndex:(i.current=-1,o)}default:{const r=Cn(e,t,n);return null!==r&&r!==t.flatIndex&&(i.current=-1),r}}}(e.key,o,r,t.sceneEdges??[],vn);if(null===s)return;if(e.preventDefault(),0>s)return mn.current=-1,xn.current=null,vn.current=-1,Yt.current=null,St(null),ln&&(ln(null),Be.current=!0),void ot();mn.current=s;const a=r.flat[s];xn.current={shape:a.shape,w:a.w,h:a.h};const l={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};Yt.current=l,St(l),ln&&(ln(l),Be.current=!0),ot()},[ln,ot]),kn=(0,Rs.useCallback)(e=>{mn.current=-1,xn.current=null,dn(e)},[dn]);it.current=()=>{rt.current=null;const e=xt.current;if(!e)return;const t=wt.current;t&&function(e){const{canvas:t,store:n,size:r,margin:i,adjustedWidth:o,adjustedHeight:s,background:a,dirtyRef:l,lastFrameTimeRef:c,reducedMotion:u,showParticles:h,isContinuous:d,animate:f,decay:y,pulse:p,thresholds:g,staleness:m,particleStyle:x,getParticleColor:v,pendingAnnotationFrameRef:b,lastAnnotationFrameTimeRef:k,setAnnotationFrame:w,scheduleNextFrame:A}=e,S=t.getContext("2d");if(!S)return;const _=performance.now(),M=c.current?Math.min((_-c.current)/1e3,.1):.016;c.current=_;const C=n.advanceTransition(u?_+1e6:_),P=!u&&C,j=!u&&n.tickAnimation([o,s],M),R=l.current;(C||R||j)&&n.buildScene([o,s]);const T=h&&!u&&!!n.particlePool,L=!!((E={dirtyOrRebuilt:R,transitioning:P,animationTicked:j,continuous:T||d,liveEncoding:!!y||!!p||!!g||!1!==f&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||E.transitioning||E.animationTicked||E.continuous||E.liveEncoding||E.forced);var E;const N=!!m&&n.lastIngestTime>0&&_-n.lastIngestTime>(m?.threshold??5e3);if(L){if(!Yo(t,r,i,Bo()))return;if(S.clearRect(-i.left,-i.top,r[0],r[1]),Wi(S,{background:a,width:o,height:s}),y&&n.applyDecay(),p&&n.applyPulse(_),g&&n.applyThresholds(_),!1!==f&&n.applyTopologyDiff(_),N&&(S.globalAlpha=m?.dimOpacity??.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Il(e,n);break;case"line":zl(e,n);break;case"ribbon":$l(e,n);break;case"curved":Wl(e,n)}}(S,n.sceneEdges),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="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,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=rn(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)),ts(e,t),e.restore())}}(S,n.sceneNodes),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="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,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=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),ns(e,t),e.restore())}}(S,n.sceneNodes),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="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,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=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(S,n.sceneNodes),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 i=Ol(t);if(!i)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const o=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle="string"==typeof t.style.fill&&rn(e,t.style.fill)||t.style.fill,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=rn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(i)),e.restore()}}(S,n.sceneNodes),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&hs(e,r,r.cx,r.cy,n);e.globalAlpha=n}(S,n.sceneNodes),T&&!N){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r){const i=r.spawnRate??.1,o=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const s=t[r];if(!s.bezier)continue;if(e.countForEdge(r)>=o)continue;const a=s.value*i*n*(s.bezier.circular?.3:1),l=Math.floor(a),c=a-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<o;t++)e.spawn(r)}}(n.particlePool,e,M,x);const t=.5*(x.speedMultiplier??1);let r;if(x.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(M,t,e,r),function(e,t,n,r,i){const o=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 l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:i(l),e.fillStyle=rn(e,c)||c,e.beginPath(),e.arc(a.x,a.y,o,0,2*Math.PI),e.fill()}e.globalAlpha=1}(S,n.particlePool,e,x,v)}}N&&(S.globalAlpha=1)}l.current=!1,(R||P||j)&&t.setAttribute("aria-label",Zi(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const D=R||P||j||b.current;D&&_-k.current>=33?(w(e=>e+1),k.current=_,b.current=!1):b.current=!!D,(d||P||null!=n.transition||j||n.hasActivePulses||n.hasActiveThresholds||!1!==f&&n.hasActiveTopologyDiff||b.current)&&A()}({canvas:e,store:t,size:Ge,margin:Ve,adjustedWidth:Ke,adjustedHeight:Qe,background:J,dirtyRef:Be,lastFrameTimeRef:vt,reducedMotion:!!Xe.current,showParticles:N,isContinuous:Zt,animate:Se,decay:ke,pulse:we,thresholds:Me,staleness:_e,particleStyle:ft,getParticleColor:Qt,pendingAnnotationFrameRef:kt,lastAnnotationFrameTimeRef:bt,setAnnotationFrame:jt,scheduleNextFrame:()=>{ot()}})},Ei({hydrated:lt,wasHydratingFromSSR:ct,storeRef:wt,dirtyRef:Be,renderFnRef:it,cancelRender:st}),(0,Rs.useEffect)(()=>{Be.current=!0,ot()},[n,Ke,Qe,J,ot]),Dn(_e,wt,Be,ot,Rt,Tt);const wn=ee&&At?(0,Kl.jsx)(Eo,{x:At.x,y:At.y,containerWidth:Ke,containerHeight:Qe,margin:Ve,className:"stream-network-tooltip",zIndex:2,children:te?te(At):(0,Kl.jsx)(Nl,{data:At})}):null;if(_i||!lt&&ct){const e=wt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),r=t?o||(Array.isArray(i)?void 0:i):void 0;if(t&&r)e.ingestHierarchy(r,[Ke,Qe]),e.buildScene([Ke,Qe]);else{const t=ut,n=Array.isArray(ht)?ht:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[Ke,Qe]),e.buildScene([Ke,Qe]))}}const t=e?.sceneNodes??[],r=e?.sceneEdges??[],s=e?.labels??[];return(0,Kl.jsxs)("div",{ref:qe,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":Pe||("string"==typeof xe?xe:"Network chart"),style:{position:"relative",width:U?"100%":Ge[0],height:K?"100%":Ge[1]},children:[(0,Kl.jsx)(po,{summary:je}),(0,Kl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ge[0],height:Ge[1],style:{position:"absolute",left:0,top:0},children:[Je&&(0,Kl.jsx)("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Je}),(0,Kl.jsxs)("g",{transform:`translate(${Ve.left},${Ve.top})`,children:[J&&(0,Kl.jsx)("rect",{x:0,y:0,width:Ke,height:Qe,fill:J}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return(0,ki.jsx)("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(0,ki.jsx)("path",{d:n.pathD,fill:Ai(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(0,ki.jsx)("path",{d:n.pathD,fill:Ai(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(0,ki.jsx)("path",{d:n.pathD,fill:Ai(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),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return(0,ki.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+t)}case"rect":{const n=e;return(0,ki.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+t)}case"arc":{const n=e,r=(0,vi.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(wi)||"";return(0,ki.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+t)}case"symbol":{const n=e,r=Ue(n.symbolType,n.size,n.path);return(0,ki.jsx)("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?Ai(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return Si(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),s.map((e,t)=>function(e,t){return(0,ki.jsx)("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)]})]}),(0,Kl.jsx)(ml,{width:Ke,height:Qe,totalWidth:Ge[0],totalHeight:Ge[1],margin:Ve,labels:s,sceneNodes:t,title:xe,legend:ue,legendPosition:de,legendLayout:fe,legendHoverBehavior:ye,legendClickBehavior:pe,legendHighlightedCategory:ge,legendIsolatedCategories:me,foregroundGraphics:Ct(Ze,Lt(wt.current?.customLayoutOverlays,Oe??null)),annotations:ae,autoPlaceAnnotations:le,svgAnnotationRules:ce,annotationFrame:0}),(0,Kl.jsx)(kl,{marks:e?.customLayoutHtmlMarks,margin:Ve,selection:Oe??null})]})}const An=wt.current;return(0,Kl.jsxs)("div",{ref:qe,className:"stream-network-frame"+(Z?" "+Z:""),role:"group","aria-label":Pe||("string"==typeof xe?xe:"Network chart"),tabIndex:0,"aria-busy":Et||void 0,style:{position:"relative",width:U?"100%":Ge[0],height:K?"100%":Ge[1],overflow:"visible"},onKeyDown:bn,children:[Ce&&(0,Kl.jsx)(go,{tableId:nt}),Ce&&(0,Kl.jsx)(yo,{nodes:An?.sceneNodes??[],edges:An?.sceneEdges??[],chartType:"Network chart",tableId:nt,chartTitle:"string"==typeof xe?xe:void 0}),(0,Kl.jsx)(po,{summary:je}),(0,Kl.jsx)(mo,{hoverPoint:At}),(0,Kl.jsxs)("div",{role:"img","aria-label":Pe||("string"==typeof xe?xe:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ee?kn:void 0,onMouseLeave:ee?fn:void 0,onClick:re||ie?gn:void 0,children:[Et&&!1!==k&&(0,Kl.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Ml(!0,Ge[0],Ge[1],k)}),Je&&(0,Kl.jsx)("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:Ge[0],height:Ge[1],pointerEvents:"none",overflow:"visible"},children:(0,Kl.jsx)("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Je})}),(0,Kl.jsx)("canvas",{ref:xt,"aria-label":Zi(An?.sceneNodes?.length??0,An?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,Kl.jsx)(ml,{width:Ke,height:Qe,totalWidth:Ge[0],totalHeight:Ge[1],margin:Ve,labels:An?.labels||[],sceneNodes:An?.sceneNodes,title:xe,legend:ue,legendPosition:de,legendLayout:fe,legendHoverBehavior:ye,legendClickBehavior:pe,legendHighlightedCategory:ge,legendIsolatedCategories:me,foregroundGraphics:Ct(Ze,Lt(wt.current?.customLayoutOverlays,Oe??null)),annotations:ae,autoPlaceAnnotations:le,svgAnnotationRules:ce,annotationFrame:Pt}),(0,Kl.jsx)(kl,{marks:An?.customLayoutHtmlMarks,margin:Ve,selection:Oe??null}),(0,Kl.jsx)(bo,{active:mn.current>=0,hoverPoint:At,margin:Ve,size:Ge,shape:xn.current?.shape,width:xn.current?.w,height:xn.current?.h}),wn,_e?.showBadge&&(0,Kl.jsx)(zn,{isStale:Rt,position:_e.badgePosition})]})]})}));tc.displayName="StreamNetworkFrame";var nc=tc,rc=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}},ic=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 i=Math.floor((e-this.size)/n)+1;r>=i;i++)this.bump(i*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new rc,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new rc;r.push(t);let i=e,o=e;const s=[],a={start:i,end:o,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),i>t.start&&(i=t.start),t.end>o&&(o=t.end));a.start=i,a.end=o,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 oc(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 sc(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const i=oc(e,n),o=e.stddev*r;return[i-o,i+o]}var ac={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},lc=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function cc(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;lc.lastIndex=0;let n,r=0,i=0;for(;null!==(n=lc.exec(t));){const e=parseFloat(n[1]),t=ac[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,i+=n[0].length}return i!==t.length?null:r>0?r:null}var uc=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}},hc=require("react"),dc=require("react");function fc(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,i]=r.range;t.push(t=>{const r=t[n];return r>=e&&i>=r})}return e=>t.every(t=>t(e))}function yc(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function pc(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[gc,mc]=M(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),i=r?.clauses.get(n.clientId);if(i&&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||!pc(r,n))return!1}return!0}(i,n))return{};const o=new Map(e.selections),s=yc(o,t),a=new Map(s.clauses);return a.set(n.clientId,n),o.set(t,{...s,clauses:a}),{selections:o}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const i=new Map(e.selections),o=new Map(r.clauses);return o.delete(n),i.set(t,{...r,clauses:o}),{selections:i}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const i=new Map(e.selections),o=yc(i,t);return i.set(t,{...o,resolution:n}),{selections:i}})},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}})}})),[xc,vc]=M(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}))}})),bc=require("react");function kc(e){const t=(0,bc.useId)(),n=e.clientId||t,{name:r}=e,i=mc(e=>e.selections.get(r)),o=mc(e=>e.setClause),s=mc(e=>e.clearClause),a=(0,bc.useMemo)(()=>!!i&&i.clauses.size>0,[i]);return{predicate:(0,bc.useMemo)(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[r,i]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(fc(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:a,selectPoints:(0,bc.useCallback)(e=>{const t={};let i=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},i=!0;i&&o(r,{clientId:n,type:"point",fields:t})},[n,r,o]),selectInterval:(0,bc.useCallback)(e=>{const t={};let i=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},i=!0;i&&o(r,{clientId:n,type:"interval",fields:t})},[n,r,o]),clear:(0,bc.useCallback)(()=>{s(r,n)},[s,r,n]),clientId:n}}function wc(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Ac(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Sc(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function _c(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const i=Number(r);return Number.isFinite(i)?i:null}function Mc(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 Cc={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Pc(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,i="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,o=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!i&&!o)return Cc;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 jc({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:r=!1,onObservation:i,chartType:o,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=(0,dc.useId)(),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),f="series"===d?.mode?[d.seriesField||c||n[0]].filter(e=>!!e):d?.fields||n||[],y=kc({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:i,selectPoints:o,clear:s}=kc({name:t,fields:n});return{onHover:(0,bc.useCallback)(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Ac(t)&&o(t)},[n,o,s,t]),predicate:r,isActive:i}}({name:d?.name||"hover",fields:f}),g=vc(e=>e.pushObservation),m=e?{isActive:y.isActive,predicate:y.predicate}:null,[x,v]=(0,dc.useState)(null),b=(0,dc.useRef)(!1),k=c||n[0],w=(0,dc.useMemo)(()=>{if(!l||null==x||!k)return null;const e=x,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,x,k]),A=(0,dc.useCallback)(e=>{const n=!e&&b.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=_c(e,t,d.xField);null!=n&&function(e,t,n){const r=Zr.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Zr={positions:new Map(Zr.positions).set(e,{xValue:t,sourceId:n})},ei())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||n||ti(d.name||"hover",h),"x-position"===d?.mode||n||p.onHover(null);if(l&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];v(null!=n?n+"":null)}else n||v(null);if(i||g){const t={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(e){const n=Mc(e),r={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};i&&i(r),g&&g(r)}else{const e={...t,type:"hover-end"};i&&i(e),g&&g(e)}}},[t,p,d,h,i,o,s,g,l,k,u]),S=(0,dc.useCallback)((n=!0)=>{b.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&l&&v(null),"x-position"===d?.mode&&(ni(d.name||"hover",h),ti(d.name||"hover",h))},[t,d,p,e,u,y,l,h]),_=(0,dc.useCallback)(n=>{const r=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),c=!!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=_c(n,e,d.xField);null!=t&&function(e,t,n){const r=Zr.positions.get(e);if(r?.locked){const t=new Map(Zr.positions);return t.delete(e),Zr={positions:t},ei(),!1}Zr={positions:new Map(Zr.positions).set(e,{xValue:t,sourceId:n,locked:!0})},ei()}(d.name||"hover",t,h)}if(r)if(n){b.current=!0;const r=Mc(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(l&&k){const e=r?.[k];v(null!=e?e+"":null)}}else c&&S();if(n||c){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})}if(i||g){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(n){const t=Mc(n),r={...e,type:"click",datum:t||{},x:n.x??0,y:n.y??0};i&&i(r),g&&g(r)}else{const t={...e,type:"click-end"};i&&i(t),g&&g(t)}}}},[a,i,g,o,s,d,h,u,t,p,e,y,f,l,k,S]);return(0,dc.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&b.current&&S()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,S]),(0,dc.useEffect)(()=>()=>{b.current&&S(!1)},[S]),(0,dc.useEffect)(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{ni(e,h),ti(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:m,hoverSelectionHook:w,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:h}}var Rc={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 Tc(e,t,n){const r=Rc[e||"primary"],i=e&&"primary"!==e||!n?.width?r.width:n.width,o=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,i=t.height,o=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 i||n.minHeight>i)||"number"==typeof n.maxHeight&&("number"!=typeof i||i>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>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"])Sc(e[r])&&Sc(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??i,height:t.height??o}).props,a=s.mode||e,l=Rc[a||"primary"],c="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?l.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?l.height:n.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:Lc(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:Pc(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Lc(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}var Ec=require("react/jsx-runtime"),Nc={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"},Dc={opacity:.7,marginRight:4};function Ic(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function zc(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function $c(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:i="y"}=e;return e=>{const o=e?.data??null,s=Ic(o,t,"time"),a=Ic(o,n,"value");return(0,Ec.jsxs)("div",{className:"semiotic-tooltip",style:Nc,children:[(0,Ec.jsxs)("div",{children:[(0,Ec.jsxs)("span",{style:Dc,children:[r,":"]}),zc(s)]}),(0,Ec.jsxs)("div",{children:[(0,Ec.jsxs)("span",{style:Dc,children:[i,":"]}),zc(a)]})]})}}function Wc(e,t){return null!=e?e:Math.max(t?.length??0,200)}var Fc="time",Oc="value",Yc="__aggLower",Bc="__aggUpper",Hc="__aggPartial",Xc="count",qc="__aggStart",Gc="__aggEnd";function Vc(e,t){const n=t.stat??"mean",r=t.band??"none",i=t.sigma??1;return e.emit().map(e=>{const t={[Fc]:(e.start+e.end)/2,[Oc]:oc(e,n),[Xc]:e.count,[Hc]:e.partial,[qc]:e.start,[Gc]:e.end},o=sc(e,r,n,i);return o&&(t[Yc]=o[0],t[Bc]=o[1]),t})}function Uc(e){const{linkedHover:t,selection:n,onObservation:r,onClick:i,hoverRadius:o,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={},y=c?.enabled?Math.max(o??30,Math.ceil((c.targetSize||44)/2),24):o;return(a||t||r||i||s)&&(f.customHoverBehavior=u),h&&(l||(d?r||i||t:r||i)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}var Kc=require("react/jsx-runtime");function Qc(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 i=Number(r);return Number.isFinite(i)?i:null}var Zc=(0,hc.forwardRef)(function(e,t){const n=Tc(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:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:x,background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:j,staleness:R,transition:T,linkedHover:L,selection:E,onObservation:N,chartId:D,loading:I,loadingContent:z,emptyContent:$,emphasis:W,legendPosition:F,aggregate:O,eventTime:Y}=e,B=n.showAxes,H=n.enableHover,X=i??n.marginDefaults,q=r??[n.width,n.height],G=b??k??$c({timeAccessor:u,valueAccessor:h}),V=(0,hc.useRef)(null),{customHoverBehavior:U}=jc({selection:E,linkedHover:L,unwrapData:!0,onObservation:N,chartType:"RealtimeLineChart",chartId:D}),K=(0,hc.useCallback)(e=>{w&&w(e),U(e)},[w,U]),Q=null!=O,[Z,J]=(0,hc.useState)([]),ee=(0,hc.useRef)(null),te=(0,hc.useRef)(O);te.current=O;const ne=(0,hc.useRef)(Q);ne.current=Q;const re=(0,hc.useRef)(Z);re.current=Z;const ie=(0,hc.useRef)({timeAccessor:u,valueAccessor:h});ie.current={timeAccessor:u,valueAccessor:h},(0,hc.useEffect)(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=cc("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?cc(e.hop):void 0,i=null!=e.gap?cc(e.gap):void 0;return new ic({window:t,size:n,hop:r??void 0,gap:i??void 0,retain:e.retain})}(e);if(ee.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const r of c){const i=Qc(r,e,"time"),o=Qc(r,n,"value");null!=i&&null!=o&&t.push(i,o)}}J(t?Vc(t,e):[])},[Q?[O.window??"tumbling",O.size,O.hop??"",O.gap??"",O.retain??""].join("|"):"",Q,c]),(0,hc.useEffect)(()=>{Q&&ee.current&&J(Vc(ee.current,te.current))},[O?.stat,O?.band,O?.sigma]);const oe=(0,hc.useCallback)(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:i}=ie.current;for(const n of e){const e=Qc(n,r,"time"),o=Qc(n,i,"value");null!=e&&null!=o&&t.push(e,o)}J(Vc(t,n))},[]),se=null!=Y,ae=(0,hc.useRef)(null),le=(0,hc.useRef)(Y);le.current=Y;const ce=(0,hc.useRef)(se);ce.current=se;const ue=(0,hc.useRef)(N);ue.current=N;const he=(0,hc.useRef)(D);he.current=D,(0,hc.useEffect)(()=>{ae.current=se?function(e){const t=cc(e.lateness);return null==t?null:new uc({lateness:t,getTime:e=>Qc(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(le.current):null},[se?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",se]);const de=(0,hc.useCallback)(e=>{0!==e.length&&(ne.current?oe(e):V.current?.pushMany(e))},[oe]),fe=(0,hc.useCallback)(e=>{const t=ae.current;if(!ce.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}=ie.current,i=le.current?.latePolicy??"drop";for(const o of e.late)n({type:"late-data",datum:o,eventTime:Qc(o,r,"time")??NaN,watermark:t.watermark,policy:i,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);(0,hc.useImperativeHandle)(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:V.current?.remove(e)??[],update:(e,t)=>ne.current?[]:V.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):V.current?.clear()},getData:()=>ne.current?re.current:V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[fe]);const ye=Ml(I,q[0],q[1],z),pe=ye?null:_l(Q?void 0:c,q[0],q[1],$),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=x&&(ge.opacity=x);const me=Wc(l,c),xe=Q?Z:c,ve=Q?Fc:u,be=Q?Oc:h,ke=Q&&O&&"none"!==(O.band??"none")?{y0Accessor:Yc,y1Accessor:Bc,perSeries:!1}:void 0;return ye||pe||(0,Kc.jsx)(js,{ref:V,chartType:"line",runtimeMode:"streaming",size:q,margin:X,className:W?`${o||""} semiotic-emphasis-${W}`.trim():o,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,O?.retain??Math.max(Z.length,600)):me,data:xe,timeAccessor:ve,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:B,background:v,hoverAnnotation:H,tooltipContent:G,...Uc({linkedHover:L,selection:E,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:j,staleness:R,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});Zc.displayName="RealtimeLineChart";var Jc=require("react"),eu=require("react/jsx-runtime");function tu(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 i=Number(r);return Number.isFinite(i)?i:null}var nu=(0,Jc.forwardRef)(function(e,t){const n=Tc(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:i,margin:o,className:s,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:x,fill:v,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:j,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:L,linkedHover:E,selection:N,decay:D,pulse:I,staleness:z,transition:$,onObservation:W,chartId:F,loading:O,loadingContent:Y,emptyContent:B,emphasis:H,legendPosition:X,brush:q,onBrush:G,linkedBrush:V}=e,U=n.showAxes,K=n.enableHover,Q=o??n.marginDefaults,Z=i??[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=Ic(r,t,"time"),i=Ic(r,n,"value");return(0,Ec.jsxs)("div",{className:"semiotic-tooltip",style:Nc,children:[(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"x:"}),zc(e)]}),(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"y:"}),zc(i)]})]})}return(0,Ec.jsxs)("div",{className:"semiotic-tooltip",style:Nc,children:[(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"range:"}),zc(r.binStart),"–",zc(r.binEnd)]}),null!=r.total&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"count:"}),zc(r.total)]}),null!=r.category&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"category:"}),zc(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),ee=(0,Jc.useRef)(null),{customHoverBehavior:te}=jc({selection:N,linkedHover:E,unwrapData:!0,onObservation:W,chartType:"RealtimeHistogram",chartId:F}),ne=(0,Jc.useCallback)(e=>{C&&C(e),te(e)},[C,te]),re=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,ie=(oe=V)?"string"==typeof oe?{name:oe}:oe:null;var oe;const se="string"==typeof h?h:"time",ae=function(e){const{name:t,xField:n,yField:r}=e,{predicate:i,isActive:o,selectInterval:s,clear:a}=kc({name:t,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=(0,bc.useCallback)(e=>{if(!e)return void a();const t={};"xyBrush"===l&&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"===l&&wc(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===l&&wc(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Ac(t)&&s(t)},[l,n,r,s,a]);return{brushInteraction:(0,bc.useMemo)(()=>({brush:l,during:c,end:c}),[l,c]),predicate:i,isActive:o,clear:a}}({name:ie?.name||"__unused_hist_brush__",xField:ie?.xField||se,...ie?.yField?{yField:ie.yField}:{}}),le=(0,Jc.useRef)(ae.brushInteraction);le.current=ae.brushInteraction;const ce=(0,Jc.useCallback)(e=>{if(G&&G(e),W&&W(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}),ie){const t=le.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)}},[G,W,F,ie]);(0,Jc.useImperativeHandle)(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=Ml(O,Z[0],Z[1],Y),he=ue?null:_l(u,Z[0],Z[1],B),de={};null!=v&&(de.fill=v),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=Wc(c,u),pe=(0,Jc.useMemo)(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:i,extentPadding:o}){if(i)return[i[1],i[0]];if(!e||0===e.length)return;const s=new Map;for(const i of e){const e=tu(i,n,"time"),o=tu(i,t,"value");if(null==e||null==o)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+o)}let a=0;for(const e of s.values())e>a&&(a=e);return[a>0?a+a*(o??.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||(0,eu.jsx)(js,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:fe,arrowOfTime:a,windowMode:l,windowSize:ye,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pe,extentPadding:g,binSize:r,categoryAccessor:m,barColors:x,barStyle:de,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Uc({linkedHover:E,selection:N,onObservation:W,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:P,autoPlaceAnnotations:j,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:L,decay:D,pulse:I,staleness:z,transition:$,pointIdAccessor:e.pointIdAccessor,legendPosition:X,brush:re||(V?{dimension:"x"}:void 0),onBrush:re||V?ce:void 0})});function ru(e){return(0,eu.jsx)(nu,{...e,windowMode:"growing"})}nu.displayName="RealtimeHistogram",ru.displayName="TemporalHistogram";var iu=require("react"),ou=require("react/jsx-runtime"),su=(0,iu.forwardRef)(function(e,t){const n=Tc(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:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:x,fill:v,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:j,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:L,linkedHover:E,selection:N,onObservation:D,chartId:I,loading:z,loadingContent:$,emptyContent:W,emphasis:F,legendPosition:O}=e,Y=n.showAxes,B=n.enableHover,H=i??n.marginDefaults,X=r??[n.width,n.height],q=_??M??$c({timeAccessor:u,valueAccessor:h}),G=(0,iu.useRef)(null),{customHoverBehavior:V}=jc({selection:N,linkedHover:E,unwrapData:!0,onObservation:D,chartType:"RealtimeSwarmChart",chartId:I}),U=(0,iu.useCallback)(e=>{C&&C(e),V(e)},[C,V]);(0,iu.useImperativeHandle)(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 K=Ml(z,X[0],X[1],$),Q=K?null:_l(c,X[0],X[1],W),Z={};null!=x&&(Z.radius=x),null!=v&&(Z.fill=v),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=F?`${o||""} semiotic-emphasis-${F}`.trim():o,te=Wc(l,c);return K||Q||(0,ou.jsx)(js,{ref:G,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:c,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:B,tooltipContent:q,...Uc({linkedHover:E,selection:N,onObservation:D,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:j,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:L,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});su.displayName="RealtimeSwarmChart";var au=require("react"),lu=require("react/jsx-runtime"),cu=(0,au.forwardRef)(function(e,t){const n=Tc(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:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:x,gap:v,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:j,tickFormatTime:R,tickFormatValue:T,linkedHover:L,selection:E,onObservation:N,chartId:D,loading:I,loadingContent:z,emptyContent:$,emphasis:W,legendPosition:F}=e,O=n.showAxes,Y=n.enableHover,B=i??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,i=Ic(r,t,"time"),o=r?.delta??Ic(r,n,"value"),s=r?.cumEnd,a="number"==typeof o?0>o?zc(o):"+"+zc(o):zc(o);return(0,Ec.jsxs)("div",{className:"semiotic-tooltip",style:Nc,children:[(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"x:"}),zc(i)]}),(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"Δ:"}),a]}),null!=s&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"total:"}),zc(s)]})]})}}({timeAccessor:u,valueAccessor:h}),q=(0,au.useRef)(null),{customHoverBehavior:G}=jc({selection:E,linkedHover:L,unwrapData:!0,onObservation:N,chartType:"RealtimeWaterfallChart",chartId:D}),V=(0,au.useCallback)(e=>{M&&M(e),G(e)},[M,G]);(0,au.useImperativeHandle)(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const U=Ml(I,H[0],H[1],z),K=U?null:_l(c,H[0],H[1],$),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=x&&(Q.connectorWidth=x),null!=v&&(Q.gap=v),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=W?`${o||""} semiotic-emphasis-${W}`.trim():o,J=Wc(l,c);return U||K||(0,lu.jsx)(js,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:B,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:O,background:A,hoverAnnotation:Y,tooltipContent:X,...Uc({linkedHover:L,selection:E,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:j,tickFormatTime:R,tickFormatValue:T,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});cu.displayName="RealtimeWaterfallChart";var uu=require("react"),hu=require("react/jsx-runtime"),du=(0,uu.forwardRef)(function(e,t){const n=Tc(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:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:x="count",background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:j,staleness:R,linkedHover:T,selection:L,onObservation:E,chartId:N,loading:D,loadingContent:I,emptyContent:z,emphasis:$,legendPosition:W}=e,F=n.showAxes,O=n.enableHover,Y=i??n.marginDefaults,B=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:i="y"}=e;return e=>{const o=e?.data??null,s=o?.xCenter??Ic(o,t,"time"),a=o?.yCenter??Ic(o,n,"value"),l=o?.count,c=o?.sum,u=o?.value,h=o?.agg??"count";return(0,Ec.jsxs)("div",{className:"semiotic-tooltip",style:Nc,children:[(0,Ec.jsxs)("div",{children:[(0,Ec.jsxs)("span",{style:Dc,children:[r,":"]}),zc(s)]}),(0,Ec.jsxs)("div",{children:[(0,Ec.jsxs)("span",{style:Dc,children:[i,":"]}),zc(a)]}),null!=l&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"count:"}),zc(l)]}),"sum"===h&&null!=c&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"sum:"}),zc(c)]}),"mean"===h&&null!=u&&(0,Ec.jsxs)("div",{children:[(0,Ec.jsx)("span",{style:Dc,children:"mean:"}),zc(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=(0,uu.useRef)(null),{customHoverBehavior:q}=jc({selection:L,linkedHover:T,unwrapData:!0,onObservation:E,chartType:"RealtimeHeatmap",chartId:N}),G=(0,uu.useCallback)(e=>{w&&w(e),q(e)},[w,q]);(0,uu.useImperativeHandle)(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 V=Ml(D,B[0],B[1],I),U=V?null:_l(c,B[0],B[1],z),K=$?`${o||""} semiotic-emphasis-${$}`.trim():o,Q=Wc(l,c);return V||U||(0,hu.jsx)(js,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:B,margin:Y,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:x,showAxes:F,background:v,hoverAnnotation:O,tooltipContent:H,...Uc({linkedHover:T,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:G}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:j,staleness:R,legendPosition:W,pointIdAccessor:e.pointIdAccessor})});du.displayName="RealtimeHeatmap";var fu=require("react"),yu=Symbol("semiotic.useStreamStatus.wrapped");function pu(e={}){const{staleThresholdMs:t=5e3,pollIntervalMs:n=1e3}=e,r=(0,fu.useRef)(null),[i,o]=(0,fu.useState)("idle"),[s,a]=(0,fu.useState)(null),l=(0,fu.useMemo)(()=>{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[yu]),e._frame=t,!t)return e._origPush=null,void(e._origPushMany=null);if(t[yu])return;t[yu]=!0;const r=t.push,i=t.pushMany,o=r.bind(t),s=i.bind(t);e._origPush=r,e._origPushMany=i,t.push=e=>(c(),o(e)),t.pushMany=e=>(e&&e.length>0&&c(),s(e))}}},[]),c=(0,fu.useCallback)(()=>{const e="undefined"!=typeof performance?performance.now():Date.now();r.current=e,a(e),o(e=>"active"===e?e:"active")},[]);return(0,fu.useEffect)(()=>{const e=setInterval(()=>{const e=r.current;if(null==e)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-e>t;o(e=>{const t=n?"stale":"active";return e===t?e:t})},n);return()=>clearInterval(e)},[t,n]),{ref:l,status:i,lastPushTime:s}}var gu=require("react");function mu(e,t,n,r){const i=new Map;n.forEach((e,t)=>{i.set(r?r(e,t):t+"",e)});const o=[];t.forEach((e,t)=>{i.has(t)||o.push(t)}),o.length>0&&e.remove?.(o);const s=[];if(i.forEach((n,r)=>{const i=t.get(r);void 0===i?s.push(n):i!==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 i}function xu(e,t,n={}){const{id:r,resetKey:i}=n,o=(0,gu.useMemo)(()=>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=(0,gu.useRef)({map:new Map,handle:null,resetKey:void 0});(0,gu.useEffect)(()=>{const n=e.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===i||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=i),r.map=mu(n,r.map,t,o)},[e,t,o,i])}
|