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/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("react-dom/server"),o=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-shape"),s=require("d3-array"),a=require("d3-interpolate"),l=require("d3-force"),c=require("d3-chord"),u=require("d3-hierarchy"),d=require("d3-geo"),h=require("d3-selection"),f=require("d3-brush"),g=require("regression");function y(t){return t&&t.__esModule?t:{default:t}}function p(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const m=p(e),v=p(n),x=y(g);function b(t,e,n,o){return new(n||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((o=o.apply(t,e||[])).next())})}function k(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function w(t){return"object"==typeof t&&null!==t&&"gradient"in t}"function"==typeof SuppressedError&&SuppressedError;class A{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=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%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(o=>{t(o)?n.push(o):e.push(o)}),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 S{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 j(t,e,n,o,i){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const t=i(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function M(t,e,n,o,i,r){const s=[];for(const i of t){const t=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:i})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function _(t,e,n,o,i,r,s,a){const l=[];for(const r of t){const t=n(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):i;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[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 P(t,e,n,o){var i,r,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;a.set(o,-t/2)}else if("wiggle"===o){t.length>0&&a.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let l=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;l+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let o=0;for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;o+=(null!==(r=a.get(i))&&void 0!==r?r:0)+t/2}const i=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-i)}}else for(const e of t)a.set(e,0);return a}function O(t,e,n,o,i,r,s){const a=n(t),l=o(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:i,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function T(t,e,n,o,i,r,s,a){const l=n(t),c=o(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:i,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function $(t,e,n,o,i,r,s){return{type:"rect",x:t,y:e,w:n,h:o,style:i,datum:r,group:s}}function L(t,e,n,o,i,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function C(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function E(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function R(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function z(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function D(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function N(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function F(t){const e=t.map(D),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return N(t,n,o)}if(t>=1){const[t,o,i]=e[n];return N(t,o,i)}const o=t*n,i=Math.floor(o),r=o-i,[s,a,l]=e[i],[c,u,d]=e[i+1];return N(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const W=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],B=F(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),I=F(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Y=F(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),G=F(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),H=F(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),q=F(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),X=F(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),V=F(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),U=F(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Z=F(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Q=F(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),K=F(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),J={blues:B,reds:I,greens:Y,viridis:X,oranges:G,purples:H,greys:q,plasma:V,inferno:U,magma:Z,cividis:Q,turbo:K};F(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),F(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),F(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),F(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),F(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),F(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),F(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const tt=Object.assign({category10:W,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},J),et=W,nt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],ot=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function it(t,e,n){if("function"==typeof e){const o=e(t);return n&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||ot.has(e)}(o)?n(o):o}const o=(null==t?void 0:t[e])+"";return n?n(o):et[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o))%et.length]}function rt(t,e,n="category10"){const i=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),r=i.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const s=tt[n]||tt.category10;if(r&&"function"==typeof s){let t=-1/0;for(const e of i){const n=Number(e);n>t&&(t=n)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:et;return o.scaleOrdinal().domain(i).range(t).unknown("#999")}}function st(t,e,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(i=t.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function at(t,e,n){var o;const i=null!==(o=t.duration)&&void 0!==o?o:500,r=n-e;return i>r?1-r/i:0}function lt(t,e){var n;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&i>o-r}function ct(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ut(t,e){return Math.min((t-e.startTime)/e.duration,1)}function dt(t,e,n){return t+(e-t)*n}function ht(){return"undefined"!=typeof performance?performance.now():Date.now()}function ft(t,e,n){var o,i,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),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(i=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i: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 gt(t,e,n,o){return"function"==typeof e.style?e.style(o||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,o)}function yt(t,e,n,o){if(!t.scales)return null;const i=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:gt(t,o,n,e[0]),datum:e,group:n,interactive:o.interactive}}function pt(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const o of t)o.perSeries?e.push(o):n.push(o);return{perSeries:e,aggregate:n}}function mt(t,e,n){const o=[];for(const i of n){const n=yt(t,e,"__ribbon_aggregate",i);n&&o.push(n)}return o}function vt(t,e,n,o){const i=[];for(const r of o){const o=yt(t,e,n,r);o&&i.push(o)}return i}function xt(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const o of e){if("band"!==o.kind)continue;const e=o.getTop(t),i=o.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&n.push({y0:i,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function bt(t,e,n,o){var i;if(!t.config.pointStyle)return;const r=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=O(s,t.scales,t.getX,r,a,o,l);c&&n.push(c)}}}const kt={topOpacity:.8,bottomOpacity:.05};function wt(t){var e,n;if(t)return!0===t?kt:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:kt.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:kt.bottomOpacity}}const At={circle:r.symbolCircle,square:r.symbolSquare,triangle:r.symbolTriangle,diamond:r.symbolDiamond,star:r.symbolStar,cross:r.symbolCross,wye:r.symbolWye},St=["circle","triangle","diamond","star","square","chevron","cross","wye"];function jt(t,e,n){var o,i;if(n)return n;const s=null!=t?t:"circle";if("chevron"===s)return function(t){const e=1.5*Mt(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 a=null!==(o=At[s])&&void 0!==o?o:r.symbolCircle;return null!==(i=r.symbol(a,Math.max(1,e))())&&void 0!==i?i:""}function Mt(t){return Math.sqrt(Math.max(1,t)/Math.PI)}const _t=new Map;function Pt(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=t.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=E(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let n=0;e.length>n;n++){const o=e[n],i=t.getX(o),r=t.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const p=c(o);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(l){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[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/a,S=t.config.showValues,j=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const o=e+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-x)/k;M.push(L(n*w,(a-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:i,count:m[o],sum:v[o],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*y,agg:l},S?{value:i,showValues:!0,valueFormat:j}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const o=E(t.config.valueAccessor,"value"),i=R(t.config.xAccessor,"x"),r=R(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],o=i(n),u=r(n);l[t]=o,c[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],i=s.get(l[t]),r=a.get(c[t]);if(void 0===i||void 0===r)continue;const d=o(n),h=r*u+i,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=m[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 J?t:"blues";let n=_t.get(e);if(n)return n;n=Array(256);const o=(i=e)&&J[i]||B;var i;for(let t=0;256>t;t++)n[t]=o(t/255);return _t.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),j=n.width/u,M=n.height/d,_=t.config.showValues,P=t.config.heatmapValueFormat,O=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const n=p[t],o=n%u;O.push(L(o*j,(d-1-(n-o)/u)*M,j,M,A[Math.min((e-k)*S+.5|0,255)],v[t],_?{value:e,showValues:!0,valueFormat:P}:void 0))}return O}function Ot(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:o,warned:i}=t;Tt(o)&&0===n.length&&$t(i,"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(i,"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 Tt(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Tt))}function $t(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function Lt(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Ct(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=Lt(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=E(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e-i: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:Lt(t.y1Accessor,"y1"),getBottom:Lt(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class Et{constructor(t){if(this.xExtent=new S,this.yExtent=new S,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 A(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=E(t.timeAccessor||t.xAccessor,"time"),this.getY=E(t.valueAccessor||t.yAccessor,"value")):(this.getX=E(t.xAccessor,"x"),this.getY=E(t.yAccessor,"y")),this.getGroup=z(t.groupAccessor),this.getCategory=z(t.categoryAccessor),this.getSize=t.sizeAccessor?E(t.sizeAccessor,"size"):void 0,this.getColor=z(t.colorAccessor),this.getSymbol=z(t.symbolAccessor),this.getY0=t.y0Accessor?E(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ct(t),this.getPointId=z(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?E(t.openAccessor,"open"):void 0,this.getHigh=E(t.highAccessor,"high"),this.getLow=E(t.lowAccessor,"low"),this.getClose=n?E(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new A(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),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}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?E(this.config.timeAccessor||this.config.xAccessor,"time"):E(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(e):e[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||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),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}}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),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}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),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}}return!0}computeScene(t){var e,n,i,r,s,a,l,c,u,d,h,f,g,y;const{config:p,buffer:m}=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(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=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],S="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!A&&m.size>0)if(p.normalize)w=[0,S?1:1+p.extentPadding];else{const t=`${m.size}:${this._ingestVersion}:${null!==(a=p.baseline)&&void 0!==a?a:"zero"}:${null!==(l=p.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)w=this._stackExtentCache.yDomain;else{const e=this.groupData(v),n=new Map,o=new Set;let i=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let a=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),o.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>i&&(i=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(c=p.stackOrder)&&void 0!==c?c:"key",l=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}),n=[],o=[];let i=0,r=0;for(const e of t)r>i?(n.push(e),i+=null!==(u=s.get(e))&&void 0!==u?u:0):(o.push(e),r+=null!==(d=s.get(e))&&void 0!==d?d:0);g=[...o.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}):e.map(t=>t.key).sort(l);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=P(t,g,(t,e)=>{var o;return(null===(o=n.get(t))||void 0===o?void 0:o.get(e))||0},p.baseline);let i=1/0,s=-1/0;for(const n of t){const t=null!==(h=e.get(n))&&void 0!==h?h:0,o=null!==(f=r.get(n))&&void 0!==f?f:0;i>t&&(i=t),t+o>s&&(s=t+o)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=S?0:a>0?a*p.extentPadding:1;w=[i-l,s+l]}else w=[0,i+(S?0:i>0?i*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:w}}}else if("bar"===p.chartType&&p.binSize&&!A&&m.size>0){const[,t]=function(t,e,n,o,i){const r=j(t,e,n,o,i);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]}(m,this.getX,this.getY,p.binSize,this.getCategory);w=[0,S?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!A&&m.size>0){const[t,e]=function(t,e){let n=0,o=0,i=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(m,this.getY),n=e-t,o=S?0:n>0?n*p.extentPadding:1;w=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!A&&w[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of v)for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&(w[0]>n&&(w[0]=n),n>w[1]&&(w[1]=n)),Number.isFinite(o)&&(w[0]>o&&(w[0]=o),o>w[1]&&(w[1]=o))}const t=w[1]-w[0],e=S?0:t>0?t*p.extentPadding:1,n=null===(g=p.yExtent)||void 0===g?void 0:g[0],o=null===(y=p.yExtent)||void 0===y?void 0:y[1];w=[null!=n?w[0]:w[0]-e,null!=o?w[1]:w[1]+e],"log"!==p.yScaleType||w[0]>0||0>=b[0]||S||(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 M="streaming"===p.runtimeMode,_=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(M)if("x"==("up"===(O=p.arrowOfTime)||"down"===O?"y":"x")){const e="right"===p.arrowOfTime?[_,t.width-_]:[t.width-_,_];this.scales={x:o.scaleLinear().domain(k).range(e),y:o.scaleLinear().domain(w).range([t.height-_,_])}}else{const e="down"===p.arrowOfTime?[_,t.height-_]:[t.height-_,_];this.scales={x:o.scaleLinear().domain(w).range([_,t.width-_]),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,[_,t.width-_]),y:e(p.yScaleType,w,[t.height-_,_])}}var O;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,Et.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(o)}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 o of t.path)o[0]*=e,o[1]*=n;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=n;for(const o of t.bottomPath)o[0]*=e,o[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(),a=this.scales.y.range(),l=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return 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=a[1]>a[0];this.scales={x:l(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:l(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,o,i,r,s,a,l,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!==(o=d.themeSemantic)&&void 0!==o?o:{},categorical:null!==(i=d.themeCategorical)&&void 0!==i?i:nt},resolveColor:(t,e)=>{var n,o;const i=this.resolveGroupColor(t);if(i)return i;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(o=null===(n=d.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(r=d.layoutConfig)&&void 0!==r?r:{},selection:null!==(s=d.layoutSelection)&&void 0!==s?s:null};let g;try{g=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!==(a=g.overlays)&&void 0!==a?a:null;const y=null!==(l=g.nodes)&&void 0!==l?l:[];if(this._customRestyle=g.restyle,this.hasCustomRestyle=!!g.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of y)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(y,null!==(c=d.layoutSelection)&&void 0!==c?c:null)}return Ot({label:"customLayout",nodes:y,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),y}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 o=t.groupData(e),i=[],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}=pt(t.ribbons);if(r.length>0&&i.push(...mt(t,e,r)),n.length>0)for(const e of o)i.push(...vt(t,e.data,e.key,n))}for(const e of o){const n=t.resolveLineStyle(e.key,e.data[0]),o=M(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(o.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return bt(t,o,i),i}(f,e);case"area":return function(t,e){const n=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=pt(t.ribbons);if(r.length>0&&o.push(...mt(t,e,r)),i.length>0)for(const e of n)o.push(...vt(t,e.data,e.key,i))}const i=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=_(e.data,t.scales,t.getX,t.getY,i,n,e.key,r),a=wt(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return bt(t,n,o),o}(f,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=pt(t.ribbons);if(r.length>0&&o.push(...mt(t,e,r)),i.length>0)for(const e of n)o.push(...vt(t,e.data,e.key,i))}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(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=_(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=wt(t.config.gradientFill);a&&(i.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=M(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return bt(t,n,o),o}(f,e);case"stackedarea":return function(t,e){var n,o,i,r;const s=t.groupData(e),a=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",l=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const n of s){let o=0;for(const e of n.data){const n=t.getX(e),i=t.getY(e);Number.isFinite(n)&&Number.isFinite(i)&&(o+=i)}e.set(n.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(t.key))&&void 0!==i?i:0)-(null!==(r=e.get(o.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(o=e.get(n.key))&&void 0!==o?o:0):(a.push(n),c+=null!==(i=e.get(n.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();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,o,i,r,s,a="zero"){var l,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 i of e.data){const e=n(i),r=o(i);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 o of t)n+=(null===(l=h.get(o.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=P(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},a),y=[],p=new Map,m=new Map;for(const t of d)m.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),o=[],a=[],l=new Map;for(const n of d){let i=t.get(n)||0;const s=m.get(n);r&&(i/=f.get(n));const c=s+i,u=e.x(n);a.push([u,e.y(s)]),o.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}p.set(n.key,l);const c={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),y.push(c)}return{nodes:y,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 o=h.get(n.key);if(o)for(const i of n.data){const n=t.getX(i),r=t.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||e.set(i,o.get(n))}}const n=n=>{var o;return null!==(o=e.get(n))&&void 0!==o?o:t.getY(n)};bt(t,s,f,n)}return f}(f,e);case"scatter":case"bubble":return function(t,e){var n;const o=[],i="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 o of n)t>o&&(t=o),o>e&&(e=o);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const a=t.getColor?t.resolveColorMap(e):null,l=(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=St[h%St.length],h++,d.set(t,n)),n};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||i;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(n);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const i=f(c(n)+""),s=T(n,t.scales,t.getX,t.getY,Math.PI*r*r,i,e,u);s&&o.push(s)}else{const i=O(n,t.scales,t.getX,t.getY,r,e,u);i&&o.push(i)}}return o}(f,e);case"heatmap":return Pt(f,e,t);case"bar":{const t=function(t,e){var n,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=j(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=n.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const s=[],a=t.scales,[l,c]=a.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,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of i.values()){const n=Math.max(e.start,l),i=Math.min(e.end,c);if(n>=i)continue;const h=a.x(n),y=a.x(i),p=Math.abs(y-h),m=p>f+1?f:0,v=Math.min(h,y)+m/2,x=Math.max(p-m,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const i of r){const r=e.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=t.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push($(v,Math.min(l,c),x,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:i,categoryValue:r},i)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push($(v,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of i.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).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,o,i,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),o=t.getY(n);if(null==o||Number.isNaN(o))continue;const i=t.scales.x(e),r=t.scales.y(o);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),l.push(c)}return l}(f,e);case"waterfall":return function(t,e,n){var o,i,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),o=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",y=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=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 o=f[e],i=t.getX(o),r=t.getY(o),s=b+r;let a;a=f.length-1>e?t.getX(f[e+1])-i:e>0?i-t.getX(f[e-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,k=Math.min(l,c)+p/2,w=Math.max(l,c)-p/2-k;if(0>=w){b=s;continue}const A=d.y(b),S=d.y(s),j=Math.min(A,S),M=Math.abs(A-S),_={fill:0>r?y:g,stroke:m,strokeWidth:v};null!=x&&(_.opacity=x),u.push($(k,j,w,M,_,Object.assign(Object.assign({},o),{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,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const i=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));o>0&&e>o&&(e=o)}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 o=t.getHigh(n),s=t.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:t.getOpen(n),h=i?s:t.getClose(n);if(!i&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};i&&(y.isRange=!0),r.push(y)}return r}(f,e);default:return[]}}resolveBoundsStyle(t,e){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{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?st(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var o,i;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 o=Array(e.length);let i=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(o[n]=st(t,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:e.length;if(2>o)continue;if(e.length===o){const i=Array(o);let a=!1;for(let n=0;e.length>n;n++){const o=s.get(e[n]);null!=o?(i[n]=st(t,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of e){const e=s.get(n);if(null!=e){const n=st(t,e,r);i>n&&(i=n)}}if(1>i){const t=Array(o);t.fill(i),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=st(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=t.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=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 i=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=o.get(e);if(null==r)continue;const a=at(t,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const i=o.get(e);if(null==i)continue;const r=at(t,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&<(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,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;e.length>l;l++){const c=e[l],u=ft(t,c,l);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===(i=c.style)||void 0===i?void 0:i.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?o.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&&o.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=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],i=ft(this.transitionContext,e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(i,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(i,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(i,{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,o,i){var r,s,a,l,c,u,d,h,f,g,y,p,m,v,x,b,k,w,A,S,j,M,_,P,O,T,$,L,C,E,R,z,D,N,F,W,B,I,Y,G,H;if(0===o.size&&0===i.size)return n;const q=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 X=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],T=ft(t,r,e);if(!T)continue;if(r._transitionKey=T,"line"===r.type||"area"===r.type){const t=i.get(T);if(t){if(U.add(T),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];X=!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]];X=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=t.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l: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}),X=!0;continue}const $=o.get(T);if("point"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,$.x===t.x&&$.y===t.y&&$.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=$.x,r.y=$.y,r.r=null!==(d=$.r)&&void 0!==d?d:r.r,X=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("rect"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,$.x===t.x&&$.y===t.y&&$.w===t.w&&$.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=$.x,r.y=$.y,r.w=null!==(g=$.w)&&void 0!==g?g:r.w,r.h=null!==(y=$.h)&&void 0!==y?y:r.h,X=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("heatcell"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,$.x===t.x&&$.y===t.y&&$.w===t.w&&$.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=$.x,r.y=$.y,r.w=null!==(x=$.w)&&void 0!==x?x:r.w,r.h=null!==(b=$.h)&&void 0!==b?b:r.h,X=!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}),X=!0;else if("candlestick"===r.type)if($&&null!=$.openY){V.add(T);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,($.x!==t.x||$.openY!==t.openY||$.closeY!==t.closeY||$.highY!==t.highY||$.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=$.x,r.openY=$.openY,r.closeY=null!==(j=$.closeY)&&void 0!==j?j:r.closeY,r.highY=null!==(M=$.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(_=$.lowY)&&void 0!==_?_:r.lowY,X=!0)}else r._targetOpacity=null!==(O=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==O?O:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[t,e]of i)if(!U.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={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!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!0}for(const[t,e]of o)if(!V.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(R=e.h)&&void 0!==R?R:0,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(W=e.openY)&&void 0!==W?W:e.y,i={type:"candlestick",x:e.x,openY:o,closeY:null!==(B=e.closeY)&&void 0!==B?B:o,highY:null!==(I=e.highY)&&void 0!==I?I:o,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:o,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(H=e.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}X=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),X&&(n.activeTransition={startTime:ht(),duration:q}),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,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=ut(t,n.activeTransition),d=ct(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?o.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=dt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=dt(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=dt(i,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==n.w&&(t.w=dt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=dt(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:dt(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==n.w&&(t.w=dt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=dt(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:dt(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=dt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=dt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=dt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=dt(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:dt(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 o=0;t.path.length>o;o++)t.path[o][0]=dt(e[o][0],n[o][0],d),t.path[o][1]=dt(e[o][1],n[o][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:dt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,o=t._targetTopPath,i=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=dt(e[n][0],o[n][0],d),t.topPath[n][1]=dt(e[n][1],o[n][1],d);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=dt(n[e][0],i[e][0],d),t.bottomPath[e][1]=dt(n[e][1],i[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(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||nt,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],i[t%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(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 i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,o;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 i=this.config.lineStyle;if("function"==typeof i){const n=i(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(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.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)||nt;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>Et.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}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,o=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)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)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(),i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(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)=>{i.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,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(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,o,i;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,a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=l||!C(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!C(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=E(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=E(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=E(this.config.xAccessor,"x"),this.getY=E(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Ct(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!C(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?z(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!C(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?z(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!C(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?E(this.config.sizeAccessor,"size"):void 0,s=!0),"symbolAccessor"in t&&!C(t.symbolAccessor,r.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?z(this.config.symbolAccessor):void 0,s=!0),"colorAccessor"in t&&!C(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?z(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!C(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?E(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!C(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Ct(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!C(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?z(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!C(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!C(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!C(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!C(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?E(this.config.openAccessor,"open"):void 0,this.getHigh=E(this.config.highAccessor,"high"),this.getLow=E(this.config.lowAccessor,"low"),this.getClose=e?E(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!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&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Rt(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function zt(t,e){var n,o=[],i=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,o,d=!1;for(i.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===n?(u(n,i),d=!0):r[o]||(d=c(o));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[o=a[t][e]];h||(s[o]=h={}),h[o]=!0}return i.pop(),d}function u(t,e){var n=[].concat(e).concat(t);o.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,o=function(t){for(var e=t.length,n=Array(e),o=Array(e),i=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(e){var l=[e],c=[e];for(n[e]=o[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=o[y]=u,i[y]=!0,u+=1,l.push(y),c.push(y);break}i[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=g}else{if(o[e]===n[e]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var x=l[g];if(i[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=d.length,x===e){l.length=g;break}}d.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];h.push(b)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(t),i=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],n=s);var l=i[n];if(!l)return!1;var c=t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return o}function Dt(t){return t.y0-t.y1>0?"up":"down"}function Nt(t,e){return e(t.source)==e(t.target)}function Ft(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 Wt(t){return t.target.x0-t.source.x1}function Bt(t,e){var n=Yt(t),o=Wt(e)/Math.tan(n);return"up"==Dt(t)?t.y1-o:t.y1+o}function It(t,e){var n=Yt(t),o=Wt(e)/Math.tan(n);return"up"==Dt(t)?t.y1+o:t.y1-o}function Yt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Gt(t,e){return e(t)}function Ht(t){return Xt(t.source)}function qt(t){return Xt(t.target)}function Xt(t){return(t.y0+t.y1)/2}function Vt(t){return t.virtual?0:t.value}function Ut(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Nt(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Nt(t,e)?o+1:o}),n+o}function Zt(t){return t.target.depth}function Qt(t,e){return t.sourceLinks.length?t.depth:e-1}function Kt(t,e){return t.y0-e.y0}function Jt(t,e){return e.y0-t.y0}function te(t,e){return t.y1-e.y1}function ee(t,e){return e.y1-t.y1}function ne(t,e){return ie(t.source,e.source)||t.index-e.index}function oe(t,e){return ie(t.target,e.target)||t.index-e.index}function ie(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function re(t,e){return se(t)==se(e)?"bottom"==t.circularLinkType?Jt(t,e):Kt(t,e):se(e)-se(t)}function se(t){return t.target.column-t.source.column}function ae(t,e){return le(t)==le(e)}function le(t){return t.y0-t.y1>0?"up":"down"}function ce(t,e,n,o,i){let r=t;var a=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var l=s.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}),ue(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),ue(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+o,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,Nt(t,e)&&Ft(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+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-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?Jt:Kt);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?ee:te),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=l-i-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,o=t.target.x0,i=t.y1,r=(e+o)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(t)}),r}function ue(t,e,n){t.sort(re);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Nt(t,e)&&Ft(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&de(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function de(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function he(t){return function(){return t}}function fe(t){return t.index}function ge(t){return t.nodes}function ye(t){return t.links}function pe(t,e,n){var o=s.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(i,r){var s=i.length;if(e)i.sort(e);else if(r>0){var a=new Map;i.forEach(function(t,e){var n,o,i,r=(o=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Xt(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Xt(t.target)*e,o+=e}}),o>0?i/o:NaN);a.set(t,{bc:r,idx:e})}),i.sort(function(t,e){var n=a.get(t),o=a.get(e),i=n.bc,r=o.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(i)||isNaN(r)?isNaN(i)?isNaN(r)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ut(e,n)-Ut(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==o.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==Ut(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+i,e.y1=e.y0+e.value*t.ky)})})}function me(t,e,n,o,i,r){var a=s.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 l=1,c=r;c>0;--c)u(l*=.99,n),d();function u(e,n){var o=a.length;a.forEach(function(i){var r=i.length,a=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ut(i,n)>0){var c=s.mean(i.sourceLinks,qt),u=s.mean(i.targetLinks,Ht),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Xt(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==r)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(a==o-1&&1==r)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=s.mean(i.sourceLinks,qt),g=s.mean(i.targetLinks,Ht),y=((f&&g?(f+g)/2:f||g)-Xt(i))*e;i.y0+=y,i.y1+=y}})})}function d(){a.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||ie),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function ve(t){t.nodes.forEach(function(t){t.sourceLinks.sort(oe),t.targetLinks.sort(ne)}),t.nodes.forEach(function(t){var e=t.y0,n=e,o=t.y1,i=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function xe(){var t=0,e=0,n=1,o=1,i=24,r=8,a=null,l=fe,c=Qt,u=void 0,d=32,h=2,f=ge,g=ye;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=o,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 s.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 o=t.source,i=t.target;"object"!=typeof o&&(o=t.source=Rt(n,o)),"object"!=typeof i&&(i=t.target=Rt(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(f,l),function(t,e){var n=0;if(null==e){for(var o=[],i=0;t.links.length>i;i++){var r=t.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=zt(o);l.sort(function(t,e){return t.length-e.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}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||c[o]&&c[o][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,o=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,t.nodes.forEach(function(t){Gt(t,e)!=Gt(i.source,e)&&Gt(t,e)!=Gt(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Nt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(s.sum(t.sourceLinks,Vt),s.sum(t.targetLinks,Vt)),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 o,i,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(f,u,c);var g=r;if(null!==a){var y=s.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=s.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,n){var o=s.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 i=s.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/s.sum(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var r=s.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,g,i),pe(f,u,l),me(f,u,l,g,g,d),ve(f),ce(f,l,h,10,8),pe(f,u,l),me(f,u,l,g,g,d),ve(f),ce(f,l,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 o=n.links.filter(function(n){return Gt(n.source,e)==Gt(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ae(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Bt(e,t);return t.y1-n}if(e.target.column>t.target.column)return Bt(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;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(f,l),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return Gt(n.target,e)==Gt(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ae(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=It(e,t);return t.y0-n}if(e.source.column>t.source.column)return It(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;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(f,l),function(t){var e=t.nodes,n=t.links,o=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==o||0==i){var r=s.min(e,function(t){return t.y0}),a=s.max(e,function(t){return t.y1}),l=(t.y1-t.y0)/(a-r);function c(e){return(e-r)/(a-r)*(t.y1-t.y0)+t.y0}1>l?(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*l})):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),ce(f,l,h,10,8)}(y),y}return y.update=function(t){return ve(t),ce(t,l,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(i=+t,y):i},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:he(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:he(t),y):g},y.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:he(t),y):l},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:he(t),y):c},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(d=+t,y):d},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],y):[[t,e],[n,o]]},y.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],y):[n-t,o-e]},y}function be(t){const{sx:e,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}Et.GROUP_COLOR_MAP_CAP=1e3,Et.QUADTREE_THRESHOLD=500;const ke=t=>{let e,n,o,i,r,s,l,c,u;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=a.interpolateNumber(r,s),c=l(.5),u=l(.5),`M${e},${r}C${e},${c} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${c} ${i},${r}Z`;const d=t.sankeyWidth/2,h=a.interpolateNumber(t.source.x1,t.target.x0),{pathD:f}=be({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 we(t){var e;const n=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,o=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${e},${o-n}L${e+a},${o-n}L${e+a},${o+n}L${e},${o+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${r},${s+h*n}Z`}const Ae=new Set,Se=new WeakMap;function je(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Se.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Se.set(t,n);const o=new Proxy(t,{get(t,n,o){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Ae.has(t)||(Ae.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,o)}});return n.set(e,o),o}const Me={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(Zt))-1:0},justify:Qt};function _e(t){return"string"==typeof t?t:t.id}const Pe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=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 v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const x=xe().extent(v).links(m).nodes(p).nodeAlign(Me[h]||Qt).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l: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>i&&(i=r.verticalFullExtent+s)}const r=e-t,s=i-n,u=o[0],d=o[1];if(r>0&&s>0&&(0>t||0>n||e>u||i>d)){const e=Math.min(u/r,d/s),o=-t*e+(u-r*e)/2,i=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of m)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,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+o,n.targetX=n.targetX*e+o,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+o,n.leftFullExtent=n.leftFullExtent*e+o,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+o,n.leftInnerExtent=n.leftInnerExtent*e+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,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 m){const e=_e(t.source),n=_e(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=d;const i=b.get(e),r=b.get(n);i&&(o.source=i),r&&(o.target=r)}}},buildScene(t,e,n,o){var i,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:W,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],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 o=d?d(je(e,"nodeStyle")):{},i={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(e.id,("string"==typeof i.fill?i.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:i,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,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,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof g?g(t)||i:"target"===g?b.get(o.id)||p.get(o.id)||i:b.get(e.id)||p.get(e.id)||i;const u=h?h(je(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=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||i;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.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!==(l=u.fillOpacity)&&void 0!==l?l: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?we(t):ke(t),!d)continue;const y={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,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,i=n.y1-n.y0;if(0>=t||0>=i)continue;const r=e?e(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+i/2),x.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:x}}};function Oe(t){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);return[e,n]}function Te(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}const $e={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r;if(0===t.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=o[0]/2,c=o[1]/2,u=n.__previousPositions;let d=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==u?void 0:u.get(e.id);t?d++:n?(e.x=n.x,e.y=n.y,d++):h.push(e)}const f=d>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 o=Le(t.id,e,n);if(o.length>0){let e=0,n=0;for(const t of o)e+=t.x,n+=t.y;const i=Ce(t.id),r=i%360*(Math.PI/180),s=10+i%20;t.x=e/o.length+s*Math.cos(r),t.y=n/o.length+s*Math.sin(r)}else{const e=Ce(t.id),n=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(n),t.y=c+o*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const o=t[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(n+.5),i=n*e;o.x=a+t*Math.cos(i),o.y=c+t*Math.sin(i)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:f?40:g,p=Ee(n.nodeSize,n.nodeSizeRange,t),m=t=>p(t);if(y>0){const n=l.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=l.forceSimulation().force("charge",l.forceManyBody().strength(t=>-25*m(t))).force("center",l.forceCenter(a,c).strength(.8)).force("x",l.forceX(a).strength(.15)).force("y",l.forceY(c).strength(.15));if(o.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),o.force("link",n)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Ee(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:W,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=d?d(je(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,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),o="object"==typeof t.target?t.target:x.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const i=h?h(je(t,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.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 o=f(je(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Le(t,e,n){const o=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.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||o.push({x:t.x,y:t.y})}}return o}function Ce(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 Ee(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[a,l]=Oe(s);if(a===l)return()=>(r[0]+r[1])/2;const c=o.scaleLinear().domain([a,l]).range(r).clamp(!0);return e=>{var n;const o=null===(n=e.data)||void 0===n?void 0:n[t];return null==o||"number"!=typeof o?r[0]:c(o)}}const Re=W,ze={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const{padAngle:i=.01,groupWidth:s=20,sortGroups:a}=n,l=Math.min(o[0],o[1])/2,u=l-s,d=o[0]/2,h=o[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=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=y.get("string"==typeof t.source?t.source:t.source.id),o=y.get(e);if(void 0===n||void 0===o)continue;const i=f(t);m[n][o]=i}const v=c.chord().padAngle(i);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=r.arc().innerRadius(u).outerRadius(l);for(const e of b){const n=t[e.index],o=k.centroid({innerRadius:u,outerRadius:l,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+d,n.y=o[1]+h,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),o=w.get(e);n&&(t.source=n),o&&(t.target=o)}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,o=t[e.target.index].id,i=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=n,d=Math.min(o[0],o[1])/2,h=d-l,f=o[0]/2,g=o[1]/2,y=n.nodeStyle,p=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Re,x=new Map;t.forEach((t,e)=>{x.set(t.id,v[e%v.length])});const b=c.ribbon().radius(h),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let r;r=y?y(je(n,"nodeStyle")).fill||x.get(n.id)||v[e%v.length]:x.get(n.id)||v[e%v.length];const s=y?y(je(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const i=De(o,f,g);let l=(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)l=p(je(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===m&&n?l=x.get(n.id)||l:e&&(l=x.get(e.id)||l)}const c=p?p(je(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=c.fillOpacity)&&void 0!==a?a:u,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=d+12;for(const n of t){const t=n.__arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;A.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function De(t,e,n){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const i=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+e+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===t||"z"===t?(i.push(t),r++):(i.push(o[r]),r++)}return i.join(" ")}const Ne=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Fe(t){const[e,n,o]=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*o>150?"#222":"#fff"}function We(t,e,n){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Be(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 Ie(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ne}function Ye(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 Ge(t,e,n,o,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${o} ${n},${o}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+o)/2} T ${n},${o}`}{const i=(e+o)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${o}`}}const He={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,o){var i;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),l=n.hierarchySum,c="function"==typeof l?l:"string"==typeof l?t=>Number(t[l])||0:t=>Number(t.value)||0,d=u.hierarchy(r,a);d.sum(c),d.sort((t,e)=>{var n,o;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.tree();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.cluster();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);break;case"treemap":!function(t,e,n,o){var i,r;const s=null!==(i=e.padding)&&void 0!==i?i:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=u.treemap().size([n,o]).tile(u.treemapBinary).padding(s);a>0&&l.paddingTop(a),l(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,o){var i;const r=null!==(i=e.padding)&&void 0!==i?i:4;u.pack().size([n,o]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,o){var i;u.partition().size([n,o]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],r={id:We(o,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=o.value)&&void 0!==i?i:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?qe(r,o,n):"treemap"===s||"partition"===s?Xe(r,o):"circlepack"===s&&Ve(r,o),r.__hierarchyNode=o,t.push(r),y.set(o,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=y.get(t.parent),o=y.get(t);n&&o&&e.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=[],y=[],p=[],m=n.treeOrientation||"vertical",v="radial"===m,x=o[0]/2,b=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,o=e.y;v&&(t+=x,o+=b);const r=i(je(e,"nodeStyle"));let l=r.fill||Ye(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ie(n);l=t[e.depth%t.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=e.x,s=e.y,a=o.x,l=o.y;v&&(i+=x,s+=b,a+=x,l+=b);const f=Ge(i,s,a,l,m),g=r(je(t,"edgeStyle")),p={fill:"none",stroke:g.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=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=Be(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let o,i,r,s=n.x,a=n.y;if(v&&(s+=x,a+=b),v){const t=s-x,e=a-b,n=Math.sqrt(t*t+e*e);n>0?(o=s+t/n*10,i=a+e/n*10,r=0>t?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-k-6,r="end"):(o=s+k+6,r="start"),i=a):(o=s,i=a+k+14,r="middle");p.push({x:o,y:i,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,o,i,r);case"treemap":case"partition":return function(t,e,n,o){var i,r,s,a,l;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 a=o(je(n,"nodeStyle"));let l=a.fill||Ye(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ie(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(i=e.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.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=Be(e.nodeLabel),i=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"===i&&!h)continue;if("parent"===i&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=o(je(c,"nodeStyle")).fill||Ye(e);if(e.colorByDepth&&void 0!==c.depth){const t=Ie(e);g=t[c.depth%t.length]}const y="string"==typeof g?Fe(g):null!==(l=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#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:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);case"circlepack":return function(t,e,n,o){var i,r,s,a,l,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=o(je(n,"nodeStyle"));let c=l.fill||Ye(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ie(e);c=t[n.depth%t.length]}const u={fill:c,stroke:l.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};g.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=Be(e.nodeLabel);for(const i of t){const t=null!==(l=i.__radius)&&void 0!==l?l:5,r=n?n(i):i.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=o(je(i,"nodeStyle")).fill||Ye(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ie(e);a=t[i.depth%t.length]}if(s){const n="string"==typeof a?Fe(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:i.x,y:i.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:g,sceneEdges:[],labels:y}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qe(t,e,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=e.x,o=e.y;t.x=o*Math.cos(n-Math.PI/2),t.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(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 Xe(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 Ve(t,e){var n;const o=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function Ue(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Ze={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;i&&function(t,e,n,o,i){var s,a;const l=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!==(s=n.orbitSize)&&void 0!==s?s:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ue(n);y.metaMap.clear(),o.length=0,i.length=0;const p=new Map;function m(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 v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,s,a,d,h,p){const v=l(e);if(!(null==v?void 0:v.length))return;const x=v.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=v.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,j={id:n,depth:h,data:e,parentId:n},M=p?d/f(j)*S:d*S,_=r.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(w),O=g(j);for(let e=0;w.length>e;e++){const r=(P[e].startAngle+P[e].endAngle)/2,l=w[e],u=m(c(l)),d=s+M*Math.sin(r),f=a+M*Math.cos(r)*O;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),y.metaMap.set(u,{ring:M,angle:r,depth:h,parentId:n,eccentricity:O}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(l,u,d,f,M,h+1,!0)}A+=k}}(t,k,v,x,b,1,!1)}(i,o,n,t,e)},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Ue(n),o=new Map;for(const e of t)o.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.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:o}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*o,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=d?d(je(e,"nodeStyle")):{},c={fill:o.fill||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};g.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 m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),n="object"==typeof t.target?t.target:m.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.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(je(n,"nodeSize"));if(4>=t)continue;const o="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:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,o,i)=>!1!==n.orbitAnimated&&(function(t,e){var n,o;const i=Ue(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o: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),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const o=t.angle+a*l*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(o),e.y=n.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Qe={sankey:Pe,force:$e,chord:ze,tree:He,cluster:He,treemap:He,circlepack:He,partition:He,orbit:Ze};function Ke(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=tt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Je(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(o)%t.length])&&void 0!==n?n:"#4e79a7"}}function tn(t){const e=t.getSymbol;if(!e)return null;const n=t.config.symbolMap,o=new Map;let i=0;return t=>{const r=e(t)+"",s=null==n?void 0:n[r];if(s)return s;let a=o.get(r);return a||(a=St[i%St.length],i++,o.set(r,a)),a}}function en(t,e,n,o,i,r,s){t.push(e?{type:"symbol",x:o,y:i,size:Math.PI*r*r,symbolType:e(n),style:s,datum:n}:{type:"point",x:o,y:i,r:r,style:s,datum:n})}function nn(t,e){var n;const{columns:o,config:i,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle,h=Object.values(o),f=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),g=d&&!f&&h.length>1&&(null!==(n=i.cornerRadius)&&void 0!==n?n:0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],o="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:e.pctStart,d=c+o*u,f=c+(o+("number"==typeof(null==n?void 0:n._pct)?n._pct:e.pct))*u,y=r(e.pieceData[0],e.name),p=0===t,m=t===h.length-1,v=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:d,endAngle:f},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:y,datum:(null==n?void 0:n._nonInteractive)?null:e.pieceData,category:e.name});(null==n?void 0:n._roundedEnds)?v.roundedEnds=n._roundedEnds:g&&(v.roundedEnds={start:p,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function on(t){var e,n,o;const i=t.length,r=t[0],a=t[i-1];return{n:i,min:r,q1:null!==(e=s.quantile(t,.25))&&void 0!==e?e:r,median:null!==(n=s.quantile(t,.5))&&void 0!==n?n:(r+a)/2,q3:null!==(o=s.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/i}}const rn={bar:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,y="horizontal"===h,p=a.normalize,m=[];if(c){const t=new Set;for(const e of Object.values(s))for(const n of e.pieceData){const e=c(n);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=l(n),o.pieces.push(n)}let n=0;if(p)for(const t of e.values())n+=Math.abs(t.total);let o=0,i=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;p&&n>0&&(a/=n);const l=u(s.pieces[0],c?r:t.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=d(0>a?i:o+a),n=0>a?d(i+a)-d(i):d(o)-d(o+a);f.push($(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?i+=a:o+=a}else if(y){const e=d(0>a?i+a:o),n=0>a?d(i)-d(i+a):d(o+a)-d(o);f.push($(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,x=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(x>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(i=e.datum)||void 0===i?void 0:i.category)||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,n;return(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)>=0}),n=e.filter(t=>{var e,n;return 0>(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=x),n.length>0&&(n.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=x)}}return f},clusterbar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const g=h.length||1;for(const t of Object.values(o)){const e=t.width/g,n=.2*e,o=e-n,i=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),f=a(i,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push($(r,Math.min(a,d),o,Math.abs(a-d),f,i,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push($(Math.min(a,d),r,Math.abs(d-a),o,f,i,h[s]))}}}}const y=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}return u},point:function(t,e){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=i,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,y=tn(t),p=2*Math.PI,m=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const i=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[i]||c,v=l(e,t.name),x=v.r||5;let b,k;if(f){const e=m+(t.pctStart+t.pct/2)*p,n=u(r);b=Math.cos(e)*n,k=Math.sin(e)*n}else h?(b=t.middle,k=u(r)):(b=u(r),k=t.middle);en(d,y,e,b,k,x,v)}return d},swarm:function(t,e){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a,u=tn(t);for(const t of Object.values(o)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const o=t.pieceData[n],a=i(o),d=r(o,t.name),h=d.r||4,f=(7919*n%100/100-.5)*e*.8;en(l,u,o,c?t.middle+f:s(a),c?s(a):t.middle+f,h,d)}}return l},pie:nn,donut:nn,boxplot:function(t,e){var n,o,i,r,a,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:f}=t,{r:g,projection:y}=c,p=[],m="vertical"===y,v=!1!==d.showOutliers;for(const e of Object.values(u)){const c=e.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const u=c[0],d=c[c.length-1],y=null!==(n=s.quantile(c,.25))&&void 0!==n?n:u,x=null!==(o=s.quantile(c,.5))&&void 0!==o?o:(u+d)/2,b=null!==(i=s.quantile(c,.75))&&void 0!==i?i:d,k=b-y,w=y-1.5*k,A=b+1.5*k,S=null!==(r=c.find(t=>t>=w))&&void 0!==r?r:u,j=null!==(a=[...c].reverse().find(t=>A>=t))&&void 0!==a?a:d,M=f(e.pieceData[0],e.name),_=[];if(v)for(const t of e.pieceData){const n=h(t);if(w>n||n>A){const o=m?e.middle:g(n),i=m?g(n):e.middle;_.push({px:o,py:i,value:n,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(x),q3Pos:g(b),maxPos:g(j),stats:{n:c.length,min:S,q1:y,median:x,q3:b,max:j,mean:c.reduce((t,e)=>t+e,0)/c.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),v)for(const e of _)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var n,o,i;const{scales:r,columns:a,config:l,getR:c,resolveSummaryStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,y=l.bins||20,p=!1!==l.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],a=e[e.length-1],l=(a-r)/y||1,h=Array(y).fill(0);for(const t of e)h[Math.min(Math.floor((t-r)/l),y-1)]++;const m=Te(h,1),v=t.width/2*.9;let x="";if(g){x=`M ${t.middle} ${d(r)}`;for(let e=0;y>e;e++){const n=d(r+(e+.5)*l);x+=` L ${t.middle+h[e]/m*v} ${n}`}x+=` L ${t.middle} ${d(a)}`;for(let e=y-1;e>=0;e--){const n=d(r+(e+.5)*l);x+=` L ${t.middle-h[e]/m*v} ${n}`}x+=" Z"}else{x=`M ${d(r)} ${t.middle}`;for(let e=0;y>e;e++)x+=` L ${d(r+(e+.5)*l)} ${t.middle-h[e]/m*v}`;x+=` L ${d(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)x+=` L ${d(r+(e+.5)*l)} ${t.middle+h[e]/m*v}`;x+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const l=null!==(n=s.quantile(e,.25))&&void 0!==n?n:r,c=null!==(o=s.quantile(e,.5))&&void 0!==o?o:(r+a)/2,u=null!==(i=s.quantile(e,.75))&&void 0!==i?i:a;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(d(a),d(r)),width:t.width,height:Math.abs(d(a)-d(r))}:{x:Math.min(d(r),d(a)),y:t.x,width:Math.abs(d(a)-d(r)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:on(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=o,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[n,o]=Oe(e),i=null!=f&&isFinite(f)?f:n,r=null!=g&&isFinite(g)?g:o,h=(r-i)/u||1,y=Array(u).fill(0);for(const t of e)i>t||t>r||y[Math.min(Math.floor((t-i)/h),u-1)]++;const p=e.length,m=Te(y,1),v=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===y[e])continue;const n=(d?y[e]/p:y[e]/m)*t.width*.9,o=l(i+e*h),r=l(i+(e+1)*h);c.push($(Math.min(o,r),t.x+t.width-n,Math.abs(r-o),n,v,{bin:e,count:y[e],range:[i+e*h,i+(e+1)*h],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=o,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],r=(i-o)/d||1,c=Array(d).fill(0);for(const t of e)o>t||t>i||c[Math.min(Math.floor((t-o)/r),d-1)]++;const g=Te(c,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(o)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(o+(t+.5)*r)} ${e-c[t]/g*p}`;m+=` L ${l(i)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(o)}`;for(let t=0;d>t;t++){const n=l(o+(t+.5)*r);m+=` L ${e+c[t]/g*p} ${n}`}m+=` L ${e} ${l(i)} Z`}const v=h?{x:Math.min(l(o),l(i)),y:t.x,width:Math.abs(l(i)-l(o)),height:t.width}:{x:t.x,y:Math.min(l(i),l(o)),width:t.width,height:Math.abs(l(i)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:on(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const n=i(e);if(!n)continue;const[o,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push($(n,t.x,i-n,t.width,u,e,t.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push($(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){var n,i,r,s,a,l,c,u;const{columns:d,getR:h,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>d[t]).filter(Boolean);if(0===v.length)return y;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],w=[];let A=0;for(const t of v){const e=new Map;let n=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=h(o);i.total+=r,i.pieces.push(o),n+=r}w.push({col:t,groups:e,stepTotal:n}),k||n>A&&(A=n)}if(k)for(const t of w){let e=0,n=0;for(let o=0;x.length>o;o++){const i=t.groups.get(x[o]);i&&(o%2==0?e+=i.total:n+=i.total)}const o=Math.max(e,n);o>A&&(A=o)}if(0===A)return y;const S=new Map;for(const t of x){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const j=w[0].stepTotal,M=k?.95*p:.9*e.width,_=o.scaleLinear().domain([0,A]).range([0,M]),P=null!==(i=t.config.connectorOpacity)&&void 0!==i?i:.3;let O=new Map;for(let e=0;w.length>e;e++){const n=w[e],o=n.col,i=0===e,d=o.width,h=.55*d,f=o.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of x){const o=n.groups.get(e);o&&(t+=_(o.total))}let e=p,r=p;for(let s=0;x.length>s;s++){const l=x[s],c=n.groups.get(l);if(!c)continue;const u=_(c.total),d=s%2==0,b=d?e:r-u;d?e+=u:r-=u;const k=g(c.pieces[0],l),w=null!==(a=S.get(l))&&void 0!==a?a:c.total,A=w>0?c.total/w*100:0,j=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(j.__funnelStepLabel=o.name,j.__funnelStepLabelX=p,j.__funnelStepLabelY=f,j.__funnelRowWidth=t),j.__funnelValueLabelX=b+u/2,j.__funnelValueLabelY=f,j.__funnelBarW=u),y.push($(b,f,u,h,k,j,l)),v.set(l,{x:b,y:f,w:u,h:h})}}else{const t=n.stepTotal,e=_(t),a=p-e/2,l=x[0],c="_default"!==l,u=null!==(s=null===(r=n.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],d=c?l:o.name,b=g(u,d),k=j>0?t/j*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:i,category:c?l:o.name});m&&(w.__funnelStepLabel=o.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=f,w.__funnelRowWidth=e,w.__funnelValueLabelX=p,w.__funnelValueLabelY=f,w.__funnelBarW=e),y.push($(a,f,e,h,b,w,d)),v.set(l,{x:a,y:f,w:e,h:h})}if(e>0&&O.size>0){const e=k?x:[x[0]];for(const i of e){const e=O.get(i),r=v.get(i);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(i);return g(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:P},datum:null!==(u=null===(c=n.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===i?o.name:i};y.push(a)}}O=v}return y},"bar-funnel":function(t,e){var n,o,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=t,d=[],h=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===h.length)return d;const f=[],g=new Set;for(const t of h)for(const e of t.pieceData){const t=l?l(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of h){const e=new Map;let n=0;for(const o of t.pieceData){const t=l?l(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=a(o);i.total+=r,i.pieces.push(o),n+=r}p.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=p[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const v=u.r,x=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],n=e.col,o=0===t,s=t>0?p[t-1]:null,a=n.width/x,l=a*b,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const p=g.total,x=null!==(i=m.get(h))&&void 0!==i?i:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:p,A=o?0:Math.max(0,w-p),S=n.x+t*a+l/2,j=v(p),M=v(0)-j,_=c(g.pieces[0],y?h:n.name),P=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(p+A)});if(d.push($(S,j,u,M,_,P,y?h:n.name)),A>0){const t=v(p+A),e=j-t,o=Object.assign({},_),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:x>0?A/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name});d.push($(S,t,u,e,o,i,y?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=o,u=[],d="horizontal"===c,h=t.config.gradientFill,f=d?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[o,r]=l.range(),s=Math.min(o,r),a=Math.abs(r-o);for(const n of Object.values(i)){const o={fill:t,opacity:e},i=d?$(s,n.x,a,n.width,o,null,"__track__"):$(n.x,s,n.width,a,o,null,"__track__");u.push(i)}}const y=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(i)){let e=0;const n=u.length;for(const n of t.pieceData){const o=Math.abs(r(n));if(0===o)continue;const i=s?s(n):t.name,c=a(n,i);let g;if(d){const r=l(e),s=l(e+o);g=$(r,t.x,s-r,t.width,c,n,i)}else{const r=l(e+o),s=l(e);g=$(t.x,r,t.width,s-r,c,n,i)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=o}if(y>0&&u.length>n){const t=u.slice(n),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:y,tr:y,br:y,bl:y}:d?(e.cornerRadii={tl:y,bl:y},o.cornerRadii={tr:y,br:y}):(e.cornerRadii={bl:y,br:y},o.cornerRadii={tl:y,tr:y})}}return u}};class sn{constructor(t){this.rExtent=new S,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new A(t.windowSize),this.getO=z(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>E(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new S)):(this.getR=E(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=z(t.stackBy),this.getGroup=z(t.groupBy),this.getColor=z(t.colorAccessor),this.getSymbol=z(t.symbolAccessor),this.getConnector=z(t.connectorAccessor),this.getDataId=z(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new A(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();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)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const i=n.toArray(),r=e.projection||"vertical",s=e.oExtent||this.resolveCategories(i),a=this.computeValueDomain(i,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,h;if(c){d=o.scaleBand().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;h=o.scaleLinear().domain(a).range([i,n])}else l?(d=o.scaleBand().domain(s).range([0,t.height]).padding(u),h=o.scaleLinear().domain(a).range([0,t.width])):(d=o.scaleBand().domain(s).range([0,t.width]).padding(u),h=o.scaleLinear().domain(a).range([t.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((i,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(n,i);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=e.extentPadding)&&void 0!==s?s:.05,h=u-c,f=h>0?h*d:1;return c-=f,u+=f,c>0&&(c=0),l?o.scaleLinear().domain([c,u]).range([0,t.width]):o.scaleLinear().domain([c,u]).range([t.height,0])}):[];let f=i;this.rAccessors.length>1&&(f=i.flatMap(t=>this.rAccessors.map((e,n)=>Object.assign(Object.assign({},t),{__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(f,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i),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.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let i=null;if(n){i=new Set;for(const e of t)i.add(this.getO(e))}const r=i?Array.from(this.categories).filter(t=>i.has(t)):Array.from(this.categories);if(n&&void 0===o){const t=Math.max(50,3*i.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;i.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var n,o,i,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,n=new Map;for(const o of t){const t=this.getO(o),i=this.getR(o);0>i?n.set(t,(n.get(t)||0)+i):e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t);for(const t of n.values())c>t&&(c=t)}else if("bar"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=this.getR(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),c>t&&(c=t)}else if("swimlane"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const t=u-c,e=t>0?t*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[c,u]}buildColumns(t,e,n,o,i){var r;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=0;if("radial"===o)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let o;o="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,o),t+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*e.length;if(t>0)for(const[e,n]of u)u.set(e,n/t*r)}let d=0,h=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),i=l>0?o/l:0;let c,f;u?(c=h,f=u.get(t)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(t))&&void 0!==r?r:0,f=n.bandwidth()),s[t]={name:t,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.step(),pieceData:e,pct:i,pctStart:d},d+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){var n,o,i;if(!this.scales)return[];if(this.config.customLayout){const r=this.buildLayoutContext(t,e);let s;try{s=this.config.customLayout(r)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(n=s.overlays)&&void 0!==n?n:null;const a=null!==(o=s.nodes)&&void 0!==o?o:[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of a)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(a,null!==(i=this.config.layoutSelection)&&void 0!==i?i:null)}return Ot({label:"ordinal customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const r=this.getSceneContext(),s=rn[this.config.chartType];let a=s?s(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,o;const{scales:i,config:r,getConnector:s,getO:a}=t;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=s(e);if(!n)continue;let o,i;"point"===t.type?(o=t.x,i=t.y):(o=t.x+t.w/2,i=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:o,y:i,datum:e,category:a(e)})}const d=i.o.domain(),h=r.connectorStyle;for(const[e,i]of u)if(i.length>=2){i.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:e})}}return l}(r,a);a=[...t,...a]}return a}buildLayoutContext(t,e){var n,o,i,r;const s=this.config,a=null!==(n=s.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},l=Ke(s.colorScheme,s.themeCategorical,nt),c=this.scales;return{data:t,scales:{o:c.o,r:c.r,projection:c.projection},dimensions:{width:e.width,height:e.height,margin:a,plot:"radial"===c.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(o=s.themeSemantic)&&void 0!==o?o:{},categorical:[...l]},resolveColor:Je(l),config:null!==(i=s.layoutConfig)&&void 0!==i?i:{},selection:null!==(r=s.layoutSelection)&&void 0!==r?r:null}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(e)}):n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||nt,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?st(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,n="function"==typeof e,o=n?null:e||"category",i=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[o];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,sn.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._pointQuadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var n,o;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const r=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,i),a=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(e);let u=null;for(const n of t){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const t=n.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let i=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>i&&(i=t)}}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const i=r-o;s>i&&(n._pulseIntensity=1-i/s,n._pulseColor=a,n._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&n>e-o}synthesizeIntroPositions(){var t,e,n,o,i;this.prevPositionMap.clear();const r=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeKey(e,r);n&&("rect"===e.type?this.prevPositionMap.set(n,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===l&&(l=e.startAngle),this.prevPositionMap.set(n,{x:e.cx,y:e.cy,startAngle:l,endAngle:l,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var n,o,i;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(n)||0;return e.set(n,o+1),`${n}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(i=t.category)&&void 0!==i?i:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const o=this.scene[n],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,x,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let w=!1;const A=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const c=this.scene[t],u=this.getNodeKey(c,S);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(e=c.style.opacity)&&void 0!==e?e:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const t=c.startAngle;c.startAngle=t,c.endAngle=t,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:t,endAngle:t,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!A.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(c=e.r)&&void 0!==c?c:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(d=e.w)&&void 0!==d?d:0,h:null!==(h=e.h)&&void 0!==h?h:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const n=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:ht(),duration:k})}advanceTransition(t){var e,n,o,i;if(!this.activeTransition)return!1;const r=ut(t,this.activeTransition),s=ct(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;t.style.opacity=dt(i,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=dt(o.x,t._targetX,s),t.y=dt(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=dt(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=dt(i,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,s),t.y=dt(n.y,t._targetY,s),void 0!==n.w&&(t.w=dt(n.w,t._targetW,s),t.h=dt(n.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:dt(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const n=this.prevPositionMap.get(e);n&&void 0!==n.startAngle&&(t.startAngle=dt(n.startAngle,t._targetStartAngle,s),t.endAngle=dt(n.endAngle,t._targetEndAngle,s))}}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(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"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getDataId,o=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)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),i}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),i.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!C(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!C(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!C(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(C(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=z(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(n)?n:[n],r=Array.isArray(o)?o:[o];if(i.length!==r.length||i.some((t,e)=>!C(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>E(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new S)):(this.getR=E(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!C(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?z(this.config.stackBy):void 0),"groupBy"in t&&!C(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?z(this.config.groupBy):void 0),"colorAccessor"in t&&!C(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?z(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!C(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?z(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!C(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?z(this.config.connectorAccessor):void 0)}}sn.QUADTREE_THRESHOLD=500;const an={mercator:d.geoMercator,equalEarth:d.geoEqualEarth,albersUsa:d.geoAlbersUsa,orthographic:d.geoOrthographic,naturalEarth:d.geoNaturalEarth1,equirectangular:d.geoEquirectangular};function ln(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function cn(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function un(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function dn(t,e){if(2>t.length)return[t];const n=.4*e,o=[];let i=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function hn(t,e,n=24){const o=e[0]-t[0],i=e[1]-t[1],r=Math.sqrt(o*o+i*i);if(0===r)return[t,e];const s=-i/r,a=o/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,d=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;d.push([r*r*t[0]+2*r*i*c+i*i*e[0],r*r*t[1]+2*r*i*u+i*i*e[1]])}return d}function fn(t,e){if(2>t.length)return t;const n=e/2+1,o=[];for(let e=0;t.length>e;e++){const i=t[e];let r,s;0===e?(r=t[1][0]-i[0],s=t[1][1]-i[1]):e===t.length-1?(r=i[0]-t[e-1][0],s=i[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([i[0]+s/a*n,i[1]+-r/a*n])}return o}function gn(t,e,n,o,i){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=i/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class yn{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t.slice()}initStreaming(t=500){this.pointBuffer=new A(t),this.timestampBuffer=new A(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const n of t)this.pointBuffer.push(n),this.timestampBuffer.push(e);this.lastIngestTime=e}pushLine(t){null!=t&&"object"==typeof t&&(this.lineData.push(t),this.version++)}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return;const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){for(const t of e)this.lineData.push(t);this.version++}}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),i=[];return this.lineData=this.lineData.filter(t=>!o.has(n(t)+"")||(i.push(t),!1)),i.length>0&&this.version++,i}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&n.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)n.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(n(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return d.geoEqualEarth();if("string"==typeof t){const e=an[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),d.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=an[t.type],n=e?e():d.geoEqualEarth();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=d.geoPath(this.projection),this.fitProjection(t),this.geoPath=d.geoPath(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null};const o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,n,o,i,r;const s=this.projection,a=this.config,l=[...this.areas],c=ln(a.xAccessor,"lon"),u=ln(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const t=d.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const h=cn(a.lineDataAccessor);for(const t of this.lineData){const e=h(t);if(e&&e.length>0){const t=e.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==l.length){if(a.projectionExtent){const[[e,n],[o,i]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[o,n],[o,i],[e,i],[e,n]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=t.width*e,i=t.height*e;s.fitExtent([[n,i],[t.width-n,t.height-i]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(i=s.rotate)||void 0===i?void 0:i.call(s))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;n&&n.rotate&&(n.rotate(t),this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,n;return null!==(n=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,yn.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._quadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,n,o;const i=[],{config:r}=this,s=this.projection,a=this.geoPath,l=ln(r.xAccessor,"lon"),c=ln(r.yAccessor,"lat"),u=function(t){var e,n;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(n=t.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(r),h=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(r);if(r.graticule){const e=!0===r.graticule?{}:r.graticule,n=d.geoGraticule();e.step&&n.step(e.step);const o=a(n())||"";o&&i.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const n=a.centroid(t),o=a.bounds(t),s=a.area(t),l=un(r.areaStyle,t,u);i.push({type:"geoarea",pathData:e,centroid:n,bounds:o,screenArea:s,style:l,datum:t,interactive:!0})}const g=cn(r.lineDataAccessor);for(const e of this.lineData){const n=g(e);if(!n||2>n.length)continue;let o=[];if("geo"===r.lineType){const t=Array(n.length);for(let e=0;n.length>e;e++)t[e]=[l(n[e]),c(n[e])];for(let e=0;t.length-1>e;e++){const n=t[e],i=t[e+1],r=d.geoDistance(n,i)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=d.geoInterpolate(n,i);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&o.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],i=s([l(e),c(e)]);null!=i&&o.push(i)}if(2>o.length)continue;const a=un(r.lineStyle,e,h),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>o.length||"arc"!==r.flowStyle?2!==n.length||2>o.length||"offset"!==r.flowStyle||(o="geo"===r.lineType?fn(o,u):gn(o[0],o[o.length-1],0,0,u)):o=hn(o[0],o[o.length-1]);const f=dn(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};i.push(n)}else i.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,v=m>0?m*Math.PI/180:null,x=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(n=b[0])&&void 0!==n?n:0)-x[0],(null!==(o=b[1])&&void 0!==o?o:0)-x[1]];for(let t=0;y.length>t;t++){const e=y[t],n=l(e),o=c(e);if(null!=v&&d.geoDistance([n,o],k)>v)continue;const a=s([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},f),h={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};i.push(h)}return i}applyCartogramTransform(t,e){var n,i,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(n=t.strength)&&void 0!==n?n:1;if(0===a)return;const l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const d=u.x,h=u.y,f=Te(s.map(t=>t.datum?c(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),g=Math.min(e.width,e.height)/2,y=o.scaleLinear().domain([0,f]).range([0,g]);this.cartogramLayout={cx:d,cy:h,maxCost:f,availableRadius:g},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;if(!t.datum)continue;const e=Math.atan2(t.y-h,t.x-d),n=Math.sqrt(Math.pow(t.x-d,2)+Math.pow(t.y-h,2)),o=c(t.datum),i=n+((isFinite(o)?y(o):n)-n)*a;t.x=d+Math.cos(e)*i,t.y=h+Math.sin(e)*i}const p=e.width/2,m=e.height/2,v=p-u.x,x=m-u.y;if(Math.abs(v)>.5||Math.abs(x)>.5)for(const t of s)t.x+=v,t.y+=x;this.cartogramLayout={cx:p,cy:m,maxCost:f,availableRadius:g};const b=this.scene.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const n=null===(i=e.datum)||void 0===i?void 0:i.source,o=null===(r=e.datum)||void 0===r?void 0:r.target;if(n&&o){const i=t.get(n+""),r=t.get(o+"");i&&r&&(e.path=[i,r])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let o=0;n.length>o;o++){const i=st(t,o,e);n[o]._decayOpacity=i,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:i})}}applyPulse(){var t;const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const n=performance.now(),o=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray();for(let r=0;o.length>r&&i.length>r;r++){const s=at(e,i[r],n);s>0&&(o[r]._pulseIntensity=s,o[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",o[r]._pulseGlowRadius=null!==(t=e.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var t;return lt(null!==(t=this.config.pulse)&&void 0!==t?t:{},this.timestampBuffer)}startTransition(t){var e,n,o,i;const r=null!==(n=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==n?n:300;if(0>=r)return;const s=new Map;for(const e of t)"point"===e.type&&e.pointId&&s.set(e.pointId,[e.x,e.y]);const a=this.scene.filter(t=>"point"===t.type);let l=!1;for(const t of a)if(t.pointId){const e=s.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(l=!0))}for(const t of a)t.pointId&&!s.has(t.pointId)&&(t._targetOpacity=null!==(i=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1,t.style=Object.assign(Object.assign({},t.style),{opacity:0}),l=!0);l&&(this.activeTransition={startTime:performance.now(),duration:r})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=ut(t,this.activeTransition),n=ct(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=dt(t.x,t._targetX,n),t.y=dt(e,t._targetY,n)}null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity*n}))}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity}),t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}}function pn(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function mn(t){if(!t||2>t.length)return;const e=pn(t[0]),n=pn(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function vn(t){var e;const{count:n,byType:o}=function(t){var e;const n={};for(const o of t){const t="string"==typeof(null==o?void 0:o.type)&&o.type.length>0?o.type:"node";n[t]=(null!==(e=n[t])&&void 0!==e?e:0)+1}return{count:t.length,byType:n}}(t.marks),i=0===n,r=[...null!==(e=t.extraWarnings)&&void 0!==e?e:[]];i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE");const s=Array.isArray(t.annotations)?t.annotations.length:0,a="string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${n} marks`;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:n,markCountByType:o,width:t.width,height:t.height},t.xDomain?{xDomain:t.xDomain}:{}),t.yDomain?{yDomain:t.yDomain}:{}),t.categories?{categories:t.categories}:{}),void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{}),void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{}),void 0!==t.legendItems?{legendItems:t.legendItems}:{}),{annotationCount:s,ariaLabel:a,warnings:r})}function xn(t){var e,n,o,i;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(o=t.br)&&void 0!==o?o:0)>0||(null!==(i=t.bl)&&void 0!==i?i:0)>0}function bn(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,o=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}yn.QUADTREE_THRESHOLD=500;const kn=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function wn(t){var e,n;const{innerRadius:o,outerRadius:i,startAngle:r,endAngle:s}=t,a=0>=o;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=kn(i,r),e=kn(i,s);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=kn(i,r),e=kn(i,s),n=kn(o,s),l=kn(o,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${o},${o} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(i-o)/2));if(0===l)return wn(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,o+l))),d=s-r,h=t.roundStart&&t.roundEnd?d/2:d,f=!!t.roundStart&&h>c,g=!!t.roundEnd&&h>c;if(!f&&!g)return wn(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const y=r+(f?c:0),p=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),x=kn(i,y),b=kn(i,p),k=(i-l)*Math.cos(c),w=kn(k,r),A=kn(k,s),S=a?null:kn(o,v),j=a?null:kn(o,m),M=a?0:(o+l)*Math.cos(u),_=a?null:kn(M,r),P=a?null:kn(M,s),O=p-y>Math.PI?1:0,T=a?0:v-m>Math.PI?1:0;let $="";if(f)$+=`M${w.x},${w.y}`,$+=` A${l},${l} 0 0 1 ${x.x},${x.y}`;else{const t=kn(i,r);$+=`M${t.x},${t.y}`}if(g)$+=` A${i},${i} 0 ${O} 1 ${b.x},${b.y}`,$+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=kn(i,s);$+=` A${i},${i} 0 ${O} 1 ${t.x},${t.y}`}if(a)$+=" L0,0";else{if(g)$+=` L${P.x},${P.y}`,$+=` A${l},${l} 0 0 1 ${S.x},${S.y}`;else{const t=kn(o,s);$+=` L${t.x},${t.y}`}if(f)$+=` A${o},${o} 0 ${T} 0 ${j.x},${j.y}`,$+=` A${l},${l} 0 0 1 ${_.x},${_.y}`;else{const t=kn(o,r);$+=` A${o},${o} 0 ${T} 0 ${t.x},${t.y}`}}return $+=" Z",$}const An={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Sn(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function jn(e,n,o){const i=jt(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?Sn(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${null!=o?o:""}symbol-${n}`)}function Mn(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function _n(e,n,o){var i,r,s,a,l;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const i="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+n)}case"area":{const l=e;if(0===l.topPath.length)return null;const c=`M${l.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...l.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(l.clipRect){const e=`${o?o+"-":""}area-clip-${n}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:l.clipRect.x,y:l.clipRect.y,width:l.clipRect.width,height:l.clipRect.height})})}),t.jsx("path",{d:c,fill:Sn(l.style.fill),fillOpacity:null!==(r=null!==(i=l.style.fillOpacity)&&void 0!==i?i:l.style.opacity)&&void 0!==r?r:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+n)}return t.jsx("path",{d:c,fill:Sn(l.style.fill),fillOpacity:null!==(a=null!==(s=l.style.fillOpacity)&&void 0!==s?s:l.style.opacity)&&void 0!==a?a:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth},"area-"+n)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Sn(o.style.fill),opacity:null!==(l=o.style.opacity)&&void 0!==l?l:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+n)}case"symbol":return jn(e,n);case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Sn(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+n)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[i,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]}(o.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+n)}case"candlestick":{const o=e,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}function Pn(e,n,o){var i,s,a,l,c,u,d,h,f;const g=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",y=t=>`ord-${e.type}-${g}-${n}-${t}`,p=`ord-${e.type}-${g}-${n}`;switch(e.type){case"rect":{const n=e,o=Mn(p)+"-grad",i=function(e,n){const o=e.fillGradient;if(!o)return null;let i=e.x,r=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let n=0;e.length>n;n++)l.push(t.jsx("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=Sn(e.style.fill);l.push(t.jsx("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(t.jsx("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(n,o),r=i?`url(#${o})`:Sn(n.style.fill);if(n.cornerRadii&&xn(n.cornerRadii)){const e=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=bn(t);let c=`M${e+r},${n}`;return c+=` L${e+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+o},${n+s}`),c+=` L${e+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+o-a},${n+i}`),c+=` L${e+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+i-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(n);return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:e,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}if(n.roundedTop&&n.roundedTop>0){const e=Math.min(n.roundedTop,n.w/2,n.h/2),{x:o,y:s,w:a,h:l}=n;let c;switch(n.roundedEdge){case"right":c=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o},${s+l} Z`;break;case"left":c=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+l-e} A${e},${e} 0 0 0 ${o+e},${s+l} L${o+a},${s+l} Z`;break;case"bottom":c=`M${o},${s} L${o+a},${s} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o+e},${s+l} A${e},${e} 0 0 1 ${o},${s+l-e} Z`;break;default:c=`M${o},${s+l} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l} Z`}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:c,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}case"point":{const n=e;return t.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:Sn(n.style.fill),opacity:null!==(i=n.style.opacity)&&void 0!==i?i:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},p)}case"symbol":return jn(e,n,o);case"wedge":{const i=e;if(i._gradientBand&&i._gradientBand.colors.length>0){const e=Mn(`${o?o+"-":""}gauge-grad-${i.category||p}-${n}`),{clipPath:r,slices:u}=function(t){const e=wn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let i=0;o.length>i;i++)n.push({d:wn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+i*e,endAngle:t.endAngle}),color:o[i]})}return{clipPath:e,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:null===(a=null===(s=i.roundedEnds)||void 0===s?void 0:s.start)||void 0===a||a,roundEnd:null===(c=null===(l=i.roundedEnds)||void 0===l?void 0:l.end)||void 0===c||c,colors:i._gradientBand.colors});return t.jsxs("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("path",{d:r})})}),t.jsx("g",{clipPath:`url(#${e})`,children:u.map((e,n)=>t.jsx("path",{d:e.d,fill:Sn(e.color)},n))}),i.style.stroke&&"none"!==i.style.stroke&&t.jsx("path",{d:r,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},p)}let u;if(i.roundedEnds)u=wn({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const t=r.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),u=t(An)||""}return t.jsx("path",{d:u,transform:`translate(${i.cx},${i.cy})`,fill:Sn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},p)}case"boxplot":{const n=e,o=n.columnWidth/2;return t.jsxs("g","vertical"===n.projection?{children:[t.jsx("line",{x1:n.x,y1:n.minPos,x2:n.x,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:n.x-o,y:Math.min(n.q1Pos,n.q3Pos),width:n.columnWidth,height:Math.abs(n.q3Pos-n.q1Pos),fill:Sn(n.style.fill),fillOpacity:null!==(u=n.style.fillOpacity)&&void 0!==u?u:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-o,y1:n.medianPos,x2:n.x+o,y2:n.medianPos,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.x-.5*o,y1:n.minPos,x2:n.x+.5*o,y2:n.minPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-.5*o,y1:n.maxPos,x2:n.x+.5*o,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:n.minPos,y1:n.y,x2:n.maxPos,y2:n.y,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(n.q1Pos,n.q3Pos),y:n.y-o,width:Math.abs(n.q3Pos-n.q1Pos),height:n.columnWidth,fill:Sn(n.style.fill),fillOpacity:null!==(d=n.style.fillOpacity)&&void 0!==d?d:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.medianPos,y1:n.y-o,x2:n.medianPos,y2:n.y+o,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.minPos,y1:n.y-.5*o,x2:n.minPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.maxPos,y1:n.y-.5*o,x2:n.maxPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1})]},p)}case"violin":{const n=e,o=[t.jsx("path",{d:n.pathString,transform:n.translateX||n.translateY?`translate(${n.translateX},${n.translateY})`:void 0,fill:Sn(n.style.fill),fillOpacity:null!==(h=n.style.fillOpacity)&&void 0!==h?h:.6,stroke:n.style.stroke||"#333",strokeWidth:n.style.strokeWidth||1},y("path"))];if(n.iqrLine&&n.bounds){const e=n.bounds,i=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:i,y1:n.iqrLine.q1Pos,x2:i,y2:n.iqrLine.q3Pos,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),t.jsx("circle",{cx:i,cy:n.iqrLine.medianPos,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med"))):o.push(t.jsx("line",{x1:n.iqrLine.q1Pos,y1:r,x2:n.iqrLine.q3Pos,y2:r,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),t.jsx("circle",{cx:n.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med")))}return t.jsx("g",{children:o},p)}case"connector":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:null!==(f=e.style.opacity)&&void 0!==f?f:.5},p);case"trapezoid":{const n=e,o=n.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:Sn(n.style.fill,"#999"),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},p)}default:return null}}const On="undefined"==typeof window||"undefined"==typeof document;function Tn(n){let o=null;const i=()=>(o||(o=e.createContext(null)),o),r=$n(n);return[function({children:o,initialState:r}){const s=e.useRef(r),a=e.useMemo(()=>$n(n,s.current),[]),l=i();return t.jsx(l.Provider,{value:a,children:o})},(t,n)=>{var o;const s=i(),a=null!==(o=e.useContext(s))&&void 0!==o?o:r,l=e.useRef(t);l.current=t;const c=e.useRef({hasValue:!1,value:void 0}),u=e.useCallback(()=>{const t=l.current(a.getState()),e=c.current;return e.hasValue&&n&&n(e.value,t)?e.value:(c.current={hasValue:!0,value:t},t)},[a,n]),d=e.useCallback(()=>l.current(a.getState()),[a]);return e.useSyncExternalStore(a.subscribe,u,d)}]}function $n(t,e){const n=new Set;let o=Object.assign(Object.assign({},t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o=Object.assign(Object.assign({},o),e);for(const t of n)t()}})),null!=e?e:{});return{getState:()=>o,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function Ln(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 Cn(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:En})})),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 En=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Rn={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}},zn={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}},Dn={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:En,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 Nn(t,e){if("light"===e)return Rn;if("dark"===e)return zn;if("high-contrast"===e)return Dn;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?zn:Rn;return Cn(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 Cn(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[Fn,Wn]=Tn(t=>({theme:Rn,setTheme(e){t(t=>({theme:Nn(t.theme,e)}))}})),Bn={light:Rn,dark:zn,"high-contrast":Dn,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function In(t){if(!t)return Rn;if("string"==typeof t){if("light"===t)return Rn;if("dark"===t)return zn;if("high-contrast"===t)return Dn;return Bn[t]||Rn}const e="dark"===t.mode?zn:Rn;return Cn(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function Yn(t){var e,n,o,i;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(n=t.typography.legendSize)&&void 0!==n?n:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(i=t.typography.tickFontFamily)&&void 0!==i?i:t.typography.fontFamily}}function Gn(t){return"left"===t?"start":"right"===t?"end":null!=t?t:"start"}function Hn(t){var e,n;return Number(null!==(n=null!==(e=t.typography.legendSize)&&void 0!==e?e:t.typography.labelSize)&&void 0!==n?n:t.typography.tickSize)||11}function qn(t,e,n,o){const i=Hn(o);return e+n+Math.ceil(t.length*i*.58)}function Xn(t){var e,n,o,i,r;const{categories:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),x="top"===l||"bottom"===l,b=Math.max(f,c-d.left-d.right),k=Math.max(p,u-d.top-d.bottom),w=s.map(t=>qn(t,f,g,a));if(x){const t=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:b),e=[];let n=0,o=0;w.forEach((i,r)=>{const s=0===o?i:o+y+i;o>0&&s>t?(e.push({start:n,end:r,width:o}),n=r,o=i):o=s}),s.length>0&&e.push({start:n,end:s.length,width:o});const i=Gn(null==h?void 0:h.align),a=[];return e.forEach((e,n)=>{let o="center"===i?Math.max(0,(t-e.width)/2):"end"===i?Math.max(0,t-e.width):0;for(let t=e.start;e.end>t;t++)a.push({category:s[t],width:w[t],x:o,y:n*p}),o+=w[t]+y}),{items:a,width:Math.max(0,...e.map(t=>t.width)),height:e.length*p,swatchSize:f,labelOffset:m,swatchRadius:v}}const A=Math.max(0,...w),S=Math.max(1,Math.floor(k/p)),j=Math.max(1,Math.ceil(s.length/S));return{items:s.map((t,e)=>({category:t,width:w[e],x:Math.floor(e/S)*(A+y),y:e%S*p})),width:j*A+Math.max(0,j-1)*y,height:Math.min(s.length,S)*p,swatchSize:f,labelOffset:m,swatchRadius:v}}function Vn(t){var e,n,o,i,r;const{legendGroups:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),x=Math.max(12,Hn(a)),b="top"===l||"bottom"===l,k=Math.max(f,c-d.left-d.right),w=Math.max(p,u-d.top-d.bottom);if(b){const e=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:k),n=Gn(null==h?void 0:h.align);let o=0,i=0;const l=[];for(const n of s){const r=n.items.map(t=>t.label),s=Xn(Object.assign(Object.assign({},t),{categories:r,legendLayout:Object.assign(Object.assign({},h),{maxWidth:Math.max(f,e-x-8),align:"start"})})),c=n.label?x:0,u=n.label?qn(n.label,0,0,a):0,d=c>0?c+8:0,g=d+s.width,y=Math.max(s.height,u);l.push({group:n,x:o,y:0,itemOffsetX:d,itemOffsetY:0,width:g,height:y,items:s.items}),o+=g+12,i=Math.max(i,y)}const c=l.length>0?o-12:0,u=c>e?0:"center"===n?Math.max(0,(e-c)/2):"end"===n?Math.max(0,e-c):0;return{groups:l.map(t=>Object.assign(Object.assign({},t),{x:t.x+u})),width:c,height:i,swatchSize:f,labelOffset:m,swatchRadius:v}}let A=0,S=0;const j=[];for(const t of s){const e=t.items.map(t=>t.label).map(t=>qn(t,f,g,a)),n=Math.max(0,...e),o=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(p,w-A)/p)))),i=Math.max(1,Math.ceil(t.items.length/o)),r=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/o)*(n+y),y:i%o*p})),s=i*n+Math.max(0,i-1)*y,l=Math.min(t.items.length,o)*p,c=t.label?qn(t.label,0,0,a):0,u=t.label?x+8:0,d=u+l+12,h=Math.max(s,c);j.push({group:t,x:0,y:A,itemOffsetX:0,itemOffsetY:u,width:h,height:d,items:r}),S=Math.max(S,h),A+=d}return{groups:j,width:S,height:Math.max(0,A),swatchSize:f,labelOffset:m,swatchRadius:v}}function Un(t){var e,n;return"top"===t.position||"bottom"===t.position?{width:Math.min(null!==(n=null===(e=t.legendLayout)||void 0===e?void 0:e.maxWidth)&&void 0!==n?n:Math.max(1,t.totalWidth-t.margin.left-t.margin.right),200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function Zn(e){const{categories:n,colorScheme:i,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=e;if(!n||0===n.length)return null;const d=function(t,e,n){const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:W;return o.scaleOrdinal().domain(t).range(i)}(n,i,r),h="top"===s||"bottom"===s,f=Xn(e);let g,y;if("left"===s?(g=Math.max(4,c.left-f.width-10),y=c.top):"top"===s?(g=c.left,y=u?32:8):"bottom"===s?(g=c.left,y=Math.min(l-c.bottom+38,l-f.height-2)):(g=Math.min(a-f.width-4,a-c.right+10),y=c.top),h){const e=f.items.map((e,n)=>t.jsxs("g",{transform:`translate(${e.x},${e.y})`,children:[t.jsx("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(e.category),rx:f.swatchRadius}),t.jsx("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:Hn(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+n));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:e})}const p=f.items.map((e,n)=>t.jsxs("g",{transform:`translate(${e.x},${e.y})`,children:[t.jsx("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(e.category),rx:f.swatchRadius}),t.jsx("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:Hn(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+n));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Qn(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=n(e);null!=t&&o.add(t+"")}return Array.from(o)}function Kn(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),r=[];let s="";for(const t of i)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function Jn(t,e,n,o){return"curly"===t?o?`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`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function to(e,n,o,i){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,y=s?u?[s]:Kn(s,c):[],p=r?u?[r]:Kn(r,c):[],m="leftRight"===d?"end"===f?-4:4:0;let v=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?(x.push(t.jsx("foreignObject",{className:"annotation-note-html",x:"end"===f?m-c:"middle"===f?m-c/2:m,y:-16,width:c,height:Math.max(g,(y.length+p.length)*g+(s&&r?2:0))+g,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")),v=y.length*g):(y.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:y.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-title")),v=y.length*g),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:v,children:p.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-label")));let k=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===d){const e=Math.min(c,120);let n=0,o=e;"end"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let n=0,o=e;"bottom"===h?(n=-e,o=0):"middle"===h&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*g;let A=0;return"topBottom"===d?A=0>o?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function eo(e,n,o,i,r){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.jsx("circle",{r:e,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&a.push(t.jsx("rect",{width:e,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;a.push(t.jsx("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(t.jsx("line",{x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:o||"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)?a.push(t.jsx("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:o||"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)||a.push(t.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"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&&a.push(t.jsx("path",{d:Jn((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:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t.jsx("g",{className:"annotation-subject",children:a})}function no(e,n,o,i,r,s){var a;const l=[];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,o=s.height||0;if(t>0||o>0){const i=t/2,r=o/2,s=e-i,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),l=t/2,d=o/2,h=e*d>n*l?l/e:d/n;c=i+s*h,u=r+a*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 o=Math.atan2(n,e);c=Math.cos(o)*t,u=Math.sin(o)*t}}const d=Math.sqrt(Math.pow(e-c,2)+Math.pow(n-u,2));if(d>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==o?void 0:o.type);let h=Math.atan2(n-u,e-c);if(s){const i=(null!==(a=null==o?void 0:o.curve)&&void 0!==a?a:.25)*d,s=(c+e)/2+-(n-u)/d*i,f=(u+n)/2+(e-c)/d*i;l.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 l.push(t.jsx("line",{x1:c,y1:u,x2:e,y2:n,stroke:r},"connector-line"));if("arrow"===(null==o?void 0:o.end)){const e=10,n=16/180*Math.PI;l.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:l})}function oo(e){var n,o;const{x:i=0,y:r=0,dx:s,dy:a,nx:l,ny:c,note:u,connector:d,subject:h,type:f,color:g,className:y,disable:p,opacity:m,strokeDasharray:v,events:x={},"data-testid":b}=e,k=Array.isArray(i)?null!==(n=i[0])&&void 0!==n?n:0:i,w=Array.isArray(r)?null!==(o=r[0])&&void 0!==o?o:0:r,A=new Set(Array.isArray(p)?p:[]);let S=s||0,j=a||0;null!=l&&(S=l-k),null!=c&&(j=c-w);const M="string"==typeof f?f:"label";if("bracket"===M&&h&&0===S&&0===j)if(void 0!==h.width){S=h.width/2;const t=h.depth||30;j=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;S=t+(0>t?-5:5),j=h.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(y||"")).trim(),transform:`translate(${k},${w})`,"data-testid":b},null!=m&&{opacity:m},v&&{strokeDasharray:v},x,{children:[!A.has("connector")&&no(S,j,d,g,M,h),!A.has("subject")&&eo(M,h,g,k,w),!A.has("note")&&to(u,S,j,g)]}))}function io(e){var n,o;const{noteData:i}=e,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const e=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.jsx(oo,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return t.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return t.jsx(oo,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}const ro={secondary:0,primary:3};function so(t){return!0===(null==t?void 0:t._annotationDeferred)}function ao(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function lo(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 co(t){return Math.max(.72,.95-.06*t)}function uo(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:lo(t.annotation),readingOrder:null,rank:1};var n}),o=n.some(t=>null!=t.emphasis||null!=t.confidence),i=e.some(t=>so(t.annotation)),r=e.some(t=>null!=ao(t.annotation)),s=e.some(t=>"layer"===ao(t.annotation));if(!o&&!i&&!r)return e.map(t=>t.node);const a=n.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>{var n,o;return(null!==(n=e.confidence)&&void 0!==n?n:0)-(null!==(o=t.confidence)&&void 0!==o?o:0)||t.i-e.i});a.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,a.length)});for(const t of n)t.emphasis&&(t.rank=ro[t.emphasis]);const l=n.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(e=>{const{p:n,i:o,emphasis:i,readingOrder:r}=e,s=so(n.annotation);let a=n.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;a=t.jsx("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i},"secondary"===i?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:co(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=ao(n.annotation);return l&&(a=t.jsx("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+o)),s&&(a=t.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return i&&l.unshift(t.jsx("style",{children:".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}}"},"annotation-disclosure-style")),s&&l.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")),l}function ho(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function fo(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function go(t){return null==t?null:t+""}function yo(t,e,n){var o;return null===(o=e.stickyPositionCache)||void 0===o||o.set(t,n),n}function po(t,e,n){var o,i;const r=t.anchor||(null===(o=t.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId)return yo(e,n,{x:i.x,y:i.y})}const o=function(t){var e,n,o,i,r,s;const a=t.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(o=t.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=t.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[t.xAccessor||"x"],h=l[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o?yo(e,n,o):null}if("semantic"===r){const o=function(t,e,n){var o,i;const r=function(t){var e,n;return go(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===(o=n.pointNodes)||void 0===o?void 0:o.find(t=>go(t.pointId)===r);if(s)return yo(e,n,{x:s.x,y:s.y});const a=null===(i=n.data)||void 0===i?void 0:i.find(t=>function(t){var e,n,o;return go(null!==(n=null!==(e=t.stableId)&&void 0!==e?e:t.id)&&void 0!==n?n:null===(o=t.provenance)||void 0===o?void 0:o.stableId)}(t)===r);if(!a)return null;const l=ho(a,n),c=fo(a,n);return null==l||null==c?null:yo(e,n,{x:l,y:c})}(t,e,n);if(o)return o}let s=null,a=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,a=e.y)}if(null!=s&&null!=a||(s=ho(t,n),a=fo(t,n)),null!=s&&null!=a)return yo(e,n,{x:s,y:a});if("sticky"===r){const t=null===(i=n.stickyPositionCache)||void 0===i?void 0:i.get(e);if(t)return t}return null}function mo(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}const vo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function xo(t){return!!t&&"object"==typeof t&&vo.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function bo(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function ko(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 wo(t){var e,n;let o;const i=null==t?void 0:t.emphasis;o="primary"===i?100:"secondary"===i?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)&&(o+=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":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const Ao=32,So=6,jo=4,Mo=8,_o=72;const Po={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Oo(t){return xo(t)}function To(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),i=[];let r="";for(const t of o)r&&r.length+t.length+1>n?(i.push(r),r=t):r=r?`${r} ${t}`:t;return r&&i.push(r),i}function $o(t,e,n,o,i){const r=t+n,s=e+o;return Math.abs(n)>Math.abs(o)?{x:0>n?r-i.width-4:r+4,y:0>o?s-i.height:s,width:i.width,height:i.height}:{x:0>n?r-i.width:r,y:0>o?s-i.height-4:s+4,width:i.width,height:i.height}}function Lo(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Co(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 Eo(t,e,n,o,i,r,s,a){const l=Lo(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,o){const i=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(i+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(n-o)))*t.width}(l,i,r,a);for(const t of n)c+=12*Co(l,t);for(const t of o)c+=4*Co(l,t);return c}function Ro(t){var e;const{annotations:n,context:o,defaultOffset:i=Ao,notePadding:r=So,markPadding:s=jo,edgePadding:a=Mo,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=_o,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=t,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)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}})}(o,s);let k=!1;const w=n.map((t,e)=>{if(!Oo(t))return t;const n=function(t,e,n){var o,i;if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=null!==(o=t.pointId)&&void 0!==o?o: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,a=null===(i=n.scales)||void 0===i?void 0:i.geoProjection;if(Array.isArray(s)&&s.length>=2&&a){const t=s[0],e=s[1];if("number"==typeof t&&"number"==typeof e){const n=a([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?po(t,e,n):{x:t.x,y:t.y}}(t,e,o);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=[...To("string"==typeof t.title?t.title:void 0,e),...To("string"==typeof t.label?t.label:void 0,e)],o=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*n.length+6)}}(t);if(l&&("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(Lo($o(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}]}(i)){const e=Eo($o(n.x,n.y,t.dx,t.dy,s),t,x,b,m,v,r,a);f>e&&(h=t,f=e)}if(!h)return t;const g=Lo($o(n.x,n.y,h.dx,h.dy,s),r);x.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=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 S=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});S=t?e:A}{let t=!1;const e=S.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 o="string"==typeof n.source?null!==(e=Po[n.source])&&void 0!==e?e:n.source:null,i="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[o,i].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});S=t?e:S}const j=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),o=1===n?t:Object.assign(Object.assign({},t),{maxAnnotations:Math.max(0,Math.round((null!==(e=t.maxAnnotations)&&void 0!==e?e:ko(m,v,t))*n))}),{deferred:i}=function(t){var e;const{annotations:n,width:o,height:i}=t,r=Math.max(0,null!==(e=t.minVisible)&&void 0!==e?e:1),s=ko(o,i,t),a=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,xo(n))};var n}),l=a.filter(t=>t.note);if(0===l.length||s>=l.length)return{visible:n.slice(),deferred:[],budget:s};const c=l.filter(t=>bo(t.annotation)),u=l.filter(t=>!bo(t.annotation)).sort((t,e)=>wo(e.annotation)-wo(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=[],g=[];for(const{annotation:t,index:e,note:n}of a)!n||h.has(e)?f.push(t):g.push(t);return{visible:f,deferred:g,budget:s}}(Object.assign({annotations:S,width:m,height:v},o));for(const t of i)j.add(t)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const t of S)Oo(t)&&"secondary"===t.emphasis&&j.add(t);if(j.size>0)for(const t of S)!0===(null==t?void 0:t.defensive)&&j.delete(t);let M;return M=0===j.size?S:h?S.map(t=>j.has(t)?Object.assign(Object.assign({},t),{_annotationDeferred:!0}):t):S.filter(t=>!j.has(t)),y?function(t,e){let n=!1;const o=t.map(t=>Oo(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,Object.assign(Object.assign({},t),{cohesion:e})):t);return n?o:t}(M,y):M}function zo(t,e){return t.color||e.colors.annotation||e.colors.text}function Do(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function No(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function Fo(e){const{annotations:n}=e;if(!n||0===n.length)return null;const o=e.autoPlaceAnnotations?Ro(Object.assign({annotations:n,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"}},"object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{})):n,i=[];for(let t=0;o.length>t;t++){const n=Wo(o[t],t,e);n&&i.push({node:n,annotation:o[t]})}const r=uo(i);return r.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function Wo(e,n,o){var i,r,s,a,l,c,u;const{scales:d,layout:h,theme:f,xAccessor:g,yAccessor:y}=o;switch(e.type){case"y-threshold":{const r=e.value;if(null==r)return null;const s=zo(e,f),a=e.label,l=e.labelPosition||"right",c=e.strokeDasharray||"6,4",u=null!==(i=e.strokeWidth)&&void 0!==i?i:1.5;if("horizontal"===o.projection&&d.r){const o=d.r(r);return null==o?null:t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:h.height,stroke:s,strokeWidth:u,strokeDasharray:c}),a&&t.jsx("text",{x:o+4,y:12,textAnchor:"start",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}const g=d.y?d.y(r):d.r?d.r(r):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:h.width,y2:g,stroke:s,strokeWidth:u,strokeDasharray:c}),a&&t.jsx("text",{x:"left"===l?4:"center"===l?h.width/2:h.width-4,y:g-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}case"x-threshold":{const o=e.value;if(null==o||!d.x)return null;const i=d.x(o);if(null==i)return null;const s=zo(e,f),a=e.label,l=e.labelPosition||"top",c=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:h.height,stroke:s,strokeWidth:c,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:i>.6*h.width?i-4:i+4,y:"bottom"===l?h.height-4:"center"===l?h.height/2:12,textAnchor:i>.6*h.width?"end":"start",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,stroke:f.colors.background,strokeWidth:3,paintOrder:"stroke",children:a})]},"ann-xthresh-"+n)}case"band":{const o=null!=e.y0&&d.y?d.y(e.y0):null,i=null!=e.y1&&d.y?d.y(e.y1):null;if(null==o||null==i)return null;const r=Math.min(o,i),a=Math.abs(i-o),l=e.fill||zo(e,f),c=null!==(s=e.fillOpacity)&&void 0!==s?s:.1;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("rect",{x:0,y:r,width:h.width,height:a,fill:l,fillOpacity:c}),e.label&&t.jsx("text",{x:h.width-4,y:Math.max(r,0)+13,textAnchor:"end",fontSize:f.typography.tickSize,fill:e.color||zo(e,f),fontFamily:f.typography.fontFamily,fontWeight:"bold",stroke:f.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-band-"+n)}case"category-highlight":{if(!e.category||!d.o)return null;const i=d.o(e.category);if(null==i)return null;const r=d.o.bandwidth?d.o.bandwidth():40,s=zo(e,f),l=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:i,width:h.width,height:r,fill:s,opacity:l}:{x:i,y:0,width:r,height:h.height,fill:s,opacity:l},"ann-cathighlight-"+n)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:i}=function(t,e,n,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Do(t,e,n),y:No(t,e,o)}}(e,d,g,y);if(null==o||null==i)return null;const r="text"===e.type,s=null!==(l=e.dx)&&void 0!==l?l:r?0:30,a=null!==(c=e.dy)&&void 0!==c?c:r?0:-30,h=e.color||f.colors.text;if(!r){const r="callout"===e.type?"callout-circle":e.type,l="callout-circle"===r?{radius:null!==(u=e.radius)&&void 0!==u?u:12,radiusPadding:e.radiusPadding}:"callout-rect"===r?{width:e.width,height:e.height}:void 0;return t.jsx(io,{noteData:Object.assign(Object.assign({x:o,y:i,dx:s,dy:a,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:r},l?{subject:l}:{}),{connector:e.connector||{end:"arrow"},color:h,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className})},"ann-label-"+n)}return t.jsx("g",{children:t.jsx("text",{x:o+s,y:i+a,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||f.typography.labelSize,fill:h,fontFamily:f.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+n)}default:return null}}function Bo(t){return Math.max(0,Math.min(1,t))}function Io(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const t=[Number(n[1]),Number(n[2]),Number(n[3])];if(t.every(Number.isFinite))return t}return null}function Yo(t,e,n){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function Go(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Bo(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=Bo(e);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],i=n[t+1];if(e.offset>o||o>i.offset)continue;const r=i.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=Io(e.color),l=Io(i.color);if(!a||!l)return.5>s?e.color:i.color;const[c,u,d]=a,[h,f,g]=l;return Yo(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function Ho(t,e,n){return`${t}-${e}`}function qo(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Xo(t,e,n){const o=e.incoming[t.id],i=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of i)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>{var n,o;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(o=s[e.kind])&&void 0!==o?o:99)})},l=r.length?function(t,e=1/0){let n=e;for(const e of t)n>e&&(n=e);return n}(r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),h=new Map;for(let t=1;d.length>t;t++)h.set(d[t],d[t-1]);const f=t=>{const e=h.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const g=[];let y=0,p=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?y:p);if(n>0){const e="top"===t.side?"bot":"top",o=Math.min(n,"top"===e?y:p);if(o>0){const i=f(t.time);g.push({time:i,delta:-o,kind:"transfer-out",side:e}),g.push({time:i,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:p-=o,"top"===t.side?y+=o:p+=o,n-=o}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?y+=n:p+=n)}"top"===t.side?y-=e:p-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:p+=e}r.push(...g),a();let m=0,v=0,x=0,b=0,k=0;const w=[],A=new Map;for(const t of r){if(w.push({t:t.time,topMass:m,botMass:v}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:v;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:v+=t.delta,m+v>x&&(x=m+v),m>b&&(b=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let j=0;for(;w.length>j;){let t=j;for(;w.length>t+1&&w[t+1].t===w[j].t;)t++;S.push(w[j]);for(let e=j+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}j=t+1}const M=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let _=null;for(const t of i)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===_||_>t.systemInTime)&&(_=t.systemInTime);let P=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===P||t.systemOutTime>P)&&(P=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=M?M:-1/0,null!=P?P:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&S.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=S[0],o=Math.min(null!=c?c:1/0,null!=_?_:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&S.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:x,topPeak:b,botPeak:k,localAttachments:A}}function Vo(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Uo(t,e){return t.map(t=>({t:Vo(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Zo(t,e,n){const o=t.value*n;if("out"===t.kind){const i=t.sideMassBefore*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}const i=t.sideMassAfter*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}function Qo(t,e){let n=0;for(let o=0;e.length>o;o++)for(let i=o+1;e.length>i;i++){const r=e[o],s=e[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function Ko(t,e){let n=0;for(const o of e)n+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return n}function Jo(t,e){return 1e3*Qo(t,e)+Ko(t,e)}function ti(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function ei(t,e,n){t.length>8||n.length>40?(function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=ti(t,e),s=Jo(e,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const t of n){const n=e[t.source],i=e[t.target];o[n]+=i*(t.value||1),a[n]+=t.value||1,o[i]+=n*(t.value||1),a[i]+=t.value||1}const l=Array.from({length:i},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const d=Jo(e,n);if(s>d)s=d,r=ti(t,e);else if(d===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=Jo(e,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;i-1>s;s++){const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Jo(e,n);if(r>a)r=a,o=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,n,6)):function(t,e,n){const o=t.length;if(1>=o)return;const i=Object.assign({},e),r=Object.keys(i),s=Array.from({length:o},(t,e)=>e),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[i[t]];const t=Jo(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],o=s[e];s[t]=o,s[e]=n,a[n]=e,a[o]=t};d();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(e=>t[e]),p=new Map;c.forEach((t,e)=>p.set(t,e));for(const t of Object.keys(e))e[t]=p.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,n)}function ni(t,e,n,o,i){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:m,lifetimeMode:v="full"}=i,x={},b={};for(const e of t)x[e.id]=n[e.id].topPeak||0,b[e.id]=n[e.id].botPeak||0;const k="half"===v,w={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let i=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of o.outgoing[e.id]){i>t.startTime&&(i=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&i>t.systemInTime&&(i=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;i>e&&(i=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}w[e.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===p){const n=new Map;for(const e of t)n.set(e.id,0);const i=new Map;for(const e of t)i.set(e.id,0);for(const t of e)i.set(t.target,(null!==(r=i.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=i.get(e.id))&&void 0!==s?s:0)&&d.push(e.id);for(;d.length;){const t=d.shift();for(const e of null!==(a=o.outgoing[t])&&void 0!==a?a:[]){const o=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,o),i.set(e.target,i.get(e.target)-1),0===i.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var o,i;const r=null!==(o=n.get(t.id))&&void 0!==o?o:0,s=null!==(i=n.get(e.id))&&void 0!==i?i:0;return r!==s?r-s:w[t.id].start-w[e.id].start}),f=t.filter(t=>null===w[t.id].start);for(const t of[...h,...f]){const e=w[t.id];let n=-1;for(let t=0;S.length>t;t++){const o=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){n=t;break}}-1===n&&(S.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=S.length-1),S[n].occupants.push({id:t.id,end:null!==(u=null==e?void 0:e.end)&&void 0!==u?u:-1/0}),S[n].peak.topPeak=Math.max(S[n].peak.topPeak,x[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,b[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,o;S.push({occupants:[{id:t.id,end:null!==(o=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:x[t.id],botPeak:b[t.id]}}),A[t.id]=e});let j=null,M=null,_=null,P=null;const O=()=>{j=Qo(A,e),_=Ko(A,e)},T=()=>{M=Qo(A,e),P=Ko(A,e)};"crossing-min"===m?(O(),ei(S,A,e),T()):"inside-out"===m?(O(),function(t,e){const n=t.length;if(1>=n)return;const o=t=>t.peak.topPeak+t.peak.botPeak,i=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let t=1;i.length>t;t++)t%2==1&&n>l||0>a?r[l++]=i[t].idx:r[a--]=i[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(S,A),T()):"crossing-min+inside-out"===m&&(O(),ei(S,A,e),function(t,e,n){const o=t.length;if(1>=o)return;const i=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=Jo(e,n);for(const{slot:a}of i){const i=t.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=t[i];t.splice(i,1),t.splice(l,0,c);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(l>i){for(let t=i+1;l>=t;t++)u.set(t,t-1);u.set(i,l)}else{for(let t=l;i>t;t++)u.set(t,t+1);u.set(i,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=Jo(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(i,0,n);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(i>l){for(let t=l+1;i>=t;t++)r.set(t,t-1);r.set(l,i)}else{for(let t=i;l>t;t++)r.set(t,t+1);r.set(l,i)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),T());const $=S.map(t=>{const e=new Map;for(const o of t.occupants){const t=n[o.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),L=(t,e)=>{let n={top:0,bot:0};for(const[o,i]of t){if(o>e)break;n=i}return n},C=[];for(let t=0;S.length-1>t;t++){const e=$[t],n=$[t+1],o=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let i=0;for(const t of o){const o=L(e,t),r=L(n,t);o.bot+r.top>i&&(i=o.bot+r.top)}C.push(i)}const E=[];let R=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*y;S.length>0&&E.push(R);for(let t=1;S.length>t;t++)R+=C[t-1]*y+g,E.push(R);if(S.length>0&&(R+=S[S.length-1].peak.botPeak*y+g),R>f){const t=f/R;for(let e=0;E.length>e;e++)E[e]*=t}const z=0===S.length?0:S[0].peak.topPeak+C.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,D={};for(const e of t)D[e.id]=E[A[e.id]];return{effectiveSlotsHeight:z,centerlines:D,laneLifetime:w,slots:S,slotByNode:A,slotCenter:E,crossingsBefore:j,crossingsAfter:M,lengthBefore:_,lengthAfter:P}}function oi(t){const{nodes:e,edges:n,domain:i,plotW:r,plotH:s,ribbonLane:a,edgeOpacity:l,colorOf:c,layoutOpts:u}=t,d=function(t,e,n){const o=[],i=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)i.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),i.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,n,i),h=o.scaleTime().domain(i).range([0,r]);if(d.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:d,xScale:h};const f=function(t,e,n){var o;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},o={};for(const e of t)n[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:o}}(t,e),u=function(t,e,n,o="value"){const i="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const o of t){const t=o[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(t);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:i);return s};for(const e of t){const t=n.outgoing[e.id],o=n.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(o,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(o,"source"),n=a(t,"target"),i=Math.max(e.length,n.length);for(let t=0;i>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=o;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=Xo(e,c,u);const h=ni(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const o=u.get(t.id);e!==n?e>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],o=new Set(t.map(t=>u.get(t.id).sourceSide)),i=new Set(n.map(t=>u.get(t.id).targetSide));if(1===o.size&&n.length>0){const t=[...o][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===i.size&&t.length>0){const e=[...i][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],n=c.outgoing[e.id];if(0===t.length||0===n.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===u.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===u.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},i=(t,e)=>{const i=o(),r="top"===t?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===e?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!f.has(e.id)&&u.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const e of t)d[e.id]=Xo(e,c,u);const g=ni(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),p=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),m=y>0?Math.max(0,(i-p*(g.slots.length+1))/y):1,v=ni(t,e,d,c,{plotH:i,padding:p,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:p,compressedPadding:12>p,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(e,n,Object.assign({plotH:s},u)),{centerlines:g,nodeData:y,valueScale:p}=f,m=[],v=[];e.forEach((t,e)=>{var o;const r=y[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,o,i){if(0===t.length)return null;const r=Uo(t,i),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${o(r[t].t)},${s(t)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${o(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,g[t.id],p,h,i);if(!s)return;const a=Uo(r.samples,i),l=a.find(t=>t.topMass+t.botMass>0)||a[0],u=g[t.id]+(l.botMass-l.topMass)*p/2,d=c(t.id,e),v=function(t,e,n,o,i){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Uo(r.samples,i),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],d=o(c.t),h=o(u.t),f=t=>o(Vo(t,i)),g=[],y=(t,e,n,o)=>`M${t},${e} L${n},${e} L${n},${o} L${t},${o} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),o=f(n.startTime),i=e-20,r=Math.max(d,i);if(o>r){const[n,l]=Zo(t,a,s);g.push({pathD:y(r,n,o,l),x0:i,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),o=f(n.endTime),i=e+20,r=Math.min(h,i);if(r>o){const[n,l]=Zo(t,a,s);g.push({pathD:y(o,n,r,l),x0:e,x1:i,from:1,to:0})}}}}return g}(t.id,n,f,h,i);m.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:d,stroke:d,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(o=t.__raw)&&void 0!==o?o:t,labelX:h(l.t)-4,labelY:u,labelText:t.id}))});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),n.forEach(t=>{var e,n,o,r;const s=null===(e=y[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=y[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!s||!u)return;const d=null!==(o=x.get(t.source))&&void 0!==o?o:0,f=c(t.source,d),m=function(t,e,n,o,i,r,s,a){const l=i,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),d=r(c(n.time)),h=t.value*l,f=n.value*l,g=t.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,v,x;"top"===t.side?(p=e-g,m=p+h):(m=e+g,p=m-h),"top"===n.side?(v=o-y,x=v+f):(x=o+y,v=x-f);const b="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:v,tBot:x,cp1X:b,cp2X:b}}(s,g[t.source],u,g[t.target],p,h,a,i),{pathD:b,bezier:k}=be(m);v.push({id:t.id,pathD:b,fill:f,opacity:l,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:f,layoutConfig:{bands:m,ribbons:v,showLabels:!0},issues:[],xScale:h}}const ii=t=>{var e,n;const{bands:o=[],ribbons:i=[],showLabels:r=!0}=t.config,s=[];for(const t of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:t.pathD},t.bezier&&{bezierCache:t.bezier}),{style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}}));for(const t of o)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of o)s.push({type:"bezier",pathD:t.pathD,style:Object.assign(Object.assign({},t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86}),{stroke:null!==(e=t.stroke)&&void 0!==e?e:t.fill,strokeWidth:null!==(n=t.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:t.rawDatum,id:t.id}});const a=r?o.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:s,labels:a}},ri=Object.freeze([]);function si(t){if(!t)return ri;let e=!1;for(let n=0;t.length>n;n++){const o=t[n];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}function ai(t){return Array.isArray(t)?t[0]:t}function li(t,e,n,o){return Object.assign({data:ai(t),x:e,y:n,__semioticHoverData:!0},o)}const ci={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(t,e){return"function"==typeof e?e(t):t[e]}function di(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function hi(e={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(o){const t=ui(e,o);a=di(t,i)}if(n&&n.length>0)n.forEach(t=>{let n,o,r;"string"==typeof t?(n=t,o=t,r=i):(n=t.label,o=t.accessor||t.key||"",r=t.format||i);const s=ui(e,o);l.push({label:n,value:di(s,r)})});else if(!o){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=di(e[n],i);break}if(!a){const t=Object.keys(e).filter(t=>!t.startsWith("_"));t.length>0&&(a=di(e[t[0]],i))}}const c=Object.assign(Object.assign({},ci),r);return t.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&t.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((e,n)=>t.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[e.label&&t.jsxs("span",{children:[e.label,": "]}),e.value]},n))]})}}function fi(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o+1>>1;e[i]>t?o=i-1:n=i}return e[n]}function gi(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i]?n=i+1:o=i}return e[n]}function yi({width:n,height:o,totalWidth:i,totalHeight:r,margin:s,dimension:a,scales:l,onBrush:c,binSize:u,snap:d,binBoundaries:g,snapDuring:y,streaming:p}){const m=e.useRef(null),v=e.useRef(null),x=e.useRef(c);x.current=c;const b=e.useRef(l);b.current=l;const k=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=e.useRef(k);w.current=k;const A=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!m.current)return;const t=h.select(m.current).select(".brush-g"),e="x"===a?f.brushX():"y"===a?f.brushY():f.brush();return e.extent([[0,0],[n,o]]),e.on("brush end",i=>{if(A.current)return;const r=b.current;if(!r)return;if(!i.selection)return S.current=null,void x.current(null);let s,l;if("x"===a){const[t,e]=i.selection;s=[r.x.invert(t),r.x.invert(e)],l=[r.y.invert(o),r.y.invert(0)]}else if("y"===a){const[t,e]=i.selection;s=[r.x.invert(0),r.x.invert(n)],l=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[n,o]]=i.selection;s=[r.x.invert(t),r.x.invert(n)],l=[r.y.invert(o),r.y.invert(e)]}if("bin"===d&&"y"!==a&&("end"===i.type||"brush"===i.type&&y)){const n=w.current;n&&n.length>0?s=function(t,e){return 0===e.length?t:[fi(t[0],e),gi(t[1],e)]}(s,n):u&&u>0&&(s=[Math.floor(s[0]/u)*u,Math.ceil(s[1]/u)*u]);const o=r.x(s[0]),l=r.x(s[1]);if(A.current=!0,"x"===a)t.call(e.move,[o,l]);else if("xy"===a){const n=i.selection;t.call(e.move,[[o,n[0][1]],[l,n[1][1]]])}A.current=!1}const c={x:s,y:l};S.current=c,x.current(c)}),t.call(e),v.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),v.current=null}},[n,o,a,d,u,y]),e.useEffect(()=>{if(!(p&&l&&v.current&&S.current))return;if(!m.current)return;if("y"===a)return;const t=S.current,e=l.x.domain()[0],n=h.select(m.current).select(".brush-g");if(e>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void x.current(null);let o=t.x[0],i=!1;if(e>t.x[0]){if(o=e,"bin"===d){const t=w.current;t&&t.length>0?o=gi(e,t):u&&u>0&&(o=Math.ceil(e/u)*u)}if(o>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void x.current(null);i=!0}const r=l.x(o),s=l.x(t.x[1]);if(A.current=!0,"x"===a)n.call(v.current.move,[r,s]);else{const e=l.y(t.y[1]),o=l.y(t.y[0]);n.call(v.current.move,[[r,e],[s,o]])}if(A.current=!1,i){const e={x:[o,t.x[1]],y:t.y};S.current=e,x.current(e)}},[l,p,a,d,u]),t.jsx("svg",{ref:m,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`})})}class pi{constructor(t,e){var n,o;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!==(o=null==e?void 0:e.chunkSize)&&void 0!==o?o: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=si(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 o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=si(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 o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,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 o=t[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),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 mi(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:m.createElement(m.Fragment,null,...e)}const vi=m.createContext(null);function xi({value:e,children:n}){return t.jsx(vi.Provider,{value:e,children:n})}function bi(e,n){return null!=e?t.jsx(xi,{value:n,children:e}):e}function ki(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 wi(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Ai(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Si(t,e){const n=Ai(t);if(!n)return!1;const o=Ai(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}const ji=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Mi=new WeakMap;let _i=0,Pi=!1,Oi=null,Ti=null,$i=null;function Li(t,e){var n,o;if(!e)return e;const i=ji.exec(e);if(!i)return e;const r=t.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||e;!function(){if(Pi)return;if("undefined"==typeof window||"undefined"==typeof document)return;Pi=!0;const t=()=>{_i++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Oi=new MutationObserver(t),Oi.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Ti=window.matchMedia("(prefers-color-scheme: dark)"),$i=t,"function"==typeof Ti.addEventListener?Ti.addEventListener("change",$i):"function"==typeof Ti.addListener&&Ti.addListener($i)}catch(t){}}();let s=Mi.get(r);s&&s.version===_i||(s={version:_i,map:new Map},Mi.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||e;return s.map.set(e,l),l}function Ci(t){switch(t){case"monotoneX":return r.curveMonotoneX;case"monotoneY":return r.curveMonotoneY;case"cardinal":return r.curveCardinal;case"catmullRom":return r.curveCatmullRom;case"step":return r.curveStep;case"stepBefore":return r.curveStepBefore;case"stepAfter":return r.curveStepAfter;case"basis":return r.curveBasis;case"natural":return r.curveNatural;default:return null}}function Ei(t,e,n){return null==e?n:"string"!=typeof e?e:Li(t,e)||n}function Ri(t,e,n,o,i,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 a=t.createLinearGradient(o,i,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;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)),d=t.createLinearGradient(o,i,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,o="#010203";try{t.fillStyle=o,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const i=t.fillStyle;if(t.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&e.trim().toLowerCase()!==o)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 r=i.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},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function zi(t,e,n,o,i,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 a=t.createLinearGradient(n,o,i,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const Di=new WeakMap;function Ni(t,e){const n=Ci(e);if(!n)return t;const o=Di.get(t);if(o)return o;const i=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let i=null;const s={moveTo(t,e){i=[t,e],o.push([t,e])},lineTo(t,e){i=[t,e],o.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const d=i/n,h=1-d;o.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){i=[n,r],o.push([n,r])}};return r.line().x(t=>t[0]).y(t=>t[1]).curve(e).context(s)(t),o}(t,n);return Di.set(t,i),i}function Fi(t,e,n,o=30,i,r=0){let s=null;if(i){const t=function(t,e,n,o,i,r=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(o,i+5,12),c=e-l,u=e+l,d=n-l,h=n+l;let f=null,g=1/0;return t.visit((t,i,l,y,p)=>{if(i>u||c>y||l>h||d>p)return!0;if(!t.length){let i=t;do{const t=i.data,l=r(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);wi(a(t),o)>=u&&g>u&&(f=t,g=u),i=i.next}while(i)}return!1}),f?{node:f,distance:g}:null}(i,e,n,o,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(i)break;t=Bi(r,e,n,o);break;case"symbol":t=Ii(r,e,n,o);break;case"line":t=Yi(r,e,n,o);break;case"rect":if(null==r.datum)break;t=Hi(r,e,n);break;case"heatcell":t=qi(r,e,n);break;case"area":if(!1===r.interactive)break;t=Vi(r,e,n);break;case"candlestick":t=Xi(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Wi(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=Ui(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>n)return null;let i=o,r=o;o>0&&t[o][0]>=e?(i=o-1,r=o):t.length-1>o&&(i=o,r=o+1);const[s,a]=t[i],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Bi(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>wi(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Ii(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>wi(Mt(t.size),o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Yi(t,e,n,o=30){var i,r;if(0===t.path.length)return null;const s=Ui(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=t.path[s],[a,l]=t.path[s+1],c=Gi(e,n,i,r,a,l);o>c&&(o=c)}c=o}else{const t=e-a,o=n-l;c=Math.sqrt(t*t+o*o)}const u=t.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function Gi(t,e,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-o,2));let c=((t-n)*s+(e-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function Hi(t,e,n){const o=ki(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function qi(t,e,n){const o=ki(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function Xi(t,e,n){const o=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,r=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function Vi(t,e,n){if(0===t.topPath.length)return null;const o=Ui(t.topPath,e);if(0>o)return null;const[i,r]=t.topPath[o],s=e-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:r,distance:l}}function Ui(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i][0]?n=i+1:o=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Zi(t,e,n){const o=t.byGroup.get(e);let i=0,r=Math.abs(o[0].x-n.x);for(let t=1;o.length>t;t++){const e=Math.abs(o[t].x-n.x);r>e&&(r=e,i=t)}return o[i]._flatIndex}function Qi(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const Ki={fresh:1,aging:.7,stale:.45,expired:.25},Ji={alpha:1,band:"fresh",isStale:!1};function tr(t,e){var n,o;if(!t||0>=e)return Ji;const i=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},o=function(t,e,n={}){var o,i,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!==(o=n.fresh)&&void 0!==o?o:1,a=null!==(i=n.aging)&&void 0!==i?i:1.5,l=null!==(r=n.stale)&&void 0!==r?r:3;return e*s>t?"fresh":e*a>t?"aging":e*l>t?"stale":"expired"}(e,i,t.thresholds);return{alpha:Object.assign(Object.assign({},Ki),null!==(n=t.opacities)&&void 0!==n?n:{})[o],band:o,isStale:"fresh"!==o}}return e>i?{alpha:null!==(o=t.dimOpacity)&&void 0!==o?o:.5,band:"stale",isStale:!0}:Ji}function er({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 nr={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 or(t,e,n,o,i){let r;return r="function"==typeof n?n(t):(0,nr[n])(o(t,e),i),r}function ir({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 rr(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const sr=(e,n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[];let p=0;const m=!(!n&&!o),v="isolate"===u||void 0===u&&null!=r,{swatchSize:x,labelGap:b,rowHeight:k}=d;return g.forEach((e,u)=>{const d=or(e,u,h,f,x),w=rr(e,i,r),A=r&&r.size>0&&r.has(e.label);y.push(t.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?A||!1:void 0,"aria-current":m&&!v&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:m?t=>{var o;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)+g.length)%g.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(l,u),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&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(ir,{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}),y};function ar({config:e,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:s,format:a}=e,l=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+m.useId();if("horizontal"===n){const e=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(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:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),t.jsx("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(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:l(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function lr(e){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical",legendLayout:h}=e,f=function(t){var e,n,o,i,r;const s=Math.max(1,null!==(e=null==t?void 0:t.swatchSize)&&void 0!==e?e:16),a=Math.max(s,null!==(n=null==t?void 0:t.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(o=null==t?void 0:t.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(i=null==t?void 0:t.itemGap)&&void 0!==i?i:10),rowHeight:a,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),[g,y]=m.useState(0),[p,v]=m.useState(0),x=m.useCallback((t,e)=>{y(t),v(e)},[]),b="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return e.forEach((e,g)=>{h+=5,f.push(t.jsx("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),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-"+g)),h+=8),f.push(t.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:sr(e,o,i,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:x,legendInteraction:a,metrics:f}):(({legendGroups:e,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var f;let g=0;const y=[];e.forEach((e,n)=>{var f;let p=0;e.label&&(p+=16);const m=((e,n,o,i,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=e,p=[],{swatchSize:m,labelGap:v,itemGap:x,rowHeight:b,align:k}=d,w=!(!n&&!o),A="isolate"===u||void 0===u&&null!=r,S=y.map(t=>m+v+7*t.label.length),j=[];let M=0,_=0;S.forEach((t,e)=>{const n=0===_?t:_+x+t;h&&h>0&&_>0&&n>h?(j.push({start:M,end:e,width:_}),M=e,_=t):_=n}),y.length>0&&j.push({start:M,end:y.length,width:_}),j.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=y[h],k=or(e,h,f,g,m),j=rr(e,i,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:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:w?l===s&&h===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&A?M||!1:void 0,"aria-current":w&&!A&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:w?t=>{var o;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)+y.length)%y.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:w?t=>{c(l,h),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:w?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:j,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+v+2+7*e.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,M&&t.jsx(ir,{swatchSize:m}),t.jsx("text",{y:m/2,x:m+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),d+=S[h]+x}});const P=Math.max(0,...j.map(t=>t.width)),O=j.length;return{items:p,offset:P,totalRows:O,totalHeight:O*b}})(e,i,r,s,a,l,c,n,u,d,h,null!==(f=h.maxWidth)&&void 0!==f?f:o);p+=m.offset+5,y.push(Object.assign(Object.assign({label:e.label},m),{offset:p,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=p+12});const p=null!==(f=h.maxWidth)&&void 0!==f?f:o;let m=g>p?0:"center"===h.align?Math.max(0,(p-g)/2):"end"===h.align?Math.max(0,p-g):0;const v=[];return y.forEach((o,i)=>{const r=e[i];r.label&&(v.push(t.jsx("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),m+=16),v.push(t.jsx("g",{className:"legend-item",transform:`translate(${m},0)`,children:o.items},"legend-group-"+i)),m+=o.offset+5,e[i+1]&&v.push(t.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),m+=12}),t.jsx("g",{children:v})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:x,legendInteraction:a,metrics:f}),k=!(!o&&!i);return t.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"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:l}),b]})}function cr(e){var n;const{legend:o,totalWidth:i,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=e;if(!o)return null;const y="top"===a||"bottom"===a,p=!!c,m=Math.max(1,y?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,i-s.left-s.right):100);let v,x;return"left"===a?(v=Math.max(4,s.left-m-10),x=s.top):"top"===a?(v=s.left,x=p?32:8):"bottom"===a?(v=s.left,x=r-s.bottom+38):(v=i-s.right+10,x=s.top),t.jsx("g",{transform:`translate(${v}, ${x})`,children:w(o)?t.jsx(ar,{config:o.gradient,orientation:y?"horizontal":"vertical",width:m}):k(o)?t.jsx(lr,{legendGroups:o.legendGroups,title:"",width:m,orientation:y?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}function ur(t){return"string"==typeof t?{type:t}:t}function dr({orient:n,config:o,values:i,scale:r,size:a,length:l}){const c=function(t){var e,n,o,i,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!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=e.useMemo(()=>{if(0===i.length)return null;const e=r.domain(),o=a-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 o=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(i);if(!e)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*o,20),g=(o-f)/2+4;if(u){const e=r(s),o=r(l),i=r(a),u=r(d),y=r(h),p="top"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:m+p*(g+f/2),x2:y,y2:m+p*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:m+p*g,x2:u,y2:m+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:y,y1:m+p*g,x2:y,y2:m+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,o),y:"top"===n?m-g-f:m+g,width:Math.abs(o-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:i,y1:"top"===n?m-g-f:m+g,x2:i,y2:"top"===n?m-g:m+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),o=r(l),i=r(a),u=r(d),y=r(h),p="left"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:m+p*(g+f/2),y1:u,x2:m+p*(g+f/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+p*g,y1:u,x2:m+p*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+p*g,y1:y,x2:m+p*(g+f),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?m-g-f:m+g,y:Math.min(e,o),width:f,height:Math.abs(o-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?m-g-f:m+g,y1:i,x2:"left"===n?m-g:m+g+f,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=s.bin().domain(e).thresholds(c.bins)(i);if(0===d.length)return null;const h=Te(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,i)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*o;if(u){const o=r(e.x0),a=r(e.x1)-r(e.x0);return t.jsx("rect",{x:o,y:"top"===n?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=r(e.x0),a=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(o,o+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=o/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(o/2),a=r((t.x0+t.x1)/2);i.push(u?`${a},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${a}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(o/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?r(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*o,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*o,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;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},[i,r,c,a,l,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}const hr={linear:r.curveLinear,monotoneX:r.curveMonotoneX,monotoneY:r.curveMonotoneY,step:r.curveStep,stepAfter:r.curveStepAfter,stepBefore:r.curveStepBefore,basis:r.curveBasis,cardinal:r.curveCardinal,catmullRom:r.curveCatmullRom};let fr={positions:new Map};const gr=new Set;function yr(){for(const t of gr)t()}function pr(t,e){const n=fr.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(fr.positions);o.delete(t),fr={positions:o},yr()}function mr(t,e){const n=fr.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const o=new Map(fr.positions);o.delete(t),fr={positions:o},yr()}function vr(){return fr}function xr(t){return gr.add(t),()=>gr.delete(t)}const br={positions:new Map};function kr(){return()=>{}}function wr(){return br}function Ar(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=i instanceof Date?i.getTime():i;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function Sr(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function jr(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Mr(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>n&&(n=o.pixel);return{min:e,max:n}}function _r(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Pr(t,e,n){if("left"===t||"right"===t){const o="left"===t?n:0,i="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+o;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${o+4*i}`,s+=`L${Math.min(n,e)},${o}`}return s}{const o="bottom"===t?0:e,i="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${o+4*i},${Math.min(8*t+4,n)}`,s+=`L${o},${Math.min(e,n)}`}return s}}function Or(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f,axisExtent:g}=n,y=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||h||Tr,r=Math.max(2,Math.floor(o/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(l.x,"exact"===g?Math.max(2,s):Math.min(s,r),g),c=a.map(t=>t.valueOf()),d=a.map((t,e)=>({value:t,pixel:l.x(t),label:i(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 $r(d,Math.max(55,f+8))},[l,u,h,o,g]),p=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||f||Tr,r=Math.max(2,Math.floor(i/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return $r((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(l.y,"exact"===g?Math.max(2,s):Math.min(s,r),g)).map(t=>({value:t,pixel:l.y(t),label:o(t)})),22)},[l,u,f,i,g]),m=d&&l,v=c&&l;if(!m&&!v)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=v&&(!x||!1!==x.baseline),w=v&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,S=(null==b?void 0:b.jaggedBase)||!1,j="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(${a.left},${a.top})`,children:[m&&(()=>{var e,n;const r=_r(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=_r(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:[y.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),p.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t.jsx("line",{x1:0,y1:i,x2:o,y2:i,stroke:j,strokeWidth:1}),A&&t.jsx("path",{d:Pr("bottom",o,i),fill:"none",stroke:j,strokeWidth:1}),w&&!S&&t.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:j,strokeWidth:1}),S&&t.jsx("path",{d:Pr("left",o,i),fill:"none",stroke:j,strokeWidth:1})]})})}function Tr(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function $r(t,e){if(2>=t.length)return t;const n=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-n[n.length-1].pixel)||n.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Lr(n){var o,i;const{width:s,height:a,totalWidth:l,totalHeight:c,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:p,yLabelRight:v,xFormat:b,yFormat:k,axisExtent:w,showGrid:A,title:S,legend:j,legendHoverBehavior:M,legendClickBehavior:_,legendHighlightedCategory:P,legendIsolatedCategories:O,legendPosition:T="right",legendLayout:$,foregroundGraphics:L,marginalGraphics:C,xValues:E,yValues:R,annotations:z,autoPlaceAnnotations:D,svgAnnotationRules:N,xAccessor:F,yAccessor:W,annotationData:B,pointNodes:I,curve:Y,underlayRendered:G,canvasObscuresUnderlay:H=!0,linkedCrosshairName:q,linkedCrosshairSourceId:X,children:V}=n,U=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||b||Tr,i=Math.max(2,Math.floor(s/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(h.x,"exact"===w?Math.max(2,r):Math.min(r,i),w),l=a.map(t=>t.valueOf()),c=a.map((t,e)=>({value:t,pixel:h.x(t),label:o(t,e,l)})),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 y=$r(c,d);if(y.length>1&&(y=y.filter((t,e)=>0===e||t.label+""!=y[e-1].label+"")),(null==n?void 0:n.includeMax)&&y.length>0&&"exact"!==w&&!(null==n?void 0:n.tickValues)){const t=h.x.domain()[1],e=h.x(t),n=y[y.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t,y.length,l);d>e-n&&y.length>1&&(y=y.slice(0,-1)),y.push({value:t,pixel:e,label:i})}}return y},[f,h,g,b,s,w]),Z=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||k||Tr,i=Math.max(2,Math.floor(a/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=$r((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(h.y,"exact"===w?Math.max(2,r):Math.min(r,i),w)).map(t=>({value:t,pixel:h.y(t),label:o(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 i=o(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:i})}}return s},[f,h,g,k,a,w]),Q=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"right"===t.orient);if(!n)return[];const o=n.tickFormat||k||Tr,i=Math.max(2,Math.floor(a/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return $r((null!==(e=n.tickValues)&&void 0!==e?e:Ar(h.y,"exact"===w?Math.max(2,r):Math.min(r,i),w)).map(t=>({value:t,pixel:h.y(t),label:o(t)})),22)},[f,h,g,k,a,w]),K=e.useRef(new Map),J=e.useRef(null!==(o=null==z?void 0:z.length)&&void 0!==o?o:0),tt=null!==(i=null==z?void 0:z.length)&&void 0!==i?i:0;J.current!==tt&&(J.current=tt,K.current=new Map);const et=e.useMemo(()=>{if(!z||0===z.length)return null;const e=function(e,n,o){var i,s,a,l,c,d,h,f,g,y,p,v,b,k,w,A,S,j,M,_,P,O,T,$,L,C,E,R,z,D,N,F,W,B,I,Y,G,H,q,X,V,U,Z,Q,K,J,tt,et,nt,ot,it;switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=po(e,n,o);if(!r)return null;const{x:l,y:c}=r;if(!mo(l,c,o))return null;const u="callout"===e.type?"callout-circle":e.type,d="callout-circle"===u?{radius:null!==(i=e.radius)&&void 0!==i?i:12,radiusPadding:e.radiusPadding}:"callout-rect"===u?{width:e.width,height:e.height}:void 0;return t.jsx(io,{noteData:Object.assign(Object.assign({x:l,y:c,dx:null!==(s=e.dx)&&void 0!==s?s:30,dy:null!==(a=e.dy)&&void 0!==a?a:-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 i=ho(null!=e.value?Object.assign(Object.assign({},e),{x:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let a;a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12;const l=i>.6*(o.width||0),c=l?i-4:i+4,u=l?"end":"start";return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:c,y:a,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 i=fo(null!=e.value?Object.assign(Object.assign({},e),{y:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"enclose":{const i=(e.coordinates||[]).map(t=>({x:ho(Object.assign(Object.assign({},t),{type:"point"}),o),y:fo(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=u.packEnclose(i),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 i=(e.coordinates||[]).map(t=>({x:ho(Object.assign(Object.assign({},t),{type:"point"}),o),y:fo(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=e.padding||10,s=i.map(t=>t.x),a=i.map(t=>t.y),[l,c]=Oe(s),[u,d]=Oe(a),h=l-r,f=c+r,g=u-r;return t.jsxs("g",{children:[t.jsx("rect",{x:h,y:g,width:f-h,height:d+r-g,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:g-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const i=o.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,i)=>{const r=ho(n,o),a=fo(n,o);if(null==r||null==a)return null;const l="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:a,r:l},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=ho(e,o),r=fo(e,o);return t.jsx(io,{noteData:{x:null!=i?i: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 i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a="ordinal"===o.frameType,u="horizontal"===o.projection,p=a?r:null,m=a?s:null;let v;const b=[],k=new Map;if(a&&p&&m){for(const t of i){const e=t[p];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,b.length),b.push(n))}v=i.map(t=>{const e=t[p],n=t[m];if(null==e||null==n)return null;const o=k.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else v=i.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>v.length)return null;const w=null!==(c=null===(l=o.scales)||void 0===l?void 0:l.x)&&void 0!==c?c:null===(d=o.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(b.length-1,n+1),i=e-n,r=t(b[n]);return r+(t(b[o])-r)*i},j=w,M=A;let _;if(a)if(u){const t=S(M);_=(e,n)=>[j(n),t(e)]}else{const t=S(j);_=(e,n)=>[t(e),M(n)]}else _=(t,e)=>[j(t),M(e)];const P=e.method||"linear";let O;O="loess"===P?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const o=t.slice().sort((t,e)=>t[0]-e[0]),i=o.map(t=>t[0]),r=o.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],o=i.map(t=>Math.abs(t-e)),l=o.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:o[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*i[t],h+=e*r[t],f+=e*i[t]*i[t],g+=e*i[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([e,h/u]);else{const t=(u*g-d*h)/y;a.push([e,(h-t*d)/u+t*e])}}return a}(v,null!==(y=e.bandwidth)&&void 0!==y?y:.3):("polynomial"===P?x.default.polynomial(v,{order:e.order||2}):x.default.linear(v)).points;const T=O.map(([t,e])=>{const[n,o]=_(t,e);return`${n},${o}`}).join(" "),$=e.color||"#6366f1",L=O[O.length-1],[C,E]=_(L[0],L[1]);return t.jsxs("g",{children:[t.jsx("polyline",{points:T,fill:"none",stroke:$,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:C+4,y:E-4,fill:$,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const i=null!==(v=null===(p=o.scales)||void 0===p?void 0:p.y)&&void 0!==v?v:null===(b=o.scales)||void 0===b?void 0:b.value,r=null!==(k=null==i?void 0:i(e.y0))&&void 0!==k?k:0,s=null!==(w=null==i?void 0:i(e.y1))&&void 0!==w?w:o.height||0;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(o.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 i=o.data||[];if(2>i.length)return null;const s=o.xAccessor||"x",a=null!==(S=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==S?S:null===(j=o.scales)||void 0===j?void 0:j.time,l=null!==(_=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==_?_:null===(P=o.scales)||void 0===P?void 0:P.value;if(!a||!l)return null;const c=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=i.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=hr[o.curve||"linear"]||r.curveLinear,g=r.area().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const y=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==($=null===(T=o.scales)||void 0===T?void 0:T.x)&&void 0!==$?$:null===(L=o.scales)||void 0===L?void 0:L.time,a=null!==(E=null===(C=o.scales)||void 0===C?void 0:C.y)&&void 0!==E?E:null===(R=o.scales)||void 0===R?void 0:R.value;if(!s||!a)return null;const l=i.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const c=l.reduce((t,e)=>t+e,0)/l.length,u=l.reduce((t,e)=>t+Math.pow(e-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(z=e.threshold)&&void 0!==z?z:2,f=c-h*d,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,x=a(c+h*d),b=a(f),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:o.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,n)=>{const i=ho(e,o),r=fo(e,o);return null==i||null==r?null:t.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(o.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(W=null===(F=o.scales)||void 0===F?void 0:F.x)&&void 0!==W?W:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(Y=null===(I=o.scales)||void 0===I?void 0:I.y)&&void 0!==Y?Y:null===(G=o.scales)||void 0===G?void 0:G.value;if(!a||!l)return null;const c=i.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=x.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const t=c.length;let e=0,n=0,o=0,i=0;for(const[t,r]of c)e+=t,n+=r,o+=t*t,i+=t*r;const r=t*o-e*e;if(1e-12>Math.abs(r))return null;const s=(t*i-e*n)/r,a=(n-s*e)/t;u=t=>a+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)),g=c.reduce((t,e)=>t+e[0],0)/d,y=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),p=null!==(H=e.confidence)&&void 0!==H?H:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(q=e.steps)&&void 0!==q?q:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;v>=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+(y>0?Math.pow(t-g,2)/y:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,j=A.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),M=`${a(b)},${l(u(b))}`,_=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(X=e.fillOpacity)&&void 0!==X?X:.15,stroke:"none"}),t.jsx("polyline",{points:`${M} ${j}`,fill:"none",stroke:_,strokeWidth:null!==(V=e.strokeWidth)&&void 0!==V?V:2,strokeDasharray:null!==(U=e.strokeDasharray)&&void 0!==U?U:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let i=null,r=null;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const t=po(e,n,o);if(!t)return null;i=t.x,r=t.y}if(null==i||null==r)return null;if(!mo(i,r,o))return null;const s=null!==(Z=e.dx)&&void 0!==Z?Z:0,a=null!==(Q=e.dy)&&void 0!==Q?Q:0,l=null!==(K=e.width)&&void 0!==K?K: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:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=po(e,n,o);if(!i)return null;const{x:r,y:s}=i,a=r+(e.dx||0),l=s+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",u=t.jsx("text",{x:a,y:l,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?m.cloneElement(u,{key:"ann-text-"+n}):t.jsxs("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[t.jsx("line",{x1:r,y1:s,x2:a,y2:l,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),m.cloneElement(u,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=t=>"function"==typeof t&&"function"==typeof t.bandwidth,s=null===(et=o.scales)||void 0===et?void 0:et.o,a=null===(nt=o.scales)||void 0===nt?void 0:nt.x,l=null===(ot=o.scales)||void 0===ot?void 0:ot.y,c=r(s)?s:r(a)?a:r(l)?l:null;if(!c)return null;const u=c(i+"");if(null==u)return null;const d=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",f=null!==(it=e.opacity)&&void 0!==it?it:.15,g=e.label;return t.jsxs("g",(o.projection?"vertical"===o.projection:c===a)?{children:[t.jsx("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&t.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t.jsx("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&t.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:F,yAccessor:W,width:s,height:a,data:B,frameType:"xy",pointNodes:I,curve:Y,stickyPositionCache:K.current};return function(t,e,n,o){const i=[];return t.forEach((t,r)=>{let s;if(n){const i=n(t,r,o);s=null!=i?i:e(t,r,o)}else s=e(t,r,o);s&&i.push({node:s,annotation:t})}),uo(i)}(D?Ro(Object.assign({annotations:z,context:n},"object"==typeof D?D:{})):z,e,N,n)},[z,D,N,s,a,F,W,B,h,I,Y]),nt=function(t){var n;const o=e.useSyncExternalStore(t?xr:kr,t?vr:wr,t?vr:wr);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(q);return e.useEffect(()=>{if(!(null==nt?void 0:nt.locked)||!q)return;const t=t=>{"Escape"===t.key&&mr(q)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==nt?void 0:nt.locked,q]),f||S||j||L||C||et&&et.length>0||A||V||nt?t.jsxs("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof S?S:"XY Chart"}),t.jsx("desc",{children:"string"==typeof S?S+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[A&&h&&(!G||H)&&(()=>{var e,n;const o=_r(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),i=_r(null===(n=null==g?void 0:g.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:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),Z.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:s,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=!e||!1!==e.baseline,i=!n||!1!==n.baseline,r=(null==e?void 0:e.jaggedBase)||!1,l=(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))",m="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&U.length>1&&(()=>{const t=s/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,S=null==e?void 0:e.tickAnchor,j=Mr(U),M=Mr(Z);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:[(!G||H)&&i&&!l&&t.jsx("line",{x1:0,y1:a,x2:s,y2:a,stroke:h,strokeWidth:1}),(!G||H)&&l&&t.jsx("path",{d:Pr("bottom",s,a),fill:"none",stroke:h,strokeWidth:1}),U.map((e,n)=>{const o=!!c&&("function"==typeof c?c(e.value,n):Si(e.value,n>0?U[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${a})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":Sr(A,e.pixel===j.min,e.pixel===j.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?k:b),transform:x?"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)}),y&&t.jsx("text",{x:s/2,y:a+40,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:y})]}),t.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!G||H)&&o&&!r&&t.jsx("line",{x1:0,y1:0,x2:0,y2:a,stroke:h,strokeWidth:1}),(!G||H)&&r&&t.jsx("path",{d:Pr("left",s,a),fill:"none",stroke:h,strokeWidth:1}),Z.map((e,n)=>{const o=!!u&&("function"==typeof u?u(e.value,n):Si(e.value,n>0?Z[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:jr(S,e.pixel===M.min,e.pixel===M.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:-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)||p;return n?t.jsx("text",{x:15-d.left,y:a/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-d.left}, ${a/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:n}):null})()]}),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===Q.length)return null;const n=!1!==e.baseline,o=e.landmarkTicks,i=e.label||v,r=e.tickAnchor,l=Mr(Q);return t.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[n&&t.jsx("line",{x1:s,y1:0,x2:s,y2:a,stroke:h,strokeWidth:1}),Q.map((e,n)=>{const i=!!o&&("function"==typeof o?o(e.value,n):Si(e.value,n>0?Q[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${s},${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:jr(r,e.pixel===l.min,e.pixel===l.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: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)}),i&&t.jsx("text",{x:s+d.right-15,y:a/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${s+d.right-15}, ${a/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:i})]})})()]})})(),et,C&&h&&E&&R&&t.jsxs(t.Fragment,{children:[C.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(dr,{orient:"top",config:ur(C.top),values:E,scale:h.x,size:d.top,length:s})}),C.bottom&&t.jsx("g",{transform:`translate(0, ${a})`,children:t.jsx(dr,{orient:"bottom",config:ur(C.bottom),values:E,scale:h.x,size:d.bottom,length:s})}),C.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(dr,{orient:"left",config:ur(C.left),values:R,scale:h.y,size:d.left,length:a})}),C.right&&t.jsx("g",{transform:`translate(${s}, 0)`,children:t.jsx(dr,{orient:"right",config:ur(C.right),values:R,scale:h.y,size:d.right,length:a})})]}),L,nt&&nt.sourceId!==X&&(null==h?void 0:h.x)&&(()=>{const e=h.x(nt.xValue);if(null==e||0>e||e>s)return null;const n=nt.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:a,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"})})(),V]}),S&&t.jsx("text",{x:l/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 S?S:null}),cr({legend:j,totalWidth:l,totalHeight:c,margin:d,legendPosition:T,title:S,legendLayout:$,legendHoverBehavior:M,legendClickBehavior:_,legendHighlightedCategory:P,legendIsolatedCategories:O})]}):null}const Cr="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Er=()=>()=>{},Rr=()=>!1,zr=()=>!0;function Dr(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;if(!Object.is(t[o],e[o]))return!1}return!0}function Nr(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 Fr(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 Wr=m.createContext(null),Br={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ir(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 o=[],i={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),o=r.indexOf(e);return(-1===n?999:n)-(-1===o?999:o)});for(const t of s)o.push(`${n[t]} ${i[t]||t}`);return`${e}, ${o.join(", ")}`}const Yr=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function Gr(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,o]of Object.entries(t))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(e[n]=o):"string"==typeof o?e[n]=o:"boolean"==typeof o?e[n]=o+"":o instanceof Date&&(e[n]=o.toISOString().slice(0,10)));return e}const Hr="semiotic-accessible-data-table",qr=Hr+" semiotic-accessible-data-table-hidden",Xr=Hr+" semiotic-accessible-data-table-visible",Vr={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"},Ur={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Zr={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)"},Qr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Kr={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))"},Jr={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},ts={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},es={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 ns({scene:e,chartType:n,tableId:o,chartTitle:i}){var r;const[s,a]=m.useState(!1),[l,c]=m.useState(5),u=m.useContext(Wr),d=null!==(r=null==u?void 0:u.visible)&&void 0!==r&&r,h=s||d,f=m.useRef(null),g=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n;m.useEffect(()=>{h||c(5)},[h]);const y=m.useCallback(t=>{t.target===t.currentTarget&&(s||d||a(!0))},[s,d]),p=m.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[d]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:Br}):null;if(!h)return t.jsx("div",{id:o,className:qr,tabIndex:-1,onFocus:y,style:Br,role:"region","aria-label":g,children:t.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," elements)"]})});const v=function(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m;const v=[];if(!Array.isArray(t))return v;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;v.push({label:"Point",values:Gr(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)v.push({label:e,values:Gr(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!==(i=null!==(o=t.value)&&void 0!==o?o:t.__aggregateValue)&&void 0!==i?i:t.total;v.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const t=Gr(b.datum);null==t.value&&"number"==typeof b.value&&Number.isFinite(b.value)&&(t.value=b.value),v.push({label:"Cell",values:t});break}case"wedge":v.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=b.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=b.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=b.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":v.push({label:"Node",values:Gr(b.datum)});break;case"arc":v.push({label:"Arc",values:Gr(b.datum)});break;case"candlestick":v.push({label:"Candlestick",values:Gr(b.datum)});break;case"geoarea":v.push({label:"Region",values:{name:null!==(y=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===(g=b.datum)||void 0===g?void 0:g.name)&&void 0!==y?y:"",value:null!==(m=null===(p=b.datum)||void 0===p?void 0:p.value)&&void 0!==m?m:""}})}}catch(t){}return v}(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 o of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[o];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],r=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),r+=n;n.push({name:o,count:e.length,numeric:!0,min:t,max:i,mean:r/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:o,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(v),b=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Yr(t.min)} to ${Yr(t.max)}, mean ${Yr(t.mean)}.`);else{const e=t.uniqueValues,o=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${o}.`)}return n.join(" ")}(v.length,x),k=Math.min(l,v.length),w=v.slice(0,k),A=v.length-k,S=new Set;for(const t of w)for(const e of Object.keys(t.values))S.add(e);const j=Array.from(S);return t.jsxs("div",{ref:f,id:o,className:Xr,tabIndex:-1,onBlur:p,style:Vr,role:"region","aria-label":g,children:[t.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&u&&u.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Zr,children:"×"}),t.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ur,children:b}),t.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+n,style:Qr,children:[t.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:ts,children:A>0?`First ${k} of ${v.length} data points`:`All ${v.length} data points`}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:Kr,children:"type"}),j.map(e=>t.jsx("th",{style:Kr,children:e},e))]})}),t.jsx("tbody",{children:w.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Jr,children:e.label}),j.map(n=>{return t.jsx("td",{style:Jr,children:(o=e.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Yr(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]}),A>0&&t.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(t=>t+25),style:es,children:["Show ",Math.min(25,A)," more"," ",1===A?"row":"rows"," (",A," remaining)"]})]})}function os({summary:e}){return e?t.jsx("div",{role:"note",style:Br,children:e}):null}function is({tableId:e}){return t.jsx("a",{href:"#"+e,style:Br,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,Br)},children:"Skip to data table"})}function rs({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:Br,children:n})}const ss="var(--semiotic-focus, #005fcc)";function as({active:e,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t.jsx("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:ss,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:ss,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ss,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function ls({x:e,y:n,containerWidth:o,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(e)&&Number.isFinite(n),u=m.useRef(null),[d,h]=m.useState(null);m.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,a,o,i]);let f;f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const g=function(t){if(!m.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(s),y=g?null:ci;return c?t.jsx("div",{ref:u,className:g?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:r.left+e,top:r.top+n,transform:f,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}const cs="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function us(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function ds(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}(),o=e.useRef(n);o.current=n;const[i,r]=function(t,n,o){const i=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const t=i.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,o]),[i,[n&&r?r.w:t[0],o&&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]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=us(t.foregroundGraphics,r,s),u=us(t.backgroundGraphics,r,s),d=Wn(t=>t.theme),{transition:h,introEnabled:f}=function(t,e){var n,o;if(!1===t)return{transition:void 0,introEnabled:!1};const i="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!==(o=t.duration)&&void 0!==o?o:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(i||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+m.useId(),y=e.useRef(0),p=e.useRef(()=>{}),v=e.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>p.current()))},[]);e.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.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)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),j=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 cs(()=>{M&&(_i++,M.current=!0,v())},[d,v,M]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:y,renderFnRef:p,scheduleRender:v,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:j}}function hs(t,e,n,o){const i=t.getContext("2d");if(!i)return null;const r=e[0]*o,s=e[1]*o,a=e[0]+"px",l=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==l&&(t.style.height=l),t.width===r&&t.height===s||(t.width=r,t.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function fs(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}function gs(t,e,n,o,i,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],o=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=o,t.lineCap=r;for(let n=0;e.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),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 ys=(t,e,n,o)=>{var i,s;const a=e.filter(t=>"line"===t.type);for(const l of a){if(2>l.path.length)continue;const c=l._introClipFraction;void 0!==c&&1>c&&(t.save(),t.beginPath(),t.rect(0,0,o.width*c,o.height),t.clip());const u=l.style.stroke||"#007bff",d=Li(t,u)||u,h=l.style.strokeWidth||2,f=l.colorThresholds,g=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=h,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const v=null!==(i=l.style.opacity)&&void 0!==i?i:1;gs(t,l.path,d,h,v,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=Ci(l.curve),p=f&&f.length>0&&g&&g.length===l.path.length,m=l._decayOpacities;if(m&&m.length===l.path.length&&!p){t.strokeStyle=d;const x=null!==(s=l.style.opacity)&&void 0!==s?s:1;for(let b=0;l.path.length-1>b;b++)t.globalAlpha=.5*(m[b]+m[b+1])*x,t.beginPath(),t.moveTo(l.path[b][0],l.path[b][1]),t.lineTo(l.path[b+1][0],l.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,S=null,j=!1;function M(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),j=!0}function _(){j&&(t.stroke(),j=!1)}for(let P=0;l.path.length>P;P++){const[O,T]=l.path[P],$=g[P],L=fs($,f,d);if(null!==k&&null!==S&&null!==A){if(L===S)t.lineTo(O,T);else{const C=[];for(const E of f){const R=E.value;(A>R||R>$)&&(R>A||$>R)||A===R||$===R||C.push({t:(R-A)/($-A)})}C.sort((t,e)=>t.t-e.t);for(const z of C){const D=k+(O-k)*z.t,N=w+(T-w)*z.t,F=fs(A+($-A)*Math.min(z.t+1e-4,1),f,d);t.lineTo(D,N),_(),M(F,D,N)}t.lineTo(O,T)}k=O,w=T,A=$,S=L}else M(L,O,T),k=O,w=T,A=$,S=L}_()}else{t.beginPath();const W=l.strokeGradient&&l.path.length>=2?zi(t,l.strokeGradient,l.path[0][0],0,l.path[l.path.length-1][0],0):null;if(t.strokeStyle=W||d,y)r.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[B,I]=l.path[0];t.moveTo(B,I);for(let Y=1;l.path.length>Y;Y++)t.lineTo(l.path[Y][0],l.path[Y][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=Ei(t,l.style.fill,l.style.fill),y&&!p)r.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[H,q]=l.path[0];t.moveTo(H,q);for(let X=1;l.path.length>X;X++)t.lineTo(l.path[X][0],l.path[X][1])}const G=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],o.height),t.lineTo(G,o.height),t.closePath(),t.fill()}void 0!==c&&1>c&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ps(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ms(t,e,n=.3){ps(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 vs(t,e,n=.6){var o,i,r,s,a;if(!ps(e))return;const l=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==a?a: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 xs(t,e,n,o=.35){ps(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function bs(t,e){const n=Ci(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 o=r.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),o(e.topPath)}}const ks=(t,e,n,o)=>{var i,s,a;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const l=e._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,o.width*l,o.height),t.clip());const c=Ei(t,e.style.fill,"#4e79a7"),u=e._decayOpacities;if(u&&u.length===e.topPath.length){const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.fillStyle=c;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(u[o]+u[o+1])*n,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Li(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!==(s=e.style.opacity)&&void 0!==s?s:1;if(bs(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 o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=Ri(t,e.fillGradient,"string"==typeof c?c:"#4e79a7",0,n,0,o);t.fillStyle=i||c,t.globalAlpha=d}else{const n=null!==(a=e.style.fillOpacity)&&void 0!==a?a:.7;t.globalAlpha=n*d,t.fillStyle=c}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(bs(t,e),xs(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=d;const n=e.strokeGradient&&e.topPath.length>=2?zi(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=Ci(e.curve);if(t.beginPath(),o)r.line().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==l&&1>l&&t.restore(),n&&t.restore(),t.globalAlpha=1}},ws=(t,e,n,o)=>{var i,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 o=null!==(r=null!==(i=n.style.opacity)&&void 0!==i?i:n.style.fillOpacity)&&void 0!==r?r:1;t.globalAlpha=e*o,t.fillStyle=Ei(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=Ei(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),vs(t,n)}}finally{t.restore()}}},As=new Map;function Ss(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 o=As.get(n);return o||(o=new Path2D(jt(t.symbolType,t.size)),As.size>256&&As.clear(),As.set(n,o)),o}catch(t){return null}}const js=(t,e)=>{var n,o,i,r;const s=t.globalAlpha;for(const a of e){if("symbol"!==a.type)continue;const e=a;if(0>=e.size)continue;const l=Ss(e);if(!l)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!==(o=e._decayOpacity)&&void 0!==o?o:1);e.style.fill&&(t.globalAlpha=s*c*(null!==(i=e.style.fillOpacity)&&void 0!==i?i:1),t.fillStyle=Ei(t,e.style.fill,"#4e79a7"),t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=s*c,t.strokeStyle=Ei(t,e.style.stroke,e.style.stroke),t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.stroke(l)),t.restore()}t.globalAlpha=s};function Ms(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=bn(e);t.beginPath(),t.moveTo(n+s,o),t.lineTo(n+i-a,o),a>0&&t.arcTo(n+i,o,n+i,o+a,a),t.lineTo(n+i,o+r-l),l>0&&t.arcTo(n+i,o+r,n+i-l,o+r,l),t.lineTo(n+c,o+r),c>0&&t.arcTo(n,o+r,n,o+r-c,c),t.lineTo(n,o+s),s>0&&t.arcTo(n,o,n+s,o,s),t.closePath()}function _s(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 Ps=(t,e,n,o)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Os(t,e);else if(e.cornerRadii&&xn(e.cornerRadii)){const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,Ms(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ms(t,e),t.globalAlpha=1}};function Os(t,e){const n=e.style.icon,o=e.style.iconPadding||2,i=Math.min(e.w,e.h)-o;if(0>=i)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=i+o,s=e.x+(e.w-i)/2;for(let o=e.y+e.h-i;o>=e.y-i;o-=r)t.drawImage(n,s,o,i,i)}else{const r=i+o,s=e.y+(e.h-i)/2;for(let o=e.x;e.x+e.w>o;o+=r)t.drawImage(n,o,s,i,i)}t.restore()}function Ts(t){const[e,n,o]=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*o>128?"#000":"#fff"}function $s(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Ls=(t,e,n,o)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){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=Li(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ms(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):$s(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Ts(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},Cs=(t,e,n,o)=>{var i,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(i=e._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(t.globalAlpha=a);const l=Li(t,e.wickColor)||e.wickColor,c=60>o.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=l,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=l,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),o=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,r=Li(t,i)||i;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1))}c&&d(),t.restore()}};function Es(t,e,n,o){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:o,fn:e}:{key:void 0,fn:null}}const Rs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function zs(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`${Rs[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Rs[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Ds={line:[ks,ys,ws],area:[ks,ws],stackedarea:[ks,ws],scatter:[ws,js],bubble:[ws,js],heatmap:[Ls],bar:[Ps],swarm:[ws],waterfall:[(t,e,n,o)=>{var i;Ps(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){t.save(),t.strokeStyle=Li(t,a)||a,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const o=r[e],i=r[e+1],s=o.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Cs],mixed:[ks,ys,ws],custom:[ks,Ps,Ls,ys,ws,js,Cs]},Ns={top:20,right:20,bottom:30,left:40},Fs={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 Ws(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],o=n[2],i=n[3];return`#${t}${t}${o}${o}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Bs={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 Is({hover:e}){var n,o,i;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:{},a=null!==(o=s.y)&&void 0!==o?o:s.value,l=null!==(i=s.x)&&void 0!==i?i:s.time;return t.jsxs("div",{className:"semiotic-tooltip",style:Bs,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(a)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:r(l)})]})}Is.ownsChrome=!0;const Ys=e.forwardRef(function(n,o){var i,r,s,a,l,c,u,d,h,f,g,y,p;const{chartType:v,runtimeMode:x,data:b,chunkThreshold:k,chunkSize:w,xAccessor:A,yAccessor:S,colorAccessor:j,sizeAccessor:M,symbolAccessor:_,symbolMap:P,groupAccessor:O,lineDataAccessor:T,curve:$,normalize:L,baseline:C,stackOrder:E,binSize:R,valueAccessor:z,arrowOfTime:D="right",windowMode:N="sliding",windowSize:F=200,timeAccessor:W,xExtent:B,yExtent:I,extentPadding:Y=.1,scalePadding:G,sizeRange:H,size:q=[500,300],responsiveWidth:X,responsiveHeight:V,margin:U,className:Z,background:Q,lineStyle:K,pointStyle:J,areaStyle:tt,barStyle:et,waterfallStyle:nt,swarmStyle:ot,barColors:it,colorScheme:rt,boundsAccessor:st,boundsStyle:at,y0Accessor:lt,band:ct,gradientFill:ut,lineGradient:dt,areaGroups:ht,openAccessor:ft,highAccessor:gt,lowAccessor:yt,closeAccessor:pt,candlestickStyle:mt,showAxes:vt=!0,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:St,yFormat:jt,axisExtent:Mt,tickFormatTime:_t,tickFormatValue:Pt,hoverAnnotation:Ot,tooltipContent:Tt,customHoverBehavior:$t,customClickBehavior:Lt,enableHover:Ct,hoverRadius:Rt=30,tooltipMode:zt,annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,showGrid:Wt,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,legendCategoryAccessor:Vt,onCategoriesChange:Ut,backgroundGraphics:Zt,foregroundGraphics:Qt,canvasPreRenderers:Kt,svgPreRenderers:Jt,title:te,categoryAccessor:ee,brush:ne,onBrush:oe,decay:ie,pulse:re,transition:se,animate:ae,staleness:le,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,marginalGraphics:ge,pointIdAccessor:ye,xScaleType:pe,yScaleType:me,accessibleTable:ve=!0,description:xe,summary:be,linkedCrosshairName:ke,linkedCrosshairSourceId:we,customLayout:Ae,layoutConfig:Se,layoutSelection:je}=n,Me=e.useId().replace(/:/g,""),_e=e.useRef(!1),Pe=e.useRef({w:-1,h:-1}),Oe=ds({sizeProp:q,responsiveWidth:X,responsiveHeight:V,userMargin:U,marginDefault:Ns,animate:ae,transitionProp:se,themeDirtyRef:_e}),Te=function(){const[t,n]=e.useState(!1);return Cr(()=>{n(!0)},[]),t}(),$e=function(){const t=e.useSyncExternalStore(Er,Rr,zr);return e.useRef(t).current}(),{reducedMotionRef:Le,responsiveRef:Ce,size:Ee,currentTheme:Re,transition:ze,introEnabled:De,tableId:Ne,rafRef:Fe,renderFnRef:We,scheduleRender:Be}=Oe;let Ie=Oe.margin;if(ge){const t=60,e=Object.assign({},Oe.margin);ge.top&&t>e.top&&(e.top=t),ge.bottom&&t>e.bottom&&(e.bottom=t),ge.left&&t>e.left&&(e.left=t),ge.right&&t>e.right&&(e.right=t),Ie=e}const Ye="function"==typeof Qt?Qt({size:Ee,margin:Ie}):Qt,Ge="function"==typeof Zt?Zt({size:Ee,margin:Ie}):Zt,He=Ee[0]-Ie.left-Ie.right,qe=Ee[1]-Ie.top-Ie.bottom,Xe=e.useMemo(()=>si(b),[b]),Ve=null!=Ot?Ot:Ct,Ue=e.useRef(null),Ze=e.useRef(null),[Qe,Ke]=e.useState(0),Je=e.useRef(0),[tn,en]=e.useState(null),nn=e.useRef(null),on=e.useRef(null),[rn,sn]=e.useState(null),an=e.useRef(Fs.primary),ln=e.useRef([]),cn=e.useRef(Vt),un=e.useRef(Ut);cn.current=Vt,un.current=Ut;const[dn,hn]=e.useState(!1),[fn,gn]=e.useState([]),[yn,pn]=e.useState([]),mn="streaming"===x||["bar","swarm","waterfall"].includes(v),vn=e.useMemo(()=>{var t,e,n;return{chartType:v,runtimeMode:mn?"streaming":"bounded",windowSize:F,windowMode:N,arrowOfTime:mn?D:"right",extentPadding:Y,scalePadding:G,axisExtent:Mt,xAccessor:A,yAccessor:S,timeAccessor:mn?W:void 0,valueAccessor:z,colorAccessor:j,sizeAccessor:M,symbolAccessor:_,symbolMap:P,groupAccessor:O||(T?"_lineGroup":void 0),categoryAccessor:ee,lineDataAccessor:T,xScaleType:pe,yScaleType:me,xExtent:B,yExtent:I,sizeRange:H,binSize:R,normalize:L,baseline:C,stackOrder:E,boundsAccessor:st,boundsStyle:at,y0Accessor:lt,band:ct,gradientFill:!0===ut?{topOpacity:.8,bottomOpacity:.05}:!1===ut?void 0:ut,areaGroups:ht?new Set(ht):void 0,lineGradient:dt,openAccessor:ft,highAccessor:gt,lowAccessor:yt,closeAccessor:pt,candlestickStyle:mt,lineStyle:K,pointStyle:J,areaStyle:tt,swarmStyle:ot,waterfallStyle:nt,colorScheme:rt,barColors:it,barStyle:et,annotations:Dt,decay:ie,pulse:re,transition:ze,introAnimation:De,staleness:le,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,pointIdAccessor:ye,curve:$,themeCategorical:null===(t=null==Re?void 0:Re.colors)||void 0===t?void 0:t.categorical,themeSemantic:Ln(Re),themeSequential:null===(e=null==Re?void 0:Re.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Re?void 0:Re.colors)||void 0===n?void 0:n.diverging,customLayout:Ae,layoutConfig:Se,layoutMargin:Ie}},[v,F,N,D,Y,G,Mt,A,S,W,z,pe,me,j,M,_,P,O,ee,T,B,I,H,R,L,C,E,st,at,lt,ct,ut,dt,ht,ft,gt,yt,pt,mt,K,J,tt,ot,nt,et,rt,it,Dt,ie,re,null==ze?void 0:ze.duration,null==ze?void 0:ze.easing,De,le,ce,ue,de,he,fe,mn,ye,$,Re,Ae,Se,Ie]),xn=function(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 Nr(t,e);if(!Fr(t)||!Fr(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;const n=t[o],i=e[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!Nr(n,i))return!1}else{if(!Fr(n)||!Fr(i))return!1;if(!Dr(n,i))return!1}}return!0}(n.current,t)||(n.current=t),n.current}(vn),bn=e.useRef(null);bn.current||(bn.current=new Et(xn));const kn=e.useCallback(()=>{var t,e;const n=cn.current,o=un.current;if(!o||!n)return;const i=function(t,e){if(!e)return[];const n=new Set,o=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),o.push(r))}return o}(null!==(e=null===(t=bn.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})(i,ln.current)||(ln.current=i,o(i))},[]);e.useEffect(()=>{var t;null===(t=bn.current)||void 0===t||t.updateConfig(xn),_e.current=!0,Be()},[xn,Be]);const wn=e.useRef(null);e.useEffect(()=>{const t=bn.current;if(!t)return;const e=null!=je?je:null;wn.current!==e&&(wn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):_e.current=!0,Be())},[je,Be]);const An=e.useRef(null);An.current||(An.current=new pi(t=>{const e=bn.current;e&&e.ingest(t)&&(_e.current=!0,Be())},{chunkThreshold:k,chunkSize:w})),e.useEffect(()=>{var t;null===(t=An.current)||void 0===t||t.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const Sn=e.useCallback(t=>{var e;null===(e=An.current)||void 0===e||e.push(t)},[]),jn=e.useCallback(t=>{var e;null===(e=An.current)||void 0===e||e.pushMany(t)},[]),Mn=e.useCallback(()=>{var t,e;null===(t=An.current)||void 0===t||t.clear(),null===(e=bn.current)||void 0===e||e.clear(),_e.current=!0,Be()},[Be]);e.useImperativeHandle(o,()=>({push:Sn,pushMany:jn,remove:t=>{var e,n,o;null===(e=An.current)||void 0===e||e.flush();const i=null!==(o=null===(n=bn.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[];return i.length>0&&(nn.current&&i.some(t=>{var e;return t===(null===(e=nn.current)||void 0===e?void 0:e.data)})&&(nn.current=null,sn(null)),_e.current=!0,Be()),i},update:(t,e)=>{var n,o,i;null===(n=An.current)||void 0===n||n.flush();const r=null!==(i=null===(o=bn.current)||void 0===o?void 0:o.update(t,e))&&void 0!==i?i:[];return r.length>0&&(_e.current=!0,Be()),r},clear:Mn,getData:()=>{var t,e,n;return null===(t=An.current)||void 0===t||t.flush(),null!==(n=null===(e=bn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=bn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=bn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Sn,jn,Mn,Be]),e.useEffect(()=>{var t,e;if(b){if(T&&Xe.length>0&&"object"==typeof Xe[0]&&null!==Xe[0]){const e="string"==typeof T?T:"coordinates";if(Array.isArray(Xe[0][e])){const n=[];for(const t of Xe){const o=t[e];if(Array.isArray(o)){const e=t.label||t.id||t.key;if(null!=e)for(const t of o)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of o)n.push(t)}}return void(null===(t=An.current)||void 0===t||t.setBoundedData(n))}}null===(e=An.current)||void 0===e||e.setBoundedData(Xe)}},[b,Xe,T]);const{hoverHandlerRef:Pn,hoverLeaveRef:Tn,onPointerMove:$n,onPointerLeave:Cn}=Oe;Pn.current=t=>{var e,n,o,i;if(!Ve)return;const r=Ue.current;if(!r)return;const s=r.getBoundingClientRect(),a=t.clientX-s.left-Ie.left,l=t.clientY-s.top-Ie.top;if(0>a||a>He||0>l||l>qe)return void(nn.current&&(nn.current=null,on.current=null,sn(null),$t&&($t(null),_e.current=!0),Be()));const c=bn.current;if(!c||0===c.scene.length)return;const u=Fi(c.scene,a,l,Rt,c.quadtree,c.maxPointRadius),d="multi"===zt,h=()=>{nn.current&&(nn.current=null,on.current=null,sn(null),$t&&$t(null),Be())};if(!u&&!d)return void h();const f=d||!u?a:u.x,g=d||!u?l:u.y,y=(null==u?void 0:u.datum)?xt(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,m="function"==typeof p?p(f):void 0;let x=li(y,f,g,null!=m?{xValue:m,xPx:f}:void 0);if(d&&c.scene.length>0&&c.scales){const t=function(t,e,n=30){const o=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const r=Wi(Ni(t.path,t.curve),e,n);if(null===r)continue;const s=Ui(t.path,e);o.push({node:i,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"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Ni(t.topPath,t.curve),s=Ni(t.bottomPath,t.curve),a=Wi(r,e,n);if(null===a)continue;const l=Wi(s,e,n),c=Ui(t.topPath,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:null!=l?l: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 o}(c.scene,f,Math.max(Rt,He));if(t.length>0){const e=c.scales.y.invert,n=an.current,o=p?p(f):f;if(u)x.xValue=o,x.xPx=f;else{const t={xValue:o};"string"==typeof A&&(t[A]=o),x=li(t,f,g,{xValue:o,xPx:f})}x.allSeries=t.map(t=>{const o=e?e(t.y):t.y,i=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===v&&null!=i?o-i:o,valuePx:t.y,color:t.color||n,datum:xt(t.datum,c.resolvedRibbons)}})}}u||(null===(o=x.allSeries)||void 0===o?void 0:o.length)?(nn.current=x,on.current=null!==(i=null==u?void 0:u.node)&&void 0!==i?i:null,sn(x),$t&&($t(x),_e.current=!0),Be()):h()},Tn.current=()=>{nn.current&&(nn.current=null,on.current=null,sn(null),$t&&($t(null),_e.current=!0),Be())};const En=e.useRef(()=>{});En.current=t=>{var e,n;if(!Lt)return;const o=Ue.current;if(!o)return;const i=o.getBoundingClientRect(),r=t.clientX-i.left-Ie.left,s=t.clientY-i.top-Ie.top;if(0>r||r>He||0>s||s>qe)return void Lt(null);const a=bn.current;if(!a||0===a.scene.length)return void Lt(null);const l=Fi(a.scene,r,s,Rt,a.quadtree,a.maxPointRadius);if(!l)return void Lt(null);const c=l.datum||{},u=null===(n=null===(e=a.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,d="function"==typeof u?u(l.x):void 0;Lt(li(c,l.x,l.y,null!=d?{xValue:d,xPx:l.x}:void 0))};const Rn=e.useCallback(t=>En.current(t),[]),zn=e.useRef(-1),Dn=e.useRef(null),Nn=e.useRef(null),Fn=e.useCallback(t=>{const e=bn.current;if(!e||0===e.scene.length)return;const n=e.version;let o;if(Nn.current&&Nn.current.version===n)o=Nn.current.graph;else{const t=function(t){var e,n,o;const i=[];for(const r of t)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=r.size)break;i.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:[],o=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)i.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:o});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],o=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)i.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:o});break}case"rect":i.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!==(o=r.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.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 i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;o=function(t){var e,n;const o=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let i=o.get(t);i||(i=[],o.set(t,i)),i.push(n)}for(const t of o.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 i=Array.from(o.keys()).sort((t,e)=>{const n=o.get(t),i=o.get(e);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.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:i,byGroup:o,idToIdx:s}}(t),Nn.current={version:n,graph:o}}const i=zn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),zn.current=0;const n=o.flat[0];Dn.current={shape:n.shape,w:n.w,h:n.h};const i=Qi(Object.assign(Object.assign({},n),{datum:xt(n.datum,e.resolvedRibbons)}));return nn.current=i,sn(i),$t&&$t(i),void Be()}const r=function(t,e){var n,o;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}(o,i),s=function(t,e,n){const{group:o,indexInGroup:i}=e,r=n.byGroup.get(o);switch(t){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(o);return n.groups.length-1>t?Zi(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?Zi(n,n.groups[t-1],r[i]):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}}(t.key,r,o);if(null===s)return;if(t.preventDefault(),0>s)return zn.current=-1,Dn.current=null,nn.current=null,on.current=null,sn(null),$t&&$t(null),void Be();zn.current=s;const a=o.flat[s];Dn.current={shape:a.shape,w:a.w,h:a.h};const l=Qi(Object.assign(Object.assign({},a),{datum:xt(a.datum,e.resolvedRibbons)}));nn.current=l,sn(l),$t&&$t(l),Be()},[$t,Be]),Wn=e.useCallback(t=>{zn.current=-1,Dn.current=null,$n(t)},[$n]);We.current=()=>{Fe.current=0;const t=Ue.current,e=Ze.current;if(!t||!e)return;const n=bn.current;if(!n)return;const o="undefined"!=typeof performance?performance.now():Date.now(),i=n.advanceTransition(Le.current?o+1e6:o),r=!Le.current&&i,s=Pe.current.w!==He||Pe.current.h!==qe,a=_e.current||i||s;let l=!1;!a||r&&!s||(n.computeScene({width:He,height:qe}),Pe.current={w:He,h:qe},l=!0,kn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return Fs;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=i||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||Fs.axisStroke,tickText:s||Fs.tickText,crosshair:s?Ws(s,"66"):Fs.crosshair,hoverFill:c?Ws(c,"4D"):Fs.hoverFill,hoverStroke:s?Ws(s,"99"):Fs.hoverStroke,pointRing:c||Fs.pointRing,primary:r||Fs.primary}:Fs}(t);an.current=u.primary;const d=tr(le,n.lastIngestTime>0?o-n.lastIngestTime:0),h=le&&d.isStale;if(a){const e=hs(t,Ee,Ie,c);if(e){if(e.clearRect(-Ie.left,-Ie.top,Ee[0],Ee[1]),le&&1>d.alpha&&(e.globalAlpha=d.alpha),"transparent"!==Q&&!Zt){const n=getComputedStyle(t).getPropertyValue("--semiotic-bg").trim(),o=Q||(n&&"transparent"!==n?n:null),i=o?Li(e,o):null;i&&(e.fillStyle=i,e.fillRect(-Ie.left,-Ie.top,Ee[0],Ee[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,He,qe),e.clip()),Kt&&n.scales)for(const t of Kt)e.save(),t(e,n.scene,n.scales,{width:He,height:qe}),e.restore();const o=Ae?Ds.custom:Ds[v];if(o&&n.scales)for(const t of o)t(e,n.scene,n.scales,{width:He,height:qe});e.restore(),le&&1>d.alpha&&(e.globalAlpha=1)}}{const t=hs(e,Ee,Ie,c);if(t&&(t.clearRect(-Ie.left,-Ie.top,Ee[0],Ee[1]),Ve&&nn.current&&n.scales&&function(t,e,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=e.allSeries,c=l&&l.length>0,u=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const d="object"==typeof i.crosshair?i.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,o),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 l)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=i.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,nn.current,He,qe,"object"==typeof Ve?Ve:{},on.current,u),on.current&&Array.isArray(Ot))){const e=Ot.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){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 o.style?n.datum?o.style(n.datum):{}:o.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||i.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,on.current,e,u)}}a&&t&&t.setAttribute("aria-label",Ir(n.scene,v+" chart"));const f=_e.current;if(_e.current=f&&r&&!l,f&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!tn||t(tn.x.domain()[0])!==t(n.scales.x.domain()[0])||t(tn.x.domain()[1])!==t(n.scales.x.domain()[1])||t(tn.y.domain()[0])!==t(n.scales.y.domain()[0])||t(tn.y.domain()[1])!==t(n.scales.y.domain()[1])||tn.x.range()[0]!==n.scales.x.range()[0]||tn.x.range()[1]!==n.scales.x.range()[1]||tn.y.range()[0]!==n.scales.y.range()[0]||tn.y.range()[1]!==n.scales.y.range()[1])&&en(n.scales),ge){const t=n.getData(),e="function"==typeof A?A:t=>t[A||"x"],o="function"==typeof S?S:t=>t[S||"y"];gn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),pn(t.map(t=>o(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Dt&&Dt.length>0||Ae)&&(l||r))||!l&&33>o-Je.current||(Ke(t=>t+1),Je.current=o),(null==le?void 0:le.showBadge)&&hn(!!h),(r||null!=n.activeTransition||n.hasActivePulses)&&(Fe.current=requestAnimationFrame(()=>We.current()))},function(t){const{hydrated:n,wasHydratingFromSSR:o,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;Cr(()=>{var t,e;n&&o&&(null===(e=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===e||e.call(t)),r.current=!0,s.current()},[n,o]);const l=e.useRef(a);l.current=a,e.useEffect(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:Te,wasHydratingFromSSR:$e,storeRef:bn,dirtyRef:_e,renderFnRef:We,cleanup:()=>{var t;return null===(t=An.current)||void 0===t?void 0:t.clear()}}),e.useEffect(()=>{_e.current=!0,Be()},[v,He,qe,vt,Q,K,Kt,Be]),function(t,n,o,i,r,s){const a=e.useRef("fresh");e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{const e=n.current;if(!e||0===e.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=tr(t,l-e.lastIngestTime);c.band===a.current&&c.isStale===r||(a.current=c.band,c.isStale!==r&&s(c.isStale),o.current=!0,i())},1e3);return()=>clearInterval(e)},[t,r,i])}(le,bn,_e,Be,dn,hn);const Bn=e.useMemo(()=>{if(St||_t)return;const t=bn.current;return(null==t?void 0:t.xIsDate)&&tn?zs(tn.x.domain()):void 0},[St,_t,tn]),In=St||_t||Bn,Yn=Ve&&rn?Tt?Tt(rn):t.jsx(Is,{hover:rn}):null,Gn=Yn?t.jsx(ls,{x:rn.x,y:rn.y,containerWidth:He,containerHeight:qe,margin:Ie,className:"stream-frame-tooltip",children:Yn}):null,Hn=Dn.current,qn=t.jsx(as,{active:zn.current>=0,hoverPoint:rn,margin:Ie,size:Ee,shape:null==Hn?void 0:Hn.shape,width:null==Hn?void 0:Hn.w,height:null==Hn?void 0:Hn.h}),Xn=Es(A,W,"__semiotic_resolvedX","__semiotic_resolvedTime"),Vn=Es(S,z,"__semiotic_resolvedY","__semiotic_resolvedValue"),Un=Xn.key,Zn=Vn.key,Qn=function(t,e,n){return o=>{if(!o||!n||!t.fn&&!e.fn)return o;let i=!1;const r=o.map(n=>{const o=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!o&&!r)return n;i=!0;const s=Object.assign({},n);return o&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return i?r:o}}(Xn,Vn,Dt&&Dt.length>0||!1);if(On||!Te&&$e){const e=bn.current;e&&b&&(e.ingest({inserts:Xe,bounded:!0}),e.computeScene({width:He,height:qe}));const n=null!==(i=null==e?void 0:e.scene)&&void 0!==i?i:[],o=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,a=In||(()=>{if((null==e?void 0:e.xIsDate)&&o)return zs(o.x.domain())})();return t.jsxs("div",{ref:Ce,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":xe||("string"==typeof te?te:"XY chart"),style:{position:"relative",width:X?"100%":Ee[0],height:V?"100%":Ee[1]},children:[t.jsx(os,{summary:be}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Ie.left},${Ie.top})`,children:Ge}),t.jsxs("g",{transform:`translate(${Ie.left},${Ie.top})`,children:[Q&&t.jsx("rect",{x:0,y:0,width:He,height:qe,fill:Q}),Jt&&o&&Jt.map((e,i)=>t.jsx(m.Fragment,{children:e(n,o,{width:He,height:qe})},"svgpre-"+i)),n.map((t,e)=>_n(t,e,Me)).filter(Boolean)]})]}),t.jsx(Lr,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:o,showAxes:vt,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:a,yFormat:jt||Pt,axisExtent:Mt,showGrid:Wt,title:te,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,foregroundGraphics:mi(Ye,bi(null===(s=bn.current)||void 0===s?void 0:s.customLayoutOverlays,null!=je?je:null)),marginalGraphics:ge,xValues:[],yValues:[],annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,annotationFrame:0,xAccessor:Un,yAccessor:Zn,annotationData:Qn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof $?$:void 0,linkedCrosshairName:ke,linkedCrosshairSourceId:we})]})}return t.jsxs("div",{ref:Ce,className:"stream-xy-frame"+(Z?" "+Z:""),role:"group","aria-label":xe||("string"==typeof te?te:"XY chart"),tabIndex:0,style:{position:"relative",width:X?"100%":Ee[0],height:V?"100%":Ee[1],overflow:"visible"},onKeyDown:Fn,children:[ve&&t.jsx(is,{tableId:Ne}),ve&&t.jsx(ns,{scene:null!==(l=null===(a=bn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:v+" chart",tableId:Ne,chartTitle:"string"==typeof te?te:void 0}),t.jsx(os,{summary:be}),t.jsx(rs,{hoverPoint:rn}),t.jsxs("div",{role:"img","aria-label":xe||("string"==typeof te?te:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ve?Wn:void 0,onMouseLeave:Ve?Cn:void 0,onClick:Lt?Rn:void 0,children:[Ge&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Ie.left},${Ie.top})`,children:Ge})}),t.jsx(Or,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:tn,showAxes:vt,axes:bt,showGrid:Wt,xFormat:In,yFormat:jt||Pt,axisExtent:Mt}),t.jsx("canvas",{ref:Ue,"aria-label":Ir(null!==(u=null===(c=bn.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],v+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:Ze,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Lr,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:tn,showAxes:vt,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:In,yFormat:jt||Pt,axisExtent:Mt,showGrid:Wt,title:te,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,foregroundGraphics:mi(Ye,bi(null===(d=bn.current)||void 0===d?void 0:d.customLayoutOverlays,null!=je?je:null)),marginalGraphics:ge,xValues:fn,yValues:yn,annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,annotationFrame:Qe,xAccessor:Un,yAccessor:Zn,annotationData:Qn(null===(h=bn.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=bn.current)||void 0===f?void 0:f.scene.filter(t=>"point"===t.type),curve:"string"==typeof $?$:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==Q&&!Zt,linkedCrosshairName:ke,linkedCrosshairSourceId:we}),(ne||oe)&&t.jsx(yi,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,dimension:null!==(g=null==ne?void 0:ne.dimension)&&void 0!==g?g:"xy",scales:tn,onBrush:null!=oe?oe:()=>{},binSize:R,snap:null==ne?void 0:ne.snap,binBoundaries:null!==(y=null==ne?void 0:ne.binBoundaries)&&void 0!==y?y:"bar"===v?null===(p=bn.current)||void 0===p?void 0:p.getBinBoundaries():void 0,snapDuring:null==ne?void 0:ne.snapDuring,streaming:"streaming"===x}),(null==le?void 0:le.showBadge)&&t.jsx(er,{isStale:dn,position:le.badgePosition}),qn,Gn]})]})});Ys.displayName="StreamXYFrame";const Gs=e.createContext(null);function Hs(){return e.useContext(Gs)}function qs(t){const e=[];for(const[n,o]of Object.entries(t.fields))if("point"===o.type)e.push(t=>o.values.has(t[n]));else{const[t,i]=o.range;e.push(e=>{const o=e[n];return o>=t&&i>=o})}return t=>e.every(e=>e(t))}function Xs(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function Vs(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[Us,Zs]=Tn(t=>({selections:new Map,setClause(e,n){t(t=>{const o=t.selections.get(e),i=null==o?void 0:o.clauses.get(n.clientId);if(i&&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,o]of n){const n=e.fields[t];if(!n||!Vs(o,n))return!1}return!0}(i,n))return{};const r=new Map(t.selections),s=Xs(r,e),a=new Map(s.clauses);return a.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},s),{clauses:a})),{selections:r}})},clearClause(e,n){t(t=>{const o=t.selections.get(e);if(!o||!o.clauses.has(n))return{};const i=new Map(t.selections),r=new Map(o.clauses);return r.delete(n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(e,n){t(t=>{const o=t.selections.get(e);if((null==o?void 0:o.resolution)===n)return{};const i=new Map(t.selections),r=Xs(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const o=new Map(t.selections);return o.set(e,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[Qs,Ks]=Tn(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 Js(t){const n=e.useId(),o=t.clientId||n,{name:i}=t,r=Zs(t=>t.selections.get(i)),s=Zs(t=>t.setClause),a=Zs(t=>t.clearClause),l=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push(qs(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,o):()=>!0,[r,o]),isActive:l,selectPoints:e.useCallback(t=>{const e={};let n=!1;for(const[o,i]of Object.entries(t))e[o]={type:"point",values:new Set(i)},n=!0;n&&s(i,{clientId:o,type:"point",fields:e})},[o,i,s]),selectInterval:e.useCallback(t=>{const e={};let n=!1;for(const[o,i]of Object.entries(t))e[o]={type:"interval",range:i},n=!0;n&&s(i,{clientId:o,type:"interval",fields:e})},[o,i,s]),clear:e.useCallback(()=>{a(i,o)},[a,i,o]),clientId:o}}const ta=e.createContext(!1),ea=e.createContext(null),na="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function oa(t,e,n){var o;const i=null!==(o=t.xValue)&&void 0!==o?o:null==e?void 0:e[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function ia(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 ra(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function sa(){var t;const e=Wn(t=>t.theme),n=null===(t=null==e?void 0:e.colors)||void 0===t?void 0:t.categorical;return n&&n.length>0?n:void 0}function aa({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,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,o),f="series"===(null==h?void 0:h.mode)?[h.seriesField||u||o[0]].filter(t=>!!t):(null==h?void 0:h.fields)||o||[],g=Js({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:r,selectPoints:s,clear:a}=Js({name:n}),l=e.useCallback(t=>{if(!t)return void a();const e={};for(const n of o){const o=t[n];void 0!==o&&(e[n]=[o])}(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(e)&&s(e)},[o,s,a,n]);return{onHover:l,predicate:i,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:f}),p=Ks(t=>t.pushObservation),m=t?{isActive:g.isActive,predicate:g.predicate}:null,[v,x]=e.useState(null),b=u||o[0],k=e.useMemo(()=>{if(!c||null==v||!b)return null;const t=v,e=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[e]?n[e]:(null!==(o=n[e])&&void 0!==o?o:"")+"")===t}}},[c,v,b]),w=e.useCallback(t=>{var e,o;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=oa(t,e,h.xField);null!=n&&function(t,e,n){const o=fr.positions.get(t);(null==o?void 0:o.locked)||o&&o.xValue===e&&o.sourceId===n||(fr={positions:new Map(fr.positions).set(t,{xValue:e,sourceId:n})},yr())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&pr(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.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:a};if(t){const i=ia(t),s=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o: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,y,h,d,r,s,a,p,c,b]),A=e.useCallback(t=>{var e,n,o,i;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=oa(t,e,h.xField);null!=n&&function(t,e,n){const o=fr.positions.get(t);if(null==o?void 0:o.locked){const e=new Map(fr.positions);return e.delete(t),fr={positions:e},yr(),!1}fr={positions:new Map(fr.positions).set(t,{xValue:e,sourceId:n,locked:!0})},yr()}(h.name||"hover",n,d)}if(t&&l){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]),l(o,{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:a};if(t){const n=ia(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(o=t.x)&&void 0!==o?o:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),p&&p(t)}}},[l,r,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{mr(t,d),pr(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:w,customClickBehavior:A,crosshairSourceId:d}}function la({data:t,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(ta),u=null!==e.useContext(ea),d=void 0!==i?i:!c&&!!n,h=!!n&&(d||u),f=e.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const e=new Set;for(const o of t){const t="function"==typeof n?n(o):o[n];null!=t&&e.add(t+"")}return Array.from(e)},[l,n,t,h]);!function(t){const n=e.useContext(ea),o=e.useId(),i=function(t){const e=new Set,n=[];for(const o of t)e.has(o)||(e.add(o),n.push(o));return n}(t),r=e.useRef([]);(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})(r.current,i)||(r.current=i);const s=r.current;na(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),na(()=>{n&&n.registerCategories(o,s)},[n,o,s])}(u&&n?f:[]);const g=e.useMemo(()=>{if(!d||!n)return;const e=function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((i,r)=>{const s=t.find("function"==typeof e?t=>e(t)===i:t=>t[e]===i),a=s?o(s,e,n):n?n(i):nt[r%nt.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:it,categories:f});return 0!==e.legendGroups.reduce((t,e)=>t+e.items.length,0)?e:void 0},[d,n,t,o,f]),y=e.useMemo(()=>{const t="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},e=e=>{const n=t[e];return"number"==typeof n?n:a[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},o=e=>"number"==typeof t[e];return g&&("right"===r&&!o("right")&&110>n.right?n.right=110:"left"===r&&!o("left")&&110>n.left?n.left=110:"top"===r&&!o("top")&&50>n.top?n.top=50:"bottom"===r&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,s,g,r]);return{legend:g,margin:y,legendPosition:r}}m.createContext(void 0);const ca={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 ua(t,e,n){if(!1!==e)return t;const o=Object.assign({},t);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function da({componentName:e,message:n,diagnosticHint:o,width:i,height:r}){return t.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:t.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&t.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class ha extends m.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,t,e)}render(){if(this.state.error){const{fallback:e}=this.props,n=this.state.error;return"function"==typeof e?e(n):void 0!==e?e:t.jsx(da,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function fa({componentName:e,width:n,height:o,children:i}){return t.jsx(ha,{fallback:i=>t.jsx(da,{componentName:e,message:i.message,width:n,height:o}),children:i})}"undefined"!=typeof process&&process;const ga={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"},ya={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function pa(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("string"==typeof t){if(""===t.trim())return NaN;const e=+t;return Number.isFinite(e)?e:NaN}return NaN}function ma(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;i.length>t;t++){const r=i[t],g=e(r),y=n(r),p=o(r);if(!Number.isFinite(g)||!Number.isFinite(y)||!Number.isFinite(p))continue;const m=u(y,p);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=y-l.a-(p-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+o*(g-l.x),e=l.a+o*(y-l.a)}else t=l.x,e=l.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else c.push({x:g,y:y,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const va=e.forwardRef(function(n,o){const i=e.useRef(null),r=function(t,e){var n,o,i,r,s,a,l;const c=ca[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:c.showAxes,showGrid:null!==(r=e.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=e.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:ua(c.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:u}}(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:f="b",seriesALabel:g="A",seriesBLabel:y="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:v=!0,lineWidth:x=1.5,showPoints:b=!1,pointRadius:k=3,curve:w="linear",areaOpacity:A=.6,gradientFill:S,tooltip:j,annotations:M,xExtent:_,yExtent:P,frameProps:O={},selection:T,linkedHover:$,onObservation:L,onClick:C,hoverHighlight:E,chartId:R,loading:z,loadingContent:D,emptyContent:N,legendInteraction:F,legendPosition:W,pointIdAccessor:B,windowSize:I}=n,{width:Y,height:G,enableHover:H,showGrid:q,showLegend:X,title:V,description:U,summary:Z,accessibleTable:Q,xLabel:K,yLabel:J}=r,tt=e.useMemo(()=>"function"==typeof d?t=>pa(d(t)):t=>pa(t[d]),[d]),et=e.useMemo(()=>"function"==typeof h?t=>pa(h(t)):t=>pa(t[h]),[h]),ot=e.useMemo(()=>"function"==typeof f?t=>pa(f(t)):t=>pa(t[f]),[f]),[it,st]=e.useState([]),at=e.useRef([]),lt=null==s,ct=e.useMemo(()=>si(lt?it:s),[lt,it,s]),ut=e.useMemo(()=>ma(ct,tt,et,ot),[ct,tt,et,ot]),dt=e.useMemo(()=>v?function(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of i){const i=e(t),s=n(t),a=o(t);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(ct,tt,et,ot):[],[v,ct,tt,et,ot]),ht=e.useMemo(()=>[...ut,...dt],[ut,dt]),ft=e.useMemo(()=>{const t=new Set;for(const e of ut)t.add(e.__diffSegment);return Array.from(t)},[ut]);e.useImperativeHandle(o,()=>{const t=t=>{const e=I&&t.length>I?t.slice(t.length-I):t;at.current=e,st(e)},e=B?"function"==typeof B?B:t=>t[B]:null;return{push:e=>t([...at.current,e]),pushMany:e=>t([...at.current,...e]),remove:n=>{if(!e)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const t of at.current)o.includes(e(t))?i.push(t):r.push(t);return t(r),i},update:(n,o)=>{if(!e)return[];const i=Array.isArray(n)?n:[n],r=[],s=at.current.map(t=>{if(i.includes(e(t))){const e=o(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>lt?at.current:ct,getScales:()=>{var t,e;return null!==(e=null===(t=i.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[lt,ct,B,I]);const gt=function(n){const{data:o,rawData:i,colorBy:r,colorScheme:s,legendInteraction:a,legendPosition:l,selection:c,linkedHover:u,fallbackFields:d,unwrapData:h=!1,onObservation:f,chartType:g,chartId:y,showLegend:p,userMargin:m,marginDefaults:v,onClick:x,hoverHighlight:b,loading:k,loadingContent:w,emptyContent:A,width:S,height:j}=n,M=void 0===i,_=e.useMemo(()=>si(o),[o]),[P,O]=e.useState([]),T=e.useCallback(t=>{O(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),$="string"==typeof n.colorBy?n.colorBy:void 0,{activeSelectionHook:L,hoverSelectionHook:C,customHoverBehavior:E,customClickBehavior:R,crosshairSourceId:z}=aa({selection:c,linkedHover:u,fallbackFields:d,unwrapData:h,onObservation:f,chartType:g,chartId:y,onClick:x,hoverHighlight:b,colorByField:$}),D=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(u,z),N=function(t,n,o){const i=Hs(),r=sa();return e.useMemo(()=>{var e;if(!n)return;const s=null!=i?i:void 0,a=null!==(e=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(t=>n(t)+"")));if(s&&ra(s)){const t=rt(e.map(t=>({_cat:t})),"_cat",a);return e=>s[e]||t(e)}return rt(e.map(t=>({_cat:t})),"_cat",a)}if(s&&ra(s)){const e=rt(t,n,a);return t=>s[t]||e(t)}return rt(t,n,a)}if(s&&ra(s)){const t=rt([{_:"a"}],"_",a);return e=>s[e]||t(e)}},[t,n,o,i,r])}(_,r,s),F=e.useMemo(()=>{if(!r)return[];const t=new Set;for(const e of _){const n="function"==typeof r?r(e):e[r];null!=n&&t.add(n+"")}return Array.from(t)},[_,r]),W=e.useMemo(()=>M&&P.length>0?P:F,[M,P,F]),B=function(t,n,o){const[i,r]=e.useState(null),[s,a]=e.useState(new Set),l=e.useMemo(()=>new Set,[]),c=e.useCallback(e=>{"highlight"===t&&r(e?e.label:null)},[t]),u=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),d=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===i}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,i,s]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?s:l,onLegendHover:c,onLegendClick:u,legendSelectionHook:d}}(a,r,W),I=e.useMemo(()=>C||(B.legendSelectionHook?B.legendSelectionHook:L),[C,B.legendSelectionHook,L]),Y=function(t){const n=Wn(t=>t.theme.colors.selectionOpacity);return e.useMemo(()=>{var e,o;if(void 0!==t||void 0!==n)return Object.assign(Object.assign({name:null!==(e=null==t?void 0:t.name)&&void 0!==e?e:""},t),{unselectedOpacity:null!==(o=null==t?void 0:t.unselectedOpacity)&&void 0!==o?o:n})},[t,n])}(c),G=sa(),H=Hs(),q=e.useMemo(()=>{if(N)return N;if(!r||0===W.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:G&&G.length>0?G:nt,e="__streamCat",n=rt(W.map(t=>({[e]:t})),e,t);return t=>(null==H?void 0:H[t])||n(t)||"#999"},[N,r,W,s,G,H]),{legend:X,margin:V,legendPosition:U}=la({data:_,colorBy:r,colorScale:q,showLegend:p,legendPosition:l,userMargin:m,defaults:v,categories:W}),Z=e.useMemo(()=>{const t={};return X&&(t.legend=X,t.legendPosition=U),a&&"none"!==a&&(t.legendHoverBehavior=B.onLegendHover,t.legendClickBehavior=B.onLegendClick,t.legendHighlightedCategory=B.highlightedCategory,t.legendIsolatedCategories=B.isolatedCategories),M&&r&&(t.legendCategoryAccessor=r,t.onCategoriesChange=T),t},[X,U,a,B.onLegendHover,B.onLegendClick,B.highlightedCategory,B.isolatedCategories,M,r,T]),Q=Array.isArray(i)?si(i):i,K=function(e,n,o,i){if(!e)return null;if(!1===i)return null;if(null!=i)return t.jsx("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),l=Math.floor((o-(r*(s+a)-a))/2);return t.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,o)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ya),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}(k,S,j,w),J=K?null:function(e,n,o,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},ga),{width:n,height:o}),children:i||"No data available"}):null}(Q,S,j,A);return{data:_,colorScale:N,allCategories:W,legendState:B,effectiveSelectionHook:I,activeSelectionHook:L,customHoverBehavior:E,customClickBehavior:R,legend:X,margin:V,legendPosition:U,earlyReturn:K||J||null,legendBehaviorProps:Z,crosshairProps:D,resolvedSelection:Y}}({data:ct,rawData:s,colorBy:"__diffWinner",colorScheme:[p,m],legendInteraction:F,legendPosition:W,selection:T,linkedHover:$,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:L,onClick:C,hoverHighlight:E,chartType:"DifferenceChart",chartId:R,showLegend:X,userMargin:a,marginDefaults:r.marginDefaults,loading:z,loadingContent:D,emptyContent:N,width:Y,height:G}),yt=e.useMemo(()=>{if(!1!==X)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:g,color:p},{label:y,color:m}]}]}},[X,g,y,p,m]),pt=e.useCallback(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?p:m,stroke:"none",fillOpacity:A}},[p,m,A]),mt=e.useCallback(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?p:m,strokeWidth:x,fill:"none"}),[p,m,x]),vt=e.useCallback(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?p:m,r:k}),[p,m,k]),xt=e.useCallback(e=>{var n;const o=e.data,i=e.allSeries,r=null!==(n=e.xValue)&&void 0!==n?n:null==o?void 0:o.__x;let s=null==o?void 0:o.__valA,a=null==o?void 0:o.__valB;if(i&&i.length>0){const t=i.find(t=>"line-A"===t.group),e=i.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(s=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(a=e.value)}if(null!=r&&(null==s||null==a)){const t=ct.find(t=>tt(t)===r);t&&(null==s&&(s=et(t)),null==a&&(a=ot(t)))}const l=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=c&&null!=r?c(r):null!=r?r+"":"";return t.jsxs("div",{className:"semiotic-tooltip",style:ci,children:[u&&t.jsx("div",{style:{fontWeight:600,marginBottom:4},children:u}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[g,": ",l(s)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[y,": ",l(a)]})]}),null!=s&&null!=a&&Number.isFinite(s)&&Number.isFinite(a)&&t.jsxs("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",l(s-a)]})]})},[ct,tt,et,ot,c,p,m,g,y]),bt="multi"===j,kt=e.useMemo(()=>{if(!1===j)return()=>null;if(bt)return xt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var o;let i=ai(!0===(null==e?void 0:e.__semioticHoverData)||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?null!==(o=e.data)&&void 0!==o?o:{}:e);("node"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.x0)&&"number"==typeof(null==i?void 0:i.x1)||"edge"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.sankeyWidth))&&i.data&&"object"==typeof i.data&&(i=i.data);const r=n(i);return null==r?null:t.jsx("div",{className:"semiotic-tooltip",style:ci,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?hi(e):hi())}}(j);return e||xt},[j,bt,xt]);if(gt.earlyReturn)return gt.earlyReturn;const wt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"mixed",data:ht,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:ft,curve:w,areaStyle:pt,lineStyle:mt},b&&{pointStyle:vt}),{size:[Y,G],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:gt.margin,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:H,showGrid:q}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),yt&&{legend:yt,legendPosition:gt.legendPosition}),function(t){const{title:e,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=t,c={};return e&&(c.title=e),n&&(c.description=n),o&&(c.summary=o),void 0!==i&&(c.accessibleTable=i),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}({title:V,description:U,summary:Z,accessibleTable:Q,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),{tooltipContent:kt}),bt&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:o,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||o||i)&&(l.customHoverBehavior=r),(a?n||o||e:n||o)&&(l.customClickBehavior=s),l}({linkedHover:$,onObservation:L,onClick:C,hoverHighlight:E,customHoverBehavior:gt.customHoverBehavior,customClickBehavior:gt.customClickBehavior})),M&&M.length>0&&{annotations:M}),_&&{xExtent:_}),P&&{yExtent:P}),gt.crosshairProps),O);return t.jsx(fa,{componentName:"DifferenceChart",width:Y,height:G,children:t.jsx(Ys,Object.assign({ref:i},wt))})});function xa(t,e,n){return"function"==typeof t?t(n):n[t||e]}function ba(t){return t instanceof Date?t.getTime():Number(t)}function ka(t,e){return X(1===e?.5:t/(e-1))}"function"==typeof va&&(va.displayName="DifferenceChart");const wa={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=null!==(r=i.min)&&void 0!==r?r:0,u=null!==(s=i.max)&&void 0!==s?s:100,d=null!==(a=i.sweep)&&void 0!==a?a:240,h=null!==(l=i.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=i.thresholds||[{value:u,color:i.color||"#4e79a7"}],y=o.gradientFill,p=function(t){const{min:e,max:n,value:o,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=t,d=n-e||1,h=(Math.max(e,Math.min(n,o))-e)/d;let f=i&&i.length>0?[...i].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>Object.assign(Object.assign({},t),{value:Math.max(e,Math.min(n,t.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const g=!!c&&c.colorStops.length>=2,y=[],p=new Map,m=[];if(g){const t=a?h:1,e=Ho("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),p.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;n>e;e++)o.push(Go(c.colorStops,t*(e+.5)/n));const i=Ho("fill",0);y.push({category:i,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),p.set(i,{fill:o[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const o=f[n],i=(o.value-t)/d,r=(t-e)/d,l=(o.value-e)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,i-c):0;if(c>0){const t=Ho("fill",n);y.push({category:t,value:c,_zone:o.label||"Zone "+(n+1),_isFill:!0}),p.set(t,{fill:o.color})}if(u>0){const t=Ho("bg",n);y.push({category:t,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),p.set(t,{fill:s,opacity:.4})}t=o.value}}if(l&&i&&i.length>0)for(const t of i)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>p.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:i.value,thresholds:g,fillColor:i.color,backgroundColor:i.backgroundColor||"#e0e0e0",fillZones:!1!==i.fillZones,showScaleLabels:!1!==i.showScaleLabels,gradientFill:y&&"object"==typeof y&&"colorStops"in y?y:void 0}),m=o.margin||{top:20,right:20,bottom:30,left:40},[v,x]=o.size||[300,300];return Object.assign(Object.assign(Object.assign({chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),x-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:p.pieceStyle},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o),{showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:i.value,startAngleDeg:f,thresholds:g}})}},Aa={Sparkline:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"area",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",y0Accessor:i.y0Accessor,groupAccessor:i.areaBy||e,colorAccessor:e,colorScheme:n},o)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xAccessor||"x",l=i.seriesAAccessor||"a",c=i.seriesBAccessor||"b",u=t=>ba(xa(a,"x",t)),d=t=>ba(xa(l,"a",t)),h=t=>ba(xa(c,"b",t)),f=i.seriesAColor||"var(--semiotic-danger, #dc2626)",g=i.seriesBColor||"var(--semiotic-info, #2563eb)",y=null!==(r=i.areaOpacity)&&void 0!==r?r:.6,p=null!==(s=i.lineWidth)&&void 0!==s?s:1.5,m=!1!==i.showLines,v=ma(Array.isArray(t)?t:[],u,d,h),x=[];if(m&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(u(t))).sort((t,e)=>u(t)-u(e));for(const t of e){const e=u(t),n=d(t),o=h(t);Number.isFinite(n)&&x.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&x.push({__x:e,__y:o,__diffSegment:"line-B"})}}const b=[...v,...x],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:b,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:k,areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?f:g,stroke:"none",fillOpacity:y}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:p,fill:"none"}),curve:i.curve||"linear"},o)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.areaBy,colorAccessor:e||i.areaBy,colorScheme:n,normalize:i.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,colorScheme:n},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"candlestick",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.highAccessor||"high",highAccessor:i.highAccessor||"high",lowAccessor:i.lowAccessor||"low",openAccessor:i.openAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[5,40],colorScheme:n},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",o=e.yAccessor||"y",i=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:ba(xa(e.orderAccessor,"order",t))-ba(xa(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=ba(xa(n,"x",t)),i=ba(xa(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&s++}let a=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=ba(xa(n,"x",t)),i=ba(xa(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&r.set(t,{idx:a++,total:s})}return{data:i,orderMap:r}}(t,i),l=null!==(r=i.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle||{stroke:i.stroke||"#6366f1",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:l,opacity:i.opacity},pointStyle:t=>{var e,n;const o=a.orderMap.get(t),i=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?ka(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},o)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xCenter,l=i.yCenter,c=i.quadrants,u=i.centerlineStyle||{},d=!1!==i.showQuadrantLabels,h=null!==(r=i.quadrantLabelSize)&&void 0!==r?r:12,f=u.stroke||"#999",g=null!==(s=u.strokeWidth)&&void 0!==s?s:1,y=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(","):u.strokeDasharray,p=m.createElement,v=c?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const o=n.width,i=n.height,r=null!=a?e.x(a):o/2,s=null!=l?e.y(l):i/2;if(null!=a&&!Number.isFinite(r))return null;if(null!=l&&!Number.isFinite(s))return null;const u=Math.max(0,Math.min(o,r)),v=Math.max(0,Math.min(i,s)),x=[{c:c.topLeft,x:0,y:0,w:u,h:v},{c:c.topRight,x:u,y:0,w:o-u,h:v},{c:c.bottomLeft,x:0,y:v,w:u,h:i-v},{c:c.bottomRight,x:u,y:v,w:o-u,h:i-v}],b=d?[p("text",{key:"ltl",x:8,y:8+h,fill:c.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.topLeft.label),p("text",{key:"ltr",x:o-8,y:8+h,fill:c.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.topRight.label),p("text",{key:"lbl",x:8,y:i-8,fill:c.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.bottomLeft.label),p("text",{key:"lbr",x:o-8,y:i-8,fill:c.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.bottomRight.label)]:[];return p(m.Fragment,null,...x.map((t,e)=>{var n;return t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:null!==(n=t.c.opacity)&&void 0!==n?n:.08}):null}),p("line",{key:"vc",x1:u,y1:0,x2:u,y2:i,stroke:f,strokeWidth:g,strokeDasharray:y}),p("line",{key:"hc",x1:0,y1:v,x2:o,y2:v,stroke:f,strokeWidth:g,strokeDasharray:y}),...b)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange,colorScheme:n,pointStyle:i.pointStyle},o),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"heatmap",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",valueAccessor:i.valueAccessor,colorScheme:n||i.colorScheme||"blues",showValues:i.showValues,cellBorderColor:i.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.stackBy,colorAccessor:e||i.stackBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",normalize:i.normalize,oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",groupBy:i.groupBy,colorAccessor:e||i.groupBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",innerRadius:i.innerRadius||60,colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"histogram",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal",bins:i.bins,colorAccessor:e,colorScheme:n},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"boxplot",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorScheme:n},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"violin",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,colorScheme:n},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swarm",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o),{showGrid:null===(r=o.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swimlane",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.subcategoryAccessor,colorAccessor:e||i.subcategoryAccessor,categoryAccessor:i.categoryAccessor,subcategoryAccessor:i.subcategoryAccessor,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,amplitude:i.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.levelAccessor||"level",colorAccessor:e||i.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===i.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r="vertical"===i.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:i.stepAccessor||"step",rAccessor:i.valueAccessor||"value",colorAccessor:e||i.categoryAccessor,categoryAccessor:i.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n},o)}},GaugeChart:wa,ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r;const{edgeWidth:s,edgeColor:a,edgeOpacity:l}=i,c=null!==(r=i.edgeStyle)&&void 0!==r?r:void 0!==s||void 0!==a||void 0!==l?t=>{const e=(null==t?void 0:t.data)||t;let n=1;if("number"==typeof s)n=s;else if("function"==typeof s)n=s(e);else if("string"==typeof s){const t=null==e?void 0:e[s],o="number"==typeof t?t:Number(t);n=Number.isFinite(o)&&o>0?o:1}return{stroke:null!=a?a:"#999",strokeWidth:n,opacity:null!=l?l:.6}}:void 0;return Object.assign({chartType:"force",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,colorBy:e,colorScheme:n,iterations:i.iterations,forceStrength:i.forceStrength,showLabels:i.showLabels,nodeLabel:i.nodeLabel,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,nodeStyle:i.nodeStyle,edgeStyle:c},o)}},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"sankey",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,orientation:i.orientation,nodeAlign:i.nodeAlign,nodeWidth:i.nodeWidth,nodePaddingRatio:i.nodePaddingRatio,showLabels:i.showLabels,nodeLabel:i.nodeLabel,colorBy:e,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,colorScheme:n},o)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),u=i.sourceAccessor||"source",d=i.targetAccessor||"target",h=i.valueAccessor||"value",f=i.nodeIdAccessor||"id",g=i.startTimeAccessor||"startTime",y=i.endTimeAccessor||"endTime",p=i.systemInTimeAccessor,m=i.systemOutTimeAccessor,v=i.xExtentAccessor||"xExtent",x=i.edgeIdAccessor||"id",b=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(i.edges)?i.edges:[],w=Array.isArray(i.nodes)?i.nodes:[],A=w.length>0?w:function(t,e,n,o){const i=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof o?o(t):t[o];i.add(e),i.add(r)}),Array.from(i).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=i.domain)||void 0===r?void 0:r[0]),c(null===(s=i.domain)||void 0===s?void 0:s[1])],j=A.map(t=>{const e=b(f,t)+"",n=b(v,t),o={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=c(n[0]),e=c(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),M=k.map((t,e)=>{const n=b(x,t),o={id:null!=n?n+"":`${b(u,t)}-${b(d,t)}-${e}`,source:b(u,t)+"",target:b(d,t)+"",value:Number(b(h,t)),startTime:c(b(g,t)),endTime:c(b(y,t)),__raw:t};if(p){const e=c(b(p,t));Number.isFinite(e)&&(o.systemInTime=e)}if(m){const e=c(b(m,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[_,P]=null!==(a=o.size)&&void 0!==a?a:[600,400],O=Object.assign({top:20,right:20,bottom:20,left:20},o.margin),T=null!==(l=o.legendPosition)&&void 0!==l?l:"right";o.showLegend&&("right"===T?O.right=Math.max(O.right,100):"left"===T?O.left=Math.max(O.left,100):"bottom"===T?O.bottom=Math.max(O.bottom,70):"top"===T&&(O.top=Math.max(O.top,40)));const $=O,L=_-$.left-$.right,C=P-$.top-$.bottom,E=Array.isArray(n)?n:null,R=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],z="function"==typeof e?e:null,D=z?A.map(t=>({_cat:z(t)})):A,N=z?"_cat":"string"==typeof e?e:void 0,F=N?rt(D,N,n):null,W=new Map;for(const t of j)W.set(t.id,t.__raw);const{layoutConfig:B,issues:I}=oi({nodes:j,edges:M,domain:S,plotW:L,plotH:C,ribbonLane:i.ribbonLane||"both",edgeOpacity:"number"==typeof i.edgeOpacity?i.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&W.has(t)){const n=W.get(t);return z?it({_cat:z(n)},"_cat",null!=F?F:void 0):it(n,e,null!=F?F:void 0)}const o=E||R;return o[n%o.length]},layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(I.length>0){const t=I.map(qo).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:ii,layoutConfig:B,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},o),{margin:$})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"cluster"===i.layout?"cluster":"tree",data:t,childrenAccessor:i.childrenAccessor,colorBy:e,colorByDepth:i.colorByDepth,orientation:i.orientation,showLabels:i.showLabels,colorScheme:n},o)},Treemap:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,colorScheme:n},o)},CirclePack:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,colorScheme:n},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({areas:i.areas,projection:i.projection||"equalEarth",areaStyle:i.areaStyle,valueAccessor:i.valueAccessor,colorScheme:n||"blues",graticule:i.graticule,fitPadding:i.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({points:t||i.points,xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",areas:i.areas,areaStyle:i.areaStyle,sizeBy:i.sizeBy,colorBy:e,colorScheme:n,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||i.flows||[],d=i.nodeIdAccessor||"id",h=i.valueAccessor||"value",f=i.xAccessor||"lon",g=i.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(i.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const x=null!==(r=i.edgeColorBy)&&void 0!==r?r:e,b="function"==typeof x,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),n=v.get(t.target+"");return e&&n?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}):null}).filter(Boolean),w="__flowMapEdgeColor",A=x?b?rt(k.map(t=>({[w]:x(t)})),w,n||"category10"):rt(k,x,n||"category10"):null,S=t=>x&&A?it(t,x,A):"#007bff";let j=1/0,M=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(j>e&&(j=e),e>M&&(M=e))}const _=M>j?M-j:0,[P,O]=null!==(a=i.edgeWidthRange)&&void 0!==a?a:[1,8],T=O-P,$=null!==(l=i.edgeOpacity)&&void 0!==l?l:.6,L=null!==(c=i.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:i.lineType||"geo",flowStyle:i.flowStyle||"basic",areas:i.areas,areaStyle:i.areaStyle,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=P+Math.max(0,Math.min(1,_>0?((Number.isFinite(e)?e:j)-j)/_:0))*T;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:$,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Sa(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function ja(t,e){if(0===e.categories.length)return;const n=e.position||"right",o=function(t){const{width:e,height:n,swatchSize:o}=Xn(t);return{width:e,height:n,swatchSize:o}}({categories:e.categories,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,legendLayout:e.legendLayout});"right"===n?t.right=Math.max(t.right,o.width+14):"left"===n?t.left=Math.max(t.left,o.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Ma(t,e){const n=e.position||"right",o={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},i=k(e.legend)?function(t){const{width:e,height:n,swatchSize:o}=Vn(t);return{width:e,height:n,swatchSize:o}}(Object.assign(Object.assign({},o),{legendGroups:e.legend.legendGroups})):w(e.legend)?Un(Object.assign(Object.assign({},o),{gradient:e.legend.gradient})):null;i&&("right"===n?t.right=Math.max(t.right,i.width+14):"left"===n?t.left=Math.max(t.left,i.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+i.height+4):t.bottom=Math.max(t.bottom,38+i.height+4))}function _a(e,n){const o={theme:n.theme,position:n.position||"right",totalWidth:n.size[0],totalHeight:n.size[1],margin:n.margin,hasTitle:n.hasTitle,legendLayout:n.legendLayout,idPrefix:n.idPrefix};return k(e)?function(e){if(0===(n=e.legendGroups,n.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var n;const o=Vn(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let s,a;"left"===e.position?(s=Math.max(4,e.margin.left-o.width-10),a=e.margin.top):"top"===e.position?(s=e.margin.left,a=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,a=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-o.height-2)):(s=Math.min(e.totalWidth-o.width-4,e.totalWidth-e.margin.right+10),a=e.margin.top);const l=o.groups.flatMap((n,s)=>{var a;const{group:l}=n,c=null!==(a=l.type)&&void 0!==a?a:"fill",u=[];if(l.label&&u.push(t.jsx("text",i?{transform:`translate(${n.x},${n.y}) rotate(90)`,textAnchor:"start",fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:l.label}:{x:n.x,y:n.y+Hn(e.theme),fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:l.label},"legend-group-label-"+s)),u.push(...n.items.map((i,r)=>{const a=l.items[r],u=l.styleFn(a,r),d="function"==typeof c?c(a):"line"===c?t.jsx("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:u}):t.jsx("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:u});return t.jsxs("g",{transform:`translate(${n.x+n.itemOffsetX+i.x},${n.y+n.itemOffsetY+i.y})`,children:[d,t.jsx("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${s}-${r}`)})),!i&&o.groups.length-1>s)u.push(t.jsx("line",{x1:0,y1:n.y+n.height-6,x2:o.width,y2:n.y+n.height-6,stroke:r},"legend-group-separator-"+s));else if(i&&o.groups.length-1>s){const e=n.x+n.width+6;u.push(t.jsx("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:r},"legend-group-separator-"+s))}return u});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${s},${a})`,"data-orientation":i?"horizontal":"vertical",children:l})}(Object.assign(Object.assign({},o),{legendGroups:e.legendGroups})):w(e)?function(e){const n=Un(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(t=>Math.round(100*t)/100+"");let s,a;"left"===e.position?(s=Math.max(4,e.margin.left-n.width-10),a=e.margin.top):"top"===e.position?(s=e.margin.left,a=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,a=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-n.height-2)):(s=Math.min(e.totalWidth-n.width-4,e.totalWidth-e.margin.right+10),a=e.margin.top);const l=Array.from({length:17},(n,i)=>{const r=i/16;return t.jsx("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,u=e.gradient.label?8:0;return t.jsxs("g",{className:"semiotic-legend",transform:`translate(${s},${a})`,children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),e.gradient.label&&t.jsx("text",{x:n.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),t.jsx("rect",{x:0,y:u,width:n.width,height:o,fill:`url(#${i})`,rx:2}),t.jsx("text",{x:0,y:u+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),t.jsx("text",{x:n.width,y:u+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return t.jsxs("g",{className:"semiotic-legend",transform:`translate(${s},${a+(e.gradient.label?12:0)})`,children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),e.gradient.label&&t.jsx("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),t.jsx("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}(Object.assign(Object.assign({},o),{gradient:e.gradient})):null}function Pa(t){return Math.round(100*t)/100+""}function Oa(e,n){const o=Yn(n.theme),i=n.idPrefix?n.idPrefix+"-":"",r="string"==typeof n.title?n.title:void 0,s=r?i+"semiotic-title":void 0,a=n.description?i+"semiotic-desc":void 0,l=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:n.className,width:n.width,height:n.height,role:"img","aria-labelledby":l,style:{fontFamily:o.fontFamily},children:[r&&t.jsx("title",{id:s,children:r}),n.description&&t.jsx("desc",{id:a,children:n.description}),n.defs&&t.jsx("defs",{children:n.defs}),n.background&&"transparent"!==n.background&&t.jsx("rect",{x:0,y:0,width:n.width,height:n.height,fill:n.background}),t.jsx("g",{id:i+"data-area",transform:n.innerTransform,children:e}),r&&t.jsx("text",{id:i+"chart-title",x:n.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:r}),n.legend&&t.jsx("g",{id:i+"legend",children:n.legend}),n.outerElements]})}function Ta(e,n){var o,i,r,s,a,l,c,u;const d=In(e.theme),h=e.size||[500,300],f=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),g=si(e.data),y=e.showLegend?Qn(g,e.colorAccessor||e.groupAccessor):[],p=e.legendPosition;k(e.legend)||w(e.legend)?Ma(f,{legend:e.legend,theme:d,position:p||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&y.length>0&&ja(f,{categories:y,theme:d,position:p||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout});const x=h[0]-f.left-f.right,b=h[1]-f.top-f.bottom,A="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),S=e.colorScheme||d.colors.categorical,j={chartType:e.chartType,windowSize:null!==(o=e.windowSize)&&void 0!==o?o:200,windowMode:null!==(i=e.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:A&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(s=e.extentPadding)&&void 0!==s?s:.1,xAccessor:A?void 0:e.xAccessor,yAccessor:A?void 0:e.yAccessor,timeAccessor:A?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:S,barColors:e.barColors},M=new Et(j);if(e.data&&M.ingest({inserts:g,bounded:!0}),M.computeScene({width:x,height:b}),!M.scales||0===M.scene.length)return n&&(n.evidence=vn({frameType:"xy",width:h[0],height:h[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:M.scales?[]:["NO_SCALES"]})),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));n&&(n.evidence=vn({frameType:"xy",width:h[0],height:h[1],marks:M.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:mn(null===(l=null===(a=M.scales.x)||void 0===a?void 0:a.domain)||void 0===l?void 0:l.call(a)),yDomain:mn(null===(u=null===(c=M.scales.y)||void 0===c?void 0:c.domain)||void 0===u?void 0:u.call(c)),legendItems:y.length>0?y.length:void 0}));const _=e._idPrefix,P=e.showGrid?function(e,n,o,i){const{grid:r}=Yn(o),s=i?i+"-":"",a=e.x.ticks(5),l=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,i)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:r,strokeWidth:.5},"gx-"+i)}),l.map((o,i)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:n.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(M.scales,{width:x,height:b},d,_):null,O=M.scene.map((t,e)=>_n(t,e,_)).filter(Boolean),T=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c;const u=Yn(i),d=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||Pa)(t)})),h=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||Pa)(t)}));return t.jsxs("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:u.border,strokeWidth:1}),d.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:u.border,strokeWidth:1}),h.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+n)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:o.yLabel})]})}(M.scales,{width:x,height:b},e,d,_):null,$=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:M.scales.x,y:M.scales.y},layout:{width:x,height:b},theme:d,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:_}):null,L=e.svgPreRenderers&&M.scales?e.svgPreRenderers.map((e,n)=>{try{return t.jsx(m.Fragment,{children:e(M.scene,M.scales,{width:x,height:b})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,C=e.showLegend?0===y.length?null:Zn({categories:y,colorScheme:e.colorScheme,theme:d,position:e.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,E=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:d,position:e.legendPosition||"right",size:h,margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||C,R=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,L,P,O,T,$,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(R,{width:h[0],height:h[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${f.left},${f.top})`,legend:E,idPrefix:e._idPrefix}))}function $a(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const La=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ca(e,n){var o,i,s,a,l;const c=In(e.theme),u=e.chartType||"force",d=()=>vn({frameType:"network",width:h[0],height:h[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),h=e.size||[500,500],f=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),g=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=si(e.nodes||[]);if(o.length>0)return Qn(o,t);const i=Array.isArray(e.edges)?si(e.edges):[];if(0===i.length)return[];const r=$a(e.sourceAccessor,"source"),s=$a(e.targetAccessor,"target");return Qn(Array.from(new Set(i.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),t)})():[],y=e.legendPosition;k(e.legend)||w(e.legend)?Ma(f,{legend:e.legend,theme:c,position:y||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&g.length>0&&ja(f,{categories:g,theme:c,position:y||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout});const p=h[0]-f.left-f.right,x=h[1]-f.top-f.bottom,b=function(t){return Qe[t]}(u);if(!b)throw Error(`No layout plugin found for chart type: "${u}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const A={chartType:u,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,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,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||c.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let S,j;if(La.has(u)){const t=e.data||e.edges;if(!t||Array.isArray(t))return n&&(n.evidence=d()),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));A.__hierarchyRoot=t,S=[],j=[]}else{const t=si(e.nodes||[]),o=Array.isArray(e.edges)?si(e.edges):[];if(0===t.length&&0===o.length)return n&&(n.evidence=d()),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));if(j=function(t,e){const n=$a(e.sourceAccessor,"source"),o=$a(e.targetAccessor,"target"),i=$a(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:o(t)+"",value:Number(i(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,A),0===t.length&&j.length>0){const t=new Set;for(const e of j){const n=Sa(e.source),o=Sa(e.target);n&&t.add(n),o&&t.add(o)}S=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else S=function(t,e){const n=$a(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,A)}let M=[],_=[],P=[],O=null;if(A.customNetworkLayout){const t=Ke(A.colorScheme,c.colors.categorical,W),e=Je(t),n={nodes:S,edges:j,dimensions:{width:p,height:x,plot:{x:0,y:0,width:p,height:x}},theme:{semantic:c.colors,categorical:[...t]},resolveColor:e,config:null!==(o=A.layoutConfig)&&void 0!==o?o:{}},r=A.customNetworkLayout(n);M=null!==(i=r.sceneNodes)&&void 0!==i?i:[],_=null!==(s=r.sceneEdges)&&void 0!==s?s:[],P=null!==(a=r.labels)&&void 0!==a?a:[],O=null!==(l=r.overlays)&&void 0!==l?l:null}else{b.computeLayout(S,j,A,[p,x]);const t=b.buildScene(S,j,A,[p,x]);M=t.sceneNodes,_=t.sceneEdges,P=t.labels}const T=Yn(c);for(const t of P)t.fill||(t.fill=T.text);n&&(n.evidence=vn({frameType:"network",width:h[0],height:h[1],marks:[...M.map(t=>{var e;return{type:"node:"+(null!==(e=t.type)&&void 0!==e?e:"node")}}),..._.map(t=>{var e;return{type:"edge:"+(null!==(e=t.type)&&void 0!==e?e:"edge")}})],title:e.title,description:e.description,annotations:e.annotations,nodeCount:M.length,edgeCount:_.length}));const $=_.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 o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),L=M.map((e,n)=>function(e,n){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=e,i=r.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(An)||"";return t.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}case"symbol":{const o=e,i=jt(o.symbolType,o.size,o.path);return t.jsx("path",{d:i,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?Sn(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-symbol-"+n)}default:return null}}(e,n)).filter(Boolean),C=P.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),E=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:p,height:x},theme:c,idPrefix:e._idPrefix}):null,R=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=Qn(S.length>0?S.map(t=>t.data||{id:t.id}):Array.from(new Set(j.flatMap(t=>[Sa(t.source),Sa(t.target)]).filter(Boolean))).map(t=>({id:t})),t);return 0===o.length?null:Zn({categories:o,colorScheme:e.colorScheme,theme:c,position:e.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout})})():null,z=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:c,position:e.legendPosition||"right",size:h,margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||R,D=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,$,L,C,E,e.foregroundGraphics,O]});return v.renderToStaticMarkup(Oa(D,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,legend:z,idPrefix:e._idPrefix}))}function Ea(e,n){var o,i,r,s,a,l,c,u,d;const h=In(e.theme),f=e.size||[500,400],g=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),y=si(e.data),p=e.showLegend?Qn(y,e.colorAccessor||e.stackBy||e.groupBy):[],x=e.legendPosition;k(e.legend)||w(e.legend)?Ma(g,{legend:e.legend,theme:h,position:x||"right",size:f,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&p.length>0&&ja(g,{categories:p,theme:h,position:x||"right",size:f,hasTitle:!!e.title,legendLayout:e.legendLayout});const b=f[0]-g.left-g.right,A=f[1]-g.top-g.bottom,S=e.projection||"vertical",j="radial"===S,M={chartType:e.chartType,windowSize:null!==(o=e.windowSize)&&void 0!==o?o:1e4,windowMode:null!==(i=e.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:S,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||h.colors.categorical,barColors:e.barColors},_=new sn(M);if(e.data&&_.ingest({inserts:y,bounded:!0}),_.computeScene({width:b,height:A}),!_.scales||0===_.scene.length)return n&&(n.evidence=vn({frameType:"ordinal",width:f[0],height:f[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:_.scales?[]:["NO_SCALES"]})),v.renderToStaticMarkup(Oa(null,{width:f[0],height:f[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:h,innerTransform:`translate(${g.left},${g.top})`,idPrefix:e._idPrefix}));if(n){const t=null===(a=null===(s=_.scales.o)||void 0===s?void 0:s.domain)||void 0===a?void 0:a.call(s);n.evidence=vn({frameType:"ordinal",width:f[0],height:f[1],marks:_.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:mn(null===(c=null===(l=_.scales.r)||void 0===l?void 0:l.domain)||void 0===c?void 0:c.call(l)),categories:Array.isArray(t)?t.map(String):void 0})}const P=e._idPrefix,O=e.showGrid?function(e,n,o,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=Yn(o),a=i?i+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t.jsx("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t.jsx("line",{x1:0,y1:i,x2:n.width,y2:i,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t.jsx("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(_,{width:b,height:A},h,P):null,T=_.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let $=null;if(T){const n=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;n.length>t;t++)o=31*o+n.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of _.scene)"rect"===t.type&&(null===(u=t.datum)||void 0===u?void 0:u.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");$=Array.from(o).map((e,o)=>function(e){const{id:n,background:o="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:s=6,angle:a=45}=e,l=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:n,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:l,height:l,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:i,strokeWidth:r}),t.jsx("line",{x1:s,y1:0,x2:s,y2:l,stroke:i,strokeWidth:r})]},n)}({id:`funnel-hatch-${n}-${o}`,background:e,stroke:"transparent"===h.colors.background?"#fff":h.colors.background,lineWidth:1.5,spacing:5,angle:45}));const i=new Map;Array.from(o).forEach((t,e)=>i.set(t,`funnel-hatch-${n}-${e}`));for(const t of _.scene)if("rect"===t.type&&(null===(d=t.datum)||void 0===d?void 0:d.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${i.get(e)})`})}}const L=_.scene.map((t,e)=>Pn(t,e,P)).filter(Boolean),C=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=Yn(i),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,v=o.valueFormat||o.rFormat,x=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),w=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(v||Pa)(t)}));return t.jsxs("g",p?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),x&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:x}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:y.border,strokeWidth:1}),w.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+n)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:b})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:y.border,strokeWidth:1}),w.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:y.border,strokeWidth:1}),k.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+n)),x&&t.jsx("text",{x:15-(null!==(d=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:n.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(h=o.margin)||void 0===h?void 0:h.left)&&void 0!==f?f:40)}, ${n.height/2})`,children:x})]})}(_,{width:b,height:A},e,h,P):null,E=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{r:_.scales.r,y:"vertical"===_.scales.projection?_.scales.r:void 0},layout:{width:b,height:A},theme:h,projection:S,idPrefix:P}):null,R=e.showLegend?0===p.length?null:Zn({categories:p,colorScheme:e.colorScheme,theme:h,position:e.legendPosition||"right",totalWidth:f[0],totalHeight:f[1],margin:g,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,z=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:h,position:e.legendPosition||"right",size:f,margin:g,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||R,D=j?g.left+b/2:g.left,N=j?g.top+A/2:g.top,F=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,O,L,C,E,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(F,{width:f[0],height:f[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:h,innerTransform:`translate(${D},${N})`,legend:z,defs:$,idPrefix:e._idPrefix}))}function Ra(e,n){var o,i,r,s,a,l,c,u,d,h;const f=In(e.theme),g=e.size||[e.width||600,e.height||400],y=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),p=Array.isArray(e.areas)?si(e.areas):e.areas,x=si(e.points),b=si(e.lines),A=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return Qn(x.length>0?x:Array.isArray(p)&&p.length>0?"string"==typeof t?p.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):p:[],t)})():[],S=e.legendPosition;k(e.legend)||w(e.legend)?Ma(y,{legend:e.legend,theme:f,position:S||"right",size:g,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&A.length>0&&ja(y,{categories:A,theme:f,position:S||"right",size:g,hasTitle:!!e.title,legendLayout:e.legendLayout});const j=g[0]-(null!==(o=y.left)&&void 0!==o?o:0)-(null!==(i=y.right)&&void 0!==i?i:0),M=g[1]-(null!==(r=y.top)&&void 0!==r?r:0)-(null!==(s=y.bottom)&&void 0!==s?s:0),_=new yn({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(p){if("string"==typeof p)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${p}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${p}')\` before calling renderGeoToStaticSVG.`);_.setAreas(p)}if(e.points&&_.setPoints(x),e.lines&&_.setLines(b),_.computeScene({width:j,height:M}),n&&(n.evidence=vn({frameType:"geo",width:g[0],height:g[1],marks:_.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:A.length>0?A.length:void 0})),0===_.scene.length){const n=e.backgroundGraphics||e.foregroundGraphics||e.annotations?t.jsxs(t.Fragment,{children:[e.backgroundGraphics,e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:(null===(a=_.scales)||void 0===a?void 0:a.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:f,idPrefix:e._idPrefix}):null,e.foregroundGraphics]}):null;return v.renderToStaticMarkup(Oa(n,{width:g[0],height:g[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:f,innerTransform:`translate(${null!==(l=y.left)&&void 0!==l?l:0},${null!==(c=y.top)&&void 0!==c?c:0})`,idPrefix:e._idPrefix}))}const P=_.scene.map((e,n)=>function(e,n){var o,i,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t.jsx("path",{d:r.pathData,fill:Sn(r.style.fill,"#e0e0e0"),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(i=r._decayOpacity)&&void 0!==i?i:1},"geoarea-"+n):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Sn(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const o=e;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),O=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:(null===(u=_.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:f,idPrefix:e._idPrefix}):null,T=e.showLegend?0===A.length?null:Zn({categories:A,colorScheme:e.colorScheme,theme:f,position:e.legendPosition||"right",totalWidth:g[0],totalHeight:g[1],margin:y,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,$=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:f,position:e.legendPosition||"right",size:g,margin:y,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||T,L=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,P,O,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(L,{width:g[0],height:g[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:f,innerTransform:`translate(${null!==(d=y.left)&&void 0!==d?d:0},${null!==(h=y.top)&&void 0!==h?h:0})`,legend:$,idPrefix:e._idPrefix}))}function za(t,e){switch(t){case"xy":return Ta(e);case"ordinal":return Ea(e);case"network":return Ca(e);case"geo":return Ra(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}const Da=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Na(t,e,n){return Fa(t,e).svg}function Fa(e,n,o,i){var r;const{data:s,width:a=600,height:l=400,theme:c,title:u,description:d,showLegend:h,showGrid:f,background:g,className:y,annotations:p,margin:m,colorScheme:x,colorBy:b,legendPosition:k}=n,w=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);o.length>i;i++)0>e.indexOf(o[i])&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[a,l],S=w.frameProps||{},j=function(t,e){const n={};for(const o of e)void 0!==t[o]&&(n[o]=t[o]);return n}(w,Da),M=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},S),j),{theme:c,title:u,description:d,showLegend:h,showGrid:f,background:g,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==k&&{legendPosition:k}),{_idPrefix:w._idPrefix}),_=Aa[e];if(!_)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const P=_.buildProps(s,b,x,M,w);let O=(0,{xy:Ta,ordinal:Ea,network:Ca,geo:Ra}[_.frameType])(P,i);if("GaugeChart"===e&&P.__gauge){const e=P.__gauge,n=M.margin||{top:20,right:20,bottom:30,left:40},o=(a||300)-n.left-n.right,i=(l||300)-n.top-n.bottom,s=Math.min(o,i)/2*.85,u=n.left+o/2,d=n.top+i/2,h=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(h-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,g=In(c).colors.text,y=v.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:d,x2:u+s*Math.cos(f),y2:d+s*Math.sin(f),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:d,r:4,fill:g})]}));O=O.replace("</svg>",y+"</svg>")}return{svg:O,frameType:_.frameType}}function Wa(t,e,n,o={}){const{stepSize:i,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,g=n.height||400,y=In(n.theme),p=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=i||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const x=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-b.left-b.right,w=g-b.top-b.bottom,A=[];if(x)for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical},h&&{decay:h}),l=new sn(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(Ya(l.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:l,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange},h&&{decay:h}),c>0&&{transition:{duration:c*(1e3/u),easing:d}}),x=new Et(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:w}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(A.push(Ia(x.scene,f,g,y,p,b)),c>0&&o>0&&x.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/c*t),A.push(Ia(x.scene,f,g,y,p,b))}}return A}function Ba(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Ia(e,n,o,i,r,s){const a=Yn(i),l=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),c=n-l.left-l.right,u=o-l.top-l.bottom,d=Ba(r,i),h=e.map((t,e)=>_n(t,e)).filter(Boolean),f=function(e,n,o,i,r,s){var a;if(!e||0===e.length)return null;const l=Yn(i),c=[];for(let i=0;e.length>i;i++){const u=e[i];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(r){const[t,n]=r,i=n-t;if(0===i)continue;e=o-(u.value-t)/i*o}if(null==e)continue;const d=u.color||l.primary,h=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";c.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:n,y2:e,stroke:d,strokeWidth:h,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?n/2:n-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:l.tickSize,fill:d,fontFamily:l.fontFamily,children:u.label})]},"ann-"+i))}}return c.length>0?t.jsx(t.Fragment,{children:c}):null}(r.annotations,c,u,i,r.yExtent,null==s?void 0:s.y),g="string"==typeof r.title?r.title:void 0,y="string"==typeof r.description?r.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily},children:[g&&t.jsx("title",{id:p,children:g}),y&&t.jsx("desc",{id:m,children:y}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[f,h]}),g&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return v.renderToStaticMarkup(b)}function Ya(e,n,o,i,r){const s=Yn(i),a=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),l="radial"===r.projection,c=l?a.left+(n-a.left-a.right)/2:a.left,u=l?a.top+(o-a.top-a.bottom)/2:a.top,d=Ba(r,i),h=e.map((t,e)=>Pn(t,e)).filter(Boolean),f="string"==typeof r.title?r.title:void 0,g="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:y,children:f}),g&&t.jsx("desc",{id:p,children:g}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsx("g",{transform:`translate(${c},${u})`,children:h}),f&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return v.renderToStaticMarkup(x)}exports.generateFrameSVGs=Wa,exports.generateFrameSequence=function(t,e,n={}){return e.map(e=>{try{return Na(t,Object.assign(Object.assign({},n),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})},exports.renderChart=Na,exports.renderChartWithEvidence=function(t,e,n){var o;const i={},{svg:r,frameType:s}=Fa(t,e,0,i),a=null!==(o=i.evidence)&&void 0!==o?o:vn({frameType:s,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return a.component=t,{svg:r,evidence:a}},exports.renderDashboard=function(e,n={}){var o;const{title:i,subtitle:r,theme:s,width:a=1200,height:l,layout:c={},background:u}=n,d=Yn(In(s)),h=c.columns||2,f=null!==(o=c.gap)&&void 0!==o?o:16;let g=0;i&&(g+=30),r&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-f-f*(h-1))/h),p=[];let m=0,x=g+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,h),n=t.props.height||300;m+e>h&&(x+=b+f,m=0,b=0),p.push({chart:t,x:f/2+m*(y+f),y:x,w:y*e+f*(e-1),h:n}),b=Math.max(b,n),m+=e}const k=l||x+b+f,w=p.map((e,n)=>{const{chart:o,x:i,y:r,w:a,h:l}=e,c=Object.assign(Object.assign({},o.props),{width:a,height:l,theme:s,_idPrefix:"chart-"+n});let u;return u=o.component?Na(o.component,c):o.frameType?za(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${l}"></svg>`,t.jsx("g",{transform:`translate(${i},${r})`,children:t.jsx("foreignObject",{width:a,height:l,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),A=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":i||"Dashboard",style:{fontFamily:d.fontFamily},children:[i&&t.jsx("title",{children:i}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),i&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:d.titleSize+4,fontWeight:"bold",fill:d.text,fontFamily:d.fontFamily,children:i}),r&&t.jsx("text",{x:a/2,y:i?46:20,textAnchor:"middle",fontSize:d.labelSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:r}),w]});return v.renderToStaticMarkup(A)},exports.renderGeoToStaticSVG=function(t){return Ra(t)},exports.renderNetworkToStaticSVG=function(t){return Ca(t)},exports.renderOrdinalToStaticSVG=function(t){return Ea(t)},exports.renderToAnimatedGif=function(t,e,n){return b(this,arguments,void 0,function*(t,e,n,o={}){var i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,x;const{fps:b=12,loop:k=!0,scale:w=1,background:A}=o,S=n.height||400,j=Math.round((n.width||600)*w),M=Math.round(S*w),_=Wa(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,o);if(0===_.length)throw Error("No frames generated — check that data is not empty");let P,O,T,$;try{const t="sharp",e=yield import(t);P=null!==(i=e.default)&&void 0!==i?i:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);O=null!==(a=null!==(r=e.GIFEncoder)&&void 0!==r?r:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(c=null===(l=e.default)||void 0===l?void 0:l.default)||void 0===c?void 0:c.GIFEncoder,T=null!==(h=null!==(u=e.quantize)&&void 0!==u?u:null===(d=e.default)||void 0===d?void 0:d.quantize)&&void 0!==h?h:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,$=null!==(m=null!==(y=e.applyPalette)&&void 0!==y?y:null===(p=e.default)||void 0===p?void 0:p.applyPalette)&&void 0!==m?m:null===(x=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===x?void 0:x.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/b),C=O();for(let t=0;_.length>t;t++){const e=_[t],n=yield P(Buffer.from(e),{density:72*w}).resize(j,M).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),i=T(o,256),r=$(o,i);C.writeFrame(r,j,M,{palette:i,delay:L,repeat:k?0:-1})}return C.finish(),Buffer.from(C.bytes())})},exports.renderToImage=function(t,e){return b(this,arguments,void 0,function*(t,e,n={}){var o,i,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?za(t,e):Na(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const d=e.width||(null===(i=e.size)||void 0===i?void 0:i[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(d*a),Math.round(h*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=za,exports.renderXYToStaticSVG=function(t){return Ta(t)},exports.resolveTheme=In,exports.themeStyles=Yn;
|
|
1
|
+
"use strict";var e,t=Object.create,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))s.call(e,c)||c===o||n(e,c,{get:()=>t[c],enumerable:!(a=i(t,c))||a.enumerable});return e},c=(e,i,r)=>(r=null!=e?t(o(e)):{},a(!i&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var i in t)n(e,i,{get:t[i],enumerable:!0})})(l,{generateFrameSVGs:()=>rg,generateFrameSequence:()=>og,generatePhysicsFrameSVGs:()=>ag,renderChart:()=>Zy,renderChartWithEvidence:()=>Qy,renderDashboard:()=>tg,renderGeoToStaticSVG:()=>Uy,renderNetworkToStaticSVG:()=>Vy,renderOrdinalToStaticSVG:()=>Xy,renderPhysicsToAnimatedGif:()=>hg,renderToAnimatedGif:()=>dg,renderToImage:()=>eg,renderToStaticSVG:()=>Hy,renderXYToStaticSVG:()=>Gy,resolveTheme:()=>Gh,themeStyles:()=>Xh}),module.exports=(e=l,a(n({},"__esModule",{value:!0}),e));var u=c(require("react-dom/server")),d=c(require("react")),h=require("d3-scale");function f(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function p(e,t,n){const i=e=>e.toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function y(e){const t=e.map(f),n=t.length-1;return e=>{if(0>=e){const[e,n,i]=t[0];return p(e,n,i)}if(e>=1){const[e,i,r]=t[n];return p(e,i,r)}const i=e*n,r=Math.floor(i),o=i-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return p(Math.round(s+(l-s)*o),Math.round(a+(u-a)*o),Math.round(c+(d-c)*o))}}var g=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=y(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),x=y(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=y(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=y(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=y(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=y(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),S=y(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=y(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),M=y(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),P=y(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),_=y(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),j=y(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),C={blues:m,reds:x,greens:b,viridis:S,oranges:v,purples:w,greys:k,plasma:A,inferno:M,magma:P,cividis:_,turbo:j};y(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),y(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),y(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),y(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),y(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var I={category10:g,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...C},T=g,R=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],L=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function $(e,t,n){if("function"==typeof t){const i=t(e);return n&&i&&"string"==typeof i&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||L.has(t)}(i)?n(i):i}const i=e?.[t]+"";return n?n(i):T[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(i))%T.length]}function E(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 z(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>E(e,t)??"#999"}const i=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=i.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,h.scaleOrdinal)().domain(i).range(n).unknown("#999");const o=I[n]||I.category10;if(r&&"function"==typeof o){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>o(Number(t)/e)}{const e=Array.isArray(o)?o:T;return(0,h.scaleOrdinal)().domain(i).range(e).unknown("#999")}}var D=Object.freeze([]);function B(e){if(!e)return D;let t=!1;for(let n=0;e.length>n;n++){const i=e[n];if(null==i||"object"!=typeof i){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function F(e,t){return"touch"===t?Math.max(e,24):e}function N(e){return Array.isArray(e)?e[0]:e}function O(e,t,n,i){return{data:N(e),x:t,y:n,__semioticHoverData:!0,...i}}var W=["name","label","title"],q=["type","kind","category","group","class","status","role","shape"],Y=["value","amount","total","count","weight","score"],H=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 G(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}var X=require("react/jsx-runtime"),V={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 U(e,t){return"function"==typeof t?t(e):e[t]}function K(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Z(e={}){const{fields:t,title:n,format:i,style:r={},className:o=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=U(e,n);s=K(t,i)}if(t&&t.length>0)t.forEach(t=>{let n,r,o;"string"==typeof t?(n=t,r=t,o=i):(n=t.label,r=t.accessor||t.key||"",o=t.format||i);const s=U(e,r);a.push({label:n,value:K(s,o)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=K(e[n],i);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=K(e[t[0]],i))}}const c={...V,...r};return(0,X.jsxs)("div",{className:("semiotic-tooltip "+o).trim(),style:c,children:[s&&(0,X.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,X.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,X.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function Q(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=N(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data);const i=t(n);return null==i?null:(0,X.jsx)("div",{className:"semiotic-tooltip",style:V,children:i})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Z(e):Z())}}function J(e){const{title:t,description:n,summary:i,accessibleTable:r,className:o,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),i&&(l.summary=i),void 0!==r&&(l.accessibleTable=r),o&&(l.className=o),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function ee(e){const{linkedHover:t,selection:n,onObservation:i,onClick:r,hoverRadius:o,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={},p=l?.enabled?Math.max(o??30,Math.ceil((l.targetSize||44)/2),24):o;return(a||t||i||r||s)&&(f.customHoverBehavior=u),d&&(c||(h?i||r||t:i||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}var te=require("react"),ne=c(require("react")),ie=require("react"),re=require("react"),oe=require("d3-selection"),se=require("d3-brush"),ae=c(require("react")),ce=require("react/jsx-runtime");function le(e,t,n,i){const[r,o]=[Math.min(...t),Math.max(...t)],s=(o-r)/20;let[a,c]=e;if(i)0>n?a=Math.max(r,a-s):c=Math.min(o,c+s);else{const e=c-a;a=Math.max(r,Math.min(o-e,a+n*s)),c=a+e}return[a,c]}function ue(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i+1>>1;t[r]>e?i=r-1:n=r}return t[n]}function de(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r]?n=r+1:i=r}return t[n]}function he({width:e,height:t,totalWidth:n,totalHeight:i,margin:r,dimension:o,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:h}){const f=(0,re.useRef)(null),p=(0,re.useRef)(null),y=(0,re.useRef)(a);y.current=a;const g=(0,re.useRef)(s);g.current=s;const m=(0,re.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),x=(0,re.useRef)(m);x.current=m;const b=(0,re.useRef)(!1),v=(0,re.useRef)(null),w=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 i=ae.useId().replace(/:/g,""),r=ae.useRef(n);return r.current=n,{description:t,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:ae.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(),r.current?.(t))},[])}}}({label:"xy"===o?"Two-dimensional data range brush":o.toUpperCase()+" data range brush",onAction:e=>{const t=g.current,n=p.current;if(!t||!n||!f.current)return;const i=(0,oe.select)(f.current).select(".brush-g");if("clear"===e.type)return b.current=!0,i.call(n.move,null),b.current=!1,v.current=null,void y.current(null);const r=t.x.domain(),s=t.y.domain(),a=v.current;let c=a?.x??[r[0]+.4*(r[1]-r[0]),r[0]+.6*(r[1]-r[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==o&&(c=le(c,r,d,e.resize)),u||"x"===o||(l=le(l,s,d,e.resize)),u&&"y"===o||!u&&"x"===o)return;const h={x:c,y:l};b.current=!0,i.call(n.move,"x"===o?[t.x(c[0]),t.x(c[1])]:"y"===o?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),b.current=!1,v.current=h,y.current(h)}});return(0,re.useEffect)(()=>{if(!f.current)return;const n=(0,oe.select)(f.current).select(".brush-g"),i="x"===o?(0,se.brushX)():"y"===o?(0,se.brushY)():(0,se.brush)();return i.extent([[0,0],[e,t]]),i.on("brush end",r=>{if(b.current)return;const s=g.current;if(!s)return;if(!r.selection)return v.current=null,void y.current(null);let a,u;if("x"===o){const[e,n]=r.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]=r.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,i]]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(i),s.y.invert(t)]}if("bin"===l&&"y"!==o&&("end"===r.type||"brush"===r.type&&d)){const e=x.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[ue(e[0],t),de(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(b.current=!0,"x"===o)n.call(i.move,[t,l]);else if("xy"===o){const e=r.selection;n.call(i.move,[[t,e[0][1]],[l,e[1][1]]])}b.current=!1}const h={x:a,y:u};v.current=h,y.current(h)}),n.call(i),p.current=i,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),p.current=null}},[e,t,o,l,c,d]),(0,re.useEffect)(()=>{if(!(h&&s&&p.current&&v.current))return;if(!f.current)return;if("y"===o)return;const e=v.current,t=s.x.domain()[0],n=(0,oe.select)(f.current).select(".brush-g");if(t>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===l){const e=x.current;e&&e.length>0?i=de(t,e):c&&c>0&&(i=Math.ceil(t/c)*c)}if(i>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);r=!0}const a=s.x(i),u=s.x(e.x[1]);if(b.current=!0,"x"===o)n.call(p.current.move,[a,u]);else{const t=s.y(e.y[1]),i=s.y(e.y[0]);n.call(p.current.move,[[a,t],[u,i]])}if(b.current=!1,r){const t={x:[i,e.x[1]],y:e.y};v.current=t,y.current(t)}},[s,h,o,l,c]),(0,ce.jsxs)("svg",{ref:f,width:n,height:i,...w.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,ce.jsx)("title",{children:w.svgProps["aria-label"]}),(0,ce.jsx)("desc",{id:w.descriptionId,children:w.description}),(0,ce.jsx)("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`})]})}var fe=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=B(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 i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=B(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 i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,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 i=e[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),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}},pe=require("react"),ye=require("react/jsx-runtime");function ge(e){let t=null;const n=()=>(t||(t=(0,pe.createContext)(null)),t),i=me(e);return[function({children:t,initialState:i}){const r=(0,pe.useRef)(i),o=(0,pe.useMemo)(()=>me(e,r.current),[]),s=n();return(0,ye.jsx)(s.Provider,{value:o,children:t})},(e,t)=>{const r=n(),o=(0,pe.useContext)(r)??i,s=(0,pe.useRef)(e);s.current=e;const a=(0,pe.useRef)({hasValue:!1,value:void 0}),c=(0,pe.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]),l=(0,pe.useCallback)(()=>s.current(o.getState()),[o]);return(0,pe.useSyncExternalStore)(o.subscribe,c,l)}]}function me(e,t){const n=new Set;let i={...e(function(e){const t=e(i);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){i={...i,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>i,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function xe(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 be(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:ve}}),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 ve=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],we={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}},ke={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}},Se={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:ve,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 Ae(e,t){if("light"===t)return we;if("dark"===t)return ke;if("high-contrast"===t)return Se;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?ke:we;return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Me,Pe]=ge(e=>({theme:we,setTheme(t){e(e=>({theme:Ae(e.theme,t)}))}})),_e=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,i=[];t.length>e&&(n=t.length-e,i=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 i}update(e,t){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const o=(i+r)%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(i=>{e(i)?n.push(i):t.push(i)}),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}},je=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 Ce(e,t){return e===t}function Ie(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Te(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Re(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Le=/^\d{4}-\d{1,2}$/;function $e(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Le.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const i=Date.parse(n);return Number.isFinite(i)?i:NaN}function Ee(e){return e instanceof Date?e.getTime():"string"==typeof e?$e(e):+e}function ze(e){return new Set(Array.isArray(e)?e:[e])}function De(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Be(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Fe(e,t,n){return e+(t-e)*n}function Ne(){return"undefined"!=typeof performance?performance.now():Date.now()}function Oe(e,t,n){if(1>=n)return 1;const i=n-1;return function(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 i=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(i>0?i:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:i-t,extent:i,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function We(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function qe(e,t,n){const i=e.duration??500,r=n-t;return i>r?1-r/i:0}function Ye(e,t,n,i){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==i&&(e._pulseGlowRadius=i,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function He(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const i=e.duration??500,r=t.peek();return null!=r&&i>n-r}function Ge(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),i=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}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 Xe(e,t,n,i,r,o){const s=[];for(const r of e){const e=n(r),o=i(r);Number.isFinite(e)&&Number.isFinite(o)&&s.push({px:t.x(e),py:t.y(o),rawY:o,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:o}}function Ve(e,t,n,i,r,o,s,a){const c=[];for(const o of e){const e=n(o),s=i(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(o):r;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:e,group:s}}function Ue(e,t,n,i){const r=new Map;if("silhouette"===i)for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r.set(i,-e/2)}else if("wiggle"===i){e.length>0&&r.set(e[0],0);for(let i=1;e.length>i;i++){const o=e[i-1],s=e[i];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,o)||0)),c+=t,l+=t}const u=r.get(o)??0;r.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let i=0;for(const o of e){let e=0;for(const i of t)e+=n(i,o)||0;i+=(r.get(o)??0)+e/2}const o=i/e.length;for(const t of e)r.set(t,(r.get(t)??0)-o)}}else for(const t of e)r.set(t,0);return r}function Ke(e,t,n,i,r,o,s){const a=n(e),c=i(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:o,datum:e};return void 0!==s&&(l.pointId=s),l}function Ze(e,t,n,i,r,o,s,a){const c=n(e),l=i(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:o,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Qe(e,t,n,i,r,o,s){return{type:"rect",x:e,y:t,w:n,h:i,style:r,datum:o,group:s}}function Je(e,t,n,i,r,o,s){const a={type:"heatcell",x:e,y:t,w:n,h:i,fill:r,datum:o};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function et(e,t,n,i){return"function"==typeof t.style?t.style(i||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,i)}function tt(e,t,n,i){if(!e.scales)return null;const r=[],o=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=i.getTop(n),a=i.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),o.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:et(e,i,n,t[0]),datum:t,group:n,interactive:i.interactive}}function nt(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const i of e)i.perSeries?t.push(i):n.push(i);return{perSeries:t,aggregate:n}}function it(e,t,n){const i=[];for(const r of n){const n=tt(e,t,"__ribbon_aggregate",r);n&&i.push(n)}return i}function rt(e,t,n,i){const r=[];for(const o of i){const i=tt(e,t,n,o);i&&r.push(i)}return r}function ot(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const i of t){if("band"!==i.kind)continue;const t=i.getTop(e),r=i.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function st(e,t,n,i){if(!e.config.pointStyle)return;const r=i??e.getY;for(const i of t){const t=e.resolveGroupColor(i.key);for(const o of i.data){let i=e.config.pointStyle(o);!i.fill&&t&&(i={...i,fill:t});const s=i.r??3,a=e.getPointId?e.getPointId(o)+"":void 0,c=Ke(o,e.scales,e.getX,r,s,i,a);c&&n.push(c)}}}var at={topOpacity:.8,bottomOpacity:.05};function ct(e){if(e)return!0===e?at:"colorStops"in e?e:{topOpacity:e.topOpacity??at.topOpacity,bottomOpacity:e.bottomOpacity??at.bottomOpacity}}var lt=require("d3-shape"),ut={circle:lt.symbolCircle,square:lt.symbolSquare,triangle:lt.symbolTriangle,diamond:lt.symbolDiamond,star:lt.symbolStar,cross:lt.symbolCross,wye:lt.symbolWye},dt=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ht(e,t,n){if(n)return n;const i=e??"circle";return"chevron"===i?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,lt.symbol)(ut[i]??lt.symbolCircle,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var pt=new Map;function yt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const i=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),o=e.config.heatmapAggregation??"count",s=Ie(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/r,f=i*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;t.length>n;n++){const o=t[n],c=e.getX(o),u=e.getY(o);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),g=Math.min(Math.floor((u-l)/h),r-1);if(0>f||0>g)continue;const m=g*i+f;p[m]++;const x=s(o);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(o){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,b=n.width/i,v=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let e=0;r>e;e++){const t=e*i;for(let n=0;i>n;n++){const i=t+n;if(0===p[i])continue;let s;switch(o){case"sum":s=y[i];break;case"mean":s=y[i]/p[i];break;default:s=p[i]}const c=(s-g)/x;S.push(Je(n*b,(r-1-e)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:p[i],sum:y[i],xCenter:a+(n+.5)*d,yCenter:l+(e+.5)*h,agg:o},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(e,t,n);if(0===t.length)return[];const i=Ie(e.config.valueAccessor,"value"),r=Te(e.config.xAccessor,"x"),o=Te(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],i=r(n),u=o(n);c[e]=i,l[e]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){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),x=new Float64Array(t.length),b=Array(t.length),v=new Map;let w=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),o=a.get(l[e]);if(void 0===r||void 0===o)continue;const d=i(n),h=o*u+r,f=v.get(h);let p;void 0!==f?p=f:(p=w++,v.set(h,p)),g[p]=h,x[p]=d,b[p]=n}let k=1/0,S=-1/0;for(let e=0;w>e;e++){const t=x[e];isFinite(t)&&(k>t&&(k=t),t>S&&(S=t))}if(!isFinite(k)||!isFinite(S))return[];const A=function(e){const t=e in C?e:"blues";let n=pt.get(t);if(n)return n;n=Array(256);const i=(r=t)&&C[r]||m;var r;for(let e=0;256>e;e++)n[e]=i(e/255);return pt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),M=255/(S-k||1),P=n.width/u,_=n.height/d,j=e.config.showValues,I=e.config.heatmapValueFormat,T=[];for(let e=0;w>e;e++){const t=x[e];if(!isFinite(t))continue;const n=g[e],i=n%u;T.push(Je(i*P,(d-1-(n-i)/u)*_,P,_,A[Math.min((t-k)*M+.5|0,255)],b[e],j?{value:t,showValues:!0,valueFormat:I}:void 0))}return T}function gt(e,t,n,i,r){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 c=Math.floor(e/i)*i;let l=o.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},o.set(c,l)),l.total+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return o}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:i,warned:r}=e;xt(i)&&0===n.length&&bt(r,"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)&&bt(r,"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 xt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(xt))}function bt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function vt(e,t,n,i){const r=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: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:i}}function wt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function kt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,i=wt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Ie(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r: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:wt(e.y1Accessor,"y1"),getBottom:wt(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 Mt(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 Pt(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function _t(e,t){const n=new _e(e.capacity);return e.forEach(()=>n.push(t)),n}function jt(e,t,n,i){const r=e.push(t);return n&&n.push(i),r}function Ct(e,t,n){if(!t||0===t.size)return;const i=new Set;if(e.forEach((e,t)=>{n(e)&&i.add(t)}),0===i.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)i.has(e)||t.push(r[e])}var It={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 Tt(e,t){const n={...e};for(const e of t)n[It[e]]++;return n}function Rt(e,t,n){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:Tt(n,i)}}var Lt=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=Rt({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(e,t){const n=Rt(e,t,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},$t=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Et=["scene-style","data-paint","accessibility","evidence"],zt=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),Dt=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},$t)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Et):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=>zt.has(e))&&n.add("scene-style"),n}(e,n):[])}},Bt=require("d3-quadtree"),Ft=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,i=0;for(const e of t)"point"===e.type&&(n++,e.r>i&&(i=e.r));if(this.maxRadius=i,500>=n)return void(this.tree=null);const r=Array(n);let o=0;for(const e of t)"point"===e.type&&(r[o++]=e);this.tree=(0,Bt.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},Nt=class e{constructor(e){if(this.xExtent=new je,this.yExtent=new je,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 Dt,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 Ft,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=r??(()=>{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 r=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=i.get(t);if(null==s)continue;const c=qe(e,s,o);c>r&&(r=c)}a&&(c=Ye(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=i.get(t);c=Ye(n,null==r?0:qe(e,r,o),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this._stylePaintPending=!1,this.config=e,this.buffer=new _e(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Ie(e.timeAccessor||e.xAccessor,"time"),this.getY=Ie(e.valueAccessor||e.yAccessor,"value")):(this.getX=Ie(e.xAccessor,"x"),this.getY=Ie(e.yAccessor,"y")),this.getGroup=Re(e.groupAccessor),this.getCategory=Re(e.categoryAccessor),this.getSize=e.sizeAccessor?Ie(e.sizeAccessor,"size"):void 0,this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getY0=e.y0Accessor?Ie(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=kt(e),this.getPointId=Re(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Ie(e.openAccessor,"open"):void 0,this.getHigh=Ie(e.highAccessor,"high"),this.getLow=Ie(e.lowAccessor,"low"),this.getClose=n?Ie(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=_t(this.buffer,Ne())):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),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}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),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}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=Ne();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 n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?Ie(this.config.timeAccessor||this.config.xAccessor,"time"):Ie(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(t):t[n||"x"],r=i instanceof Date,o="string"==typeof i&&Number.isFinite($e(i));if(this.xIsDate=r||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>Ee(t[e]):e=>Ee(n(e))}}Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(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=jt(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))}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,i=this.scales,r=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),c=At(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:i,getY:r}=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,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const o of e.data){const e=i(o),s=r(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===h)p=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}),t=[],i=[];let r=0,o=0;for(const n of e)o>r?(t.push(n),r+=d.get(n)??0):(i.push(n),o+=d.get(n)??0);p=[...i.reverse(),...t]}else p="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ue(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let i=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,o=u.get(t)??0;i>e&&(i=e),e+o>r&&(r=e+o)}Number.isFinite(i)&&Number.isFinite(r)||(i=0,r=0);const s=r-i,l=o?0:s>0?s*t.extentPadding:1;y=[i-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,i]=function(e,t,n){let i=0,r=0;for(const o of e){let e=0,s=0;for(const i of t){const t=n(i,o)||0;0>t?s+=t:e+=t}i>s&&(i=s),e>r&&(r=e)}return[i,r]}(e,p,(e,t)=>a.get(e)?.get(t)||0),r=i-n,s=o?0:r>0?r*t.extentPadding:1;y=[n-s,i+s]}else y=[0,l+(o?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:t,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,i,r,o,s){const[,a]=function(e,t,n,i,r){const o=gt(e,t,n,i,r);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,i,r);return[0,s?a:a+a*o]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,i){const[r,o]=function(e,t){let n=0,i=0,r=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(e,t),s=o-r,a=i?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,o+Math.abs(a))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[i,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(i>n&&(i=n),n>r&&(r=n)),Number.isFinite(o)&&(i>o&&(i=o),o>r&&(r=o))}return[i,r]}(c,o,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],i=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-i,null!=t.userMax?e[1]:e[1]+i];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const i=t[0],r=t[1];return null==i&&null==r?e:[null!=i?i:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let i=e,r=t;if(i[0]===1/0||i[1]===-1/0)if("time"===n){const e=Date.now();i=[e-864e5,e]}else i=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:i,yDomain:r}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:i,yDomain:r}=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(i).range(e),y:Mt(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Mt(t.yScaleType,r,[s,n.width-s]),y:(0,St.scaleLinear)().domain(i).range(e)}}var a;return{x:Mt(t.xScaleType,i,[s,n.width-s]),y:Mt(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=r):(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=h,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 i of e.path)i[0]*=t,i[1]*=n;break;case"area":for(const i of e.topPath)i[0]*=t,i[1]*=n;for(const i of e.bottomPath)i[0]*=t,i[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 i=this.scales.x.domain(),r=this.scales.y.domain(),o=this.scales.x.range(),s=this.scales.y.range(),a=Mt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,o[0]>o[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:i}=this;if(!i)return[];if(n.customLayout){const r={data:t,scales:i,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??R},resolveColor:(e,t)=>{const i=this.resolveGroupColor(e);if(i)return i;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let o;try{o=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,i=vt("xy",e,t,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(i)}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 mt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const r={scales:i,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),i=[],r=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:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),o=Xe(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(o.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),i.push(o)}return st(e,n,i),i}(r,t);case"area":return function(e,t){const n=e.groupData(t),i=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}const r=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Ve(t.data,e.scales,e.getX,e.getY,r,n,t.key,o),a=ct(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),i.push(s)}return st(e,n,i),i}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),i=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}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(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Ve(t.data,e.scales,e.getX,e.getY,o,n,t.key,s),a=ct(e.config.gradientFill);a&&(r.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=Xe(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}return st(e,n,i),i}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),i=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===i);else if("key"===i)r();else if("asc"===i||"desc"===i||"insideOut"===i){const t=new Map;for(const i of n){let n=0;for(const t of i.data){const i=e.getX(t),r=e.getY(t);Number.isFinite(i)&&Number.isFinite(r)&&(n+=r)}t.set(i.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===i)n.sort((e,n)=>{const i=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==i?i:r(e.key,n.key)});else if("desc"===i)n.sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)}),i=[],o=[];let s=0,a=0;for(const n of e)a>s?(i.push(n),s+=t.get(n.key)??0):(o.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...o.reverse(),...i)}}else r();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:c}=function(e,t,n,i,r,o,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),o=i(r);Number.isFinite(t)&&Number.isFinite(o)&&e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let d;if(o){d=new Map;for(const t of l){let n=0;for(const i of e)n+=u.get(i.key)?.get(t)||0;d.set(t,n||1)}}const h=Ue(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!o,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),i=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,l,u=r?e.get(n):0;if(o&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=t.x(n);c.push([p,t.y(s)]),a.push([p,t.y(l)]),i.set(n,l)}h(),y.set(n.key,i)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const i of n){const n=c.get(i.key);if(n)for(const r of i.data){const i=e.getX(r),o=e.getY(r);null==i||Number.isNaN(i)||null==o||Number.isNaN(o)||!n.has(i)||t.set(r,n.get(i))}}const i=n=>t.get(n)??e.getY(n);st(e,n,l,i)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],i="bubble"===e.config.chartType?10:5,r=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 i of n)e>i&&(e=i),i>t&&(t=i);o=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=dt[d%dt.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},l=t.r||i;if(o&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=o(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const i=h(c(r)+""),o=Ze(r,e.scales,e.getX,e.getY,Math.PI*l*l,i,t,u);o&&n.push(o)}else{const i=Ke(r,e.scales,e.getX,e.getY,l,t,u);i&&n.push(i)}}return n}(r,t);case"heatmap":return yt(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let i=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 r=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(r),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?i=e.barCategoryCache.order:(i=[...a,...s],e.barCategoryCache={key:c,order:i})}const r=[],o=e.scales,[s,a]=o.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=o.x(n),p=o.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&t.categories.size>0){let n=0;for(const s of i){const i=t.categories.get(s)||0;if(0===i)continue;const a=o.y(n),u=o.y(n+i);r.push(Qe(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:i},s)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(Qe(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{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:r,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],i=e.config.swarmStyle||{},r=i.radius??3,o=i.fill??e.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth;for(const i of t){const t=e.getX(i),l=e.getY(i);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=o;if(e.getCategory){const t=e.getCategory(i);h=e.config.barColors?.[t]||h}const{r:f,...p}=e.config.pointStyle?.(i)??{},y={type:"point",x:u,y:d,r:f??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:i};e.getPointId&&(y.pointId=e.getPointId(i)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const i=[],r=e.scales,o=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),i=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=o?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,d=o?.strokeWidth,h=o?.opacity;let f=0;for(let t=0;s.length>t;t++){const p=s[t],y=e.getX(p),g=e.getY(p),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+n.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=r.y(f),A=r.y(m),M=Math.min(S,A),P=Math.abs(S-A),_={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(_.opacity=h),i.push(Qe(w,M,k,P,_,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),f=m}return i}(r,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 i=[],r=e.config.candlestickStyle||{},o=r.rangeColor||"#6366f1",s=n?o:r.upColor||"#28a745",a=n?o:r.downColor||"#dc3545",c=n?o:r.wickColor||"#333",l=r.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=r.bodyWidth??0;if(null==r.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const i=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));i>0&&t>i&&(t=i)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const r of t){const t=e.getX(r);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(r),u=e.getLow(r);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const h=n?o:e.getOpen(r),f=n?u:e.getClose(r);if(!n&&[h,f].some(e=>null==e||Number.isNaN(e)))continue;const p=f>=h,y={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(h),closeY:e.scales.y(f),highY:e.scales.y(o),lowY:e.scales.y(u),bodyWidth:d,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:r};n&&(y.isRange=!0),i.push(y)}return i}(r,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,i){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:i(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?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,i=We(n)){const r=n.length;if(r>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=i.get(t[n]);null!=a?(o[n]=Oe(e,a,r),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=i.get(t[n]);null!=o?(s[n]=Oe(e,o,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=i.get(n);if(null!=t){const n=Oe(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(o);e.fill(s),n._decayOpacities=e}}continue}const t=i.get(n.datum);if(null==t)continue;const o=Oe(e,t,r);"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&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,i){n.clear(),i.clear();for(let r=0;t.length>r;r++){const o=t[r],s=Ge(e,o,r);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?i.set(s,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}):"area"===o.type&&i.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],i=Ge(this.transitionContext,n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(i,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(i,{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,i,r){if(0===i.size&&0===r.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,c=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],l=Ge(e,o,t);if(!l)continue;if(o._transitionKey=l,"line"===o.type||"area"===o.type){const e=r.get(l);if(e){if(c.add(l),"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=i.get(l);if("point"===o.type)if(u){a.add(l);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(l);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(l);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(l);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(l);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 r)if(!c.has(e))if(e.startsWith("l:")&&t.path){const i={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(i),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const i={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(i),s=!0}for(const[e,t]of i)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 i=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:i,closeY:t.closeY??i,highY:t.highY??i,lowY:t.lowY??i,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:Ne(),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,i){if(!n.activeTransition)return!1;const r=Be(e,n.activeTransition),o=De(r,"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?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.r=Fe(n.r,e._targetR,o))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.size=Fe(n.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),void 0!==n.openY&&(e.openY=Fe(n.openY,e._targetOpenY,o)),void 0!==n.closeY&&(e.closeY=Fe(n.closeY,e._targetCloseY,o)),void 0!==n.highY&&(e.highY=Fe(n.highY,e._targetHighY,o)),void 0!==n.lowY&&(e.lowY=Fe(n.lowY,e._targetLowY,o))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(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 i=0;e.path.length>i;i++)e.path[i][0]=Fe(t[i][0],n[i][0],o),e.path[i][1]=Fe(t[i][1],n[i][1],o)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevTopPath,n=e._prevBottomPath,i=e._targetTopPath,r=e._targetBottomPath;if(t&&i&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Fe(t[n][0],i[n][0],o),e.topPath[n][1]=Fe(t[n][1],i[n][1],o);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Fe(n[t][0],r[t][0],o),e.bottomPath[t][1]=Fe(n[t][1],r[t][1],o)}}if(r>=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,i){if(i&&i.version===n&&i.group===t&&i.data===e)return{result:i.result,cache:i};let r;if(t){const n=new Map;for(const i of e){const e=t(i);n.has(e)||n.set(e,[]),n.get(e).push(i)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,i,r){if(r&&r.version===i)return{map:r.map,cache:r};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(r&&r.key===a){const e={...r,version:i};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||R,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:i}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,i){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=i(t);if(n)return{...e,stroke:n}}return e}const o=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||o||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:i(t)||o||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,i){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=i(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=i(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const o=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||o||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||o||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=i(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:i}=function(e){const{group:t,colorMapCache:n,groupColorMap:i,groupColorMapCap:r,config:o}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=i.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||R;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,i.set(t,l),i.size>r){const e=i.keys().next().value;void 0!==e&&i.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,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=ze(e),n=this.getPointId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ze(e),i=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(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)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),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 i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}: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 i=!1,r=!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||!Ce(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=o||!Ce(n,s);(a||c)&&(e?(this.getX=Ie(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ie(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ie(this.config.xAccessor,"x"),this.getY=Ie(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=kt(this.config)),i=!0,r=!0)}if("groupAccessor"in e&&!Ce(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Re(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Re(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in e&&!Ce(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ie(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in e&&!Ce(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ie(this.config.y0Accessor,"y0"):void 0,i=!0,r=!0),("boundsAccessor"in e&&!Ce(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=kt(this.config),i=!0,r=!0),"pointIdAccessor"in e&&!Ce(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Re(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in e&&!Ce(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ce(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ce(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ce(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Ie(this.config.openAccessor,"open"):void 0,this.getHigh=Ie(this.config.highAccessor,"high"),this.getLow=Ie(this.config.lowAccessor,"low"),this.getClose=t?Ie(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,i=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(i=!0,r=!0),!i){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){i=!0;break}}i&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,i,r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Nt.GROUP_COLOR_MAP_CAP=1e3;var Ot=Nt,Wt={sceneGeometry:0,layout:0,domain:0},qt="production"!==process.env.NODE_ENV,Yt={revisions:Wt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},Ht=class{constructor(){this.lastConsumed=Wt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(e,t){if(!qt)return Yt;const n=function(e){const{domain:t,layout:n,sceneGeometry:i}=e.revisions;return{domain:t,layout:n,sceneGeometry:i}}(e),i=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((o=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&o.layout===s.layout&&o.domain===s.domain);var o,s;return{revisions:n,signature:i,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==i}}afterCompute(e,t,n){if(qt){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="")}}},Gt=c(require("react"));function Xt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:Gt.createElement(Gt.Fragment,null,...t)}var Vt=c(require("react")),Ut=require("react/jsx-runtime"),Kt=Vt.createContext(null);function Zt({value:e,children:t}){return(0,Ut.jsx)(Kt.Provider,{value:e,children:t})}function Qt(e,t){return null!=e?(0,Ut.jsx)(Zt,{value:t,children:e}):e}var Jt=require("react");function en(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function tn(e,t=30){return Math.max((e??4)+5,12,t)}function nn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function rn(e,t){const n=nn(e);if(!n)return!1;const i=nn(t);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}var on=[40,40],sn=[.5,.5];function an(e,t){const[n,i]=e.viewBox??on,[r,o]=e.anchor??sn,s=i>0?i:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-o*l}}function cn(e,t,n,i){if("none"!==e)return"color"===e||null==e?t??i:"accent"===e?n:e}var ln=null;function un(e){if("undefined"==typeof Path2D)return null;ln||(ln=new Map);const t=ln.get(e);if(t)return t;const n=new Path2D(e);return ln.size>1024&&ln.clear(),ln.set(e,n),n}function dn(e,t,n=0,i="horizontal"){const[r,o]=e.viewBox??on,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===i?{x:0,y:o*(1-a),width:r,height:o*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:o}:null:{x:0,y:0,width:0,height:0}}function hn(e,t){const n=an(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 fn(e,t,n,i,r,o=e=>e){for(const s of t.parts){const t=un(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:cn(s.fill,n,i);l&&(e.fillStyle=o(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:cn(s.stroke??"none",n,i);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=c)}}var pn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,yn=new WeakMap,gn=0,mn=!1,xn=null,bn=null;function vn(e,t){if(!t)return t;const n=pn.exec(t);if(!n)return t;const i=e.canvas;if(!i)return n[2]?.trim()||t;!function(){if(mn)return;if("undefined"==typeof window||"undefined"==typeof document)return;mn=!0;const e=()=>{gn++};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{xn=window.matchMedia("(prefers-color-scheme: dark)"),bn=e,"function"==typeof xn.addEventListener?xn.addEventListener("change",bn):"function"==typeof xn.addListener&&xn.addListener(bn)}catch{}}();let r=yn.get(i);r&&r.version===gn||(r={version:gn,map:new Map},yn.set(i,r));const o=r.map.get(t);if(void 0!==o)return o;const s=getComputedStyle(i).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return r.map.set(t,s),s}var wn=require("d3-shape");function kn(e){switch(e){case"monotoneX":return wn.curveMonotoneX;case"monotoneY":return wn.curveMonotoneY;case"cardinal":return wn.curveCardinal;case"catmullRom":return wn.curveCatmullRom;case"step":return wn.curveStep;case"stepBefore":return wn.curveStepBefore;case"stepAfter":return wn.curveStepAfter;case"basis":return wn.curveBasis;case"natural":return wn.curveNatural;default:return null}}function Sn(e,t,n){return null==t?n:"string"!=typeof t?t:vn(e,t)||n}function An(e,t,n,i,r,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(i,r,o,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),d=e.createLinearGradient(i,r,o,s),[h,f,p]=function(e,t){const n=e.fillStyle,i="#010203";try{e.fillStyle=i,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===i&&t.trim().toLowerCase()!==i)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const o=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return d.addColorStop(0,`rgba(${h},${f},${p},${l})`),d.addColorStop(1,`rgba(${h},${f},${p},${u})`),d}function Mn(e,t,n,i,r,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,i,r,o);for(const e of s)a.addColorStop(e.offset,e.color);return a}var Pn=require("d3-shape"),_n=new WeakMap;function jn(e,t){const n=kn(t);if(!n)return e;const i=_n.get(e);if(i)return i;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const i=[];let r=null;const o={moveTo(e,t){r=[e,t],i.push([e,t])},lineTo(e,t){r=[e,t],i.push([e,t])},bezierCurveTo(e,t,o,s,a,c){if(!r)return r=[a,c],void i.push([a,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;i.push([h*h*h*l+3*h*h*d*e+3*h*d*d*o+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,o){r=[n,o],i.push([n,o])}};return(0,Pn.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(o)(e),i}(e,n);return _n.set(e,r),r}function Cn(e,t,n,i=30,r,o=0){let s=null;if(r){const e=function(e,t,n,i,r,o=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(i,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let f=null,p=1/0;return e.visit((e,r,c,y,g)=>{if(r>u||l>y||c>h||d>g)return!0;if(!e.length){let r=e;do{const e=r.data,c=o(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);tn(a(e),i)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(r,t,n,i,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(r)break;e=Tn(o,t,n,i);break;case"symbol":e=Rn(o,t,n,i);break;case"glyph":e=Ln(o,t,n,i);break;case"line":e=$n(o,t,n,i);break;case"rect":if(null==o.datum)break;e=zn(o,t,n);break;case"heatcell":e=Dn(o,t,n);break;case"area":if(!1===o.interactive)break;e=Fn(o,t,n);break;case"candlestick":e=Bn(o,t,n)}e&&i>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function In(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const i=Nn(e,t);if(0>i)return null;if(Math.abs(e[i][0]-t)>n)return null;let r=i,o=i;i>0&&e[i][0]>=t?(r=i-1,o=i):e.length-1>i&&(r=i,o=i+1);const[s,a]=e[r],[c,l]=e[o];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function Tn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(e.r,i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Rn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(ft(e.size),i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ln(e,t,n,i=30){if(null==e.datum)return null;const r=hn(e.glyph,e.size),o=e.x+r.centerDx,s=e.y+r.centerDy,a=t-o,c=n-s,l=Math.sqrt(a*a+c*c);return l>tn(r.radius,i)?null:{node:e,datum:e.datum,x:o,y:s,distance:l}}function $n(e,t,n,i=30){if(0===e.path.length)return null;const r=Nn(e.path,t);if(0>r)return null;const[o,s]=e.path[r];let a;if(e.path.length>1){let i=1/0;const o=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=o;s>=r;r++){const[o,s]=e.path[r],[a,c]=e.path[r+1],l=En(t,n,o,s,a,c);i>l&&(i=l)}a=i}else{const e=t-o,i=n-s;a=Math.sqrt(e*e+i*i)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,i)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:s,distance:a}}function En(e,t,n,i,r,o){const s=r-n,a=o-i,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-i)**2);let l=((e-n)*s+(t-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(i+l*a))**2)}function zn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function Dn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function Bn(e,t,n){const i=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-i-3>t||t>e.x+i+3||e.highY-3>n||n>e.lowY+3)){const i=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,o=t-e.x,s=n-i;return{node:e,datum:e.datum,x:e.x,y:i,distance:Math.sqrt(o*o+s*s)}}return null}function Fn(e,t,n){if(0===e.topPath.length)return null;const i=Nn(e.topPath,t);if(0>i)return null;const[r,o]=e.topPath[i],s=t-r,a=n-o,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:r,y:o,distance:c}}function Nn(e,t){if(0===e.length)return-1;let n=0,i=e.length-1;for(;i>n;){const r=n+i>>1;t>e[r][0]?n=r+1:i=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function On(e,t,n){const i=e.byGroup.get(t);let r=0,o=Math.abs(i[0].x-n.x);for(let e=1;i.length>e;e++){const t=Math.abs(i[e].x-n.x);o>t&&(o=t,r=e)}return i[r]._flatIndex}function Wn(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}var qn=require("react"),Yn={fresh:1,aging:.7,stale:.45,expired:.25},Hn={alpha:1,band:"fresh",isStale:!1};function Gn(e,t){if(!e||0>=t)return Hn;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,i=e.graded;if(i){const e="object"==typeof i?i:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...Yn,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Hn}var Xn=require("react/jsx-runtime");function Vn({isStale:e,position:t}){return(0,Xn.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 Un=require("react"),Kn=c(require("react")),Zn=require("react/jsx-runtime"),Qn={fill:(e,t)=>(0,Zn.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Zn.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Jn(e,t,n,i,r){let o;return o="function"==typeof n?n(e):(0,Qn[n])(i(e,t),r),o}function ei({swatchSize:e}){return(0,Zn.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 ti(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var ni=(e,t,n,i,r,o,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=r,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,l)=>{const u=Jn(e,l,d,h,x),w=ti(e,i,r),k=r&&r.size>0&&r.has(e.label);p.push((0,Zn.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===o&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.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:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,Zn.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"}),u,k&&(0,Zn.jsx)(ei,{swatchSize:x}),(0,Zn.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-"+l)),y+=v}),p};function ii({config:e,orientation:t="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+Kn.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[0]+t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),o&&(0,Zn.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,Zn.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[1]-t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[o&&(0,Zn.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,Zn.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,Zn.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function ri(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=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}}(d),[f,p]=Kn.useState(0),[y,g]=Kn.useState(0),m=Kn.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push((0,Zn.jsx)("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push((0,Zn.jsx)("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(0,${d})`,children:ni(e,n,i,r,o,s,a,f,c,l,u)},"legend-group-"+f)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,i,r,o,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=p.map(e=>g+m+7*e.label.length),A=[];let M=0,P=0;S.forEach((e,t)=>{const n=0===P?e:P+x+e;d&&d>0&&P>0&&n>d?(A.push({start:M,end:t,width:P}),M=t,P=e):P=n}),p.length>0&&A.push({start:M,end:p.length,width:P}),A.forEach((e,l)=>{let u="center"===v?Math.max(0,((d??e.width)-e.width)/2):"end"===v?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],v=Jn(e,d,h,f,g),A=ti(e,i,r),M=r&&r.size>0&&r.has(e.label);y.push((0,Zn.jsxs)("g",{transform:`translate(${u},${l*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===o&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,d),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&(0,Zn.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"}),v,M&&(0,Zn.jsx)(ei,{swatchSize:g}),(0,Zn.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-"+d)),u+=S[d]+x}});const _=Math.max(0,...A.map(e=>e.width)),j=A.length;return{items:y,offset:_,totalRows:j,totalHeight:j*b}})(e,i,r,o,s,a,c,t,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,i)=>{const r=e[i];r.label&&(g.push((0,Zn.jsx)("text",{transform:`translate(${y},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-"+i)),y+=16),g.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+i)),y+=n.offset+5,e[i+1]&&g.push((0,Zn.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+i)),y+=12}),(0,Zn.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!i);return(0,Zn.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"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,Zn.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}),x]})}function oi(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function si(e){return"object"==typeof e&&null!==e&&"gradient"in e}var ai=require("react/jsx-runtime");function ci(e){const{legend:t,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===o||"bottom"===o,p=!!a,y=Math.max(0,n-r.left-r.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===o?(m=Math.max(4,r.left-g-10),x=r.top):"top"===o?(m=r.left,x=p?32:8):"bottom"===o?(m=r.left,x=i-r.bottom+38):(m=n-r.right+10,x=r.top),(0,ai.jsx)("g",{transform:`translate(${m}, ${x})`,children:si(t)?(0,ai.jsx)(ii,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):oi(t)?(0,ai.jsx)(ri,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t})}var li=require("react"),ui=require("d3-array");function di(e){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);return[t,n]}function hi(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}var fi=require("react/jsx-runtime");function pi(e){return"string"==typeof e?{type:e}:e}function yi({orient:e,config:t,values:n,scale:i,size:r,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,c=(0,li.useMemo)(()=>{if(0===n.length)return null;const t=i.domain(),c=r-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 i=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],s=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(t[0],i-1.5*s),whiskerHigh:Math.min(t[n-1],o+1.5*s)}}(n);if(!t)return null;const{q1:r,median:o,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="top"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="left"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,ui.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=hi(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,fi.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:o,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(o,o+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const o=r.length/u*(c/2),s=i((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-o):t-o}`:`${"left"===e?-(t-o):t-o},${s}`)}for(let r=l.length-1;r>=0;r--){const o=l[r];if(null==o.x0||null==o.x1)continue;const s=o.length/u*(c/2),d=i((o.x0+o.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,fi.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,fi.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,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${o},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${o}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${n},${s}`),t.push("Z")}return(0,fi.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,fi.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,i,s,r,o,e,a,4]);return c?(0,fi.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var gi=c(require("react")),mi=require("react/jsx-runtime");function xi(e,t=120,n=8){if(!e)return[];const i=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),o=[];let s="";for(const e of r)s&&s.length+1+e.length>i?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function bi(e,t,n,i){return"curly"===e?i?`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`:i?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function vi(e,t,n,i){if(!e)return(0,mi.jsx)("g",{className:"annotation-note"});const{label:r,title:o,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!o)return(0,mi.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=o?l?[o]:xi(o,c):[],y=r?l?[r]:xi(r,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,mi.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(o&&r?2:0))+f,style:{overflow:"visible"},children:(0,mi.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[o&&(0,mi.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:o}),r&&(0,mi.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,mi.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,mi.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((o||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,mi.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,mi.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function wi(e,t,n,i,r){const o=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&o.push((0,mi.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,i=t?.height||0;(e>0||i>0)&&o.push((0,mi.jsx)("rect",{width:e,height:i,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=i||0,s=r||0;if(void 0!==t?.x){const i=(t.x||0)-e;o.push((0,mi.jsx)("line",{x1:i,y1:(t.y1||0)-s,x2:i,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const i=(t.y||0)-s;o.push((0,mi.jsx)("line",{x1:(t.x1||0)-e,y1:i,x2:(t.x2||0)-e,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?o.push((0,mi.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,mi.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",i=t?.width??t?.height;void 0!==i&&o.push((0,mi.jsx)("path",{d:bi(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,mi.jsx)("g",{className:"annotation-subject",children:o})}function ki(e,t,n,i,r,o){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!o?.radius){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,s=e-r,l=t-o;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=i/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=o+l*h}}}else if("bracket"===r&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const i=Math.atan2(t,e);a=Math.cos(i)*n,c=Math.sin(i)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",o="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(o){const i=(a+e)/2,o=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,f=(n?.curve??.25)*l,p=i+d*f,y=o+h*f;s.push((0,mi.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,mi.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,mi.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,mi.jsx)("g",{className:"annotation-connector",children:s})}function Si(e){const{x:t=0,y:n=0,dx:i,dy:r,nx:o,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=i||0,k=r||0;null!=o&&(w=o-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return(0,mi.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ki(w,k,c,d,S,l),!v.has("subject")&&wi(S,l,d,x,b),!v.has("note")&&vi(a,w,k,d)]})}function Ai(e){const{noteData:t}=e,{screenCoordinates:n}=t,i="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=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:r});return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+o)});return(0,mi.jsx)("g",{children:o})}const o=t.note||{title:"none",label:t.label},s=`${o.label}-${o.title}-${t.i}`;return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",events:r,...t,type:i},s)}var Mi=require("d3-hierarchy"),Pi=require("d3-shape"),_i=c(require("regression"));function ji(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 Ci(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 Ii(e){return null==e?null:e+""}function Ti(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ri(e,t,n){const i=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId)return Ti(t,n,{x:r.x,y:r.y})}const i=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],i=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!i||!r)return null;const o=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==o||null==s?null:{x:i(o),y:r(s)}}(n);return i?Ti(t,n,i):null}if("semantic"===i){const i=function(e,t,n){const i=function(e){return Ii(e.provenance?.stableId??e.stableId)}(e);if(!i)return null;const r=n.pointNodes?.find(e=>Ii(e.pointId)===i);if(r)return Ti(t,n,{x:r.x,y:r.y});const o=n.data?.find(e=>function(e){return Ii(e.stableId??e.id??e.provenance?.stableId)}(e)===i);if(!o)return null;const s=ji(o,n),a=Ci(o,n);return null==s||null==a?null:Ti(t,n,{x:s,y:a})}(e,t,n);if(i)return i}let r=null,o=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,o=t.y)}if(null!=r&&null!=o||(r=ji(e,n),o=Ci(e,n)),null!=r&&null!=o)return Ti(t,n,{x:r,y:o});if("sticky"===i){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Li(e,t,n,i=50){return!(-i>e||e>(n.width||0)+i||-i>t||t>(n.height||0)+i)}var $i=require("react/jsx-runtime"),Ei={secondary:0,primary:3},zi=1,Di=2,Bi=.6,Fi="0.88em",Ni=.95,Oi=.72,Wi=.06,qi=".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}}",Yi=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Hi(e){return!0===e?._annotationDeferred}function Gi(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Xi(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Vi(e){return Math.max(Oi,Ni-e*Wi)}function Ui(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:Xi(e.annotation),readingOrder:null,rank:zi};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),i=e.some(e=>Hi(e.annotation)),r=e.some(e=>null!=Gi(e.annotation)),o=e.some(e=>"layer"===Gi(e.annotation));if(!n&&!i&&!r)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=Di-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Ei[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:i,readingOrder:r}=e,o=Hi(t.annotation);let s=t.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;s=(0,$i.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:Bi,fontSize:Fi}:{},...e?{opacity:Vi(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=Gi(t.annotation);return a&&(s=(0,$i.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),o&&(s=(0,$i.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return i&&a.unshift((0,$i.jsx)("style",{children:qi},"annotation-disclosure-style")),o&&a.unshift((0,$i.jsx)("style",{children:Yi},"annotation-cohesion-style")),a}var Ki=require("react/jsx-runtime"),Zi={linear:Pi.curveLinear,monotoneX:Pi.curveMonotoneX,monotoneY:Pi.curveMonotoneY,step:Pi.curveStep,stepAfter:Pi.curveStepAfter,stepBefore:Pi.curveStepBefore,basis:Pi.curveBasis,cardinal:Pi.curveCardinal,catmullRom:Pi.curveCatmullRom};function Qi(e,t,n,i){const r=[];return e.forEach((e,o)=>{let s;if(n){const r=n(e,o,i);s=null!=r?r:t(e,o,i)}else s=t(e,o,i);s&&r.push({node:s,annotation:e})}),Ui(r)}function Ji(e){return function(e,t,n){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i;if(!Li(r,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,Ki.jsx)(Ai,{noteData:{x:r,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 i=ji(null!=e.value?{...e,x:e.value}:e,n);if(null==i)return null;const r=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=i>.6*(n.width||0),c=a?i-4:i+4,l=a?"end":"start";return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:c,y:s,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const i=Ci(null!=e.value?{...e,y:e.value}:e,n);if(null==i)return null;const r=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,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:s,y:i-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=(0,Mi.packEnclose)(i),o=e.padding||10;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("circle",{cx:r.x,cy:r.y,r:r.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,Ki.jsx)("text",{x:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=e.padding||10,o=i.map(e=>e.x),s=i.map(e=>e.y),[a,c]=di(o),[l,u]=di(s),d=a-r,h=c+r,f=l-r;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("rect",{x:d,y:f,width:h-d,height:u+r-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,Ki.jsx)("text",{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const i=n.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Ki.jsx)("g",{children:r.map((t,i)=>{const r=ji(t,n),s=Ci(t,n);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||o;return(0,Ki.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+i)})},"ann-"+t)}case"bracket":{const i=ji(e,n),r=Ci(e,n);return(0,Ki.jsx)(Ai,{noteData:{x:i??0,y: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-"+t)}case"trend":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,c=s?r:null,l=s?o:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const e of i){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=i.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const i=h.get(t+"");return null!=i?[i,+n]:null}).filter(e=>null!==e)}else u=i.map(e=>[e[r],e[o]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,p=n.scales?.y??n.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),i=Math.min(d.length-1,n+1),r=t-n,o=e(d[n]);return o+(e(d[i])-o)*r},g=f,m=p;let x;if(s)if(a){const e=y(m);x=(t,n)=>[g(n),e(t)]}else{const e=y(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const b=e.method||"linear";let v;v="loess"===b?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const i=e.slice().sort((e,t)=>e[0]-t[0]),r=i.map(e=>e[0]),o=i.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],i=r.map(e=>Math.abs(e-t)),c=i.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:i[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*o[e],f+=t*r[e]*r[e],p+=t*r[e]*o[e])}if(0===u){a.push([t,o[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*p-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3):("polynomial"===b?_i.default.polynomial(u,{order:e.order||2}):_i.default.linear(u)).points;const w=v.map(([e,t])=>{const[n,i]=x(e,t);return`${n},${i}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const i=n.scales?.y??n.scales?.value,r=i?.(e.y0)??0,o=i?.(e.y1)??(n.height||0);return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.max(Math.min(r,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 i=n.scales?.x??n.scales?.time,r=null!=e.x0&&i?i(e.x0):null,o=null!=e.x1&&i?i(e.x1):null;return null==r||null==o?null:(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:Math.min(r,o),y:0,width:Math.abs(o-r),height:n.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ki.jsx)("text",{x:Math.min(r,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 i=n.data||[];if(2>i.length)return null;const r=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",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=i.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=Zi[n.curve||"linear"]||Pi.curveLinear,h=(0,Pi.area)().x(e=>o(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ki.jsx)("text",{x:o(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+d*u),b=s(h),v=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,Ki.jsxs)("g",{children:[f&&(0,Ki.jsx)("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const i=ji(e,n),r=Ci(e,n);return null==i||null==r?null:(0,Ki.jsx)("circle",{cx:i,cy:r,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=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 c=i.map(e=>[e[r],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>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=_i.default.polynomial(c,{order:e.order||2}).equation;l=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const e=c.length;let t=0,n=0,i=0,r=0;for(const[e,o]of c)t+=e,n+=o,i+=e*e,r+=e*o;const o=e*i-t*t;if(1e-12>Math.abs(o))return null;const s=(e*r-t*n)/o,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-l(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-f)**2,0),y=e.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,m=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),v=[];for(let e=1;m>=e;e++)v.push(x+e*b);const w=[];for(const e of v){const t=l(e),n=h*Math.sqrt(1+1/u+(p>0?(e-f)**2/p:0))*g;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),A=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ki.jsx)("polyline",{points:`${A} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,Ki.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let i,r;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const o=Ri(e,t,n);if(!o)return null;i=o.x,r=o.y}if(!Li(i,r,n))return null;const o=e.width??32,s=e.height??32;return(0,Ki.jsx)("foreignObject",{x:i+(e.dx??0)-o/2,y:r+(e.dy??0)-s/2,width:o,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ki.jsx)("div",{style:{width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??(0,Ki.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i,s=r+(e.dx||0),a=o+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,Ki.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?gi.cloneElement(l,{key:"ann-text-"+t}):(0,Ki.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ki.jsx)("line",{x1:r,y1:o,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),gi.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,o=n.scales?.o,s=n.scales?.x,a=n.scales?.y,c=r(o)?o:r(s)?s:r(a)?a:null;if(!c)return null;const l=c(i+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Ki.jsxs)("g",(n.projection?"vertical"===n.projection:c===s)?{children:[(0,Ki.jsx)("rect",{x:l,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:l+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[(0,Ki.jsx)("rect",{x:0,y:l,width:n.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+t)}default:return null}}}var er=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function tr(e){return!!e&&"object"==typeof e&&er.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var nr=2e4,ir=1;function rr(e){return"primary"===e?.emphasis||!0===e?.defensive}function or(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:nr))):1/0}function sr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const i=e?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(t+=15*Math.max(0,Math.min(1,i))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var ar=32,cr=6,lr=4,ur=8,dr=72,hr=30,fr=-30,pr=8,yr=480,gr=3;var mr={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function xr(e){if(!br(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 br(e){return tr(e)}function vr(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),i=e.split(/\s+/).filter(Boolean),r=[];let o="";for(const e of i)o&&o.length+e.length+1>n?(r.push(o),o=e):o=o?`${o} ${e}`:e;return o&&r.push(o),r}function wr(e,t,n,i,r){const o=e+n,s=t+i;return Math.abs(n)>Math.abs(i)?{x:0>n?o-r.width-4:o+4,y:0>i?s-r.height:s,width:r.width,height:r.height}:{x:0>n?o-r.width:o,y:0>i?s-r.height-4:s+4,width:r.width,height:r.height}}function kr(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Sr(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 Ar(e,t,n,i,r,o,s,a){const c=kr(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,i){const r=Math.max(0,i-e.x),o=Math.max(0,i-e.y);return(r+Math.max(0,e.x+e.width-(t-i)))*e.height+(o+Math.max(0,e.y+e.height-(n-i)))*e.width}(c,r,o,a);for(const e of n)l+=12*Sr(c,e);for(const e of i)l+=4*Sr(c,e);return l}function Mr(e){const{annotations:t,context:n,defaultOffset:i=ar,notePadding:r=cr,markPadding:o=lr,edgePadding:s=ur,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=dr,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??yr,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(xr):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,P=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const _=[],j=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 C=!1;const I=k.map((e,t)=>{if(!br(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 i=e.pointId??e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,o=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&o){const e=r[0],t=r[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?Ri(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=[...vr("string"==typeof e.title?e.title:void 0,t),...vr("string"==typeof e.label?e.label:void 0,t)],i=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*i)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:hr,dy:fr}}(e);return _.push(kr(wr(o.x,o.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=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}]}(i)){const t=Ar(wr(o.x,o.y,e.dx,e.dy,u),e,_,j,m,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=kr(wr(o.x,o.y,h.dx,h.dy,u),r);_.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),T=C?I:k.slice();let R=T;if(h){let e=!1;const t=T.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<pr?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});R=e?t:T}{let e=!1;const t=R.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?mr[t.source]??t.source:null,i="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!i)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,i].filter(Boolean).join(" · "),o="string"==typeof e.label?e.label:"";return o.includes(`(${r})`)?e:{...e,label:o?`${o} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});R=e?t:R}const L=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return gr;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?gr: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??or(m,x,e))*t))},{deferred:i}=function(e){const{annotations:t,width:n,height:i}=e,r=Math.max(0,e.minVisible??ir),o=or(n,i,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,tr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||o>=a.length)return{visible:t.slice(),deferred:[],budget:o};const c=a.filter(e=>rr(e.annotation)),l=a.filter(e=>!rr(e.annotation)).sort((e,t)=>sr(t.annotation)-sr(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,o-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:o}}({annotations:R,width:m,height:x,...n});for(const e of i)L.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:yr)>=m)for(const e of R)br(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of R)!0===e?.defensive&&L.delete(e);let $;return $=0===L.size?R:A?R.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!L.has(e)),P?function(e,t){let n=!1;const i=e.map(e=>br(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?i:e}($,P):$}var Pr=require("react"),_r={positions:new Map},jr=new Set;function Cr(){for(const e of jr)e()}function Ir(e,t){const n=_r.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Tr(e,t){const n=_r.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Rr(){return _r}function Lr(e){return jr.add(e),()=>jr.delete(e)}var $r={positions:new Map};function Er(){return()=>{}}function zr(){return $r}function Dr(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),i=n[0],r=n[n.length-1],o=i instanceof Date,s=i instanceof Date?i.getTime():i,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return o?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=o?new Date(n):n}return l}(e,t):e.ticks(t)}var Br=require("react/jsx-runtime");function Fr(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Nr(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Or(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const i of e)t>i.pixel&&(t=i.pixel),i.pixel>n&&(n=i.pixel);return{min:t,max:n}}function Wr(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function qr(e,t,n){if("left"===e||"right"===e){const i="left"===e?n:0,r="left"===e?-1:1,o=Math.ceil(t/8);let s="M0,"+i;for(let e=0;o>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${i+4*r}`,s+=`L${Math.min(n,t)},${i}`}return s}{const i="bottom"===e?0:t,r="bottom"===e?1:-1,o=Math.ceil(n/8);let s=`M${i},0`;for(let e=0;o>e;e++){const t=8*(e+1);s+=`L${i+4*r},${Math.min(8*e+4,n)}`,s+=`L${i},${Math.min(t,n)}`}return s}}function Yr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,f=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i),a=e?.tickValues??Dr(s.x,o,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=d.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 Gr(d,Math.max(55,f+8))},[s,c,u,t,h]),p=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i);return Gr((e?.tickValues??Dr(s.y,o,h)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,Br.jsx)("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[f.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),p.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),b&&!w&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Hr(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Gr(e,t){if(2>=e.length)return e;const n=[e[0]];for(let i=1;e.length-1>i;i++)t>Math.abs(e[i].pixel-n[n.length-1].pixel)||n.push(e[i]);const i=e[e.length-1];return t>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Xr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:P,yValues:_,annotations:j,autoPlaceAnnotations:C,svgAnnotationRules:I,xAccessor:T,yAccessor:R,annotationData:L,pointNodes:$,curve:E,underlayRendered:z,canvasObscuresUnderlay:D=!0,linkedCrosshairName:B,linkedCrosshairSourceId:F,children:N}=e,O=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i),l=e?.tickValues??Dr(s.x,o,p),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=d.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),y=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Gr(d,y);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==p&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),i=g[g.length-1].pixel;if(Math.abs(t-i)>1){const r=n(e,g.length,u);y>t-i&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[a,s,c,h,t,p]),W=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i);let l=Gr((e?.tickValues??Dr(s.y,o,p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==p&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),i=l[l.length-1].pixel;if(Math.abs(n-i)>1){const r=t(e);22>Math.abs(n-i)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,f,n,p]),q=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return Gr((e.tickValues??Dr(s.y,"exact"===p?Math.max(2,r):Math.min(r,i),p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,p]),Y=(0,Un.useRef)(new Map),H=(0,Un.useRef)(j?.length??0),G=j?.length??0;H.current!==G&&(H.current=G,Y.current=new Map);const X=(0,Un.useMemo)(()=>{if(!j||0===j.length)return null;const e=Ji(),i={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:t,height:n,data:L,frameType:"xy",pointNodes:$,curve:E,stickyPositionCache:Y.current};return Qi(C?Mr({annotations:j,context:i,..."object"==typeof C?C:{}}):j,e,I,i)},[j,C,I,t,n,T,R,L,s,$,E]),V=function(e){const t=(0,Pr.useSyncExternalStore)(e?Lr:Er,e?Rr:zr,e?Rr:zr);return e?t.positions.get(e)??null:null}(B);return(0,Un.useEffect)(()=>{if(!V?.locked||!B)return;const e=e=>{"Escape"===e.key&&Tr(B)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[V?.locked,B]),a||g||m||A||M||X&&X.length>0||y||N||V?(0,Br.jsxs)("svg",{role:"img",width:i,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Br.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Br.jsx)("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&s&&(!z||D)&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[O.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),W.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),i=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,s=!i||!1!==i.baseline,a=e?.jaggedBase||!1,h=i?.jaggedBase||!1,f=i?.landmarkTicks,p=e?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!i?.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})(),b=x?12:18,v=n+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=i?.tickAnchor,M=e?.tickAnchor,P=Or(O),_=Or(W);return(0,Br.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!z||D)&&s&&!h&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:y,strokeWidth:1}),(!z||D)&&h&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:y,strokeWidth:1}),O.map((e,t)=>{const i=!!f&&("function"==typeof f?f(e.value,t):rn(e.value,t>0?O[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Br.jsx)("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{y:b,textAnchor:x?"end":Fr(A,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},transform:x?"rotate(-45)":void 0,children:e.label}):(0,Br.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),l&&(0,Br.jsx)("text",{x:t/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:l})]}),(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!z||D)&&r&&!a&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:y,strokeWidth:1}),(!z||D)&&a&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:y,strokeWidth:1}),W.map((e,t)=>{const n=!!p&&("function"==typeof p?p(e.value,t):rn(e.value,t>0?W[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Br.jsx)("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:Nr(M,e.pixel===_.min,e.pixel===_.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Br.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",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const i=!1!==e.baseline,r=e.landmarkTicks,s=e.label||d,a=e.tickAnchor,l=Or(q);return(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&(0,Br.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:y,strokeWidth:1}),q.map((e,n)=>{const i=!!r&&("function"==typeof r?r(e.value,n):rn(e.value,n>0?q[n-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Br.jsx)("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Nr(a,e.pixel===l.min,e.pixel===l.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+n)}),s&&(0,Br.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",...S},children:s})]})})()]})})(),X,M&&s&&P&&_&&(0,Br.jsxs)(Br.Fragment,{children:[M.top&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"top",config:pi(M.top),values:P,scale:s.x,size:o.top,length:t})}),M.bottom&&(0,Br.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Br.jsx)(yi,{orient:"bottom",config:pi(M.bottom),values:P,scale:s.x,size:o.bottom,length:t})}),M.left&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"left",config:pi(M.left),values:_,scale:s.y,size:o.left,length:n})}),M.right&&(0,Br.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Br.jsx)(yi,{orient:"right",config:pi(M.right),values:_,scale:s.y,size:o.right,length:n})})]}),A,V&&V.sourceId!==F&&s?.x&&(()=>{const e=s.x(V.xValue);if(null==e||0>e||e>t)return null;const i=V.locked;return(0,Br.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:i?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:i?1.5:1,strokeDasharray:i?"6,3":"4,4",pointerEvents:"none"})})(),N]}),g&&(0,Br.jsx)("text",{x:i/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}),ci({legend:m,totalWidth:i,totalHeight:r,margin:o,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}var Vr=c(require("react")),Ur=require("d3-shape");function Kr(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Zr(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,i=e=>Math.max(0,Math.min(e??0,n));return{tl:i(t.tl),tr:i(t.tr),br:i(t.br),bl:i(t.bl)}}var Qr=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Jr(e){const{innerRadius:t,outerRadius:n,startAngle:i,endAngle:r}=e,o=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(o){const e=Qr(n,i),t=Qr(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-i>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=Qr(n,i),s=Qr(n,r),a=Qr(t,r),c=Qr(t,i),l=r-i>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=o?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-i,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=r-(h?a:0),y=i+(d?c:0),g=r-(h?c:0),m=Qr(n,f),x=Qr(n,p),b=(n-s)*Math.cos(a),v=Qr(b,i),w=Qr(b,r),k=o?null:Qr(t,g),S=o?null:Qr(t,y),A=o?0:(t+s)*Math.cos(c),M=o?null:Qr(A,i),P=o?null:Qr(A,r),_=p-f>Math.PI?1:0,j=o?0:g-y>Math.PI?1:0;let C="";if(d)C+=`M${v.x},${v.y}`,C+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=Qr(n,i);C+=`M${e.x},${e.y}`}if(h)C+=` A${n},${n} 0 ${_} 1 ${x.x},${x.y}`,C+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=Qr(n,r);C+=` A${n},${n} 0 ${_} 1 ${e.x},${e.y}`}if(o)C+=" L0,0";else{if(h)C+=` L${P.x},${P.y}`,C+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=Qr(t,r);C+=` L${e.x},${e.y}`}if(d)C+=` A${t},${t} 0 ${j} 0 ${S.x},${S.y}`,C+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=Qr(t,i);C+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return C+=" Z",C}var eo=require("react/jsx-runtime"),to={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function no(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function io(e,t,n){const i=ht(e.symbolType,e.size,e.path);return(0,eo.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?no(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}function ro(e,t,n,i){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const o=an(r,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),c=dn(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?oo(i+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,i)=>{const r=t?"none"===n.fill?void 0:t:cn(n.fill,a,e.accent),o=t?n.stroke&&"none"!==n.stroke?t:void 0:cn(n.stroke??"none",a,e.accent);return r||o?(0,eo.jsx)("path",{d:n.d,fill:r??"none",stroke:o,strokeWidth:o?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},i):null});return(0,eo.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,eo.jsx)("clipPath",{id:l,children:(0,eo.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,eo.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,eo.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function oo(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function so(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return(0,eo.jsx)("path",{d:i,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 i=e;if(0===i.topPath.length)return null;const r=`M${i.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(i.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})}),(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"area-"+t)}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+t)}case"symbol":return io(e,t);case"glyph":return ro(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const n=e;return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(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),[i,r,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*i+.587*r+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,eo.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,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,eo.jsx)("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1})]},"candle-"+t)}default:return null}}function ao(e,t,n){const i=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${i}-${t}-${n}`,o=`ord-${e.type}-${i}-${t}`;switch(e.type){case"rect":{const t=e,n=oo(o)+"-grad",i=function(e,t){const n=e.fillGradient;if(!n)return null;let i=e.x,r=e.y,o=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,o=e.x,s=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,o=e.x+e.w,s=e.y);const a=[];if("colorStops"in n){const e=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>e.length)return null;for(let t=0;e.length>t;t++)a.push((0,eo.jsx)("stop",{offset:e[t].offset,stopColor:e[t].color},t))}else{const t=no(e.style.fill);a.push((0,eo.jsx)("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),a.push((0,eo.jsx)("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return(0,eo.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:o,y2:s,children:a})}(t,n),r=i?`url(#${n})`:no(t.style.fill);if(t.cornerRadii&&Kr(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:i,h:r}=e,{tl:o,tr:s,br:a,bl:c}=Zr(e);let l=`M${t+o},${n}`;return l+=` L${t+i-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+i},${n+s}`),l+=` L${t+i},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+i-a},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+o}`,o>0&&(l+=` A${o},${o} 0 0 1 ${t+o},${n}`),l+=" Z",l}(t);return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:e,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:s,w:a,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n},${s+c} Z`;break;case"left":l=`M${n+a},${s} L${n+e},${s} A${e},${e} 0 0 0 ${n},${s+e} L${n},${s+c-e} A${e},${e} 0 0 0 ${n+e},${s+c} L${n+a},${s+c} Z`;break;case"bottom":l=`M${n},${s} L${n+a},${s} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n+e},${s+c} A${e},${e} 0 0 1 ${n},${s+c-e} Z`;break;default:l=`M${n},${s+c} L${n},${s+e} A${e},${e} 0 0 1 ${n+e},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c} Z`}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:l,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}case"point":{const t=e;return(0,eo.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:no(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}case"symbol":return io(e,t,n);case"glyph":return ro(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const i=e;if(i._gradientBand&&i._gradientBand.colors.length>0){const e=oo(`${n?n+"-":""}gauge-grad-${i.category||o}-${t}`),{clipPath:r,slices:s}=function(e){const t=Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],i=e.colors;if(i.length>0){const t=(e.endAngle-e.startAngle)/i.length;for(let r=0;i.length>r;r++)n.push({d:Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:i[r]})}return{clipPath:t,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds?.start??!0,roundEnd:i.roundedEnds?.end??!0,colors:i._gradientBand.colors});return(0,eo.jsxs)("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("path",{d:r})})}),(0,eo.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,eo.jsx)("path",{d:e.d,fill:no(e.color)},t))}),i.style.stroke&&"none"!==i.style.stroke&&(0,eo.jsx)("path",{d:r,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},o)}let r;if(i.roundedEnds)r=Jr({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const e=(0,Ur.arc)().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&e.cornerRadius(i.cornerRadius),r=e(to)||""}return(0,eo.jsx)("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},o)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,eo.jsxs)("g","vertical"===t.projection?{children:[(0,eo.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,eo.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},o)}case"violin":{const t=e,n=[(0,eo.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,i=e.x+e.width/2,o=e.y+e.height/2;e.height>e.width?n.push((0,eo.jsx)("line",{x1:i,y1:t.iqrLine.q1Pos,x2:i,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:i,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,eo.jsx)("line",{x1:t.iqrLine.q1Pos,y1:o,x2:t.iqrLine.q3Pos,y2:o,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:t.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,eo.jsx)("g",{children:n},o)}case"connector":return(0,eo.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??.5},o);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return(0,eo.jsx)("polygon",{points:n,fill:no(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}default:return null}}var co="undefined"==typeof window||"undefined"==typeof document,lo=require("react"),uo="undefined"!=typeof window?lo.useLayoutEffect:lo.useEffect;function ho(){const[e,t]=(0,lo.useState)(!1);return uo(()=>{t(!0)},[]),e}var fo=()=>()=>{},po=()=>!1,yo=()=>!0;function go(){const e=(0,lo.useSyncExternalStore)(fo,po,yo);return(0,lo.useRef)(e).current}function mo(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:o,cancelRender:s,cleanup:a}=e;uo(()=>{t&&n&&i.current?.cancelIntroAnimation?.(),r.current=!0,s?.(),o.current()},[t,n]);const c=(0,lo.useRef)(a);c.current=a,(0,lo.useEffect)(()=>()=>c.current?.(),[])}var xo=require("react");function bo(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Object.is(e[i],t[i]))return!1}return!0}function vo(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 wo(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}var ko={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 So(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],i=n[2],r=n[3];return`#${e}${e}${i}${i}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ao=c(require("react")),Mo=c(require("react")),Po=(require("react/jsx-runtime"),Mo.createContext(null));function _o(){return Mo.useContext(Po)}function jo(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,i]of Object.entries(e))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(t[n]=i):"string"==typeof i?t[n]=i:"boolean"==typeof i?t[n]=i+"":i instanceof Date&&(t[n]=i.toISOString().slice(0,10)));return t}function Co(e){return e&&"object"==typeof e?e:{}}function Io(e){return Co(e.accessibility).tableFields??e.accessibleDatum??e.datum}var To=require("react/jsx-runtime"),Ro={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Lo(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 i=[],r={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),i=o.indexOf(t);return(-1===n?999:n)-(-1===i?999:i)});for(const e of s)i.push(`${n[e]} ${r[e]||e}`);return`${t}, ${i.join(", ")}`}var $o=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Eo="semiotic-accessible-data-table",zo=Eo+" semiotic-accessible-data-table-hidden",Do=Eo+" semiotic-accessible-data-table-visible",Bo={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"},Fo={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},No={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)"},Oo={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Wo={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))"},qo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Yo={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 Go({scene:e,chartType:t,tableId:n,chartTitle:i}){const[r,o]=Ao.useState(!1),[s,a]=Ao.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=Ao.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ao.useEffect(()=>{u||a(5)},[u]);const f=Ao.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=Ao.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!e||0===e.length)return n?(0,To.jsx)("span",{id:n,tabIndex:-1,style:Ro}):null;if(!u)return(0,To.jsx)("div",{id:n,className:zo,tabIndex:-1,onFocus:f,style:Ro,role:"region","aria-label":h,children:(0,To.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",e.length," elements)"]})});const y=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const i of e)if(i&&"object"==typeof i&&null!==i.datum)try{switch(i.type){case"point":if(n)break;t.push({label:"Point",values:jo(Io(i))});break;case"line":case"area":{const e=Io(i),n=Array.isArray(e)?e:[],r="line"===i.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:jo(e)});break}case"rect":{const e=Io(i),n=null!=e&&"object"==typeof e?e:{},r=n.category??i.group??"",o=n.value??n.__aggregateValue??n.total,s=jo(n);null==s.category&&""!==r&&(s.category=r+""),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=jo(Io(i));null==e.value&&"number"==typeof i.value&&Number.isFinite(i.value)&&(e.value=i.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Io(i),n=jo(e);if(null==n.category){const t=Co(e),i=t.category??t.label;null!=i&&(n.category=i+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:jo(Io(i))});break;case"arc":t.push({label:"Arc",values:jo(Io(i))});break;case"candlestick":t.push({label:"Candlestick",values:jo(Io(i))});break;case"geoarea":{const e=Co(Io(i)),n=jo(e);if(null==n.name){const t=Co(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 i of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[i];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],o=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),o+=n;n.push({name:i,count:t.length,numeric:!0,min:e,max:r,mean:o/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:i,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${$o(e.min)} to ${$o(e.max)}, mean ${$o(e.mean)}.`);else{const t=e.uniqueValues,i=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${i}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const e of b)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return(0,To.jsxs)("div",{ref:d,id:n,className:Do,tabIndex:-1,onBlur:p,style:Bo,role:"region","aria-label":h,children:[(0,To.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},"aria-label":"Close data summary",style:No,children:"×"}),(0,To.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Fo,children:m}),(0,To.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Oo,children:[(0,To.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Yo,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,To.jsx)("thead",{children:(0,To.jsxs)("tr",{children:[(0,To.jsx)("th",{style:Wo,children:"type"}),k.map(e=>(0,To.jsx)("th",{style:Wo,children:e},e))]})}),(0,To.jsx)("tbody",{children:b.map((e,t)=>(0,To.jsxs)("tr",{children:[(0,To.jsx)("td",{style:qo,children:e.label}),k.map(t=>{return(0,To.jsx)("td",{style:qo,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":$o(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,To.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ho,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function Xo({summary:e}){return e?(0,To.jsx)("div",{role:"note",style:Ro,children:e}):null}function Vo({tableId:e}){return(0,To.jsx)("a",{href:"#"+e,style:Ro,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,Ro)},children:"Skip to data table"})}function Uo({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,To.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ro,children:t})}var Ko=require("react/jsx-runtime"),Zo="var(--semiotic-focus, #005fcc)";function Qo({active:e,hoverPoint:t,margin:n,size:i,shape:r="circle",width:o,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=o&&null!=s){const e=Math.max(o,4),t=Math.max(s,4);u=(0,Ko.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Ko.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Ko.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Ko.jsx)("path",{d:a,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Ko.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Jo=c(require("react")),es=require("react/jsx-runtime");function ts({x:e,y:t,containerWidth:n,containerHeight:i,margin:r,children:o,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=Jo.useRef(null),[u,d]=Jo.useState(null);Jo.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[o,s,n,i]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Jo.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 i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background&&"transparent"!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor&&"transparent"!==i.backgroundColor)return!0}return!1}(o),p=f?null:V;return c?(0,es.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:o}):null}var ns=c(require("react")),is=require("react"),rs=require("react");var os=require("react"),ss="undefined"==typeof window?is.useEffect:is.useLayoutEffect,as={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function cs(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function ls(e){const t=function(){const[e,t]=(0,rs.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,rs.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,is.useRef)(t);n.current=t;const[i,r]=function(e,t,n){const i=(0,os.useRef)(null),[r,o]=(0,os.useState)(null);return(0,os.useEffect)(()=>{if(!t&&!n)return;const e=i.current;if(!e)return;const r=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 r.observe(e),()=>r.disconnect()},[t,n]),[i,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=(0,is.useMemo)(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),s=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,c=cs(e.foregroundGraphics,r,o),l=cs(e.backgroundGraphics,r,o),u=Pe(e=>e.theme),{transition:d,introEnabled:h}=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-"+ns.useId(),p=(0,is.useRef)(null),y=(0,is.useRef)(e.frameScheduler??as);y.current=e.frameScheduler??as;const g=(0,is.useRef)(null),m=(0,is.useRef)(!1),x=(0,is.useRef)(()=>{}),b=(0,is.useCallback)(()=>{if(null!==p.current||m.current)return;const e=y.current;let t=!1,n=!1;const i=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(m.current=!0),p.current=null,g.current=null;try{x.current()}finally{e&&(m.current=!1)}});n=!0,t||(p.current=i,g.current=e)},[]),v=(0,is.useCallback)(()=>{null!==p.current&&((g.current??y.current).cancelAnimationFrame(p.current),p.current=null,g.current=null)},[]);(0,is.useEffect)(()=>()=>{v()},[v]);const w=(0,is.useRef)(()=>{}),k=(0,is.useRef)(()=>{}),S=(0,is.useRef)(null),A=(0,is.useRef)(null),M=(0,is.useRef)(null),P=(0,is.useCallback)(()=>{const e=S.current;S.current=null,e&&w.current(e)},[]),_=(0,is.useCallback)(e=>{if(S.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===A.current){const e=y.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,A.current=null,M.current=null,P()});t||(A.current=n,M.current=e)}},[P]),j=(0,is.useCallback)(()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null),k.current()},[]);(0,is.useEffect)(()=>()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null)},[]);const C=e.themeDirtyRef;return ss(()=>{C&&(gn++,C.current=!0,b())},[u,b,C]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:i,size:r,margin:o,adjustedWidth:s,adjustedHeight:a,resolvedForeground:c,resolvedBackground:l,currentTheme:u,transition:d,introEnabled:h,tableId:f,rafRef:p,renderFnRef:x,scheduleRender:b,cancelRender:v,hoverHandlerRef:w,hoverLeaveRef:k,onPointerMove:_,onPointerLeave:j}}function us(e,t,n,i){const r=e.getContext("2d");if(!r)return null;const o=Math.round(t[0]*i),s=Math.round(t[1]*i),a=o/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===o&&e.height===s||(e.width=o,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}function ds(){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 hs=require("react");function fs(e,t,n,i){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:i,fn:t}:{key:void 0,fn:null}}var ps=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ys=3156e7;function gs(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")}`}:ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function ms(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:ft(n.size)});else if("glyph"===n.type){const e=hn(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 xs=require("d3-shape");function bs(e,t,n){let i=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(i=n.color):e>n.value&&(i=n.color);return i}function vs(e,t,n,i,r,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],i=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=i,e.lineCap=o;for(let n=0;t.length-1>n;n++){const i=(s[n]+s[n+1])/2;let o=r;c>i&&(o*=i/c),c>a-i&&(o*=(a-i)/c),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 ws=(e,t,n,i)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,i.width*n,i.height),e.clip());const r=t.style.stroke||"#007bff",o=vn(e,r)||r,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){vs(e,t.path,o,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=kn(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=o;const n=t.style.opacity??1;for(let i=0;t.path.length-1>i;i++)e.globalAlpha=.5*(d[i]+d[i+1])*n,e.beginPath(),e.moveTo(t.path[i][0],t.path[i][1]),e.lineTo(t.path[i+1][0],t.path[i+1][1]),e.stroke()}else if(u){let n=function(t,n,i){e.beginPath(),e.strokeStyle=t,e.moveTo(n,i),d=!0},i=function(){d&&(e.stroke(),d=!1)},r=null,s=null,l=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=c[d],y=bs(p,a,o);if(null!==r&&null!==u&&null!==l){if(y===u)e.lineTo(h,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>p)&&(n>l||p>n)||l===n||p===n||t.push({t:(n-l)/(p-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=r+(h-r)*c.t,u=s+(f-s)*c.t,d=bs(l+(p-l)*Math.min(c.t+1e-4,1),a,o);e.lineTo(t,u),i(),n(d,t,u)}e.lineTo(h,f)}r=h,s=f,l=p,u=y}else n(y,h,f),r=h,s=f,l=p,u=y}i()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Mn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||o,l)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);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=Sn(e,t.style.fill,t.style.fill),l&&!u)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);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],i.height),e.lineTo(n,i.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function ks(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ss(e,t,n=.3){ks(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 As(e,t,n=.6){if(!ks(t))return;const i=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,o=t.cy??t.y??0;e.beginPath(),e.arc(r,o,i,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 Ms(e,t,n,i=.35){ks(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Ps=require("d3-shape");function _s(e,t){const n=kn(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 i=(0,Ps.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),i(t.topPath)}}var js=(e,t,n,i)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){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 r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,i.width*r,i.height),e.clip());const o=Sn(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 i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(s[i]+s[i+1])*n,e.beginPath(),e.moveTo(t.topPath[i][0],t.topPath[i][1]),e.lineTo(t.topPath[i+1][0],t.topPath[i+1][1]),e.lineTo(t.bottomPath[i+1][0],t.bottomPath[i+1][1]),e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=vn(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(_s(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 i=-1/0;for(const e of t.bottomPath)e[1]>i&&(i=e[1]);const r=An(e,t.fillGradient,"string"==typeof o?o:"#4e79a7",0,n,0,i);e.fillStyle=r||o,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=o;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(_s(e,t),Ms(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?Mn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const i=kn(t.curve);if(e.beginPath(),i)(0,Ps.line)().x(e=>e[0]).y(e=>e[1]).curve(i).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!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Cs=(e,t,n,i)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)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=Sn(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Sn(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),As(e,n)}finally{e.restore()}}},Is=new Map;function Ts(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Is.get(t);return n||(n=new Path2D(ht(e.symbolType,e.size)),Is.size>256&&Is.clear(),Is.set(t,n)),n}catch{return null}}var Rs=(e,t)=>{const n=e.globalAlpha;for(const i of t){if("symbol"!==i.type)continue;const t=i;if(0>=t.size)continue;const r=Ts(t);if(!r)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=Sn(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=Sn(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function Ls(e,t,n,i,r){if(0>=t.size)return;const o=t.glyph;if(!o||!o.parts?.length)return;const s=an(o,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Sn(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,i),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=dn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&fn(e,o,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),fn(e,o,l,t.accent,void 0,c),e.restore()}function $s(e,t){const{x:n,y:i,w:r,h:o}=t,{tl:s,tr:a,br:c,bl:l}=Zr(t);e.beginPath(),e.moveTo(n+s,i),e.lineTo(n+r-a,i),a>0&&e.arcTo(n+r,i,n+r,i+a,a),e.lineTo(n+r,i+o-c),c>0&&e.arcTo(n+r,i+o,n+r-c,i+o,c),e.lineTo(n+l,i+o),l>0&&e.arcTo(n,i+o,n,i+o-l,l),e.lineTo(n,i+s),s>0&&e.arcTo(n,i,n+s,i,s),e.closePath()}function Es(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 zs=(e,t,n,i)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Ds(e,t);else if(t.cornerRadii&&Kr(t.cornerRadii)){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n,$s(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n;const o=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+o,a),e.arcTo(s,a,s,a+o,o),e.lineTo(s,a+l-o),e.arcTo(s,a+l,s+o,a+l,o),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s+o,a+l),e.arcTo(s,a+l,s,a+l-o,o);break;default:e.moveTo(s,a+l),e.lineTo(s,a+o),e.arcTo(s,a,s+o,a,o),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Ss(e,t),e.globalAlpha=1}};function Ds(e,t){const n=t.style.icon,i=t.style.iconPadding||2,r=Math.min(t.w,t.h)-i;if(0>=r)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=r+i,s=t.x+(t.w-r)/2;for(let i=t.y+t.h-r;i>=t.y-r;i-=o)e.drawImage(n,s,i,r,r)}else{const o=r+i,s=t.y+(t.h-r)/2;for(let i=t.x;t.x+t.w>i;i+=o)e.drawImage(n,i,s,r,r)}e.restore()}function Bs(e){const[t,n,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*i>128?"#000":"#fff"}function Fs(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ns=(e,t,n,i)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){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=vn(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Ss(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):Fs(t.value),i=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=Bs(t.fill),e.font=i+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,o)}}}finally{e.restore()}},Os=(e,t,n,i)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const o=vn(e,t.wickColor)||t.wickColor,s=60>i.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=o,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*i.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),i=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,o=vn(e,r)||r;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1))}s&&c(),e.restore()}},Ws={line:[js,ws,Cs],area:[js,Cs],stackedarea:[js,Cs],scatter:[Cs,Rs],bubble:[Cs,Rs],heatmap:[Ns],bar:[zs],swarm:[Cs],waterfall:[(e,t,n,i)=>{zs(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const o=r[0].datum,s=o?._connectorStroke;if(s){e.save(),e.strokeStyle=vn(e,s)||s,e.lineWidth=o?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const i=r[t],o=r[t+1],s=i.datum,a=o.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=i.x+i.w,u=o.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Os],mixed:[js,ws,Cs],custom:[js,zs,Ns,ws,Cs,Rs,(e,t)=>{const n=e.globalAlpha;for(const i of t)"glyph"===i.type&&Ls(e,i,i.x,i.y,n);e.globalAlpha=n},Os]};require("react/jsx-runtime");var qs=require("react/jsx-runtime");function Ys(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Hs({hover:e}){const t=e.data??{},n=t.y??t.value,i=t.x??t.time;if(void 0===n&&void 0===i){const e=function(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,i=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(i&&H.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let o=r.findIndex(e=>W.includes(e.lower));const s=o>=0;0>o&&(o=r.findIndex(e=>"id"===e.lower)),0>o&&(o=r.findIndex(e=>"string"==typeof e.value));const a=0>o?void 0:r[o];let c=r.filter((e,t)=>t!==o);s&&(c=c.filter(e=>"id"!==e.lower));const l=G(c,q),u=G(c,Y),d=new Set(q),h=new Set(Y),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}(t);if(null!=e.title||e.entries.length>0)return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[null!=e.title&&(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,qs.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,qs.jsx)("span",{style:{fontWeight:600},children:Ys(e.value)})]},e.key))]})}return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Ys(n)}),(0,qs.jsx)("div",{style:{opacity:.7,fontSize:11},children:Ys(i)})]})}Hs.ownsChrome=!0;var Gs=require("react/jsx-runtime"),Xs={top:20,right:20,bottom:30,left:40},Vs=ko;function Us(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Ks=(0,ie.memo)((0,ie.forwardRef)(function(e,t){const{chartType:n,runtimeMode:i,data:r,chunkThreshold:o,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:P,yExtent:_,extentPadding:j=.1,scalePadding:C,sizeRange:I,size:T=[500,300],responsiveWidth:R,responsiveHeight:L,margin:$,className:E,background:z,lineStyle:D,pointStyle:N,areaStyle:W,barStyle:q,waterfallStyle:Y,swarmStyle:H,barColors:G,colorScheme:X,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:Q,lineGradient:J,areaGroups:ee,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,showAxes:ce=!0,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ye,yFormat:ge,axisExtent:me,tickFormatTime:be,tickFormatValue:ve,hoverAnnotation:we,tooltipContent:ke,customHoverBehavior:Se,customClickBehavior:Ae,enableHover:Me,hoverRadius:Pe=30,tooltipMode:_e,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,showGrid:Te,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,legendCategoryAccessor:Fe,onCategoriesChange:Ne,backgroundGraphics:Oe,foregroundGraphics:We,canvasPreRenderers:qe,svgPreRenderers:Ye,title:He,categoryAccessor:Ge,brush:Xe,onBrush:Ve,decay:Ue,pulse:Ke,transition:Ze,animate:Qe,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,marginalGraphics:st,pointIdAccessor:at,xScaleType:ct,yScaleType:lt,accessibleTable:ut=!0,description:dt,summary:ht,linkedCrosshairName:ft,linkedCrosshairSourceId:pt,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutSelection:xt}=e,bt=(0,ie.useId)().replace(/:/g,""),vt=(0,ie.useRef)(!1),wt=(0,ie.useRef)({w:-1,h:-1}),kt=(0,ie.useRef)(!1),St=ls({sizeProp:T,responsiveWidth:R,responsiveHeight:L,userMargin:$,marginDefault:Xs,animate:Qe,transitionProp:Ze,themeDirtyRef:vt}),At=ho(),Mt=go(),{reducedMotionRef:Pt,responsiveRef:_t,size:jt,currentTheme:Ct,transition:It,introEnabled:Tt,tableId:Rt,rafRef:Lt,renderFnRef:$t,scheduleRender:Et,cancelRender:zt}=St;let Dt=St.margin;if(st){const e=60,t={...St.margin};st.top&&e>t.top&&(t.top=e),st.bottom&&e>t.bottom&&(t.bottom=e),st.left&&e>t.left&&(t.left=e),st.right&&e>t.right&&(t.right=e),Dt=t}const Bt=jt[0]-Dt.left-Dt.right,Ft=jt[1]-Dt.top-Dt.bottom,Nt=(0,ie.useMemo)(()=>B(r),[r]),Wt=we??Me,qt=(0,ie.useRef)(null),Yt=(0,ie.useRef)(null),[Gt,Vt]=(0,ie.useState)(0),Ut=(0,ie.useRef)(0),[Kt,Zt]=(0,ie.useState)(null),en=(e,t)=>"function"==typeof e?e({size:jt,margin:Dt,scales:t}):e,tn=en(We,Kt),nn=en(Oe,Kt),rn=(0,ie.useRef)(null),on=(0,ie.useRef)(null),sn=(0,ie.useRef)(void 0),[an,cn]=(0,ie.useState)(null),ln=(0,ie.useRef)(Vs.primary),un=(0,ie.useRef)(function(){let e=-1,t=ko;return{resolve(n){if(!n)return ko;const i=gn;return i===e||(t=function(e){if(!e)return ko;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),i=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),o=t.getPropertyValue("--semiotic-primary").trim(),s=i||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||o?{axisStroke:c||ko.axisStroke,tickText:s||ko.tickText,crosshair:s?So(s,"66"):ko.crosshair,hoverFill:l?So(l,"4D"):ko.hoverFill,hoverStroke:s?So(s,"99"):ko.hoverStroke,pointRing:l||ko.pointRing,primary:o||ko.primary,background:l||ko.background}:ko}(n),e=i),t},invalidate(){e=-1}}}()),dn=(0,ie.useRef)(!1),fn=(0,ie.useRef)(new Ht),pn=(0,ie.useRef)([]),yn=(0,ie.useRef)(Fe),mn=(0,ie.useRef)(Ne);yn.current=Fe,mn.current=Ne;const[xn,bn]=(0,ie.useState)(!1),[wn,kn]=(0,ie.useState)([]),[Sn,An]=(0,ie.useState)([]),Mn="streaming"===i||["bar","swarm","waterfall"].includes(n),Pn=function(e){const t=(0,xo.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return vo(e,t);if(!wo(e)||!wo(t))return!1;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;const n=e[i],r=t[i];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!vo(n,r))return!1}else{if(!wo(n)||!wo(r))return!1;if(!bo(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,ie.useMemo)(()=>({chartType:n,runtimeMode:Mn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Mn?k:"right",extentPadding:j,scalePadding:C,axisExtent:me,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Mn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Ge,lineDataAccessor:y,xScaleType:ct,yScaleType:lt,xExtent:P,yExtent:_,sizeRange:I,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:!0===Q?{topOpacity:.8,bottomOpacity:.05}:!1===Q?void 0:Q,areaGroups:ee?new Set(ee):void 0,lineGradient:J,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,lineStyle:D,pointStyle:N,areaStyle:W,swarmStyle:H,waterfallStyle:Y,colorScheme:X,barColors:G,barStyle:q,annotations:je,decay:Ue,pulse:Ke,transition:It,introAnimation:Tt,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,pointIdAccessor:at,curve:g,themeCategorical:Ct?.colors?.categorical,themeSemantic:xe(Ct),themeSequential:Ct?.colors?.sequential,themeDiverging:Ct?.colors?.diverging,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutMargin:Dt}),[n,A,S,k,j,C,me,a,c,l,M,w,ct,lt,u,d,h,f,p,Ge,y,P,_,I,v,m,x,b,V,U,K,Z,Q,J,ee,te,re,oe,se,ae,D,N,W,H,Y,q,X,G,je,Ue,Ke,It?.duration,It?.easing,Tt,Je,et,tt,nt,it,rt,Mn,at,g,Ct,yt,gt,mt,Dt])),_n=(0,ie.useRef)(null);_n.current||(_n.current=new Ot(Pn));const Tn=function(e,t,n,i){return(0,hs.useCallback)(()=>{const r=t.current,o=n.current;if(!o||!r)return;const s=function(e,t){if(!t)return[];const n=new Set,i=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const o=e+"";n.has(o)||(n.add(o),i.push(o))}return i}(e.current?.getData()??[],r);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,o(s))},[t,n,i,e])}(_n,yn,mn,pn);!function(e,t,n,i){(0,Jt.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,i()},[t,i,e,n])}(_n,Pn,vt,Et),function(e,t,n,i){const r=(0,Jt.useRef)(null);(0,Jt.useEffect)(()=>{const o=e.current;if(!o)return;const s=t??null;r.current!==s&&(r.current=s,o.setLayoutSelection(s),o.hasCustomRestyle?o.restyleScene(s):n.current=!0,i())},[t,i,e,n])}(_n,xt,vt,Et);const Rn=(0,ie.useRef)(null);Rn.current||(Rn.current=new fe(e=>{const t=_n.current;t&&t.ingest(e)&&(vt.current=!0,Et())},{chunkThreshold:o,chunkSize:s})),(0,ie.useEffect)(()=>{Rn.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const Ln=(0,ie.useCallback)(e=>{Rn.current?.push(e)},[]),$n=(0,ie.useCallback)(e=>{Rn.current?.pushMany(e)},[]),En=(0,ie.useCallback)(()=>{Rn.current?.clear(),_n.current?.clear(),vt.current=!0,Et()},[Et]);(0,ie.useImperativeHandle)(t,()=>({push:Ln,pushMany:$n,remove:e=>{Rn.current?.flush();const t=_n.current?.remove(e)??[];return t.length>0&&(rn.current&&t.some(e=>e===rn.current?.data)&&(rn.current=null,cn(null)),vt.current=!0,Et()),t},update:(e,t)=>{Rn.current?.flush();const n=_n.current?.update(e,t)??[];return n.length>0&&(vt.current=!0,Et()),n},clear:En,getData:()=>(Rn.current?.flush(),_n.current?.getData()??[]),getScales:()=>_n.current?.scales??null,getExtents:()=>_n.current?.getExtents()??null,getCustomLayout:()=>_n.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>_n.current?.lastCustomLayoutFailure??null}),[Ln,$n,En,Et]),(0,ie.useEffect)(()=>{if(r){if(y&&Nt.length>0&&"object"==typeof Nt[0]&&null!==Nt[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(Nt[0][e])){const t=[];for(const n of Nt){const i=n[e];if(Array.isArray(i)){const e=n.label||n.id||n.key;if(null!=e)for(const n of i)t.push({...n,_lineGroup:e});else for(const e of i)t.push(e)}}return void Rn.current?.setBoundedData(t)}}Rn.current?.setBoundedData(Nt)}},[r,Nt,y]);const{hoverHandlerRef:zn,hoverLeaveRef:Dn,onPointerMove:Bn,onPointerLeave:Fn}=St;zn.current=e=>{if(!Wt)return;const t=qt.current;if(!t)return;const i=t.getBoundingClientRect(),r=e.clientX-i.left-Dt.left,o=e.clientY-i.top-Dt.top;if(0>r||r>Bt||0>o||o>Ft)return void(rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et()));const s=_n.current;if(!s||0===s.scene.length)return;const c=F(Pe,e.pointerType),l=Cn(s.scene,r,o,c,s.quadtree,s.maxPointRadius),u="multi"===_e,d=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&Se(null),Et())};if(!l&&!u)return void d();const h=u||!l?r:l.x,f=u||!l?o:l.y,p=l?.datum?ot(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=O(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const i=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const o=In(jn(e.path,e.curve),t,n);if(null===o)continue;const s=Nn(e.path,t);i.push({node:r,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"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const o=jn(e.topPath,e.curve),s=jn(e.bottomPath,e.curve),a=In(o,t,n);if(null===a)continue;const c=In(s,t,n),l=Nn(e.topPath,t);i.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return i}(s.scene,h,Math.max(c,Bt));if(e.length>0){const t=s.scales.y.invert,i=ln.current,r=y?y(h):h;if(l)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=O(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=o?r-o:r,valuePx:e.y,color:e.color||i,datum:ot(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(rn.current=m,on.current=l?.node??null,cn(m),Se&&(Se(m),vt.current=!0),Et()):d()},Dn.current=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et())};const Yn=(0,ie.useRef)(()=>{});Yn.current=e=>{if(!Ae)return;const t=qt.current;if(!t)return;const n=t.getBoundingClientRect(),i=e.clientX-n.left-Dt.left,r=e.clientY-n.top-Dt.top;if(0>i||i>Bt||0>r||r>Ft)return void Ae(null);const o=_n.current;if(!o||0===o.scene.length)return void Ae(null);const s=F(Pe,sn.current),a=Cn(o.scene,i,r,s,o.quadtree,o.maxPointRadius);if(!a)return void Ae(null);const c=a.datum||{},l=o.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Ae(O(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Hn=(0,ie.useCallback)(e=>Yn.current(e),[]),Xn=(0,ie.useRef)(-1),Un=(0,ie.useRef)(null),Kn=(0,ie.useRef)(null),Zn=(0,ie.useCallback)(e=>{const t=_n.current;if(!t||0===t.scene.length)return;const n=t.version;let i;if(Kn.current&&Kn.current.version===n)i=Kn.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=hn(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,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&i.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:i[n],shape:"circle",group:r});break}case"area":{const e=n,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&i.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:i[n],shape:"circle",group:r});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;i=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let i=t.get(e);i||(i=[],t.set(e,i)),i.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 i=t.get(e),r=t.get(n);return(i.length>0?i[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(t.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=i[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:i,groups:n,byGroup:t,idToIdx:r}}(e),Kn.current={version:n,graph:i}}const r=Xn.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Xn.current=0;const n=i.flat[0];Un.current={shape:n.shape,w:n.w,h:n.h};const r=Wn({...n,datum:ot(n.datum,t.resolvedRibbons)});return rn.current=r,cn(r),Se&&Se(r),void Et()}const o=function(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)),i=e.flat[n];return{flatIndex:n,group:i.group??"_default",indexInGroup:i._groupIndex??0}}(i,r),s=function(e,t,n){const{group:i,indexInGroup:r}=t,o=n.byGroup.get(i);switch(e){case"ArrowRight":return o.length-1>r?o[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?o[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(i);return n.groups.length-1>e?On(n,n.groups[e+1],o[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(i);return e>0?On(n,n.groups[e-1],o[r]):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}}(e.key,o,i);if(null===s)return;if(e.preventDefault(),0>s)return Xn.current=-1,Un.current=null,rn.current=null,on.current=null,cn(null),Se&&Se(null),void Et();Xn.current=s;const a=i.flat[s];Un.current={shape:a.shape,w:a.w,h:a.h};const c=Wn({...a,datum:ot(a.datum,t.resolvedRibbons)});rn.current=c,cn(c),Se&&Se(c),Et()},[Se,Et]),Qn=(0,ie.useCallback)(e=>{sn.current=e.pointerType,Xn.current=-1,Un.current=null,Bn(e)},[Bn]),Jn=(0,ie.useCallback)(e=>{sn.current="mouse",Xn.current=-1,Un.current=null,Bn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Bn]),ei=(0,ie.useCallback)(e=>{sn.current=e.pointerType},[]);$t.current=()=>{Lt.current=null;const e=qt.current,t=Yt.current;if(!e||!t)return;const i=_n.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=i.advanceTransition(Pt.current?r+1e6:r),s=!Pt.current&&o,l=wt.current.w!==Bt||wt.current.h!==Ft,u=vt.current||o||l,d=i.consumeStylePaintPending();let h=!1;const f=i.getLastUpdateResult(),p=fn.current.beforeCompute(f,s);!u||s&&!l||(i.computeScene({width:Bt,height:Ft}),wt.current={w:Bt,h:Ft},h=!0,Tn()),fn.current.afterCompute(p,h,l);const y=function(e,t,n,i){const r=i.current,o=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!o&&e.hasActivePulsesAt(t),a=!(n||o||!s&&!r)&&e.refreshPulse(t);return i.current=s,{changed:a,pending:s}}(i,r,h,kt),g=ds(),m=un.current.resolve(e);ln.current=m.primary;const x=Gn(Je,i.lastIngestTime>0?r-i.lastIngestTime:0),b=Je&&x.isStale;if(u||d||y.changed){const t=us(e,jt,Dt,g);if(t){if(t.clearRect(-Dt.left,-Dt.top,jt[0],jt[1]),Je&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:i=!1,themeBackground:r="",x:o=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(i)return!1;const l=n||(r&&"transparent"!==r?r:"")||null;if(!l)return!1;const u=vn(e,l);u&&(e.fillStyle=u,e.fillRect(o,s,a,c))}(t,{background:z,hasBackgroundGraphics:!!Oe,themeBackground:m.background,x:-Dt.left,y:-Dt.top,width:jt[0],height:jt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Bt,Ft),t.clip()),qe&&i.scales)for(const e of qe)t.save(),e(t,i.scene,i.scales,{width:Bt,height:Ft}),t.restore();const e=yt?Ws.custom:Ws[n];if(e&&i.scales)for(const n of e)n(t,i.scene,i.scales,{width:Bt,height:Ft});t.restore(),Je&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(Wt&&rn.current&&i.scales),w=!!(on.current&&Array.isArray(we)&&we.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||dn.current){const e=us(t,jt,Dt,g);if(e&&(e.clearRect(-Dt.left,-Dt.top,jt[0],jt[1]),v&&rn.current&&function(e,t,n,i,r,o,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,i),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=r.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,rn.current,Bt,Ft,"object"==typeof Wt?Wt:{},on.current,m),w&&on.current&&Array.isArray(we))){const t=we.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,i,r){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 i.style?n.datum?i.style(n.datum):{}:i.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||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,i.scene,on.current,t,m)}dn.current=k}u&&e&&e.setAttribute("aria-label",Lo(i.scene,n+" chart"));const S=vt.current;if(vt.current=S&&s&&!h,S&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Kt||e(Kt.x.domain()[0])!==e(i.scales.x.domain()[0])||e(Kt.x.domain()[1])!==e(i.scales.x.domain()[1])||e(Kt.y.domain()[0])!==e(i.scales.y.domain()[0])||e(Kt.y.domain()[1])!==e(i.scales.y.domain()[1])||Kt.x.range()[0]!==i.scales.x.range()[0]||Kt.x.range()[1]!==i.scales.x.range()[1]||Kt.y.range()[0]!==i.scales.y.range()[0]||Kt.y.range()[1]!==i.scales.y.range()[1])&&Zt(i.scales),st){const e=i.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];kn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),An(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((je&&je.length>0||yt)&&(h||s))||!h&&33>r-Ut.current||(Vt(e=>e+1),Ut.current=r),Je?.showBadge&&bn(!!b),(s||null!=i.activeTransition||y.pending)&&Et()},mo({hydrated:At,wasHydratingFromSSR:Mt,storeRef:_n,dirtyRef:vt,renderFnRef:$t,cancelRender:zt,cleanup:()=>Rn.current?.clear()}),(0,ie.useEffect)(()=>{vt.current=!0,Et()},[n,Bt,Ft,ce,z,Oe,D,qe,Et]),function(e,t,n,i,r,o){const s=(0,qn.useRef)("fresh");(0,qn.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Gn(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&o(l.isStale),n.current=!0,i())},1e3);return()=>clearInterval(a)},[e,r,i])}(Je,_n,vt,Et,xn,bn);const ti=(0,ie.useMemo)(()=>{if(ye||be)return;const e=_n.current;return e?.xIsDate&&Kt?gs(Kt.x.domain()):void 0},[ye,be,Kt]),ni=ye||be||ti,ii=Wt&&an?ke?ke(an):(0,Gs.jsx)(Hs,{hover:an}):null,ri=ii?(0,Gs.jsx)(ts,{x:an.x,y:an.y,containerWidth:Bt,containerHeight:Ft,margin:Dt,className:"stream-frame-tooltip",children:ii}):null,oi=Un.current,si=(0,Gs.jsx)(Qo,{active:Xn.current>=0,hoverPoint:an,margin:Dt,size:jt,shape:oi?.shape,width:oi?.w,height:oi?.h}),ai=fs(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),ci=fs(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),li=ai.key,ui=ci.key,di=function(e,t,n){return i=>{if(!i||!n||!e.fn&&!t.fn)return i;let r=!1;const o=i.map(n=>{const i=e.fn&&e.key&&!(e.key in n),o=t.fn&&t.key&&!(t.key in n);if(!i&&!o)return n;r=!0;const s={...n};return i&&(s[e.key]=e.fn(n)),o&&(s[t.key]=t.fn(n)),s});return r?o:i}}(ai,ci,je&&je.length>0||!1);if(co||!At&&Mt){const e=_n.current;e&&r&&(e.ingest({inserts:Nt,bounded:!0}),e.computeScene({width:Bt,height:Ft}));const t=e?.scene??[],n=e?.scales??null,i=en(We,n),o=en(Oe,n),s=ni||(()=>{if(e?.xIsDate&&n)return gs(n.x.domain())})();return(0,Gs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1]},children:[(0,Gs.jsx)(Xo,{summary:ht}),(0,Gs.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:jt[0],height:jt[1],style:{position:"absolute",left:0,top:0},children:[(0,Gs.jsx)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:o}),(0,Gs.jsxs)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:[z&&(0,Gs.jsx)("rect",{x:0,y:0,width:Bt,height:Ft,fill:z}),Ye&&n&&Ye.map((e,i)=>(0,Gs.jsx)(ne.Fragment,{children:e(t,n,{width:Bt,height:Ft})},"svgpre-"+i)),t.map((e,t)=>so(e,t,bt)).filter(Boolean)]})]}),(0,Gs.jsx)(Xr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:n,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:s,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,foregroundGraphics:Xt(i,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:[],yValues:[],annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:0,xAccessor:li,yAccessor:ui,annotationData:di(e?.getData()),pointNodes:ms(e?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:ft,linkedCrosshairSourceId:pt})]})}return(0,Gs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"group","aria-label":dt||("string"==typeof He?He:"XY chart"),tabIndex:0,style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1],overflow:"visible",touchAction:Us(Xe)},onKeyDown:Zn,children:[ut&&(0,Gs.jsx)(Vo,{tableId:Rt}),ut&&(0,Gs.jsx)(Go,{scene:_n.current?.scene??[],chartType:n+" chart",tableId:Rt,chartTitle:"string"==typeof He?He:void 0}),(0,Gs.jsx)(Xo,{summary:ht}),(0,Gs.jsx)(Uo,{hoverPoint:an}),(0,Gs.jsxs)("div",{role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Wt?Qn:void 0,onMouseMove:Wt?Jn:void 0,onPointerLeave:Wt?Fn:void 0,onMouseLeave:Wt?Fn:void 0,onPointerDown:Wt||Ae?ei:void 0,onClick:Ae?Hn:void 0,children:[nn&&(0,Gs.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:jt[0],height:jt[1],pointerEvents:"none"},children:(0,Gs.jsx)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:nn})}),(0,Gs.jsx)(Yr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:Kt,showAxes:ce,axes:le,showGrid:Te,xFormat:ni,yFormat:ge||ve,axisExtent:me}),(0,Gs.jsx)("canvas",{ref:qt,"aria-label":Lo(_n.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Gs.jsx)("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Gs.jsx)(Xr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:Kt,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ni,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,foregroundGraphics:Xt(tn,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:wn,yValues:Sn,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:Gt,xAccessor:li,yAccessor:ui,annotationData:di(_n.current?.getData()),pointNodes:ms(_n.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==z&&!Oe,linkedCrosshairName:ft,linkedCrosshairSourceId:pt}),(Xe||Ve)&&(0,Gs.jsx)(he,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,dimension:Xe?.dimension??"xy",scales:Kt,onBrush:Ve??(()=>{}),binSize:v,snap:Xe?.snap,binBoundaries:Xe?.binBoundaries??("bar"===n?_n.current?.getBinBoundaries():void 0),snapDuring:Xe?.snapDuring,streaming:"streaming"===i}),Je?.showBadge&&(0,Gs.jsx)(Vn,{isStale:xn,position:Je.badgePosition}),si,ri]})]})}));Ks.displayName="StreamXYFrame";var Zs=Ks,Qs=require("react"),Js=require("react"),ea=(require("react/jsx-runtime"),(0,Js.createContext)(null));function ta(){return(0,Js.useContext)(ea)}var na=require("react");function ia(e){const t=[];for(const[n,i]of Object.entries(e.fields))if("point"===i.type)t.push(e=>i.values.has(e[n]));else{const[e,r]=i.range;t.push(t=>{const i=t[n];return i>=e&&r>=i})}return e=>t.every(t=>t(e))}function ra(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function oa(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[sa,aa]=ge(e=>({selections:new Map,setClause(t,n){e(e=>{const i=e.selections.get(t),r=i?.clauses.get(n.clientId);if(r&&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,i]of n){const n=t.fields[e];if(!n||!oa(i,n))return!1}return!0}(r,n))return{};const o=new Map(e.selections),s=ra(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 i=e.selections.get(t);if(!i||!i.clauses.has(n))return{};const r=new Map(e.selections),o=new Map(i.clauses);return o.delete(n),r.set(t,{...i,clauses:o}),{selections:r}})},setResolution(t,n){e(e=>{const i=e.selections.get(t);if(i?.resolution===n)return{};const r=new Map(e.selections),o=ra(r,t);return r.set(t,{...o,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const i=new Map(e.selections);return i.set(t,{...n,clauses:new Map}),{selections:i}})}})),[ca,la]=ge(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}))}})),ua=require("react");function da(e){const t=(0,ua.useId)(),n=e.clientId||t,{name:i}=e,r=aa(e=>e.selections.get(i)),o=aa(e=>e.setClause),s=aa(e=>e.clearClause),a=(0,ua.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,ua.useMemo)(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[i,r]of e.clauses)"crossfilter"===e.resolution&&i===t||n.push(ia(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"point",values:new Set(i)},r=!0;r&&o(i,{clientId:n,type:"point",fields:t})},[n,i,o]),selectInterval:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"interval",range:i},r=!0;r&&o(i,{clientId:n,type:"interval",fields:t})},[n,i,o]),clear:(0,ua.useCallback)(()=>{s(i,n)},[s,i,n]),clientId:n}}require("react/jsx-runtime");var ha=(0,na.createContext)(!1);(0,na.createContext)(!1);var fa=(0,na.createContext)(null),pa="undefined"==typeof window?na.useEffect:na.useLayoutEffect;var ya=c(require("react")),ga={light:we,dark:ke,"high-contrast":Se,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function ma(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function xa(e,t,n){const i=e.xValue??t?.[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function ba(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||{}}function va(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime"),ya.createContext(void 0);var wa={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function ka(e,t={}){const n=t.mobileSemantics?.interaction,i="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,o=!!n||void 0!==i,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!o)return wa;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Sa(){const e=Pe(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Aa({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:o,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Qs.useId)(),h=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"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n||[],p=da({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:o,clear:s}=da({name:t,fields:n});return{onHover:(0,ua.useCallback)(e=>{if(!e)return void s();const t={};for(const i of n){const n=e[i];void 0!==n&&(t[i]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&o(t)},[n,o,s,t]),predicate:i,isActive:r}}({name:h?.name||"hover",fields:f}),g=la(e=>e.pushObservation),m=e?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=(0,Qs.useState)(null),v=(0,Qs.useRef)(!1),w=l||n[0],k=(0,Qs.useMemo)(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=(0,Qs.useCallback)(e=>{const n=!e&&v.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"===h?.mode&&h.xField){const n=xa(e,t,h.xField);null!=n&&function(e,t,n){const i=_r.positions.get(e);i?.locked||i&&i.xValue===t&&i.sourceId===n||(_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n})},Cr())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||n||Ir(h.name||"hover",d),"x-position"===h?.mode||n||y.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else n||b(null);if(r||g){const t={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(e){const n=ba(e),i={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};r&&r(i),g&&g(i)}else{const e={...t,type:"hover-end"};r&&r(e),g&&g(e)}}},[t,y,h,d,r,o,s,g,c,w,u]),A=(0,Qs.useCallback)((n=!0)=>{v.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===h?.mode&&(Tr(h.name||"hover",d),Ir(h.name||"hover",d))},[t,h,y,e,u,p,c,d]),M=(0,Qs.useCallback)(n=>{const i=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),l=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=xa(n,e,h.xField);null!=t&&function(e,t,n){const i=_r.positions.get(e);if(i?.locked){const t=new Map(_r.positions);return t.delete(e),_r={positions:t},Cr(),!1}_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Cr()}(h.name||"hover",t,d)}if(i)if(n){v.current=!0;const i=ba(n);if(t&&"x-position"!==h?.mode&&y.onHover(i),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=i[t];void 0!==n&&(e[t]=[n])}va(e)&&p.selectPoints(e)}if(c&&w){const e=i?.[w];b(null!=e?e+"":null)}}else l&&A();if(n||l){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(r||g){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(n){const t=ba(n),i={...e,type:"click",datum:t||{},x:n.x??0,y:n.y??0};r&&r(i),g&&g(i)}else{const t={...e,type:"click-end"};r&&r(t),g&&g(t)}}}},[a,r,g,o,s,h,d,u,t,y,e,p,f,c,w,A]);return(0,Qs.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&v.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,Qs.useEffect)(()=>()=>{v.current&&A(!1)},[A]),(0,Qs.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Tr(e,d),Ir(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:d}}function Ma({data:e,colorBy:t,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:o,defaults:s={top:50,bottom:60,left:70,right:40},categories:a}){const c=(0,na.useContext)(ha),l=null!==(0,na.useContext)(fa),u=void 0!==i?i:!c&&!!t,d=!!t&&(u||l),h=(0,Qs.useMemo)(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const i of e){const e="function"==typeof t?t(i):i[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,d]);!function(e){const t=(0,na.useContext)(fa),n=(0,na.useId)(),i=function(e){const t=new Set,n=[];for(const i of e)t.has(i)||(t.add(i),n.push(i));return n}(e),r=(0,na.useRef)([]);(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})(r.current,i)||(r.current=i);const o=r.current;pa(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),pa(()=>{t&&t.registerCategories(n,o)},[t,n,o])}(l&&t?h:[]);const f=(0,Qs.useMemo)(()=>{if(!u||!t)return;const i=function({data:e,colorBy:t,colorScale:n,getColor:i,strokeColor:r,strokeWidth:o,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==o&&(n.strokeWidth=o),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,o)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?i(s,t,n):n?n(r):R[o%R.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:$,categories:h});return 0!==i.legendGroups.reduce((e,t)=>e+t.items.length,0)?i:void 0},[u,t,e,n,h]),p=(0,Qs.useMemo)(()=>{const e="number"==typeof o?{top:o,bottom:o,left:o,right:o}:o??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},i=t=>"number"==typeof e[t];return f&&("right"===r&&!i("right")&&110>n.right?n.right=110:"left"===r&&!i("left")&&110>n.left?n.left=110:"top"===r&&!i("top")&&50>n.top?n.top=50:"bottom"===r&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,o,f,r]);return{legend:f,margin:p,legendPosition:r}}var Pa={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 _a(e,t,n){const i=Pa[e||"primary"],r=e&&"primary"!==e||!n?.width?i.width:n.width,o=e&&"primary"!==e||!n?.height?i.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const i=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,i=t.width,r=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>i||"number"==typeof n.maxWidth&&i>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>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:i.reduce((e,t)=>function(e,t){const n={...e,...t};for(const i of["margin","frameProps","mobileSemantics","style"])ma(e[i])&&ma(t[i])&&(n[i]={...e[i],...t[i]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:i}}({...t,mode:e},{width:t.width??r,height:t.height??o}).props,a=s.mode||e,c=Pa[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:ja(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:ka(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function ja(e,t,n){if(!1!==t)return e;const i={...e};return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}var Ca=c(require("react")),Ia=require("react/jsx-runtime");function Ta({componentName:e,message:t,diagnosticHint:n,width:i,height:r}){return(0,Ia.jsx)("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,Ia.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Ia.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Ia.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Ia.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Ra=require("react/jsx-runtime"),La=class extends Ca.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Ra.jsx)(Ta,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},$a=require("react/jsx-runtime");function Ea({componentName:e,width:t,height:n,children:i}){return(0,$a.jsx)(La,{fallback:i=>(0,$a.jsx)(Ta,{componentName:e,message:i.message,width:t,height:n}),children:i})}"undefined"!=typeof process&&process;var za={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"},Da={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ba(e,t,n,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,$a.jsx)("div",{style:{...za,width:t,height:n},children:i||"No data available"}):null}function Fa(e,t,n,i){if(!e)return null;if(!1===i)return null;if(null!=i)return(0,$a.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(o+s)-s))/2);return(0,$a.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:r},(e,n)=>(0,$a.jsx)("div",{className:"semiotic-loading-bar",style:{...Da,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 Na=require("react"),Oa=require("react");var Wa=require("react/jsx-runtime");function qa(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}function Ya(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>o.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;r.length>e;e++){const o=r[e],p=t(o),y=n(o),g=i(o);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const n=y-c.a-(g-c.b);if(0!==n){const i=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+i*(p-c.x),t=c.a+i*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)f(l[e],a)}else for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:o})}for(const e of l)f(e,a??"A");return o}var Ha=(0,te.forwardRef)(function(e,t){const n=(0,te.useRef)(null),i=_a(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:r,margin:o,className:s,xFormat:a,yFormat:c,xAccessor:l="x",seriesAAccessor:u="a",seriesBAccessor:d="b",seriesALabel:h="A",seriesBLabel:f="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:g=!0,lineWidth:m=1.5,showPoints:x=!1,pointRadius:b=3,curve:v="linear",areaOpacity:w=.6,gradientFill:k,tooltip:S,annotations:A,xExtent:M,yExtent:P,frameProps:_={},selection:j,linkedHover:C,onObservation:I,onClick:T,hoverHighlight:L,chartId:$,loading:E,loadingContent:D,emptyContent:F,legendInteraction:N,legendPosition:O,pointIdAccessor:W,windowSize:q}=e,{width:Y,height:H,enableHover:G,showGrid:X,showLegend:U,title:K,description:Z,summary:ne,accessibleTable:ie,xLabel:re,yLabel:oe}=i,se=(0,te.useMemo)(()=>"function"==typeof l?e=>qa(l(e)):e=>qa(e[l]),[l]),ae=(0,te.useMemo)(()=>"function"==typeof u?e=>qa(u(e)):e=>qa(e[u]),[u]),ce=(0,te.useMemo)(()=>"function"==typeof d?e=>qa(d(e)):e=>qa(e[d]),[d]),[le,ue]=(0,te.useState)([]),de=(0,te.useRef)([]),he=null==r,fe=(0,te.useMemo)(()=>B(he?le:r),[he,le,r]),pe=(0,te.useMemo)(()=>Ya(fe,se,ae,ce),[fe,se,ae,ce]),ye=(0,te.useMemo)(()=>g?function(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];for(const e of r){const r=t(e),s=n(e),a=i(e);Number.isFinite(s)&&o.push({__x:r,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&o.push({__x:r,__y:a,__diffSegment:"line-B"})}return o}(fe,se,ae,ce):[],[g,fe,se,ae,ce]),ge=(0,te.useMemo)(()=>[...pe,...ye],[pe,ye]),me=(0,te.useMemo)(()=>{const e=new Set;for(const t of pe)e.add(t.__diffSegment);return Array.from(e)},[pe]);(0,te.useImperativeHandle)(t,()=>{const e=e=>{const t=q&&e.length>q?e.slice(e.length-q):e;de.current=t,ue(t)},t=W?"function"==typeof W?W:e=>e[W]:null;return{push:t=>e([...de.current,t]),pushMany:t=>e([...de.current,...t]),remove:n=>{if(!t)return[];const i=Array.isArray(n)?n:[n],r=[],o=[];for(const e of de.current)i.includes(t(e))?r.push(e):o.push(e);return e(o),r},update:(n,i)=>{if(!t)return[];const r=Array.isArray(n)?n:[n],o=[],s=de.current.map(e=>{if(r.includes(t(e))){const t=i(e);return o.push(t),t}return e});return e(s),o},clear:()=>e([]),getData:()=>he?de.current:fe,getScales:()=>n.current?.getScales()??null}},[he,fe,W,q]);const xe=function(e){const{data:t,rawData:n,colorBy:i,colorScheme:r,legendInteraction:o,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,userMargin:y,marginDefaults:g,onClick:m,hoverHighlight:x,mobileInteraction:b,mobileSemantics:v,loading:w,loadingContent:k,emptyContent:S,width:A,height:M}=e,P=void 0===n,_=(0,Na.useMemo)(()=>B(t),[t]),[j,C]=(0,Na.useState)([]),I=(0,Na.useCallback)(e=>{C(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),T="string"==typeof e.colorBy?e.colorBy:void 0,L=(0,Na.useMemo)(()=>ka(b,{width:A,mobileSemantics:v}),[b,A,v]),{activeSelectionHook:$,hoverSelectionHook:E,customHoverBehavior:D,customClickBehavior:F,crosshairSourceId:N}=Aa({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:m,hoverHighlight:x,colorByField:T,mobileInteraction:L}),O=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,N),W=function(e,t,n){const i=ta(),r=Sa();return(0,Qs.useMemo)(()=>{if(!t)return;const o=i??void 0,s=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&va(o)){const e=z(n.map(e=>({_cat:e})),"_cat",s);return t=>o[t]||e(t)}return z(n.map(e=>({_cat:e})),"_cat",s)}if(o&&va(o)){const n=z(e,t,s);return e=>o[e]||n(e)}return z(e,t,s)}if(o&&va(o)){const e=z([{_:"a"}],"_",s);return t=>o[t]||e(t)}},[e,t,n,i,r])}(_,i,r),q=(0,Na.useMemo)(()=>{if(!i)return[];const e=new Set;for(const t of _){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[_,i]),Y=(0,Na.useMemo)(()=>P&&j.length>0?j:q,[P,j,q]),H=function(e,t,n){const[i,r]=(0,Qs.useState)(null),[o,s]=(0,Qs.useState)(new Set),a=(0,Qs.useMemo)(()=>new Set,[]),c=(0,Qs.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,Qs.useCallback)(t=>{"isolate"===e&&s(e=>{const i=new Set(e);return i.has(t.label)?i.delete(t.label):i.add(t.label),i.size===n.length?new Set:i})},[e,n.length]),u=(0,Qs.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&o.size>0?{isActive:!0,predicate:e=>{const i=n?e[n]:"function"==typeof t?t(e):null;return o.has(i)}}:null},[e,t,i,o]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?o:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(o,i,Y),G=(0,Na.useMemo)(()=>E||(H.legendSelectionHook?H.legendSelectionHook:$),[E,H.legendSelectionHook,$]),X=function(e){const t=Pe(e=>e.theme.colors.selectionOpacity);return(0,Oa.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),V=Sa(),U=ta(),K=(0,Na.useMemo)(()=>{if(W)return W;if(!i||0===Y.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:V&&V.length>0?V:R,t="__streamCat",n=z(Y.map(e=>({[t]:e})),t,e);return e=>U?.[e]||n(e)||"#999"},[W,i,Y,r,V,U]),{legend:Z,margin:Q,legendPosition:J}=Ma({data:_,colorBy:i,colorScale:K,showLegend:p,legendPosition:s,userMargin:y,defaults:g,categories:Y}),ee=(0,Na.useMemo)(()=>{const e={};return Z&&(e.legend=Z,e.legendPosition=J),o&&"none"!==o&&(e.legendHoverBehavior=H.onLegendHover,e.legendClickBehavior=H.onLegendClick,e.legendHighlightedCategory=H.highlightedCategory,e.legendIsolatedCategories=H.isolatedCategories),P&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=I),e},[Z,J,o,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,P,i,I]),te=Array.isArray(n)?B(n):n,ne=Fa(w,A,M,k),ie=ne?null:Ba(te,A,M,S);return{data:_,colorScale:W,allCategories:Y,legendState:H,effectiveSelectionHook:G,activeSelectionHook:$,customHoverBehavior:D,customClickBehavior:F,mobileInteraction:L,legend:Z,margin:Q,legendPosition:J,earlyReturn:ne||ie||null,legendBehaviorProps:ee,crosshairProps:O,resolvedSelection:X}}({data:fe,rawData:r,colorBy:"__diffWinner",colorScheme:[p,y],legendInteraction:N,legendPosition:O,selection:j,linkedHover:C,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"DifferenceChart",chartId:$,showLegend:U,userMargin:o,marginDefaults:i.marginDefaults,loading:E,loadingContent:D,emptyContent:F,width:Y,height:H}),be=(0,te.useMemo)(()=>{if(!1!==U)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:h,color:p},{label:f,color:y}]}]}},[U,h,f,p,y]),ve=(0,te.useCallback)(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?p:y,stroke:"none",fillOpacity:w}},[p,y,w]),we=(0,te.useCallback)(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,strokeWidth:m,fill:"none"}),[p,y,m]),ke=(0,te.useCallback)(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,r:b}),[p,y,b]),Se=(0,te.useCallback)(e=>{const t=e.data,n=e.allSeries,i=e.xValue??t?.__x;let r=t?.__valA,o=t?.__valB;if(n&&n.length>0){const e=n.find(e=>"line-A"===e.group),t=n.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(r=e.value),null!=t?.value&&Number.isFinite(t.value)&&(o=t.value)}if(null!=i&&(null==r||null==o)){const e=fe.find(e=>se(e)===i);e&&(null==r&&(r=ae(e)),null==o&&(o=ce(e)))}const s=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",c=a&&null!=i?a(i):null!=i?i+"":"";return(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[c&&(0,Wa.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:c}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[h,": ",s(r)]})]}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[f,": ",s(o)]})]}),null!=r&&null!=o&&Number.isFinite(r)&&Number.isFinite(o)&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(r-o)]})]})},[fe,se,ae,ce,a,p,y,h,f]),Ae="multi"===S,Me=(0,te.useMemo)(()=>!1===S?()=>null:Ae?Se:Q(S)||Se,[S,Ae,Se]);if(xe.earlyReturn)return xe.earlyReturn;const _e={chartType:"mixed",data:ge,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:me,curve:v,areaStyle:ve,lineStyle:we,...x&&{pointStyle:ke},size:[Y,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:xe.margin,showAxes:i.showAxes,xLabel:re,yLabel:oe,xFormat:a,yFormat:c,enableHover:G,showGrid:X,...k&&{gradientFill:!0===k?{topOpacity:.85,bottomOpacity:.15}:k},...be&&{legend:be,legendPosition:xe.legendPosition},...J({title:K,description:Z,summary:ne,accessibleTable:ie,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:Me,...Ae&&{tooltipMode:"multi"},...ee({linkedHover:C,selection:j,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:xe.mobileInteraction,customHoverBehavior:xe.customHoverBehavior,customClickBehavior:xe.customClickBehavior}),...A&&A.length>0&&{annotations:A},...M&&{xExtent:M},...P&&{yExtent:P},...xe.crosshairProps,..._};return(0,Wa.jsx)(Ea,{componentName:"DifferenceChart",width:Y,height:H,children:(0,Wa.jsx)(Zs,{ref:n,..._e})})});function Ga(e,t,n){return"function"==typeof e?e(n):n[e||t]}function Xa(e){return e instanceof Date?e.getTime():Number(e)}function Va(e,t){return S(1===t?.5:e/(t-1))}"function"==typeof Ha&&(Ha.displayName="DifferenceChart");var Ua={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>Xa(Ga(o,"x",e)),l=e=>Xa(Ga(s,"a",e)),u=e=>Xa(Ga(a,"b",e)),d=r.seriesAColor||"var(--semiotic-danger, #dc2626)",h=r.seriesBColor||"var(--semiotic-info, #2563eb)",f=r.areaOpacity??.6,p=r.lineWidth??1.5,y=!1!==r.showLines,g=Ya(Array.isArray(e)?e:[],c,l,u),m=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),n=l(e),i=u(e);Number.isFinite(n)&&m.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:h,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...i}}},Ka={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=t||r.areaBy,s="string"==typeof o&&Array.isArray(e)?z(e,o,n):void 0;return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:o,colorScheme:n,normalize:r.normalize,stackOrder:r.stackOrder,lineStyle:null==r.areaOpacity?void 0:e=>{const t=null==o?void 0:$(e,o,s),n=r.showLine??!0;return{fill:r.color??t,stroke:n?r.stroke??t:"none",...n?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:r.areaOpacity,...null==r.opacity?{}:{opacity:r.opacity}}},...i}}},Za={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,h=c.stroke||"#999",f=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,y=d.createElement,g=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const i=n.width,r=n.height,c=null!=o?t.x(o):i/2,g=null!=s?t.y(s):r/2;if(null!=o&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(i,c)),x=Math.max(0,Math.min(r,g)),b=[{c:a.topLeft,x:0,y:0,w:m,h:x},{c:a.topRight,x:m,y:0,w:i-m,h:x},{c:a.bottomLeft,x:0,y:x,w:m,h:r-x},{c:a.bottomRight,x:m,y:x,w:i-m,h:r-x}],v=l?[y("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),y("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),y("text",{key:"lbl",x:8,y:r-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),y("text",{key:"lbr",x:i-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return y(d.Fragment,null,...b.map((e,t)=>e.w>0&&e.h>0?y("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:r,stroke:h,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:i,y2:x,stroke:h,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle,...i,...g&&{svgPreRenderers:g}}}},Qa={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",i=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:Xa(Ga(t.orderAccessor,"order",e))-Xa(Ga(t.orderAccessor,"order",n))):e,o=new WeakMap;let s=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Xa(Ga(n,"x",e)),r=Xa(Ga(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Xa(Ga(n,"x",e)),r=Xa(Ga(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&o.set(e,{idx:a++,total:s})}return{data:r,orderMap:o}}(e,r),s=r.pointRadius??4;return{chartType:"line",data:o.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle||{stroke:r.stroke||"#6366f1",strokeWidth:r.strokeWidth??s,opacity:r.opacity},pointStyle:e=>{const t=o.orderMap.get(e),n=t?.idx??0,i=t?.total??1;return{fill:i>0?Va(n,i):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...i}}};function Ja(e){return Math.max(0,Math.min(1,e))}function ec(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function tc(e,t,n){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function nc(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ja(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const i=Ja(t);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1];if(t.offset>i||i>r.offset)continue;const o=r.offset-t.offset,s=o>0?(i-t.offset)/o:0,a=ec(t.color),c=ec(r.color);if(!a||!c)return.5>s?t.color:r.color;const[l,u,d]=a,[h,f,p]=c;return tc(l+(h-l)*s,u+(f-u)*s,d+(p-d)*s)}return n[n.length-1].color}function ic(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var rc={frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=180+(360-a)/2,u=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],d=i.gradientFill,h=function(e){const{min:t,max:n,value:i,thresholds:r,fillColor:o,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,i))-t)/d;let f=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:o||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?h:1,t=ic("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;n>t;t++)i.push(nc(l.colorStops,e*(t+.5)/n));const r=ic("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),g.set(r,{fill:i[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const i=f[n],r=(i.value-e)/d,o=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-o),u=a?Math.max(0,r-l):0;if(l>0){const e=ic("fill",n);y.push({category:e,value:l,_zone:i.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:i.color})}if(u>0){const e=ic("bg",n);y.push({category:e,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=i.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:o,max:s,value:r.value,thresholds:u,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:!1!==r.fillZones,showScaleLabels:!1!==r.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),f=i.margin||{top:20,right:20,bottom:30,left:40},[p,y]=i.size||[300,300];return{chartType:"donut",data:h.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(f.left||0)-(f.right||0),y-(f.top||0)-(f.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:h.pieceStyle,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...h.gaugeAnnotations],__gauge:{gMin:o,gMax:s,sweep:a,arcWidth:c,value:r.value,startAngleDeg:l,thresholds:u}}}},oc=require("d3-scale");function sc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function ac(e,t,n){const i=t.incoming[e.id],r=t.outgoing[e.id],o=[];for(const e of i)o.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)o.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{o.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=o.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(o.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(o.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let y=0,g=0;for(const e of o)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",i=Math.min(n,"top"===t?y:g);if(i>0){const r=f(e.time);p.push({time:r,delta:-i,kind:"transfer-out",side:t}),p.push({time:r,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?y-=i:g-=i,"top"===e.side?y+=i:g+=i,n-=i}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}o.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const e of o){if(k.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:e.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let e=M;for(;k.length>e+1&&k[e+1].t===k[M].t;)e++;A.push(k[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||A.push(k[t])}M=e+1}const P=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let _=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===_||_>e.systemInTime)&&(_=e.systemInTime);let j=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=P?P:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],i=Math.min(null!=l?l:1/0,null!=_?_:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&A.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function cc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function lc(e,t){return e.map(e=>({t:cc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function uc(e,t,n){const i=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}function dc(e,t){let n=0;for(let i=0;t.length>i;i++)for(let r=i+1;t.length>r;r++){const o=t[i],s=t[r];o.source!==s.source&&o.target!==s.target&&o.source!==s.target&&o.target!==s.source&&(Math.min(o.endTime,s.endTime)>Math.max(o.startTime,s.startTime)&&e[s.source]>e[o.source]!=e[s.target]>e[o.target]&&n++)}return n}function hc(e,t){let n=0;for(const i of t)n+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return n}function fc(e,t){return 1e3*dc(e,t)+hc(e,t)}function pc(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function yc(e,t,n){e.length>8||n.length>40?(function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=pc(e,t),s=fc(t,n);for(let a=0;i>a;a++){const i=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];i[n]+=r*(e.value||1),a[n]+=e.value||1,i[r]+=n*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),u=new Map;c.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=fc(t,n);if(s>d)s=d,o=pc(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,o)}(e,t,n,6),function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=fc(t,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=fc(t,n);if(o>a)o=a,i=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!i)break}}(e,t,n,6)):function(e,t,n){const i=e.length;if(1>=i)return;const r={...t},o=Object.keys(r),s=Array.from({length:i},(e,t)=>t),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const d=()=>{for(const e of o)c[e]=a[r[e]];const e=fc(c,n);u>e&&(u=e,l=s.slice())},h=(e,t)=>{const n=s[e],i=s[t];s[e]=i,s[t]=n,a[n]=t,a[i]=e};d();const f=Array(i).fill(0);let p=0;for(;i>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(t=>e[t]),g=new Map;l.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function gc(e,t,n,i,r){const{plotH:o,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,o=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of i.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>o&&(o=t)}for(const e of i.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>o&&(o=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>o&&(o=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(o)?o:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(r.get(e.target)??0)+1);const o=[];for(const t of e)0===(r.get(t.id)??0)&&o.push(t.id);for(;o.length;){const e=o.shift();for(const t of i.outgoing[e]??[]){const i=(n.get(e)??0)+1;i>(n.get(t.target)??0)&&n.set(t.target,i),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&o.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=n.get(e.id)??0,r=n.get(t.id)??0;return i!==r?i-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...s,...a]){const t=p[e.id];let n=-1;for(let e=0;g.length>e;e++){const i=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){n=e;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:e.id,end:t?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=dc(y,t),b=hc(y,t)},k=()=>{x=dc(y,t),v=hc(y,t)};"crossing-min"===l?(w(),yc(g,y,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const i=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),o=Array(n),s=Math.floor((n-1)/2);o[s]=r[0].idx;let a=s-1,c=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>a?o[c++]=r[e].idx:o[a--]=r[e].idx;const l=o.map(t=>e[t]),u=new Map;o.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),yc(g,y,t),function(e,t,n){const i=e.length;if(1>=i)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),o=Math.floor((i-1)/2);let s=fc(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=o;if(r===c)continue;const l=e[r];e.splice(r,1),e.splice(c,0,l);const u=new Map;for(let e=0;i>e;e++)u.set(e,e);if(c>r){for(let e=r+1;c>=e;e++)u.set(e,e-1);u.set(r,c)}else{for(let e=c;r>e;e++)u.set(e,e+1);u.set(r,c)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=fc(t,n);if(d>s){const n=e[c];e.splice(c,1),e.splice(r,0,n);const o=new Map;for(let e=0;i>e;e++)o.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)o.set(e,e-1);o.set(c,r)}else{for(let e=r;c>e;e++)o.set(e,e+1);o.set(c,r)}for(const e of Object.keys(t))t[e]=o.get(t[e])}else s=d}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const i of e.occupants){const e=n[i.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[i,r]of e){if(i>t)break;n=r}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],i=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of i){const i=A(t,e),o=A(n,e);i.bot+o.top>r&&(r=i.bot+o.top)}M.push(r)}const P=[];let _=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&P.push(_);for(let e=1;g.length>e;e++)_+=M[e-1]*a+s,P.push(_);if(g.length>0&&(_+=g[g.length-1].peak.botPeak*a+s),_>o){const e=o/_;for(let t=0;P.length>t;t++)P[t]*=e}const j=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,C={};for(const t of e)C[t.id]=P[y[t.id]];return{effectiveSlotsHeight:j,centerlines:C,laneLifetime:p,slots:g,slotByNode:y,slotCenter:P,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function mc(e){const{sx:t,sTop:n,sBot:i,tx:r,tTop:o,tBot:s,cp1X:a,cp2X:c}=e,l=(n+i)/2,u=(o+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${o} ${r},${o}`,`L${r},${s}`,`C${c},${s} ${a},${i} ${t},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(i-n)/2}}}function xc(e){const{nodes:t,edges:n,domain:i,plotW:r,plotH:o,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,n){const i=[],r=new Set(e.map(e=>e.id)),o=Array.isArray(n)&&2===n.length,s=o&&Number.isFinite(n[0])&&Number.isFinite(n[1]);o&&s&&s&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,n,i),d=(0,oc.scaleTime)().domain(i).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(e,t,n){const{plotH:i,pairing:r="temporal",packing:o="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(e,t){const n={},i={};for(const t of e)n[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:i}}(e,t),l=function(e,t,n,i="value"){const r="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,o="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const i of e){const e=i[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(i),r.total+=i.value,r.earliestStart=Math.min(r.earliestStart,i.startTime),r.latestEnd=Math.max(r.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?o:r);return s};for(const t of e){const e=n.outgoing[t.id],i=n.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(i,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(i,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=i;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=i}}}return s}(e,t,c,r);let u={};for(const t of e)u[t.id]=ac(t,c,l);const d=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const i=l.get(e.id);t!==n?t>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(h.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===i.size&&n.length>0){const e=[...i][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=i(),o="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=o||0>=s)return!1;const a=Math.min(o,s),c=n.filter(t=>!h.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let o=n.length+1;for(;o-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=ac(t,c,l);const f=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,m=gc(e,t,u,c,{plotH:i,padding:y,valueScale:g,packing:o,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,n,{plotH:o,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const o=function(e,t,n,i,r){if(0===e.length)return null;const o=lc(e,r),s=e=>t-o[e].topMass*n,a=e=>t+o[e].botMass*n;let c=`M${i(o[0].t)},${s(0)}`;for(let e=1;o.length>e;e++)c+=` L${i(o[e].t)},${s(e)}`;c+=` L${i(o[o.length-1].t)},${a(o.length-1)}`;for(let e=o.length-2;e>=0;e--)c+=` L${i(o[e].t)},${a(e)}`;return c+" Z"}(r.samples,f[e.id],y,d,i);if(!o)return;const s=lc(r.samples,i),a=s.find(e=>e.topMass+e.botMass>0)||s[0],l=f[e.id]+(a.botMass-a.topMass)*y/2,u=c(e.id,t),m=function(e,t,n,i,r){const o=n.nodeData[e];if(!o||0===o.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],c=lc(o.samples,r),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),h=i(u.t),f=e=>i(cc(e,r)),p=[],y=(e,t,n,i)=>`M${e},${t} L${n},${t} L${n},${i} L${e},${i} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=o.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),i=f(n.startTime),r=t-20,o=Math.max(d,r);if(i>o){const[n,c]=uc(e,a,s);p.push({pathD:y(o,n,i,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=o.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),i=f(n.endTime),r=t+20,o=Math.min(h,r);if(o>i){const[n,c]=uc(e,a,s);p.push({pathD:y(i,n,o,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,n,h,d,i);g.push({id:e.id,pathD:o,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),n.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),n=p[e.target]?.localAttachments.get(e.id);if(!t||!n)return;const r=x.get(e.source)??0,o=c(e.source,r),l=function(e,t,n,i,r,o,s,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=o(l(e.time)),d=o(l(n.time)),h=e.value*c,f=n.value*c,p=e.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===e.side?(g=t-p,m=g+h):(m=t+p,g=m-h),"top"===n.side?(x=i-y,b=x+f):(b=i+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,d,s,i),{pathD:u,bezier:h}=mc(l);m.push({id:e.id,pathD:u,fill:o,opacity:a,rawDatum:e.__raw??e,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var bc=e=>{const{bands:t=[],ribbons:n=[],showLabels:i=!0}=e.config,r=[];for(const e of n)r.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)r.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const o=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:r,labels:o}},vc={frameType:"network",buildProps:(e,t,n,i,r)=>{const{edgeWidth:o,edgeColor:s,edgeOpacity:a}=r;return{chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:t,colorScheme:n,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle??(void 0!==o||void 0!==s||void 0!==a?e=>{const t=e?.data||e;let n=1;if("number"==typeof o)n=o;else if("function"==typeof o)n=o(t);else if("string"==typeof o){const e=t?.[o],i="number"==typeof e?e:Number(e);n=Number.isFinite(i)&&i>0?i:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),...i}}},wc={frameType:"network",buildProps:(e,t,n,i,r)=>{const o=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",d=r.endTimeAccessor||"endTime",h=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:function(e,t,n,i){const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],o="function"==typeof i?i(e):e[i];r.add(t),r.add(o)}),Array.from(r).map(e=>({id:e}))}(0,m,s,a),v=[o(r.domain?.[0]),o(r.domain?.[1])],w=b.map(e=>{const t=g(l,e)+"",n=g(p,e),i={id:t,__raw:e};if(Array.isArray(n)&&2===n.length){const e=o(n[0]),t=o(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),k=m.map((e,t)=>{const n=g(y,e),i={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(c,e)),startTime:o(g(u,e)),endTime:o(g(d,e)),__raw:e};if(h){const t=o(g(h,e));Number.isFinite(t)&&(i.systemInTime=t)}if(f){const t=o(g(f,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[S,A]=i.size??[600,400],M={top:20,right:20,bottom:20,left:20,...i.margin},P=i.legendPosition??"right";i.showLegend&&("right"===P?M.right=Math.max(M.right,100):"left"===P?M.left=Math.max(M.left,100):"bottom"===P?M.bottom=Math.max(M.bottom,70):"top"===P&&(M.top=Math.max(M.top,40)));const _=M,j=S-_.left-_.right,C=A-_.top-_.bottom,I=Array.isArray(n)?n:null,T=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],R="function"==typeof t?t:null,L=R?b.map(e=>({_cat:R(e)})):b,E=R?"_cat":"string"==typeof t?t:void 0,D=E?z(L,E,n):null,B=new Map;for(const e of w)B.set(e.id,e.__raw);const{layoutConfig:F,issues:N}=xc({nodes:w,edges:k,domain:v,plotW:j,plotH:C,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:(e,n)=>{if(t&&B.has(e)){const n=B.get(e);return R?$({_cat:R(n)},"_cat",D??void 0):$(n,t,D??void 0)}const i=I||T;return i[n%i.length]},layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(N.length>0){const e=N.map(sc).join("; ");throw Error("ProcessSankey: data invalid — "+e)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:bc,layoutConfig:F,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:n,...i,margin:_}}},kc={frameType:"geo",buildProps:(e,t,n,i,r)=>{const o=(Array.isArray(e)?e:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(r.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(const e of h)f.set(e[s]+"",e);const p=r.edgeColorBy??t,y="function"==typeof p,g=o.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=f.get(e.source+""),n=f.get(e.target+"");return t&&n?{...e,coordinates:[{x:t.x,y:t.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?z(g.map(e=>({[m]:p(e)})),m,n||"category10"):z(g,p,n||"category10"):null,b=e=>p&&x?$(e,p,x):"#007bff";let v=1/0,w=-1/0;for(const e of g){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>w&&(w=t))}const k=w>v?w-v:0,[S,A]=r.edgeWidthRange??[1,8],M=A-S,P=r.edgeOpacity??.6,_=r.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,i=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:i,strokeLinecap:_,opacity:P,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}};function Sc(e){const[t,n]=e;return{width:t,height:n,plot:{x:32,y:24,width:Math.max(80,t-64),height:Math.max(80,n-58)}}}function Ac(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let e=0;t.length>e;e+=1)i=31*i+t.charCodeAt(e)>>>0;return n[i%n.length]}function Mc(e,t="#4e79a7"){return n=>{const i=n.datum,r=i&&e?"function"==typeof e?e(i,0):i[e]:void 0;return{fill:null==r?t:Ac(r),stroke:"#111827",strokeWidth:1,opacity:.9}}}function Pc(e,t,n,i){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function _c(e,t,n){return"function"==typeof n?n(e,t):e[n]}function jc(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Cc(e,t,n){return Math.max(t,Math.min(n,e))}function Ic(e,t){const n=jc(e);return null!=n&&n>0?n:t}function Tc(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Rc(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var Lc=require("d3-scale");function $c(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var Ec={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},zc=1e-9,Dc=.005;function Bc(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Fc(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Nc(e,t,n){return Math.max(t,Math.min(n,e))}function Oc(e){return 0>e?-1:1}function Wc(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function qc(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function Yc(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Hc(e,t,n,i,r,o,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=o-t,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:Oc(c),ny:0,penetration:l}:{nx:0,ny:Oc(u),penetration:d}:null}function Gc(e,t,n,i,r,o,s){const a=o/2,c=s/2;let l=e-Nc(e,i-a,i+a),u=t-Nc(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(zc>=d){const o=Math.abs(e-(i-a)),s=Math.abs(e-(i+a)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),f=Math.min(o,s,d,h);return f===o?(l=-1,u=0,{nx:l,ny:u,penetration:n+o}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function Xc(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,i,r,o){const s=i-e,a=r-t,c=n+o,l=s*s+a*a;if(l>=c*c)return null;if(zc>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Hc(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const n=Gc(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Gc(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Vc(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Gc(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Hc(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,i,r,o,s,a=0){const c=o-i,l=s-r,u=c*c+l*l,d=u>zc?Nc(((e-i)*c+(t-r)*l)/u,0,1):0,h=n+a/2,f=e-(i+c*d),p=t-(r+l*d),y=f*f+p*p;if(y>=h*h)return null;if(zc>=y){const e=Math.sqrt(u);return e>zc?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function Uc(e,t){return`${e}\0${t}`}function Kc(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Zc(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:Bc(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Qc(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Jc(e){return{id:e.id,shape:Fc(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Qc(e.bodyFilter),index:e.index}}function el(e,t){return!!t?.some(t=>Object.is(e,t))}function tl(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const i=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(i,n.equals)||"notEquals"in n&&Object.is(i,n.notEquals)||n.oneOf&&!el(i,n.oneOf)||n.notOneOf&&el(i,n.notOneOf))}var nl=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...Ec,...e},this.random=$c(this.options.seed)}init(e={}){this.options={...Ec,...e},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(zc,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:Bc(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Kc(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Fc(t.shape),bodyFilter:Qc(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,n){const i=this.bodies.get(e);i&&(i.vx+=t/i.mass,i.vy+=n/i.mass,this.wake(i))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const i=this.options.maxVelocity;for(const e of n)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,i>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>i){const n=i/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),o=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,o,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:Bc(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Kc)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Zc),colliders:this.sortedColliders().map(Jc),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Zc(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Jc(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const i="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!i)continue;const r=i.x-n.x,o=i.y-n.y,s=Math.sqrt(r*r+o*o);if(zc>=s)continue;const a=r/s,c=o/s,l=(s-t.restLength)*t.stiffness+((("vx"in i?i.vx:0)-n.vx)*a+(("vy"in i?i.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const i of t){const[t,r]=i.split(":").map(Number),o=e[t],s=e[r];if(!o||!s)continue;const a=Xc(o,s);a&&(this.resolveDynamicCollision(o,s,a),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let i=0;e.length>i;i+=1){if(!1===e[i].bodyCollisions)continue;const r=Wc(e[i]),o=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=o;s>=e;e+=1)for(let t=a;c>=t;t+=1){const r=`${e}:${t}`,o=n.get(r);o?o.push(i):n.set(r,[i])}}const i=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const o=r[t],s=r[n];!1!==e[o].bodyCollisions&&!1!==e[s].bodyCollisions&&Yc(Wc(e[o]),Wc(e[s]))&&i.add(`${o}:${s}`)}}return Array.from(i).sort((e,t)=>{const[n,i]=e.split(":").map(Number),[r,o]=t.split(":").map(Number);return n===r?i-o:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const i=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,o=i+r;if(zc>=o)return;const s=Math.max(0,n.penetration-Dc)/o;e.x-=n.nx*s*i,e.y-=n.ny*s*i,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/o,u=l*n.nx,d=l*n.ny;e.vx-=u*i,e.vy-=d*i,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,i,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,i,r,o){const s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+o;if(zc>=Math.abs(c)||zc>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=Nc(-c/l,-i*u,i*u),h=d*s,f=d*a;e.vx-=h*r,e.vy-=f*r,t.vx+=h*o,t.vy+=f*o}resolveColliders(e,t,n){for(const i of e)for(const e of t){if(!tl(e,i))continue;if(!Yc(Wc(i),qc(e)))continue;const t=Vc(i,e);t&&(this.resolveStaticCollision(i,e,t),this.supportedThisStep.add(i.id),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-Dc),e.y+=n.ny*Math.max(0,n.penetration-Dc);const i=e.vx*n.nx+e.vy*n.ny;if(0>i){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*i*n.nx,e.vy-=(1+r)*i*n.ny;const o=-n.ny,s=n.nx,a=e.vx*o+e.vy*s,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*o*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const i of e){const e=Wc(i);for(const r of n){if(!tl(r,i))continue;if(!Yc(e,qc(r)))continue;if(!Vc(i,r))continue;const n=Uc(r.id,i.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:i}=Kc(e);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of e)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=t,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},il=class{constructor(e={}){this.id="builtin",this.capabilities={...(new nl).capabilities,engine:"builtin"},this.world=new nl(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function rl(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new il(e)}(t)}var ol=["binId","targetBin","category","windowIndex","lane","group"];function sl(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function al(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function cl(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function ll(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function ul(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):void 0}function dl(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function hl(e){const t=al(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:al(e.x),y:al(e.y),value:t}}var fl=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const n=dl(ul(this.config.binAccessor,e,t))??function(e){for(const t of ol){const n=dl(ll(e,t));if(n)return n}return"sediment"}(e),i=dl(ul(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const i="function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):1,r="number"==typeof i?i:Number(i);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:i,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=i,s.lastBodyId=e.id,s.lastDatum=e.datum,sl(s.x,e.x),sl(s.y,e.y),sl(s.value,r),o>0&&(s.bodyIds.push(e.id),s.bodyIds.length>o&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-o))),hl(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(hl)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:cl(t.x),y:cl(t.y),value:cl(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function pl(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var yl={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},gl={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function ml(e={},t=gl){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function xl(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function bl(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function vl(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function wl(e){return{...xl(e),sequence:e.sequence,spawnAt:e.spawnAt}}function kl(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Sl(e){return!1!==e&&{...e}}function Al(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Ml(e){return{...e,gravity:{...e.gravity}}}function Pl(e,t,n,i){if("circle"===e.shape.type){const r=e.x-t,o=e.y-n,s=e.shape.radius+i,a=r*r+o*o;return a>s*s?null:a}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),o=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),s=r*r+o*o;return s>i*i?null:s}function _l(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function jl(e,t={}){const{idPrefix:n="plot",includeFloor:i=!0,includeCeiling:r=!1,includeLeftWall:o=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return i&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),o&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Cl(e){const{idPrefix:t="bin",count:n,domainStart:i,domainStep:r,xScale:o,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=o(i+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=i+e*r,s=n+r;if(s>=d)continue;const a=o(n),l=o(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var Il=require("d3-quadtree"),Tl=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,i,r,o=0){const s=this.ensure(e,t);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,o)+this.maxSearchRadius,u=i-l,d=i+l,h=r-l,f=r+l;return s.visit((e,t,s,l,p)=>{if(u>l||t>d||h>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=Pl(e,i,r,Math.max(0,o));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=(0,Il.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},Rl=["data","scene-geometry","data-paint","accessibility","evidence"],Ll=["scene-geometry","data-paint","accessibility","evidence"],$l=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],El=["overlay","accessibility","evidence"],zl=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function Dl(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&zl.every(n=>e[n]===t[n])}function Bl(e,t,n,i){return e||!t?"paused":n||!i?"running":"settled"}var Fl=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Tl,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Lt,this.simulationState="settled",this.visible=!0;const{bodyBudget:t,colliders:n,engine:i,kernel:r,observation:o,sediment:s,...a}=e;this.config={...yl,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=i,this.observation=ml(o),this.sediment=new fl(s??!1),this.world=rl(i,{fixedDt:this.config.fixedDt,...r}),n&&this.world.setColliders(kl(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!Dl(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:i,engine:r,kernel:o,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=rl(r,e.options),this.world.restore(e),this.revision+=1}if(o&&!Dl(o,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...o,gravity:{...e.options.gravity,...o.gravity}};this.world.restore({...e,options:t}),this.revision+=1}s&&(this.observation=ml(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(kl(n)),this.revision+=1),this.configInput={...this.configInput,...e},this.updateResults.record({kind:"config",keys:t},t.length?$l:[])}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(kl(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},$l)}enqueue(e,t){const n=Array.isArray(e)?e:[e],i=t?function(e,t={}){const n=bl(t.startAt)??0,i=t.pacing??"immediate";if("arrival"===i){const i=e.map((e,n)=>function(e,t,n){return"function"==typeof n?bl(n(e,t)):"string"==typeof n?bl(vl(e,n)):bl(e.spawnAt)??bl(vl(e,"arrivalTime"))??bl(vl(e,"timestamp"))??bl(vl(e,"time"))??bl(vl(e,"eventTime"))}(e,n,t.timeAccessor)),r=i.filter(e=>null!=e),o=r.length>0?Math.min(...r):0,s=bl(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=i[t],s=null==r?0:Math.max(0,r-o);return{...xl(e),spawnAt:n+s/a}})}if("object"==typeof i){const t=bl(i.ratePerSec);if(t&&t>0)return e.map((e,i)=>({...xl(e),spawnAt:n+i/t}))}return e.map(e=>({...xl(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of i)this.queue.push({...xl(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Al),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?Rl:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(xl(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Rl)}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},Rl)}tick(e){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);i.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const d=this.result(u,n,i,r,o,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const n=this.world.settle(e,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==t?Ll:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);i.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;e>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),l+=1}(l>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const u=this.result(l,n,i,r,o,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),u}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:n=0,binWidth:i=24,gap:r=2,maxHeight:o=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*o),u=a?.(e,t)??t*(i+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:i,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:n,chartId:i,...r}=e,o={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?El:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?El:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),i=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const r=e.filter(e=>n.has(e)||i.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?Rl:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Ll),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Ll)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Ll)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,i)=>e.applyImpulse(t,n,i),clear:()=>e.clear(),hitTest:(t,n,i)=>e.hitTest(t,n,i),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Sl(this.bodyBudget),config:{...this.config,kernel:Ml(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(wl),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Sl(e.bodyBudget??{}),kernel:Ml(e.world.options)},this.bodyBudget=Sl(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(wl).sort(Al),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Bl(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},$l)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const n=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,i,r,o,s,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:i,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const i=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=i.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,n){const i=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===i.size&&0===t.size)return i;const r=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{const{sensorId:i,bodyId:o}=_l(t),s=n.observation.sensors[i],a=r.get(o);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const e of Array.from(i).sort())t.has(e)||o("enter",e);for(const e of Array.from(t).sort())i.has(e)||o("exit",e);return i}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(_l(n).bodyId)&&e.delete(n)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),n=Math.max(0,Math.floor(e.queuedBodies??0)),i=t+n,r=pl(e.bodyLimit),o=pl(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const i=pl(n?.warnAt);return null!=i?i:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,o,e.options),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:o,liveBodies:t,overflow:a,projectedBodies:i,queuedBodies:n,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=Bl(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,t,this.observationContext(e))}evictOverflow(e){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const t=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(t))return{evicted:[],sedimented:[]};const n=this.liveBodyOrder.length-t;if(0>=n)return{evicted:[],sedimented:[]};const i=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,n);if(0===i.length)return{evicted:[],sedimented:[]};const r=this.absorbSediment(i,e);this.world.remove(i);const o=new Set(i);return this.liveBodyOrder=this.liveBodyOrder.filter(e=>!o.has(e)),this.removeActiveSensorPairsForBodies(o),{evicted:i,sedimented:r}}absorbSediment(e,t){const n=new Map(this.world.readState().map(e=>[e.id,e])),i=[];for(const r of e){const e=n.get(r);if(!e)continue;const o=this.sediment.add(e);o&&(i.push(r),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:r,datum:e.datum,x:e.x,y:e.y,binId:o.id,count:o.count,total:o.total},t))}return i}sleepingFirstEvictionOrder(){const e=new Map(this.world.readState().map(e=>[e.id,e.sleeping])),t=[],n=[];for(const i of this.liveBodyOrder)e.get(i)?t.push(i):n.push(i);return[...t,...n]}};var Nl=require("d3-scale");function Ol(e){const{count:t,idPrefix:n,wallThickness:i,xScale:r,yBottom:o,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(o-1,a?.(t)??s),l=Math.max(1,o-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:i,height:l}}})}var Wl=require("d3-scale");function ql(e){if(Array.isArray(e)&&e.length>=2){const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=jc(t.x),i=jc(t.y);return null!=n&&null!=i?{x:n,y:i}:null}return null}function Yl(e){return Array.isArray(e)?e.map(ql).filter(e=>null!=e):[]}function Hl(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:Cc(e.x,t.plot.x,t.plot.x+t.plot.width),y:Cc(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Gl(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Xl(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=Cc(t,0,1)*Gl(e);let i=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],o=e[t],s=Math.hypot(o.x-r.x,o.y-r.y);if(s>0){if(i+s>=n){const e=(n-i)/s;return{x:r.x+(o.x-r.x)*e,y:r.y+(o.y-r.y)*e}}i+=s}}return{...e[e.length-1]}}function Vl(e,t){const n=Xl(e,Math.max(0,t-.02)),i=Xl(e,Math.min(1,t+.02)),r=i.x-n.x,o=i.y-n.y,s=Math.hypot(r,o)||1;return{x:r/s,y:o/s}}function Ul(e,t,n){return Math.max(t,Math.min(n,e))}function Kl(e,t,n,i,r,o={}){return{id:e,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:i,y2:r,thickness:o.thickness??8}}}function Zl(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,i=e.width,r=e.height,{type:"aabb",x:t,y:n,width:i,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,i,r}function Ql(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Jl(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function eu(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,i=Sc(n),r=Cc(e.ballRadius??6,2,18),o=e.seed??1,s=Rc(o),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(l?"allAbsorbed":"none"),p=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=function(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height)),r=e.padX??46,o=e.padY??72,s=r,a=n-r,c=o,l=i-Math.max(24,Math.round(.45*o)),u=(c+l)/2,d=Math.max(1,l-c),h=Ul(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Ul(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Ul(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),P=a-s;let _=s;const j=S.map((e,t)=>{const n=_,i=t===S.length-1?a:_+(e.share??1)/M*P;return _=i,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:i,x:(n+i)/2,width:i-n,y:u,height:d}}),C=j[A],I=C.x0,T=C.x1,R=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Ul((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(I>=e){const t=Ul((e-s)/Math.max(1,I-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(T>=e)return"top"===n?m:x;const i=Ul((e-T)/Math.max(1,a-T),0,1);return"top"===n?m+(c-m)*i:x+(l-x)*i},L=j.map(e=>{const t=Math.min(R(e.x0,"top"),R(e.x1,"top")),n=Math.max(R(e.x0,"bottom"),R(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:v,restitution:w},E=[];"lane"===t?E.push(Kl(b+"-top",s,c,a,c,$),Kl(b+"-bottom",s,l,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?E.push(Kl(b+"-top",s,c,a,m,$),Kl(b+"-bottom",s,l,a,x,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,m,a,x,{...$,thickness:Math.max(6,k)})):E.push(Kl(b+"-left-top",s,c,I,m,$),Kl(b+"-left-bottom",s,l,I,x,$),Kl(b+"-center-top",I,m,T,m,$),Kl(b+"-center-bottom",I,x,T,x,$),Kl(b+"-right-top",T,m,a,c,$),Kl(b+"-right-bottom",T,x,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)}));const z=e.membraneDampingScale??.5,D=s,B=Math.max(1,("bowtie"===t?I:a)-D),F=(e.membranes??[]).map(e=>{const t=D+Ul(e.offset,0,1)*B,n=e.width??18+18*e.cost,i=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:i}}),N=!1===e.includeMembraneRegions?[]:F.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,i=Ul(e.cost,0,2);return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i*t,energyDelta:-i*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??z,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:i,padX:r,padY:o,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:T,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:L,membranes:F,colliders:E,regionEffects:N,boundaryY:R}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=v.get(e.id)??k;return function(e,t){const n={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Zl({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...n,kind:e.kind??"sink",force:Jl(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return i={...n,kind:e.kind??"force-field",force:Jl(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Zl({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Jl(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,i=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*i,energyDelta:r?-t*r:void 0,force:e.force}}({...n,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:Jl(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Ql({...n,kind:e.kind??"force-field",force:Jl(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});A.unshift(Ql({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const e of x.stages)M.set(e.id,0);const P=[];e.data.forEach((e,t)=>{const n=(a?_c(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",i=(_c(e,t,c)??w)+"",o=b.has(i)?i:w;M.set(o,(M.get(o)??0)+1);const s=l?(_c(e,t,l)??"")+"":void 0,f=s&&u?(_c(e,t,u)??s)+"":s,p=d?jc(_c(e,t,d))??1:1,y=h?jc(_c(e,t,h)):null,g=Cc(null!=y&&y>0?y:r,2,18);P.push({datum:e,id:n,stageId:o,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});const _=new Map,j=new Map;for(const e of P){if(!e.groupId)continue;const t=_.get(e.groupId)??[];t.push(e.id),_.set(e.groupId,t),e.groupLabel&&j.set(e.groupId,e.groupLabel)}const C=Cc(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*C,T=Array.from(_.keys()),R=T.map((e,n)=>{const i=_.get(e)??[],r=T.length>1?x.topY+28+n/Math.max(1,T.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:j.get(e)??e,bodyIds:i,anchor:{x:I,y:r},x:I,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),L=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],i=t.filter(e=>!n.has(e)),r=t.length-i.length,o=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===o?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:o,complete:t.length>0&&("anyAbsorbed"===o?r>0:"threshold"===o?l>=(d??c):0===i.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(R,P.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(R.map(e=>[e.id,e])),E=P.map((e,t)=>{const n=v.get(e.stageId)??k,i=n.x+(s()-.5)*Math.min(24,.2*n.width),r=x.boundaryY(i,"top")+e.radius+10,o=x.boundaryY(i,"bottom")-e.radius-10,a=o>r?r+s()*Math.max(1,o-r):x.midY,c=g?i:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),z={kernel:{seed:o,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},D=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),B=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:z,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:D,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:B,groups:R,groupCompletion:L,regionEffects:A}}}var tu=require("react"),nu=require("d3-scale");function iu(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=I[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}function ru(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&E(n,e)||"#4e79a7":t=>{if(n){const e=E(n,t);if(e)return e}let i=0;for(let e=0;t.length>e;e++)i=31*i+t.charCodeAt(e)|0;return e[Math.abs(i)%e.length]??"#4e79a7"}}var ou=c(require("react")),su=require("react"),au={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},cu={names:["--semiotic-border","--surface-3"],fallback:"#334155"},lu={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},uu={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},du={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},hu={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},fu={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},pu={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},yu={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},gu={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function mu(e,t){const n=e.canvas;if("function"!=typeof getComputedStyle||!n)return t.fallback;const i=getComputedStyle(n);for(const n of t.names){const t=i.getPropertyValue(n).trim();if(t)return vn(e,t)??t}return t.fallback}function xu(e,t){const n=Math.max(0,Math.min(1,t)),i=e.trim(),r=i.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(r){const[,e,t,i]=r;return xu(`#${e}${e}${t}${t}${i}${i}`,n)}const o=i.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(o){const[,e,t,i]=o;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(i,16)}, ${n})`}const s=i.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(s)return`rgba(${s[1]}, ${n})`;const a=i.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return a?`rgba(${a[1]}, ${n})`:i}var bu=c(require("react")),vu=require("d3-scale"),wu=require("react/jsx-runtime");function ku(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Su(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,title:s,legend:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:f,pointNodes:p=[],annotations:y,autoPlaceAnnotations:g,svgAnnotationRules:m,children:x}=e,b=bu.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(y),[y]),v=bu.useMemo(()=>function(e){const{width:t,height:n,pointNodes:i=[],data:r}=e;return{scales:{x:(0,vu.scaleLinear)().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:(0,vu.scaleLinear)().domain([0,Math.max(1,n)]).range([0,Math.max(1,n)])},width:t,height:n,frameType:"network",pointNodes:i,data:r,xAccessor:"x",yAccessor:"y"}}({width:t,height:n,pointNodes:p}),[n,p,t]),w=bu.useMemo(()=>b&&g?Mr({annotations:b,context:v,..."object"==typeof g?g:{}}):b,[v,g,b]),k=bu.useMemo(()=>Ji(),[]),S=w?Qi(w.filter(e=>"widget"!==e.type),k,m,v):null,A=!0===w?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,wu.jsxs)(wu.Fragment,{children:[A?(0,wu.jsx)("style",{children:qi},"physics-annotation-disclosure-style"):null,(0,wu.jsxs)("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,wu.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[S,x]}),s&&"string"==typeof s?(0,wu.jsx)("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,wu.jsx)("foreignObject",{x:0,y:0,width:i,height:Math.max(o.top,28),children:s}):null,a?ci({legend:a,totalWidth:i,totalHeight:r,margin:o,legendPosition:h,legendLayout:f,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function Au(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Mu(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,Au(e.thickness)??Au(n)??Au(t.thickness)??4)}var Pu=2500;function _u(e){return"function"==typeof e}function ju(e){return void 0===e||!1===e||!_u(e.binAccessor)&&!_u(e.labelAccessor)&&!_u(e.valueAccessor)}function Cu(e){if(void 0!==e){if(!1===e)return!1;if(!ju(e))throw new TypeError("Physics worker sediment config only supports string or numeric accessors");return{binAccessor:"string"==typeof e.binAccessor?e.binAccessor:void 0,labelAccessor:"string"==typeof e.labelAccessor?e.labelAccessor:void 0,valueAccessor:"string"==typeof e.valueAccessor||"number"==typeof e.valueAccessor?e.valueAccessor:void 0,retainBodyIds:e.retainBodyIds}}}function Iu(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function Tu(e){return function(e){return!_u(e?.timeAccessor)}(e)}function Ru(e={}){if(e.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:t,observation:n,sediment:i,...r}=e;return{...r,observation:Iu(n),sediment:Cu(i)}}var Lu={};function $u(){if("undefined"!=typeof DOMException)return new DOMException("Physics worker request aborted","AbortError");const e=Error("Physics worker request aborted");return e.name="AbortError",e}var Eu=class{constructor(e=function(){const e="string"==typeof Lu.url&&Lu.url?new URL("./physicsWorker.js",Lu.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)}("physicsWorker.js");return new Worker(e,{type:"module",name:"semiotic-physics"})}()){this.nextRequestId=1,this.pending=new Map,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=this.pending.get(t.requestId);n&&(this.pending.delete(t.requestId),n.cleanup(),t.ok?n.resolve(t.payload):n.reject(function(e){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),t}(t)))},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Physics worker failed")),this.worker.terminate()}}request(e,t){if(t?.aborted)return Promise.reject($u());const n=this.nextRequestId;this.nextRequestId+=1;const i={command:e,requestId:n};return new Promise((e,r)=>{const o=()=>{this.pending.delete(n),t?.removeEventListener("abort",o),r($u())},s=()=>t?.removeEventListener("abort",o);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",o,{once:!0});try{this.worker.postMessage(i)}catch(e){this.pending.delete(n),s(),r(e)}})}async init(e,t,n,i){if(!Tu(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:Ru(e),initialSpawns:t,initialSpawnPacing:n},i);if("frame"!==r.type)throw Error("Physics worker returned a non-frame init response");return r.frame}async restore(e,t){const n=await this.request({type:"restore",snapshot:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame restore response");return n.frame}async initFromSnapshot(e,t,n){const i=await this.request({type:"init",config:Ru(e),snapshot:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame init response");return i.frame}async enqueue(e,t,n){if(!Tu(t))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const i=await this.request({type:"enqueue",spawns:e,pacing:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame enqueue response");return i.frame}async tick(e,t){const n=await this.request({type:"tick",deltaSeconds:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame tick response");return n.frame}async settle(e,t){const n=await this.request({type:"settle",maxSteps:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame settle response");return n.frame}async snapshot(e){const t=await this.request({type:"snapshot"},e);if("snapshot"!==t.type)throw Error("Physics worker returned a non-snapshot response");return t.snapshot}async remove(e,t){const n=await this.request({type:"remove",ids:e},t);if("removed"!==n.type)throw Error("Physics worker returned a non-remove response");return{frame:n.frame,removed:n.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(e){for(const[t,n]of this.pending)this.pending.delete(t),n.cleanup(),n.reject(e)}},zu=c(require("react-dom/server"));function Du(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var Bu={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function Fu(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Nu(e,t){const n="function"==typeof t?t(e):t;return{...Bu,...n??{}}}function Ou(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),i={label:t.getBodyLabel?.(e)??Fu(e)},r={style:Nu(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:i,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}var Wu=require("react/jsx-runtime");function qu(e,t={}){const{width:n=640,height:i=360,title:r,description:o,background:s,className:a,idPrefix:c="physics",...l}=t,u=function(e,t={}){const n=e.settle(t.maxSteps),i=e.readBodies(),r=e.snapshot(),o=Ou(i,t),s=function(e,t={}){const n=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),i=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:i,settled:"settled"===e.simulationState&&0===e.queue.length&&i===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Du(t.projectionRows)}}(r,{bodies:i,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:r,bodies:i,sceneNodes:o,evidence:s,stepsRun:n}}(e,l),d=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(c),h=r?d+"-title":void 0,f=o?d+"-desc":void 0,p=[h,f].filter(Boolean).join(" ")||void 0;return{svg:zu.renderToStaticMarkup((0,Wu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:i,viewBox:`0 0 ${n} ${i}`,role:"img","aria-labelledby":p,children:[r&&(0,Wu.jsx)("title",{id:h,children:r}),o&&(0,Wu.jsx)("desc",{id:f,children:o}),s&&"transparent"!==s?(0,Wu.jsx)("rect",{x:0,y:0,width:n,height:i,fill:s}):null,(0,Wu.jsx)("g",{id:d+"-data-area",children:u.sceneNodes.map((e,t)=>so(e,t,d))})]})),scene:u,evidence:u.evidence}}function Yu(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const i=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(i)&&i>0?i:1}function Hu(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=Xu(e.datum,t),i=Xu(e,t),r=n??i;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Gu(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.floor(n);return e[i]+(e[Math.ceil(n)]-e[i])*(n-i)}function Xu(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Vu(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=Xu(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function Uu(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),i=e.queueLayout??"lane",r=e.queueSlotSpacing??14,o=e.queueStiffness??.35,s=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,a=Math.max(.25,e.metricWindowSeconds??30),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,p=new Map,y=new Map,g=new Map,m=[];let x=0,b=new Map,v=new Map,w=0,k=0,S=0,A=null,M=0,P=0,_=0,j=0,C=0,I=0,T=0,R=0,L=0,$=0,E=0,z=0,D=-1,B=!1;function F(e,n){const i=n(e);return!!i&&i.activeRegionIds.includes(t)}function N(){z+=1}function O(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function W(n,i,r,o){const s={bodyId:n.id,jobId:i.jobId,visitId:i.visitId,visit:i.visit,remaining:i.work,total:i.work,queuedAt:i.queuedAt,sequence:o};return u.set(i.jobId,s),g.delete(n.id),y.set(n.id,i.jobId),P+=1,_+=i.work,N(),function(n,i,r){const o=O(i);e.onQueued?.(n,o),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:i.total,jobId:i.jobId,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,queueDepth:u.size})}(n,s,r),s}function q(e){if(u.size>=s||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(u.size>=s)break;const t=p.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),W(t,n,e,n.sequence)):d.delete(n.jobId)}}function Y(){let e=0;for(const t of u.values())e+=t.remaining;return e}function H(){L=Math.max(L,u.size),$=Math.max($,Y())}function G(){const e=S-a,t=Math.max(0,Math.min(a,S-(A??S)));let i=0,r=0,o=0,s=0,c=0;for(const t of m){if(e>t.end)continue;i+=t.arrivals,r+=t.arrivalWork,o+=t.completions,s+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:i,arrivalWork:r,completions:o,completedWork:s,processedWork:c,arrivalsPerSecond:t>0?i/t:0,throughputPerSecond:t>0?o/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:i=>{const r=i.controls.readBodies(),o=new Map,P=new Map;for(const t of r){if(o.set(t.id,t),!F(t.id,i.getRegionState))continue;if(!Vu(t,e.bodyFilter))continue;const n=Hu(t,e.jobKey),r=P.get(n)??[];r.push(t),P.set(n,r)}const _=Number.isFinite(i.dt)?Math.max(0,i.dt):0;if(!B){const e=Number.isFinite(i.elapsed)?Math.max(0,i.elapsed):_;S=Math.max(0,e-_),B=!0}const L=S,$=L+_;S=$,A=null==A?L:Math.min(A,L);const z={start:L,end:$,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},Y=new Map;for(const[e,t]of P){const n=h.get(e)?.bodyId,i=t.find(e=>e.id===n)??t[0];Y.set(e,i),p.set(e,i)}for(const[n,r]of h){if(Y.has(n))continue;const s=u.get(n),a=o.get(r.bodyId)??p.get(n);if(s){u.delete(n),y.delete(s.bodyId),T+=1,R+=s.remaining,N();const o={...O(s),abandonedAt:S,remainingWork:s.remaining,queueSeconds:Math.max(0,S-s.queuedAt)};a&&e.onAbandoned?.(a,o),i.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:t,work:s.total,remainingWork:s.remaining,jobId:n,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:S,queueSeconds:o.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(r.bodyId),h.delete(n),p.delete(n)}for(const[n,r]of Y){if(h.has(n))continue;const o=(f.get(n)??0)+1;f.set(n,o);const a=Yu(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${o}`,visit:o,regionId:t,work:a,queuedAt:S};h.set(n,c),M+=1,z.arrivals+=1,z.arrivalWork+=a;const l=x++;if(s>u.size)W(r,c,i,l);else{const s={...c,blockedAt:S,sequence:l};d.set(n,s),g.set(r.id,n),I+=1,N(),e.onBlocked?.(r,s),i.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:a,jobId:n,visitId:c.visitId,visit:o,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}q(i),H();const G=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let X=n*_;for(const n of G){if(0>=X)break;const r=Math.min(n.remaining,X);if(n.remaining-=r,X-=r,j+=r,z.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,C+=n.total,z.completions+=1,z.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);E+=s,N();const a=o.get(n.bodyId);if(!a)continue;i.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...O(n),completedAt:S,queueSeconds:s};e.onProcessed?.(a,c),i.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:s,queueDepth:u.size})}q(i),H(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);b=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);v=new Map(t.map((e,t)=>[e.bodyId,t])),w=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&m.push(e);const t=S-a;for(;m.length>0&&t>m[0].end;)m.shift()}(z);const V=Math.floor(S/c);V!==D&&(D=V,N())},getSnapshot:()=>{const e=Y(),i=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=u.size,o=Array.from(u.values()).map(e=>Math.max(0,S-e.queuedAt)).sort((e,t)=>e-t),s=o.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:r,processedCount:k,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+i,blockedDepth:d.size,blockedWork:i,arrivalCount:M,admittedCount:P,admittedWork:_,processedWork:j,completedWork:C,blockedCount:I,abandonedCount:T,abandonedWork:R,peakQueueDepth:L,peakRemainingWork:$,queueAge:{count:o.length,meanSeconds:o.length>0?s/o.length:0,p50Seconds:Gu(o,.5),p95Seconds:Gu(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:k>0?E/k:0,window:G(),simulatedAt:S,metricRevision:z}},bodyForce:e=>{if("none"===i)return null;const n=y.get(e.body.id),s=g.get(e.body.id),a=n?u.get(n):void 0,c=s?d.get(s):void 0;if(!a&&!c)return null;const l=a?b.get(e.body.id):v.get(e.body.id);if(null==l)return null;let h;const f=e.regions;if(f)for(let e=0;f.length>e;e+=1)if(f[e].id===t){const t=f[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*o,y:(h.y-(l-((c?d.size:w)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:w))-e.body.y)*o*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Ku(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}var Zu=require("react");function Qu(){return"undefined"==typeof document||!document.hidden}function Ju(e,t,n){const i=n.fill??"#4e79a7",r=n.stroke,o=n.strokeWidth??0,s=n.opacity??1,a=n.fillOpacity??1,c=function(e,t){const n=t.mark;if(n)return n;const i=e.datum,r=i?.__physicsMark??i?.mark;return"circle"===r||"halo"===r||"faceted"===r||"pill"===r||"diamond"===r||"square"===r?r:"circle"===e.shape.type?"circle":"square"}(t,n),l="circle"===t.shape.type?n.r??t.shape.radius:Math.max(t.shape.width,t.shape.height)/2;if(e.save(),e.globalAlpha*=s,e.beginPath(),"pill"===c||"square"===c||"aabb"===t.shape.type){const n="pill"===c?2.4*l:"aabb"===t.shape.type?t.shape.width:1.7*l,i="pill"===c?1.35*l:"aabb"===t.shape.type?t.shape.height:1.7*l,r=t.x-n/2,o=t.y-i/2,s="pill"===c?i/2:Math.min(4,n/4);e.moveTo(r+s,o),e.arcTo(r+n,o,r+n,o+i,s),e.arcTo(r+n,o+i,r,o+i,s),e.arcTo(r,o+i,r,o,s),e.arcTo(r,o,r+n,o,s),e.closePath()}else if("diamond"===c)e.moveTo(t.x,t.y-l),e.lineTo(t.x+l,t.y),e.lineTo(t.x,t.y+l),e.lineTo(t.x-l,t.y),e.closePath();else if("faceted"===c){const n=6;for(let i=0;n>i;i+=1){const r=2*Math.PI*i/n-Math.PI/2,o=t.x+Math.cos(r)*l,s=t.y+Math.sin(r)*l;0===i?e.moveTo(o,s):e.lineTo(o,s)}e.closePath()}else e.arc(t.x,t.y,l,0,2*Math.PI);i&&(e.save(),e.globalAlpha*=a,e.fillStyle=i,e.fill(),e.restore()),"halo"===c&&(e.beginPath(),e.arc(t.x,t.y,1.35*l,0,2*Math.PI),e.strokeStyle=r??i,e.lineWidth=Math.max(1.5,o||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),r&&o>0&&(e.strokeStyle=r,e.lineWidth=o,n.strokeDasharray&&e.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function ed(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function td(e){return e.sensorId??"stream-region-"+e.id}function nd(e){const t=td(e),n={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){const i=e.colliderThickness??8,r=e.shape.x-e.shape.width/2,o=e.shape.x+e.shape.width/2,s=e.shape.y-e.shape.height/2,a=e.shape.y+e.shape.height/2;return[{...n,id:t+"-top",shape:{type:"segment",x1:r,y1:s,x2:o,y2:s,thickness:i}},{...n,id:t+"-right",shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:i}},{...n,id:t+"-bottom",shape:{type:"segment",x1:o,y1:a,x2:r,y2:a,thickness:i}},{...n,id:t+"-left",shape:{type:"segment",x1:r,y1:a,x2:r,y2:s,thickness:i}}]}return e.collider?[{...n,id:t+"-collider",shape:e.shape}]:[]}function id(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function rd(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}function od(e){if(!1===e.semanticItem)return null;const t=e.shape,n=e.semanticItem??{},i="aabb"===t.type?{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:t.x,y:t.y,width:t.width,height:t.height}:{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2,pathData:`M ${t.x1} ${t.y1} L ${t.x2} ${t.y2}`};return{...i,...n,id:n.id??i.id}}function sd(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function ad(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}var cd=[];function ld(e){const t=e.store.controls(),n=e.store.snapshot(),i=Math.max(0,e.result.steps*(n.config.fixedDt||1/60)),r=function(e,t,n,i){const r=Number.isFinite(i)?Math.max(0,i):0;if(0>=r||!sd(t))return!1;const o=new Map(t.map(e=>[e.id,e])),s=e.readBodies();let a=!1;for(const t of s){const i=n.get(t.id);if(!i||!i.activeRegionIds.size)continue;const s=id(i);if(s)for(const n of i.activeRegionIds){const i=o.get(n);if(!i)continue;const c=rd(i.force,{body:t,region:i,regionState:s}),l=Number(i.damping??0),u=(c?.x??0)*r-(Number.isFinite(l)?t.vx*l*r:0),d=(c?.y??0)*r-(Number.isFinite(l)?t.vy*l*r:0);(u||d)&&(e.applyImpulse(t.id,u,d),a=!0)}}return a}(t,e.regionEffects,e.regionState,i),o=function(e,t,n,i,r,o){const s=Number.isFinite(o)?Math.max(0,o):0;if(0>=s||!t)return!1;const a=new Map(n.map(e=>[e.id,e])),c=e.readBodies();let l=!1;for(let n=0;c.length>n;n+=1){const o=c[n],u=i.get(o.id),d=id(u);let h=cd;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const n=a.get(t);n&&e.push(n)}h=e}const f=ad(t,{body:o,bodies:c,index:n,regionState:d,regions:h,simulationState:r});if(!f)continue;const p=(f.x??0)*s,y=(f.y??0)*s;(p||y)&&(e.applyImpulse(o.id,p,y),l=!0)}return l}(t,e.bodyForces,e.regionEffects,e.regionState,n.simulationState,i);return e.composed&&e.composed.onTick(e.result,t,{dt:i,elapsed:e.result.elapsedSeconds,getRegionState:t=>id(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:o,snapshot:n}}function ud(e,t,n,i,r,o,s,a,c,l){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,r),d={selected:u,simulationState:t,regionState:o,regions:s},h="function"==typeof n?n(e,d):n,f=s.reduce((t,n)=>n.bodyStyle?{...t,..."function"==typeof n.bodyStyle?n.bodyStyle(e,d):n.bodyStyle}:t,{}),p=u?"function"==typeof i?i(e,d):i:void 0;return{fill:l?.color??a,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...f,...p}}var dd=c(require("react")),hd=require("react/jsx-runtime"),fd={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},pd="semiotic-accessible-data-table",yd=pd+" semiotic-accessible-data-table-hidden",gd=pd+" semiotic-accessible-data-table-visible",md={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"},xd={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},bd={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)"},vd={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},wd={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))"},kd={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Sd={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ad={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 Md(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function Pd(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function _d(e){if("circle"===e.shape.type){const t=Math.max(4,2*e.shape.radius);return{height:t,shape:"circle",width:t}}return{height:e.shape.height,shape:"rect",width:e.shape.width}}function jd(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e+""}return e.id}function Cd(e){const t=Id(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function Id(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=Md(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function Td({hover:e}){const t=Id(e.data);return(0,hd.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,hd.jsx)("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>(0,hd.jsxs)("div",{children:[(0,hd.jsxs)("span",{style:{opacity:.72},children:[e,": "]}),(0,hd.jsx)("span",{children:t})]},e))]})}function Rd(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=Md(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function Ld(e){const t=[`${e.length} semantic item${1===e.length?"":"s"}.`],n=new Map;for(const t of e)t.group&&n.set(t.group,(n.get(t.group)??0)+1);return n.size&&t.push(Array.from(n).map(([e,t])=>`${e}: ${t}`).join(", ")),t.join(" ")}function $d(e){const{chartTitle:t,items:n,tableId:i}=e,[r,o]=dd.useState(!1),[s,a]=dd.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=dd.useRef(null),h="Data summary for "+(t??"physics chart");dd.useEffect(()=>{u||a(5)},[u]);const f=dd.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=dd.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!n.length)return(0,hd.jsx)("span",{id:i,tabIndex:-1,style:fd});if(!u)return(0,hd.jsx)("div",{id:i,className:yd,role:"region","aria-label":h,tabIndex:-1,style:fd,onFocus:f,children:(0,hd.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",n.length," semantic items)"]})});const y=Math.min(s,n.length),g=n.slice(0,y),m=n.length-y;return(0,hd.jsxs)("div",{ref:d,id:i,className:gd,role:"region","aria-label":h,tabIndex:-1,onBlur:p,style:md,children:[(0,hd.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},style:bd,children:"×"}),(0,hd.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:xd,children:Ld(n)}),(0,hd.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:vd,children:[(0,hd.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Sd,children:m>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),(0,hd.jsx)("thead",{children:(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"col",style:wd,children:"Item"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Description"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Group"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Position"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Data"})]})}),(0,hd.jsx)("tbody",{children:g.map((e,t)=>(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"row",style:kd,children:e.label}),(0,hd.jsx)("td",{style:kd,children:e.description??e.label}),(0,hd.jsx)("td",{style:kd,children:e.group??""}),(0,hd.jsxs)("td",{style:kd,children:[Math.round(e.x),", ",Math.round(e.y)]}),(0,hd.jsx)("td",{style:kd,children:Rd(e)})]},e.id??`${e.label}-${t}`))})]}),m>0?(0,hd.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ad,children:["Show ",Math.min(25,m)," more"," ",1===m?"row":"rows"," (",m," remaining)"]}):null]})}Td.ownsChrome=!0;var Ed=require("react/jsx-runtime"),zd=[640,360],Dd={top:0,right:0,bottom:0,left:0},Bd=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Fd(e,t,n){const i=new Fl(e);return t?.length&&i.enqueue(t,n),i}var Nd="StreamPhysicsFrame";function Od(){return"undefined"!=typeof performance?performance.now():Date.now()}var Wd=(0,su.memo)((0,su.forwardRef)(function(e,t){const{accessibleTable:n=!0,annotations:i,autoPlaceAnnotations:r,background:o,backgroundGraphics:s,bodySemanticItemLimit:a=200,bodySemanticItems:c=!1,bodySemanticUpdateMs:l=200,bodyForces:u,bodyStyle:d,chartId:h,className:f,frameScheduler:p,clock:y,color:g,config:m,controllers:x,continuous:b=!1,description:v,emphasis:w,chartMode:k,enableHover:S=!0,foregroundGraphics:A,hoverRadius:M=16,initialSpawns:P,initialSpawnPacing:_,legend:j,legendClickBehavior:C,legendHighlightedCategory:I,legendHoverBehavior:T,legendIsolatedCategories:R,legendLayout:L,legendPosition:$,margin:E,onClick:z,onObservation:D,onRegionEvent:B,onSimulationExecutionChange:F,onBodyHover:N,onBodyPointerDown:O,onSemanticItemActivate:W,onSemanticItemFocus:q,onTick:Y,opacity:H,paused:G=!1,regionEffects:X=[],responsiveHeight:V,responsiveWidth:U,selectedBodyStyle:K={stroke:"#111827",strokeWidth:2,opacity:1},selection:Z,semanticItems:Q=[],simulationExecution:J="auto",size:ee=zd,stroke:te,strokeWidth:ne,summary:ie,suspendWhenHidden:re=!0,svgAnnotationRules:oe,title:se,tooltipContent:ae,workerBodyThreshold:ce=Pu,renderBody:le,beforePaint:ue,afterPaint:de}=e,he=ou.useMemo(()=>({color:g,stroke:te,strokeWidth:ne,opacity:H}),[g,H,te,ne]),fe=(0,su.useRef)(D);fe.current=D;const pe=(0,su.useRef)(h);pe.current=h;const ye=(0,su.useRef)(new Map),ge=(0,su.useRef)(X);ge.current=X;const me=(0,su.useRef)(u);me.current=u;const xe=(0,su.useRef)(Y);xe.current=Y;const be=ou.useMemo(()=>function(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,i)=>{const r={result:e,controls:n,dt:i.dt,elapsed:i.elapsed,getRegionState:i.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const i of t)i.bodyForce&&(n=Ku(n,i.bodyForce(e)));return n}}}(x),[x]),ve=(0,su.useRef)(be);ve.current=be;const we=b||!!be?.continuous,ke=(0,su.useRef)(we);ke.current=we;const Se=ou.useMemo(()=>{if(!u&&!be?.bodyForce)return u;if(!be?.bodyForce)return u;if(!u)return be.bodyForce;const e=be.bodyForce;return t=>{const n="function"==typeof u?u(t):u,i="function"==typeof e?e(t):e;return n||i?{x:(n?.x??0)+(i?.x??0),y:(n?.y??0)+(i?.y??0)}:null}},[u,be]);me.current=Se;const Ae=ou.useMemo(()=>new Map(X.map(e=>[td(e),e])),[X]),Me=ou.useMemo(()=>new Map(X.map(e=>[e.id,e])),[X]),Pe=ou.useMemo(()=>X.map(od).filter(e=>null!=e),[X]),[_e,je]=ou.useState([]),Ce=ou.useMemo(()=>_e.length||Pe.length?[...Q,..._e,...Pe]:Q,[_e,Pe,Q]),Ie=ou.useMemo(()=>sd(X),[X]),Te=!!Se,Re=(0,su.useRef)(null),Le=(0,su.useRef)(y??Od);Le.current=y??Od;const $e=(0,su.useCallback)((e,t,n)=>{const i=Re.current;if(!i||!n)return!1;const r=i.readBodies().find(t=>t.id===e),o=id(ye.current.get(e));if(!r||!o)return!1;const s=rd(n,{body:r,region:t,regionState:o});return!(!s||!s.x&&!s.y||(i.applyImpulse(e,s.x??0,s.y??0),0))},[]),Ee=(0,su.useCallback)((e,t,n)=>{if(!n.bodyId)return;const i=id(ye.current.get(n.bodyId));if(!i)return;const r={bodyId:n.bodyId,datum:n.datum,observation:n,region:t,regionState:i,type:e};"region-enter"===e?t.onEnter?.(r):t.onExit?.(r),B?.(r)},[B]),ze=(0,su.useCallback)(e=>{const t=e.sensorId?Ae.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const n=function(e,t){let n=e.get(t);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,n)),n}(ye.current,e.bodyId),i=Re.current?.readBodies().find(t=>t.id===e.bodyId),r=id(n),o=i&&r?{body:i,region:t,regionState:r}:null;if("physics-proximity-enter"===e.type){if(n.activeRegionIds.add(t.id),n.regionIds.add(t.id),n.energy+=t.energyDelta??0,o){!function(e,t,n){const i="function"==typeof e.attributes?e.attributes(t):e.attributes;i&&(n.attributes={...n.attributes,...i})}(t,o,n);const e=function(e,t){return void 0!==e.charge?"function"==typeof e.charge?e.charge(t):e.charge:"charge-gate"===e.kind?1:void 0}(t,o);void 0!==e&&(n.charges[t.id]=e)}$e(e.bodyId,t,t.impulseOnEnter),Ee("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),$e(e.bodyId,t,t.impulseOnExit),Ee("region-exit",t,e))},[$e,Ee,Ae]),De=ou.useMemo(()=>{if(!i?.length)return[];const e=i.filter(e=>"barrier"===e.physics||"sensor"===e.physics);return e.length?function(e=[],t={}){const n=t.idPrefix?t.idPrefix+"-":"",i=[];for(const r of e){if("barrier"!==r.physics&&"sensor"!==r.physics)continue;const e=r.axis??t.defaultAxis??"x",o=Mu(r,t),s=r.colliderId??`${n}${r.id}`;let a;if("x"===e){const e=Au(r.x),n=Au(r.y1)??Au(t.plotBounds?.y)??Au(r.y),i=Au(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??Au(r.y);if(null==e||null==n||null==i)continue;a={type:"segment",x1:e,y1:n,x2:e,y2:i,thickness:o}}else{const e=Au(r.y),n=Au(r.x1)??Au(t.plotBounds?.x)??Au(r.x),i=Au(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??Au(r.x);if(null==e||null==n||null==i)continue;a={type:"segment",x1:n,y1:e,x2:i,y2:e,thickness:o}}i.push({id:s,shape:a,sensor:"sensor"===r.physics,..."barrier"!==r.physics||null==r.restitution&&null==t.barrierRestitution?{}:{restitution:Au(r.restitution)??Au(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:Au(r.friction)??Au(t.barrierFriction)}})}return i}(e,{idPrefix:h?h+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:ee?.[0]??zd[0],height:ee?.[1]??zd[1]}}):[]},[i,h,ee]),Be=ou.useMemo(()=>{const e=X.flatMap(e=>[{id:td(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...nd(e)]),t=Object.fromEntries(X.map(e=>[td(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),n=m?.observation,i=X.length>0;return i||e.length>0||De.length>0||null!=h||n?{...m,colliders:[...m?.colliders??[],...e,...De],observation:{...n,chartId:h??n?.chartId,chartType:n?.chartType??Nd,sensors:{...n?.sensors??{},...t},onObservation:e=>{i&&ze(e),n?.onObservation?.(e)}}}:m},[De,h,m,ze,X]);if(!Re.current){const e=Fd(Be,P,_);e.setPaused(G),re&&e.setVisible(Qu()),Re.current=e}const Fe=(0,su.useRef)(null),Ne=(0,su.useRef)(-1),Oe=(0,su.useRef)(null),We=(0,su.useRef)(!0),qe=(0,su.useRef)(""),Ye=(0,su.useId)().replace(/:/g,""),He=(0,su.useRef)(!1),Ge=(0,su.useRef)(!1),Xe=(0,su.useRef)(0),Ve=(0,su.useRef)(!1),Ue=(0,su.useRef)(null),Ke=(0,su.useRef)(!1),Ze=ls({sizeProp:ee,responsiveWidth:U,responsiveHeight:V,userMargin:E,marginDefault:Dd,foregroundGraphics:A,backgroundGraphics:s,frameScheduler:p}),{margin:Qe,rafRef:Je,reducedMotionRef:et,renderFnRef:tt,cancelRender:nt,resolvedBackground:it,resolvedForeground:rt,responsiveRef:ot,scheduleRender:st,size:at}=Ze,ct=ho(),lt=go(),[ut,dt]=ou.useState(null),[ht,ft]=ou.useState(null),pt=(0,su.useRef)(null),yt=(0,su.useRef)(0),gt=(0,su.useRef)(new Map),mt=Ye+"-physics-live",xt=(0,su.useCallback)((e,t,n=!1)=>{if(!c)return void je(e=>e.length?[]:e);const i=Le.current();if(!n&&l>0&&l>i-yt.current)return;yt.current=i;const r=function(e,t,n,i){if(!n)return[];const r=Math.max(0,Math.floor(i));if(!r)return[];const o=[];for(let i=0;e.length>i&&r>o.length;i+=1){const r=e[i],s="function"==typeof n?n(r,{index:i,simulationState:t}):void 0;if(!1===s)continue;const a=_d(r);o.push({datum:r.datum??r,description:Cd(r),group:"body",label:jd(r),...a,...s??{},bodyId:s?.bodyId??r.id,id:s?.id??"body:"+r.id,x:s?.x??r.x,y:s?.y??r.y})}return o}(e,t,c,a);je(e=>function(e,t){if(e.length!==t.length)return!0;for(let n=0;e.length>n;n+=1){const i=e[n],r=t[n];if(i.id!==r.id||i.label!==r.label||i.description!==r.description||i.group!==r.group||i.bodyId!==r.bodyId||Math.round(i.x)!==Math.round(r.x)||Math.round(i.y)!==Math.round(r.y))return!0}return!1}(e,r)?r:e)},[a,c,l]),bt=(0,su.useCallback)(e=>{if(!Ce.length)return;const t=Math.max(0,Math.min(e,Ce.length-1));Ne.current=t;const n=Ce[t];if(pt.current=n.bodyId??null,dt(n),q?.(n),n.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=Pd(e);ft(t),N?.(e,t)}}},[Ce,N,q]),vt=(0,su.useCallback)(()=>{Ne.current=-1,pt.current=null,dt(null),q?.(null)},[q]),wt=(0,su.useCallback)((e,t)=>{const n=fe.current;if(!n)return;const i=Le.current();n("hover"!==e&&"click"!==e?{type:e,timestamp:i,chartType:Nd,chartId:pe.current}:{type:e,datum:t?.datum??{},x:t?.x??0,y:t?.y??0,timestamp:i,chartType:Nd,chartId:pe.current})},[]),kt=(0,su.useCallback)(()=>{ft(e=>e?(N?.(null,null),wt("hover-end"),null):e)},[wt,N]),St=(0,su.useCallback)(e=>{if(!S||!Re.current)return;const t=e.currentTarget.getBoundingClientRect(),n=Re.current.hitTest(e.clientX-t.left,e.clientY-t.top,M);if(!n)return void kt();const i=Pd(n);ft(e=>e&&e.id===i.id&&e.x===i.x&&e.y===i.y?e:(N?.(n,i),wt("hover",{datum:n.datum,x:n.x,y:n.y}),i))},[kt,wt,S,M,N]),At=(0,su.useCallback)(e=>{vt();const t=Re.current,n=e.currentTarget.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=t?t.hitTest(i,r,Math.max(16,M)):null;O?.(o,e),o?(wt("click",{datum:o.datum,x:o.x,y:o.y}),z?.(o.datum??null,{x:o.x,y:o.y,body:o})):(wt("click-end"),z?.(null,{x:i,y:r,body:null}),kt())},[kt,vt,wt,M,O,z]);(0,su.useEffect)(()=>{if(!Ce.length)return void vt();const e=Ne.current;if(Ce.length>e){if(e>=0){const t=Ce[e];if(pt.current=t.bodyId??null,dt(e=>null!=e&&e.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t),t.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=Pd(e);ft(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else bt(Ce.length-1)},[Ce,vt,bt]),(0,su.useEffect)(()=>{S||kt()},[kt,S]);const Mt=(0,su.useCallback)(e=>{if(!Ce.length)return;if("Escape"===e.key)return e.preventDefault(),void vt();if(("Enter"===e.key||" "===e.key)&&Ne.current>=0)return e.preventDefault(),void W?.(Ce[Ne.current]);if(!Bd.has(e.key))return;e.preventDefault();const t=Ne.current;if(0>t)return void bt(0);const n=Math.max(1,Math.floor(.1*Ce.length));let i=t;"Home"===e.key?i=0:"End"===e.key?i=Ce.length-1:"PageDown"===e.key?i=Math.min(Ce.length-1,t+n):"PageUp"===e.key?i=Math.max(0,t-n):"ArrowRight"===e.key||"ArrowDown"===e.key?i=Math.min(Ce.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(i=Math.max(0,t-1)),bt(i)},[vt,bt,W,Ce]),[Pt,_t]=ou.useState([]),jt=(0,su.useRef)(0),Ct=!!i?.length&&i.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),It=(0,su.useCallback)(()=>{const e=Fe.current,t=Re.current;if(!e||!t)return;const n=ds(),i=us(e,at,Qe,n);if(!i)return;const r=function(e){const t=mu(e,hu),n=mu(e,lu),i=mu(e,gu),r=mu(e,fu),o=mu(e,cu),s=mu(e,au),a=mu(e,pu),c=mu(e,yu),l=mu(e,uu),u=mu(e,du);return{annotationBackground:xu(s,.94),annotationStroke:o,annotationText:a,background:s,border:o,closedWindowFill:xu(n,.08),closedWindowStroke:xu(n,.55),danger:n,focus:l,grid:u,gutterFill:xu(c,.14),lateFill:i,openWindowFill:xu(t,.07),openWindowStroke:xu(t,.3),primary:t,selectedFill:i,selectedStroke:l,success:r,text:a,textSecondary:c,warning:i}}(i);i.clearRect(-Qe.left,-Qe.top,at[0],at[1]),s||"transparent"===o||(i.fillStyle=o??r.background,i.fillRect(-Qe.left,-Qe.top,at[0],at[1]));const a=t.snapshot(),c=t.readBodies();if(xt(c,a.simulationState),Ct){const e=Le.current();if(e-jt.current>=100){jt.current=e;const t=function(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,ku(e))}))}(c);_t(e=>e.length===t.length&&e.every((e,n)=>e.pointId===t[n].pointId&&Math.round(e.x)===Math.round(t[n].x)&&Math.round(e.y)===Math.round(t[n].y))?e:t)}}ue&&(i.save(),ue(i,c),i.restore());for(const e of c){const t=ye.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Me.get(e)).filter(e=>null!=e):[],o=ud(e,a.simulationState,d,K,Z,id(t),n,r.primary,r.text,he);le?(i.save(),le(i,e,o),i.restore()):Ju(i,e,o)}de&&(i.save(),de(i,c),i.restore()),function(e,t,n){let i=!1;for(const[r,o]of t){const s=Math.min(1,Math.max(0,(n-o.startedAt)/o.durationMs));if(s>=1){t.delete(r);continue}i=!0;const a=1-Math.pow(1-s,3),{body:c}=o,l=o.radius+28*a,u=1-s;e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.fillStyle=o.color,e.lineWidth=2.4*u+.4,e.beginPath(),e.arc(c.x,c.y,l,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(c.x,c.y,.52*l,0,2*Math.PI),e.fill(),e.restore(),e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.lineWidth=1.8;for(let t=0;8>t;t+=1){const n=t*(Math.PI/4)+1.4*s,i=o.radius+5+12*a,r=o.radius+12+34*a;e.beginPath(),e.moveTo(c.x+Math.cos(n)*i,c.y+Math.sin(n)*i),e.lineTo(c.x+Math.cos(n)*r,c.y+Math.sin(n)*r),e.stroke()}e.restore()}}(i,gt.current,Le.current()),We.current=!1},[de,o,s,ue,d,Qe,Ct,Me,le,K,Z,he,xt,at]),Tt=(0,su.useCallback)((e,t)=>{const n=Re.current,i=`${J}:${e}:${t??""}`;qe.current!==i&&(qe.current=i,F?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:J}))},[F,J]),Rt=(0,su.useCallback)((e,t=!0)=>{Xe.current+=1,He.current=!1,Ve.current=!1,Ke.current=!1,Ue.current?.terminate(),Ue.current=null,t&&Tt("sync",e)},[Tt]),Lt=(0,su.useCallback)(()=>ct?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Ie?"runtime region effects require sync":Te?"body forces require sync":be?"physics controllers require sync":function(e){return!e||!e.engine&&ju(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(Be??{})?Tu(_)?Ge.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Be,be,Te,Ie,ct,_]),$t=(0,su.useCallback)(()=>{const e=Re.current,t=Lt();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),i=e.queueSize(),r=function(e,t,n=0,i=Pu){return"sync"!==e&&("worker"===e||t+n>=i)}(J,n,i,ce);return{reason:r?"worker"===J?"forced worker":"body threshold":"below threshold",useWorker:r}},[J,ce,Lt]),Et=(0,su.useCallback)(e=>{const t=Re.current;return t&&e.snapshot?(t.restore(e.snapshot),We.current=!0,t):t},[]),zt=(0,su.useCallback)((e,t=!0)=>{const n=Et(e);if(!n)return;t&&Y?.(e.result,n.controls()),It();const i=n.snapshot();!e.result.shouldContinue&>.current.size<=0||i.paused||!i.visible||et.current||st()},[Et,Y,It,et,st]),Dt=(0,su.useCallback)(e=>{Ge.current=!0,Rt("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Rt]),Bt=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return!1;const t=$t();if(!t.useWorker)return He.current||Ke.current?Rt(t.reason??"sync fallback"):Tt("sync",t.reason??"sync"),!1;if(He.current||Ke.current)return!0;const n=Ue.current??new Eu;Ue.current=n,Ke.current=!0;const i=Xe.current+1;return Xe.current=i,n.initFromSnapshot(Be??{},e.snapshot()).then(e=>{if(Xe.current!==i)return;Ke.current=!1,He.current=!0,Ge.current=!1,Et(e),Tt("worker",t.reason??"worker"),It();const n=Re.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!et.current&&(Oe.current=null,st())}).catch(e=>{Xe.current===i&&Dt(e)}),!0},[Et,Be,Dt,It,et,Tt,st,Rt,$t]),Ft=(0,su.useCallback)(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Nt=(0,su.useCallback)((e,t=!0)=>{const n=Ue.current;if(!n||!He.current)return;const i=Xe.current;n.request(e).then(e=>{if(Xe.current!==i)return;const n=Ft(e);n&&zt(n,t)}).catch(Dt)},[zt,Ft,Dt]),Ot=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return;const t=Bt(),n=e.snapshot(),i=we||Te||Ie||!!be;n.paused||!n.visible||!e.hasPendingWork()&&!i||et.current?tt.current():t&&Ke.current||(Oe.current=null,st())},[be,we,Te,Ie,et,tt,st,Bt]),Wt=(0,su.useCallback)(()=>{nt(),Je.current=null;const e=Re.current;if(!e)return;if(He.current&&Ue.current){if(Ve.current)return;let t=0;if(!et.current){const e=Le.current();t=null!==Oe.current?(e-Oe.current)/1e3:0,Oe.current=e}const n=Ue.current,i=Xe.current;return Ve.current=!0,void(et.current?n.settle():n.tick(t)).then(e=>{Ve.current=!1,Xe.current===i&&zt(e)}).catch(n=>{if(Ve.current=!1,Xe.current!==i)return;Dt(n);const r=et.current?e.settleWithObservations():e.tick(t);ld({store:e,result:r,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),It()})}let t;if(et.current)t=e.settleWithObservations();else{const n=Le.current(),i=null!==Oe.current?(n-Oe.current)/1e3:0;Oe.current=n,t=e.tick(i)}const n=ve.current,{regionEffectsApplied:i,bodyForcesApplied:r,snapshot:o}=ld({store:e,result:t,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:n,onTick:xe.current});It(),(ke.current||t.shouldContinue||i||r||n||gt.current.size>0)&&!o.paused&&o.visible&&!et.current&&st()},[zt,Dt,It,nt,st,et,Je]);tt.current=Wt,mo({hydrated:ct,wasHydratingFromSSR:lt,storeRef:Re,dirtyRef:We,renderFnRef:tt,cancelRender:nt}),(0,su.useEffect)(()=>{Ge.current=!1,(He.current||Ke.current)&&Rt("config changed",!1),Re.current?.updateConfig(Be??{}),Ot()},[Be,Rt]),(0,su.useEffect)(()=>{Ge.current=!1,Ot()},[ct,J,ce]),function({cancelRender:e,lastFrameTimeRef:t,paused:n,postWorkerCommand:i,requestRender:r,storeRef:o,suspendWhenHidden:s}){const a=(0,Zu.useRef)(i);a.current=i;const c=(0,Zu.useRef)(r);c.current=r,(0,Zu.useEffect)(()=>{const i=o.current;i&&(i.setPaused(n),n&&(t.current=null,e()),a.current({type:"setPaused",paused:n},!1),c.current())},[e,n]),(0,Zu.useEffect)(()=>{if(!s||"undefined"==typeof document)return;const n=()=>{const n=o.current;if(!n)return;const i=Qu();n.setVisible(i),i||(t.current=null,e()),a.current({type:"setVisible",visible:i},!1),c.current()};return n(),document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[e,s])}({cancelRender:nt,lastFrameTimeRef:Oe,paused:G,postWorkerCommand:Nt,requestRender:Ot,storeRef:Re,suspendWhenHidden:re}),(0,su.useEffect)(()=>()=>Rt("unmount",!1),[Rt]),(0,su.useEffect)(()=>{It()},[It]),(0,su.useImperativeHandle)(t,()=>({...Re.current.controls(),applyImpulse:(e,t,n)=>{Re.current.applyImpulse(e,t,n),Nt({type:"applyImpulse",id:e,ix:t,iy:n}),Ot()},clear:()=>{Re.current.clear(),ye.current.clear(),gt.current.clear(),Nt({type:"clear"}),Ot()},clearRegionState:e=>{e?ye.current.delete(e):ye.current.clear(),Ot()},getData:()=>Re.current.readBodies(),getRegionState:e=>e?id(ye.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const i=id(e);i&&(t[n]=i)}),t}(ye.current),getStore:()=>Re.current,pause:()=>{Re.current.setPaused(!0),Nt({type:"setPaused",paused:!0},!1),Ot()},push:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:[e],pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},pushMany:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:e,pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},popBodies:(e,t={})=>{const n=Re.current,i=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),o=Le.current();for(const e of r){const n=i.get(e);n&&(ye.current.delete(e),gt.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??ed(n),startedAt:o}),pt.current===e&&(pt.current=null,dt(null)),ft(t=>t?.id===e?null:t))}return r.length&&(Nt({type:"remove",ids:r}),Ot()),r},remove:e=>{const t=Re.current.remove(e);for(const t of e)ye.current.delete(t);return Nt({type:"remove",ids:e}),Ot(),t},restore:e=>{Re.current.restore(e),ye.current.clear(),gt.current.clear(),Nt({type:"restore",snapshot:e},!1),Ot()},resume:()=>{Re.current.setPaused(!1),Nt({type:"setPaused",paused:!1},!1),Ot()},settle:e=>{const t=Re.current.settle(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},settleWithObservations:e=>{const t=Re.current.settleWithObservations(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},step:e=>{const t=Re.current,n=t.tick(e);return ld({store:t,result:n,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),Nt({type:"tick",deltaSeconds:e}),It(),n}}),[It,Nt,Ot,Rt]);const qt=co||!ct&<,Yt=["stream-physics-frame",k?"stream-physics-frame--mode-"+k:null,w?"stream-physics-frame--emphasis-"+w:null,f].filter(Boolean).join(" "),Ht=v??("string"==typeof se?se:void 0)??"Physics chart",Gt=Ye+"-physics-table",Xt=Math.max(1,at[0]-Qe.left-Qe.right),Vt=Math.max(1,at[1]-Qe.top-Qe.bottom),Ut=S&&ht?ae?ae(ht):(0,Ed.jsx)(Td,{hover:ht}):null,Kt=Ut&&ht?(0,Ed.jsx)(ts,{x:ht.x-Qe.left,y:ht.y-Qe.top,containerWidth:Math.max(1,at[0]-Qe.left-Qe.right),containerHeight:Math.max(1,at[1]-Qe.top-Qe.bottom),margin:Qe,className:"stream-physics-tooltip",children:Ut}):null;if(qt){const e=Re.current??Fd(Be,P,_),t="string"==typeof se?se:void 0,{svg:n}=qu(e,{width:at[0],height:at[1],title:t,description:v,background:"transparent"===o?void 0:o,className:"stream-physics-frame__svg",idPrefix:"physics-"+Ye});return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"img","aria-label":Ht,style:{width:at[0],height:at[1]},children:[(0,Ed.jsx)(Xo,{summary:ie}),(0,Ed.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"group","aria-label":Ht,"aria-describedby":ut?mt:void 0,tabIndex:0,style:{position:"relative",width:at[0],height:at[1]},onKeyDown:Mt,children:[n?(0,Ed.jsx)(Vo,{tableId:Gt}):null,n?(0,Ed.jsx)($d,{chartTitle:"string"==typeof se?se:Ht,items:Ce,tableId:Gt}):null,(0,Ed.jsx)(Xo,{summary:ie}),(0,Ed.jsx)(Uo,{hoverPoint:ht}),(0,Ed.jsx)("div",{id:mt,"aria-live":"polite","aria-atomic":"true",style:fd,children:ut?ut.description??ut.label:""}),(0,Ed.jsxs)("div",{role:"img","aria-label":Ht,style:{position:"relative",width:"100%",height:"100%"},children:[it,(0,Ed.jsx)("canvas",{ref:Fe,width:at[0],height:at[1],"aria-hidden":"true",onPointerDown:At,onPointerMove:S?St:void 0,onPointerLeave:S?kt:void 0}),rt,(0,Ed.jsx)(Su,{width:Xt,height:Vt,totalWidth:at[0],totalHeight:at[1],margin:Qe,title:se,legend:j,legendPosition:$,legendLayout:L,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:I,legendIsolatedCategories:R,pointNodes:Pt,annotations:i,autoPlaceAnnotations:r,svgAnnotationRules:oe}),(0,Ed.jsx)(Qo,{active:null!=ut,hoverPoint:ut?{x:ut.x,y:ut.y}:null,margin:Qe,size:at,shape:ut?.shape,width:ut?.width,height:ut?.height,pathData:ut?.pathData}),Kt]})]})}));Wd.displayName="StreamPhysicsFrame";var qd=Wd,Yd=require("react");function Hd(e,t){if(!t?.length)return[e];const n=t.filter(t=>{if(t.id===e||t.id.startsWith(e+"-"))return!0;const n=t.datum;return!(!n||"object"!=typeof n||null==n.id)&&n.id+""===e}).map(e=>e.id);return n.length?n:[e]}function Gd(e,t,n){if("function"==typeof n)return n(e,t)+"";if("string"==typeof n){const t=e[n];if(null!=t)return t+""}return null!=e&&"object"==typeof e&&"id"in e&&null!=e.id?e.id+"":"physics-row-"+t}function Xd(e,t){const n=e?.getData().find(e=>e.id===t),i=n?.datum;if(i&&"object"==typeof i)return i}var Vd=require("react"),Ud=require("react/jsx-runtime"),Kd=new Set(["sample","mechanical"]);function Zd(e,t,n){const i=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&Kd.has(e);return e.simulationMode?{chartMode:t(e.mode)?void 0:e.mode,simulationMode:e.simulationMode}:t(e.mode)?{chartMode:void 0,simulationMode:e.mode}:{chartMode:e.mode,simulationMode:"sample"}}({mode:e.mode,simulationMode:e.simulationMode}):{chartMode:"sample"===e.mode||"mechanical"===e.mode?void 0:e.mode,simulationMode:"sample"},r=_a(i.chartMode,{width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:t[0],height:t[1]}),o=e.size?.[0],s=e.size?.[1],a=t[0],c=t[1],l=(0,Vd.useMemo)(()=>{return e=[a,c],(null!=o&&null!=s?[o,s]:void 0)??[r.width??e[0],r.height??e[1]];var e},[c,a,r.height,r.width,s,o]),u=r.compactMode?"sparkline"===i.chartMode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0};const d=e.showProjection??!r.compactMode,h=e.showChrome??!r.compactMode,f=th(e.tooltip,void 0),p=void 0!==f.enableHover?f.enableHover:r.enableHover,y=r.compactMode?r.title:r.title??e.title,g=[e.className,i.chartMode&&"primary"!==i.chartMode?"semiotic-physics--"+i.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:i.chartMode,simulationMode:i.simulationMode,resolved:r,chartSize:l,margin:u,showProjection:d,showChrome:h,enableHover:p,title:y,description:r.description??e.description,summary:r.summary??e.summary,accessibleTable:r.accessibleTable??e.accessibleTable,className:g,compactMode:r.compactMode,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics}}function Qd(e){const[t,n]=e.size;return Fa(e.loading,t,n,e.loadingContent)||Ba(e.data,t,n,e.emptyContent)}function Jd(e,t,n){return(0,Ud.jsx)(Ea,{componentName:e,width:t[0],height:t[1],children:n})}function eh(e,t){return e?t?n=>(0,Ud.jsxs)(Ud.Fragment,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function th(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:Q(e)||t?.tooltipContent}}function nh(e,t,n,i){return{accessibleTable:i?.accessibleTable??e.accessibleTable??t?.accessibleTable,annotations:e.annotations??t?.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations??t?.autoPlaceAnnotations,background:e.background??t?.background,chartId:e.chartId??t?.chartId,chartMode:i?.chartMode??t?.chartMode,className:i?.className??e.className??t?.className,color:e.color??t?.color,description:i?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:i?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:i?.margin??t?.margin,onClick:null!=e.onClick?(t,n)=>{e.onClick?.(t,{x:n.x,y:n.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,opacity:e.opacity??t?.opacity,semanticItems:t?.semanticItems??n,stroke:e.stroke??t?.stroke,strokeWidth:e.strokeWidth??t?.strokeWidth,summary:i?.summary??e.summary??t?.summary,svgAnnotationRules:e.svgAnnotationRules??t?.svgAnnotationRules,title:i?.title??e.title??t?.title}}var ih=require("react/jsx-runtime");function rh(e,t){const n=t.config??{},i=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...i],o=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...o.length>0&&{colliders:o}}}function oh(e){const t=function(e,t,n){const i=e?.observation;return{...e,observation:{...i,chartId:t??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:n??i?.onObservation}}}(e.config,e.chartId,e.onObservation),n=iu(e.colorScheme,e.themeCategorical,g),i=Sc(e.size),r={data:e.data,scales:{x:(0,nu.scaleLinear)().domain(e.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:(0,nu.scaleLinear)().domain(e.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:ru(n,e.colorScheme),config:e.layoutConfig??{},world:new Fl(t)},o=e.skipLayout?{}:e.layout(r)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...i}=e,r=n.get(t)??[];r.push(i),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...o.initialSpawns??o.bodies??[]],o.constraints);return{config:rh(t,o),context:r,initialSpawnPacing:o.initialSpawnPacing,initialSpawns:s,result:o}}(0,tu.forwardRef)(function(e,t){const{chartId:n,color:i,colorBy:r,colorScheme:o,config:s,controllers:a,data:c,emptyContent:l,frameProps:u={},layout:d,layoutConfig:h,loading:f,loadingContent:p,onObservation:y,opacity:g,paused:m,spawnDatum:x,stroke:b,strokeWidth:v,title:w,xExtent:k,yExtent:S}=e,A=Zd(e,[700,380]),{chartSize:M,className:P,title:_,chartMode:j,margin:C,enableHover:I,description:T,summary:R,accessibleTable:L}=A,$=(0,tu.useRef)(null),E=(0,tu.useRef)(null),z=(0,tu.useRef)(""),D=Qd({data:c,emptyContent:l,loading:f,loadingContent:p,size:M}),F=null!=D,N=(0,tu.useMemo)(()=>B(c??[]),[c]),O=Pe(e=>e.theme),W=(0,tu.useMemo)(()=>xe(O)??{},[O]),q=O?.colors?.categorical??we.colors.categorical,Y=(0,tu.useMemo)(()=>[M[0],M[1],N.length,N.map((e,t)=>(e.id??t)+"").join("|"),k?.join(",")??"",S?.join(",")??""].join("::"),[M,N,k,S]),H=(0,tu.useMemo)(()=>oh({chartId:n,colorScheme:o,config:s,data:N,layout:d,layoutConfig:h,onObservation:y,semantic:W,skipLayout:F,size:M,themeCategorical:q,xExtent:k,yExtent:S}),[n,M,o,s,d,h,y,N,W,F,q,k,S]);z.current===Y&&null!=E.current||(z.current=Y,E.current=H.initialSpawns);const G=E.current,X=(0,tu.useMemo)(()=>{const e=[...H.result.controllers??[],...a??[],...u.controllers??[]];return e.length?e:void 0},[u.controllers,a,H.result.controllers]),V=(0,tu.useMemo)(()=>{const e=[...H.result.regionEffects??[],...u.regionEffects??[]];return e.length?e:void 0},[u.regionEffects,H.result.regionEffects]),U=(0,tu.useCallback)(e=>{const t=e.datum,n=t&&r?function(e,t,n){return"function"==typeof n?n(e,0):e[n]}(t,0,r)+"":e.id;return{fill:i??H.context.resolveColor(n,t),stroke:b??"#111827",strokeWidth:v??1,opacity:g??.9}},[i,r,g,H.context,b,v]);!function(e,t){const{frameRef:n,spawnDatum:i,seedRows:r,idAccessor:o,bodyIdsForSeed:s,seedSpawns:a}=t,c=(0,Yd.useRef)(new Map),l=(0,Yd.useRef)(new Map),u=(0,Yd.useRef)(""),d=r?r.map((e,t)=>Gd(e,t,o)).join("\0"):"";if(d!==u.current&&(u.current=d,r))for(let e=0;r.length>e;e+=1){const t=r[e],n=Gd(t,e,o);c.current.set(n,t),l.current.set(n,s?.(t,n,e)??Hd(n,a))}(0,Yd.useImperativeHandle)(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=i(e,t);return{datumId:n.datumId||Gd(e,t,o),spawns:n.spawns.map(e=>({...e,spawnAt:void 0}))}}function s(i){const r=[];for(const{datum:n,result:o}of i)e.set(o.datumId,n),t.set(o.datumId,o.spawns.map(e=>e.id)),r.push(...o.spawns);if(!r.length)return;const o=n.current;o?(o.pushMany(r),o.step(0)):"production"!==process.env.NODE_ENV&&console.warn("[semiotic/physics] push() called before the physics frame mounted (loading/empty early-return). Omit data for push mode and ensure the chart is mounted.")}function a(i){const r=e.get(i);if(r)return r;const o=t.get(i)??[i];for(const r of o){const o=Xd(n.current,r);if(o)return e.set(i,o),t.has(i)||t.set(i,[r]),o}}return{push:t=>{s([{datum:t,result:r(t,e.size)}])},pushMany:t=>{const n=e.size;s(t.map((e,t)=>({datum:e,result:r(e,n+t)})))},remove:i=>{const r=Array.isArray(i)?i:[i],o=[],s=[];for(const n of r){const i=a(n);i&&o.push(i),e.delete(n),s.push(...t.get(n)??[n]),t.delete(n)}return s.length&&n.current?.remove(s),o},update:(i,o)=>{const c=Array.isArray(i)?i:[i],l=[];for(const i of c){const c=a(i);if(!c)continue;l.push(c);const u=t.get(i)??[i];n.current?.remove(u),e.delete(i),t.delete(i);const d=o(c);s([{datum:d,result:r(d,e.size)}])}return l},clear:()=>{e.clear(),t.clear(),u.current="",n.current?.clear()},getData:()=>{const t=n.current;if(!t)return Array.from(e.values());const i=t.getData().map(e=>e.datum).filter(e=>!!e&&"object"==typeof e);return i.length?i:Array.from(e.values())},getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(e,t)=>n.current?.popBodies(e,t)??[]}},[s,n,o,i])}(t,{frameRef:$,spawnDatum:(0,tu.useCallback)((e,t)=>{const i=e;if(x)return function(e,t,n){return Array.isArray(n)?{datumId:(e.id??n[0]?.id??"physics-custom-"+t)+"",spawns:n}:"spawns"in n?n:{datumId:(e.id??n.id??"physics-custom-"+t)+"",spawns:[n]}}(e,t,x(i,t,H.context));const r=oh({chartId:n,colorScheme:o,config:s,data:[i],layout:d,layoutConfig:h,onObservation:y,semantic:W,size:M,themeCategorical:q,xExtent:k,yExtent:S}),a=r.initialSpawns.length?r.initialSpawns:[{id:(e.id??"physics-custom-"+t)+"",x:r.context.dimensions.plot.x+r.context.dimensions.plot.width/2,y:r.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:e}];return{datumId:(e.id??a[0].id)+"",spawns:a}},[n,M,o,s,x,d,h,y,H.context,W,q,k,S]),seedRows:N,seedSpawns:G});const K=(0,tu.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]);if(D)return D;const Z=th(e.tooltip,u),Q=nh(e,u,H.result.semanticItems,{chartMode:j,className:P,title:_??w,description:T,summary:R,accessibleTable:L,enableHover:I,margin:C});return Jd("PhysicsCustomChart",M,(0,ih.jsx)(qd,{...u,...Z,...Q,ref:$,backgroundGraphics:eh(u.backgroundGraphics,H.result.backgroundOverlays),bodyForces:H.result.bodyForces??u.bodyForces,bodyStyle:H.result.bodyStyle??u.bodyStyle??U,config:H.config,controllers:X,foregroundGraphics:eh(u.foregroundGraphics,H.result.overlays),initialSpawnPacing:H.initialSpawnPacing,initialSpawns:G,onBodyPointerDown:K,paused:m,regionEffects:V,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:H.result.selectedBodyStyle??u.selectedBodyStyle,size:M}))}).displayName="PhysicsCustomChart";var sh=require("react"),ah="gauntlet-core",ch="gauntlet-positive",lh="gauntlet-negative";function uh(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function dh(e,t,n,i){return n?"function"==typeof n?n(e,t):e[n]??i:i}function hh(e){return e?.label??e?.id??"property"}function fh(e){return`gauntlet:${e}:core`}function ph(e,t){return`gauntlet:${e}:positive:${t}`}function yh(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}function gh(e,t,n,i){const r=Math.max(2,n+2),o=80+r,s=i.floorY-r;return{x:Math.max(32+r,Math.min(i.width-30-4-r,e)),y:Math.max(o,Math.min(s,t))}}function mh(e,t,n){const[i,r]=e,o=Math.round(.48*r),s=r-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,u=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:s-n,floorY:s,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*u),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:s-4,height:r,routeY:o,socketX:Math.round(.92*i),startX:d,width:i}}function xh(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function bh(e,t,n,i){const r=xh(n),o=i?.(e,t,n)??{};return{...r,...o,startY:o.startY??o.routeY??r.startY,socketY:o.socketY??o.routeY??r.socketY,graveyardY:o.graveyardY??r.graveyardY}}function vh(e,t){const n=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?i/(n.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function wh(e,t,n){const i=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,o=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*o-1.2*e.delay-5*r))}function kh(e,t,n,i,r){const o=dh(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=i.map(e=>e.id),a=[...dh(e,t,n.positiveAccessor,s)],c=[...dh(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:o,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...dh(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(dh(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:dh(e,t,n.initialViability,100)}}function Sh(e,t,n,i,r,o,s){const a=i.startX,c=i.startY+(i.startY===n.routeY?38*t:0),l=s?.(e,t,n,i)??{},u={__gauntlet:!0,kind:ah,projectId:e.id,sourceDatum:e.datum},d=[{...l,id:fh(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:u}],h=gh(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,n);d[0].x=h.x,d[0].y=h.y;for(const t of e.activePositiveIds){const i=r.get(t);if(!i)continue;const o=vh(e.activePositiveIds,t),s=i.radius??10,a=gh(h.x+Math.cos(o.angle)*o.radius,h.y+Math.sin(o.angle)*o.radius,s,n);d.push({id:ph(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(o.angle),vy:18*Math.sin(o.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:ch,projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.56,damping:.9,restLength:52+o.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const r=o.get(t);r&&d.push(Ah(e,r,i,h.x,h.y,n,l.spawnAt??e.startedAt))}),d}function Ah(e,t,n,i,r,o,s){const a=t.radius??7.2,c=gh(i-12+n%4*12,r+54+12*Math.floor(n/4),a,o);return{id:yh(e.id,t.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:lh,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.62,damping:.92,restLength:52+n%4*3,...t.spring??{}}]}}function Mh(e){return e?Array.isArray(e)?[...e]:Object.entries(e).flatMap(([e,t])=>Array.from({length:Math.max(0,Math.round(Number(t)||0))},()=>e)):[]}function Ph(e,t){return t?Array.isArray(t)?[...t]:t.ids?[...t.ids]:t.candidates?t.candidates.filter(t=>e.includes(t)).slice(0,t.count??1):[]:[]}function _h(e,t){return Ph(e.activePositiveIds,t.popPositive)}function jh(e,t){const n=Ph(e.negativeIds,t.popNegative);if(!n.length)return[];const i=new Map;for(const e of n)i.set(e,(i.get(e)??0)+1);const r=[];return e.negativeIds.forEach((e,t)=>{const n=i.get(e)??0;n>0&&(r.push({propertyId:e,index:t}),i.set(e,n-1))}),r}function Ch(e,t,n){if(t.when&&!t.when(n))return e;let i={...e};const r=_h(i,t);r.length&&(i={...i,activePositiveIds:i.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...i.poppedPositiveIds,...r]))});const o=jh(i,t);if(o.length){const e=new Set(o.map(e=>e.index));i={...i,negativeIds:i.negativeIds.filter((t,n)=>!e.has(n)),poppedNegativeIds:[...i.poppedNegativeIds,...o.map(e=>e.propertyId)]}}const s=Mh(t.addPositive);s.length&&(i={...i,activePositiveIds:Array.from(new Set([...i.activePositiveIds,...s])),missingPositiveIds:i.missingPositiveIds.filter(e=>!s.includes(e))});const a=Mh(t.addNegative);if(a.length&&(i={...i,negativeIds:[...i.negativeIds,...a]}),t.delayDelta&&(i={...i,delay:i.delay+t.delayDelta}),t.metricsDelta){const e={...i.metrics};for(const[n,i]of Object.entries(t.metricsDelta))e[n]=Number(e[n]??0)+i;i={...i,metrics:e}}return t.viabilityDelta&&(i={...i,viability:i.viability+t.viabilityDelta}),t.stage&&(i={...i,stage:t.stage}),t.outcome&&(i={...i,outcome:t.outcome}),i}function Ih(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function Th(e,t){return e.eventsApplied.includes(t.id)?e:{...e,eventsApplied:[...e.eventsApplied,t.id],eventHistory:[...e.eventHistory??[],t],lastEvent:t,stage:t.label??e.stage}}function Rh(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==lh)}function Lh(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}var $h=require("react/jsx-runtime");function Eh(e){const t=e.data;return t?.__gauntlet?(0,$h.jsxs)("div",{className:"semiotic-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(15, 23, 42, 0.94))",color:"var(--semiotic-tooltip-text, #f8fafc)",padding:"8px 12px",borderRadius:6,boxShadow:"var(--semiotic-tooltip-shadow, 0 8px 24px rgba(0,0,0,0.35))",maxWidth:280},children:[(0,$h.jsx)("strong",{children:t.kind===ah?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:hh(t.property)}),(0,$h.jsx)("div",{children:t.kind===ch?"Positive property":t.kind===lh?"Negative property":"Project core"})]}):null}function zh(e,t,n){const i=t.datum;if(!i?.__gauntlet)return;const r="circle"===t.shape.type?t.shape.radius:8;if(e.save(),e.translate(t.x,t.y),i.kind===ah)e.fillStyle=Dh(e,n.fill,"#0f766e"),e.strokeStyle=Dh(e,n.stroke,"#f8fafc"),e.lineWidth=2.4,e.beginPath(),e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke();else{const t=i.property;e.fillStyle=Dh(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=Dh(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),i.kind===lh?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=Dh(e,"var(--semiotic-background, #07111f)","#07111f"),e.font=`900 ${i.kind===lh?9:8}px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(t?.short??t?.id?.slice(0,1).toUpperCase()??"?",0,.5)}e.restore()}function Dh(e,t,n){if("string"!=typeof t)return n;if("function"!=typeof getComputedStyle||!e.canvas)return t||n;const i=t.startsWith("var(")?t.match(/var\((--[^,\s)]+)/)?.[1]:t.startsWith("--")?t:null;return i?getComputedStyle(e.canvas).getPropertyValue(i).trim()||n:t||n}function Bh({layout:e,states:t}){return(0,$h.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-accent, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,$h.jsx)("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-negative, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,$h.jsx)("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),e.gates.map(t=>(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:t.x-t.width/2,y:Math.max(80,e.routeY-180),width:t.width,height:Math.min(360,e.height-170),rx:12,fill:t.color??"var(--semiotic-accent, #38bdf8)",fillOpacity:.1,stroke:t.color??"var(--semiotic-accent, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),(0,$h.jsx)("text",{x:t.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:t.label??t.id})]},t.id)),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-positive, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-positive, #22c55e)",strokeWidth:1.5}),(0,$h.jsx)("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-negative, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-negative, #ef4444)",strokeOpacity:.7}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function Fh(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===ah?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${hh(t.property)} ${t.kind===ch?"positive":"negative"} property`,group:t.kind===ch?"positive property":"negative property",description:`${hh(t.property)} attached to ${t.projectId}.`})}function Nh({states:e,layout:t}){const n=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!n.length)return null;const i=Math.max(1,...n.map(e=>e.value)),r=Math.max(40,(t.width-80)/n.length);return(0,$h.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),n.map((e,t)=>{const n=40+t*r,o=Math.max(2,e.value/i*28),s=/kill|crash|block|grave/i.test(e.outcome);return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:n+.18*r,y:28-o+22,width:Math.max(10,.45*r),height:o,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,$h.jsx)("text",{x:n+.4*r,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}var Oh=require("react/jsx-runtime"),Wh=require("react"),qh=[];function Yh(e){return e.map(e=>({...e,spawnAt:void 0}))}(0,sh.forwardRef)(function(e,t){const{bodyGroups:n,coreBody:i,coreForceMode:r="route",crashDetection:o=!0,crashOffset:s=30,data:a,emptyContent:c,events:l,frameProps:u={},gates:d,initialSpawnPacing:h,loading:f,loadingContent:p,negativeProperties:y,onCapacityChange:g,onClick:m,onStateChange:x,outcome:b,paused:v,positiveProperties:w=qh,projectPlacement:k,responsiveHeight:S,responsiveWidth:A,showTethers:M=!0,terminalBehavior:P="outcome",viability:_}=e,j=(0,sh.useRef)(null),C=(0,sh.useMemo)(()=>({idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor}),[e.idAccessor,e.initialViability,e.metricsAccessor,e.negativeAccessor,e.positiveAccessor,e.startTimeAccessor]),I=Zd(e,[900,520]),{chartSize:T,showProjection:R,showChrome:L,className:$,title:E,chartMode:z,margin:D,enableHover:F,description:N,summary:O,accessibleTable:W}=I,q=Qd({data:a,emptyContent:c,loading:f,loadingContent:p,size:T}),Y=(0,sh.useMemo)(()=>B(a??[]),[a]),H=(0,sh.useMemo)(()=>Y.map((e,t)=>dh(e,t,C.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[Y,C.idAccessor]),G=(0,sh.useMemo)(()=>new Map(w.map(e=>[e.id,e])),[w]),X=(0,sh.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),V=(0,sh.useMemo)(()=>mh(T,d,s),[T,s,d]),U=(0,sh.useMemo)(()=>new Map(V.gates.map(e=>[e.id,e])),[V.gates]),K=(0,sh.useMemo)(()=>V.gates.map(e=>({kind:"force-field",damping:.035,force:{x:12,y:0},semanticItem:!1,...e.regionEffect,id:"gauntlet-gate-"+e.id,label:e.label??e.id,description:e.description,bodyFilter:e.capacity?{property:"datum.kind",equals:ah}:e.regionEffect?.bodyFilter,shape:{type:"aabb",x:e.x,y:V.routeY,width:e.capacity?e.capacity.sensorWidth??Math.max(96,6*e.width):Math.max(e.width,54),height:Math.min(360,V.height-170)}})),[V.gates,V.height,V.routeY]),[Z,Q]=(0,sh.useState)(()=>Y.map((e,t)=>{const n=kh(e,t,C,w,X);return{...n,viability:_?.(n,{negativeProperties:X,positiveProperties:G})??wh(n,G,X)}})),J=(0,sh.useRef)(Z),ee=(0,sh.useRef)(0),te=(0,sh.useRef)(new Map),ne=(0,sh.useRef)([]),ie=(0,sh.useRef)(g);ie.current=g;const re=(0,sh.useMemo)(()=>function(e){const{dataKey:t,gates:n,statesRef:i,processedGateVisitsRef:r}=e;return n.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[Uu({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:ah},maxQueue:e.capacity.maxQueue,queueLayout:e.capacity.queueLayout,queueSlotSpacing:e.capacity.queueSlotSpacing,queueStiffness:e.capacity.queueStiffness??24,releaseImpulse:{x:36,y:0},unitAccessor:t=>{const n=t.datum,r=n?.sourceDatum,o=e.capacity?.unitAccessor,s=i.current.find(e=>e.id===n?.projectId);let a;"function"==typeof o?a=s?o(s):void 0:o&&(a=r?.[o]);const c=Number(a??r?.reviewWork??r?.work??s?.metrics.reviewWork??r?.points);return Number.isFinite(c)&&c>0?c:1},onProcessed:t=>{const n=t.datum;if(!n?.projectId)return;const i=`${n.projectId}:${e.id}`;r.current.set(i,(r.current.get(i)??0)+1)}})]:[])}({dataKey:H,gates:V.gates,statesRef:J,processedGateVisitsRef:te}),[H,V.gates]),oe=(0,sh.useMemo)(()=>[...re,...u.controllers??[]],[re,u.controllers]),se=(0,sh.useRef)(Y);se.current=Y;const ae=(0,sh.useRef)(x);ae.current=x;const ce=(0,sh.useRef)({negativeById:X,positiveById:G,positiveProperties:w,stateAccessors:C,viability:_});ce.current={negativeById:X,positiveById:G,positiveProperties:w,stateAccessors:C,viability:_};const le=(0,sh.useCallback)((e,t,n=0)=>{const i=ce.current,r=kh(e,t,i.stateAccessors,i.positiveProperties,i.negativeById);return i.stateAccessors.startTimeAccessor||(r.startedAt=Math.max(0,n)),{...r,viability:i.viability?.(r,{negativeProperties:i.negativeById,positiveProperties:i.positiveById})??wh(r,i.positiveById,i.negativeById)}},[]);(0,sh.useEffect)(()=>{te.current.clear(),ne.current=[];const e=se.current.map((e,t)=>le(e,t));J.current=e,Q(e)},[le,H]),(0,sh.useEffect)(()=>{J.current=Z,ae.current?.(Z)},[Z]);const ue=(0,sh.useCallback)(e=>[...("function"==typeof l?l(e,V):l)??[]].sort((e,t)=>e.time-t.time),[l,V]),de=(0,sh.useCallback)((e,t,n)=>{if(!t.gateId||!U.get(t.gateId)?.capacity)return!0;const i=Number(t.gateVisit),r=Number.isFinite(i)&&i>0?Math.floor(i):n.filter(e=>e.gateId===t.gateId).findIndex(e=>e.id===t.id)+1;return r>0&&(te.current.get(`${e.id}:${t.gateId}`)??0)>=r},[U]),he=(0,sh.useCallback)(()=>{if(!re.length)return;const e=re.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,n;(t=ne.current).length===(n=e).length&&t.every((e,t)=>{const i=n[t];return!!i&&e.regionId===i.regionId&&e.queueDepth===i.queueDepth&&e.blockedDepth===i.blockedDepth&&e.processedCount===i.processedCount&&e.metricRevision===i.metricRevision})||(ne.current=e,ie.current?.(e))},[re]),fe=(0,sh.useMemo)(()=>Z.flatMap((e,t)=>{const n=bh(e,t,V,k);return Sh(e,t,V,n,G,X,i)}),[i,V,X,G,k,Z]),pe=(0,sh.useCallback)((e,t)=>{let n=!1;const i=J.current.map(i=>{if(i.id!==e)return i;const r=t(i);return n=n||r!==i,r});n&&(J.current=i,Q(i))},[]);(0,sh.useImperativeHandle)(t,()=>function(e){const{statesRef:t,setStates:n,elapsedRef:i,frameRef:r,layout:o,projectPlacement:s,positiveById:a,negativeById:c,coreBody:l,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,i.current),h=bh(d,t.current.length,o,s),f=Sh(d,t.current.length,o,h,a,c,l),p=[...t.current,d];t.current=p,n(p),r.current?.pushMany(f),r.current?.step(0)},pushMany:e=>{const d=[...t.current],h=[],f=i.current;e.forEach(e=>{const t=u(e,d.length,f),n=bh(t,d.length,o,s);h.push(...Sh(t,d.length,o,n,a,c,l)),d.push(t)}),t.current=d,n(d),h.length&&r.current?.pushMany(h),r.current?.step(0)},remove:e=>{const i=Array.isArray(e)?e:[e],o=[],s=[];for(const e of i){const n=t.current.find(t=>t.id===e);n&&(o.push(n.datum),s.push(fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e))),n.negativeIds.forEach((e,t)=>{s.push(yh(n.id,e,t))}))}return t.current=t.current.filter(e=>!i.includes(e.id)),n(t.current),r.current?.remove(s),o},update:(e,d)=>{const h=Array.isArray(e)?e:[e],f=[];for(const e of h){const n=t.current.find(t=>t.id===e);if(!n)continue;const h=t.current.findIndex(t=>t.id===e);f.push(n.datum);const p=d(n.datum),y=u(p,0>h?t.current.length:h,n.startedAt??i.current),g=bh(y,0>h?t.current.length:h,o,s);r.current?.remove([fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e)),...n.negativeIds.map((e,t)=>yh(n.id,e,t))]),r.current?.pushMany(Sh(y,0>h?t.current.length:h,o,g,a,c,l)),t.current=t.current.map(t=>t.id===e?y:t)}return n(t.current),f},clear:()=>{t.current=[],n([]),r.current?.clear()},getData:()=>t.current.map(e=>e.datum),getScales:()=>null,getCustomLayout:()=>r.current?.snapshot()??null,popBodies:(e,t)=>r.current?.popBodies(e,t)??[]}}({statesRef:J,setStates:Q,elapsedRef:ee,frameRef:j,layout:V,projectPlacement:k,positiveById:G,negativeById:X,coreBody:i,createState:le}),[i,le,V,X,G,k]);const ye=(0,sh.useCallback)((e,t,n)=>{!function(e){const{project:t,effect:n,controls:i,layout:r,positiveById:o,negativeById:s,coreBody:a,popBodies:c}=e,l=i.readBodies().find(e=>e.id===fh(t.id)),u=i.readBodies(),d=l?.x??r.startX,h=l?.y??r.routeY,f=function(e,t){let n=-1;for(const i of t)Rh(i,e.id)&&(n=Math.max(n,Lh(i)));return Math.max(e.negativeIds.length,n+1)}(t,u),p=Mh(n.addNegative).flatMap((e,n)=>{const i=s.get(e);return i?[Ah(t,i,f+n,d,h,r)]:[]}),y=Mh(n.addPositive).flatMap(e=>{if(!o.get(e)||t.activePositiveIds.includes(e))return[];const n={...xh(r),routeY:h,socketY:h,startX:d,startY:h};return Sh({...t,activePositiveIds:[e],negativeIds:[]},0,r,n,o,s,a).filter(e=>e.id.includes(":positive:"))});(p.length||y.length)&&i.pushMany([...p,...y]);const g=_h(t,n);for(const e of g){const n=o.get(e);c([ph(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3})}const m=jh(t,n),x=function(e,t,n){const i=t.filter(t=>Rh(t,e.id)).sort((e,t)=>Lh(e)-Lh(t)||e.id.localeCompare(t.id)),r=new Set;return n.map(t=>{const n=i.find(e=>!r.has(e.id)&&e.datum.property?.id===t.propertyId);return n?(r.add(n.id),n.id):yh(e.id,t.propertyId,t.index)})}(t,u,m);m.forEach((e,t)=>{const n=s.get(e.propertyId);c([x[t]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3})})}({project:e,effect:t,controls:n,layout:V,positiveById:G,negativeById:X,coreBody:i,popBodies:(e,t)=>j.current?.popBodies(e,t)})},[i,V,X,G]),ge=(0,sh.useCallback)(({body:e,bodies:t})=>function(e){const{body:t,bodies:n,layout:i,states:r,projectPlacement:o,positiveById:s,negativeById:a,projectEvents:c,gateById:l,coreForceMode:u,terminalBehavior:d,elapsed:h}=e,f=t.datum;if(!f?.__gauntlet)return null;const p=r.findIndex(e=>e.id===f.projectId),y=0>p?void 0:r[p];if(!y)return null;const g=bh(y,p,i,o),m=n.find(e=>e.id===fh(y.id)),x=y.negativeIds.reduce((e,t)=>e+(a.get(t)?.load??1),0),b=y.killed?0:58;if(f.kind!==ah){if(!m)return null;let e;const r=f.property;if(r?.target){const o=n.filter(e=>{const t=e.datum;return t?.__gauntlet&&t.projectId===y.id&&t.kind===f.kind}).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),s=Math.max(0,o.findIndex(e=>e.id===t.id));e=r.target({body:t,bodies:n,core:m,index:s,layout:i,placement:g,project:y})??{x:m.x,y:m.y}}else if(f.kind===ch&&f.property){const t=vh(y.activePositiveIds,f.property.id);e={x:m.x+Math.cos(t.angle)*t.radius,y:m.y+Math.sin(t.angle)*t.radius-2}}else{const i=n.filter(e=>e.datum?.kind===lh&&e.datum.projectId===y.id).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),r=Math.max(0,i.findIndex(e=>e.id===t.id)),o=Math.floor(r/4);e={x:m.x+18*(r%4-(Math.min(4,i.length-4*o)-1)/2),y:m.y+54+13*o}}const o="circle"===t.shape.type?t.shape.radius:8;e=gh(e.x,e.y,o,i);const s=gh(t.x,t.y,o,i);if(Math.abs(s.x-t.x)>.5||Math.abs(s.y-t.y)>.5)return{x:48*(s.x-t.x)-6*t.vx,y:48*(s.y-t.y)-6*t.vy};const a=f.kind!==ch||y.killed?0:3.2*(r?.buoyancy??r?.value??1),c=f.kind===lh?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return{x:28*(e.x-t.x)-3*(t.vx-m.vx)+c.x+.01*b,y:28*(e.y-t.y)-3*(t.vy-m.vy)+c.y-a}}if(y.killed)return{x:44*((y.crashX??y.metrics.lastX??t.x)-t.x)-9*t.vx,y:160+12*x-1.6*t.vy};const v=c(y),w=function(e,t,n,i,r,o,s){if(t.killed)return{x:t.metrics.lastX??i.graveyardX,y:i.graveyardY};const a=r[r.length-1];if(!a)return{x:i.socketX,y:i.routeY};const c=r.find(n=>e>=n.time&&!t.eventsApplied.includes(n.id)&&!(!n.gateId||!o.get(n.gateId)?.capacity)),l=c?Math.min(e,c.time):e,u="built"===t.outcome||"built_diminished"===t.outcome;if(l>a.time+.85){if("hold-last"===s){const e=a.gateId?o.get(a.gateId):void 0;return{x:a.routeX??e?.x??i.socketX,y:a.routeY??i.routeY}}return u?{x:i.socketX,y:i.socketY}:{x:i.graveyardX,y:i.graveyardY-14}}const d=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),h=[{time:0,x:i.startX,y:i.startY},...r.map(e=>{const t=e.gateId?o.get(e.gateId):void 0;return{time:e.time,x:e.routeX??t?.x??i.startX,y:e.routeY??i.routeY+.28*Math.min(180,d)}})].sort((e,t)=>e.time-t.time);let f=h[0],p=h[h.length-1];for(let e=1;h.length>e;e+=1){if(h[e].time>=l){p=h[e];break}f=h[e]}const y=Math.max(0,Math.min(1,(l-f.time)/Math.max(.1,p.time-f.time))),g=y*y*(3-2*y);return{x:f.x+(p.x-f.x)*g,y:f.y+(p.y-f.y)*g+7*Math.sin(2.6*l)}}(Math.max(0,h-(y.startedAt??0)),y,0,g,v,l,d),k=y.activePositiveIds.reduce((e,t)=>e+(s.get(t)?.buoyancy??s.get(t)?.value??1),0);return"net"===u?{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:1.25*(g.routeY-t.y)-1.4*t.vy+32*(x-k)}:{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:15*(w.y-t.y)-1.8*t.vy+13*x-2.2*k}}({body:e,bodies:t,layout:V,states:J.current,projectPlacement:k,positiveById:G,negativeById:X,projectEvents:ue,gateById:U,coreForceMode:r,terminalBehavior:P,elapsed:ee.current}),[r,U,V,X,G,ue,k,P]),me=(0,sh.useCallback)((e,t)=>{!function(e,t,n){const{frameProps:i,elapsedRef:r,statesRef:o,crashDetection:s,layout:a,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:f,positiveById:p,negativeById:y,outcome:g,reportCapacity:m}=n;i.onTick?.(e,t),r.current=e.elapsedSeconds??t.snapshot().elapsedSeconds,m();for(const e of o.current){const n=t.readBodies().find(t=>t.id===fh(e.id));if(!n)continue;if(s&&!e.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=a.crashY){t.readBodies().forEach(n=>{const i=n.datum;i?.__gauntlet&&i.projectId===e.id&&t.applyImpulse(n.id,-n.vx*n.mass,0)}),h(e.id,e=>{const t={appliedAt:Math.max(0,r.current-(e.startedAt??0)),id:"gauntlet-crash-line",label:"Crash Line",summary:"The project hit the crash threshold; lift and forward motion shut off.",time:Math.max(0,r.current-(e.startedAt??0))};return{...e,crashX:n.x,eventHistory:[...e.eventHistory??[],t],killed:!0,lastEvent:t,metrics:{...e.metrics,lastX:n.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,e.viability)}});continue}if(e.killed)continue;const i=Math.max(0,r.current-(e.startedAt??0)),o=c(e),m=o.filter(t=>i>=t.time&&!e.eventsApplied.includes(t.id)&&u(e,t,o));let x=e;for(const n of m){const r=n.gateId?l.get(n.gateId):void 0,o=n.effects??[];for(const e of o){const i={event:n,gate:r,negativeProperties:y,positiveProperties:p,project:x};e.when&&!e.when(i)||(d(x,e,t),x=Ch(x,e,i))}const s={...Ih(n,o),appliedAt:i};x=Th(x,s),h(e.id,e=>{let t=Th(e,s);if(t===e)return e;for(const e of o)t=Ch(t,e,{event:n,gate:r,negativeProperties:y,positiveProperties:p,project:t});const i=f?.(t,{negativeProperties:y,positiveProperties:p})??wh(t,p,y);return t={...t,viability:i},n.final&&(t={...t,outcome:n.outcome??g?.(t,{layout:a,negativeProperties:y,positiveProperties:p})??(t.viability>20?"built":"approved_not_built")}),t})}}}(e,t,{frameProps:u,elapsedRef:ee,statesRef:J,crashDetection:o,layout:V,projectEvents:ue,gateById:U,capacityEventReady:de,addBodiesForEffect:ye,updateProjectState:pe,viability:_,positiveById:G,negativeById:X,outcome:b,reportCapacity:he})},[ye,de,o,u,U,V,X,b,G,ue,he,pe,_]),xe=(0,sh.useCallback)((e,t)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(e,t):u.bodyStyle,i=e.datum;return i?.__gauntlet?{fill:i.kind===ah?"var(--semiotic-accent, #0f766e)":i.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:i.kind===ah?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),be=(0,sh.useMemo)(()=>"function"==typeof n?n(Z,V):n??[],[n,V,Z]),ve=(0,sh.useMemo)(()=>be.flatMap(e=>{if(!1===e.semanticItem)return[];const t=e.semanticItem??{},n={id:e.id,label:e.label??e.id,description:e.description,datum:e.datum,group:e.group??e.state??"body group",x:e.x??0,y:e.y??0,width:e.width,height:e.height};return[{...n,...t,id:t.id??n.id}]}),[be]),we=(0,sh.useMemo)(()=>R?function(e,t){if(!e.length)return[];const n=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const i=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:i,description:i,datum:e,x:40+(t+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(Z,V):[],[V,R,Z]),ke=(0,sh.useMemo)(()=>[...we,...ve],[ve,we]),Se=(0,sh.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]),Ae=(0,sh.useCallback)((e,t)=>{m&&m(e&&"object"==typeof e&&e.__gauntlet?e.sourceDatum:e,{x:t.x,y:t.y})},[m]);if(q)return q;const Me=th(e.tooltip,u),Pe=nh(e,u,ke,{chartMode:z,className:$,title:E,description:N,summary:O,accessibleTable:W,enableHover:F,margin:D}),_e=R?(0,Oh.jsx)(Nh,{states:Z,layout:V}):void 0,je=eh(L?(0,Oh.jsx)(Bh,{layout:V,states:Z}):void 0,u.backgroundGraphics),Ce=eh(_e,u.foregroundGraphics),Ie=u.renderBody??zh,Te=Me.tooltipContent??Eh;return Jd("GauntletChart",T,(0,Wh.createElement)(qd,{...u,...Me,...Pe,key:`${T[0]}x${T[1]}:${H}`,ref:j,accessibleTable:e.accessibleTable??u.accessibleTable,backgroundGraphics:je,bodyForces:ge,bodySemanticItems:u.bodySemanticItems??Fh,bodyStyle:xe,beforePaint:(e,t)=>{u.beforePaint?.(e,t),M&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===ah).map(e=>[e.datum.projectId,e]));e.save(),e.lineWidth=1.1,e.setLineDash([3,4]);for(const i of t){const t=i.datum;if(!t?.__gauntlet||t.kind===ah)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===lh?.24:.36,e.strokeStyle=t.kind===lh?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(i.x,i.y),e.stroke())}e.restore()}(e,t)},onClick:m?Ae:Pe.onClick,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...u.config?.kernel??{}},colliders:[...uh(V),...u.config?.colliders??[]]},controllers:oe,enableHover:Me.enableHover??!0,foregroundGraphics:Ce,hoverRadius:e.hoverRadius??u.hoverRadius??18,initialSpawns:fe,initialSpawnPacing:h,onBodyPointerDown:Se,onTick:me,paused:v,regionEffects:[...K,...u.regionEffects??[]],renderBody:Ie,responsiveHeight:S,responsiveWidth:A,size:T,tooltipContent:Te}))}).displayName="GauntletChart";var Hh={Sparkline:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle,...i})},AreaChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"area",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||t,colorAccessor:t,colorScheme:n,...i})},DifferenceChart:Ua,StackedAreaChart:Ka,Scatterplot:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,colorScheme:n,...i})},CandlestickChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"candlestick",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:n,...i})},ConnectedScatterplot:Qa,QuadrantChart:Za,Heatmap:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:n||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,colorAccessor:t,colorScheme:n,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:t||r.stackBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:t||r.groupBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},PieChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"histogram",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:t,colorScheme:n,...i})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:n,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"violin",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:n,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swarm",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i})},DotPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:t||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",...i})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:t||r.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o="vertical"===r.orientation;return{chartType:o?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:t||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:o?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,barPadding:o?40:0,showAxes:o,showGrid:o,colorScheme:n,...i}}},GaugeChart:rc,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:vc,NetworkCustomChart:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"force",nodes:r.nodes||e||[],edges:r.edges||[],nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor||"id",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",valueAccessor:r.valueAccessor||"value",colorBy:t,colorScheme:n,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:t,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:n,...i})},ProcessSankey:wc,ChordDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:t,edgeColorBy:r.edgeColorBy,colorScheme:n,...i})},TreeDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"cluster"===r.layout?"cluster":"tree",data:e,childrenAccessor:r.childrenAccessor,colorBy:t,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:n,...i})},Treemap:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:n,...i})},CirclePack:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,colorScheme:n,...i})},ChoroplethMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:n||"blues",graticule:r.graticule,fitPadding:r.fitPadding,...i})},ProportionalSymbolMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:e||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:t,colorScheme:n,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...i})},FlowMap:kc,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:r.points||e||[],areas:r.areas||[],lines:r.lines||[],projection:r.projection||"equirectangular",xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",lineDataAccessor:r.lineDataAccessor,colorBy:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=r.bins??21,a=r.seed??1,c=Math.max(1,Math.round(r.pegRows??s-1)),l="mechanical"===r.mode,u=l?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),i=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=Cc(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:i},(e,t)=>{let i=0;for(let e=0;n>e;e+=1)o()<r&&(i+=1);const a=n/2;return{id:`${s}-${t}`,value:i,mechanical:!0,pegRows:n,branchProbability:r,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],d=function(e){const{data:t,valueAccessor:n,bins:i,ballRadius:r,seed:o,size:s,valueExtent:a}=e,c=Sc(s),l=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=(0,Lc.scaleLinear)().domain([0,i]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:i},()=>0),g=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const s=Math.max(0,Math.min(i-1,Math.floor((o-d)/f*i)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:o,bin:s}})});const m=c.plot.y+c.plot.height;return{config:Pc(o,[...jl({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Cl({idPrefix:"galton-bin",count:i,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:i,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:o,valueExtent:l?[0,c]:void 0});return{...i,config:d.config,initialSpawns:Yh(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:Mc(t||r.colorBy||(l?"side":void 0))}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:i,windows:r,watermark:o,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=Sc(c),h=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),f=jc(l?.[0]),p=jc(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+r.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/r.size)*r.size,v=Math.max(1,Math.ceil((x-b+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof o?o(w):jc(o?.value)??w-(o?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,s),M=b+v*r.size,P=(0,Nl.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),_=Array.from({length:v},()=>({value:0,secondary:0})),j=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const a=jc(_c(e,t,i))??o,c=Math.max(0,Math.min(v-1,Math.floor((o-b)/r.size))),l=k>=b+(c+1)*r.size;_[c].value+=l?0:1,_[c].secondary+=l?1:0,j.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,P(o))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:o,arrivalTime:a,windowIndex:c,late:l}})});const C=d.plot.y+d.plot.height,I=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const i=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,o=(0,Nl.scaleLinear)().domain([i,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=o(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,i=n+e.windowSize,r=o(n),s=o(i);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Pc(a,[...jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Ol({idPrefix:"eventdrop-window",count:v,xScale:e=>P(b+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?I[0]?.y1:I[e-1]?.y2??I[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:C,wallThickness:6}),...I.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:_.map((e,t)=>({label:`${b+t*r.size}-${b+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:I,lateCount:_.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy)}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s="mechanical"===r.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:i,unitValue:r,ballRadius:o,seed:s,size:a}=e,c=Ic(r,1),l=Sc(a),u=[],d=new Map,h=new Map,f=[];function p(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{p((_c(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const i=e.width/Math.max(1,t),r=Math.max(2,2*n),o=Math.min(.7*i,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(o/r));return{laneWidth:i,tubeWidth:o,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*i,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}(l.plot,y,o),m=Math.max(0,g.tubeWidth/2-o-1),x=u.map(()=>[]);t.forEach((e,t)=>{const r=(_c(e,t,n)??"unknown")+"",s=p(r),a=i?jc(_c(e,t,i)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const i=h.get(r)??0,a=g.perRow>1?((g.perRow>1?i%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(r,i+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,y:l.plot.y+o+2,vx:(n%3-1)*o/2,vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,category:r,unitIndex:n}})}});const b=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;b>e;e+=1)for(const t of x)t.length>e&&f.push(t[e]);const v=l.plot.y+l.plot.height,w=[...jl({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;y>e;e+=1){const t=g.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Pc(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}({data:s?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],i=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=Ic(e.unitValue,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*o()),c=a.reduce((e,t)=>e+t,0)||1,l=i-n.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=i-d.reduce((e,t)=>e+t,0);const f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/i}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o});return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Mc(t||r.colorBy||(s?"category":void 0))}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:i,radiusAccessor:r,pointRadius:o,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=Sc(a),h=Rc(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=jc(_c(e,t,n));if(null==s)return;const a=i?(_c(e,t,i)??"All")+"":"All",c=r?jc(_c(e,t,r)):null,l=Cc(null!=c&&c>0?c:o,2,18);!function(e){let t=y.get(e);null==t&&(t=p.length,p.push(e),y.set(e,t))}(a),f.push({datum:e,index:t,value:s,group:a,radius:l})});const g=f.map(e=>e.value),m=c?jc(c[0]):null,x=c?jc(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(o,...f.map(e=>e.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,P=(0,Wl.scaleLinear)().domain([w,k]).range([A,M]),_=Math.max(1,p.length),j=d.plot.y+Math.max(28,3*S),C=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-j),I=e=>{const t=y.get(e)??0;return 1===_?d.plot.y+.54*d.plot.height:j+t/(_-1)*C},T=new Map,R=f.map((e,t)=>{T.set(e.group,(T.get(e.group)??0)+1);const n=P(e.value),i=I(e.group),r=(h()-.5)*e.radius*1.6,o=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:Cc(n+(t%9-4)*e.radius*2.5,A,M),y:u?i+o:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:i},springs:[{target:{type:"point",x:n,y:i},restLength:0,stiffness:34,damping:5.5}]}});return{config:Pc(s,jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:R,projectionRows:p.map(e=>({label:e,value:T.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:I(e),count:T.get(e)??0})),plot:d.plot}}}({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:o,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||r.groupAccessor)}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=eu({data:Array.isArray(e)?e:[],stages:s,size:o,idAccessor:r.idAccessor,stageAccessor:r.stageAccessor||"stage",groupBy:r.groupBy,groupLabelAccessor:r.groupLabelAccessor,workAccessor:r.workAccessor,radiusAccessor:r.radiusAccessor,ballRadius:r.ballRadius??6,seed:r.seed??1,groupCompletion:r.groupCompletion,groupAnchorAlong:r.groupAnchorAlong,settle:r.settle??!0,gravityX:r.gravityX,gravityY:r.gravityY}),c=a.metadata;return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Mc(t||r.colorBy||r.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,520],s=function(e){const t=mh(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],i=new Map(n.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),o={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=kh(t,s,o,n,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:i})??wh(a,i,r)}}).flatMap((n,o)=>{const s=bh(n,o,t,e.projectPlacement);return Sh(n,o,t,s,i,r,e.coreBody)});return{layout:t,initialSpawns:s,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:uh(t)}}}({data:Array.isArray(e)?e:[],size:o,gates:r.gates,positiveProperties:r.positiveProperties,negativeProperties:r.negativeProperties,crashOffset:r.crashOffset,idAccessor:r.idAccessor,positiveAccessor:r.positiveAccessor,negativeAccessor:r.negativeAccessor,metricsAccessor:r.metricsAccessor,initialViability:r.initialViability,projectPlacement:r.projectPlacement,coreBody:r.coreBody,viability:r.viability});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:Mc(t||r.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:i,maxParticles:r,nodeIdAccessor:o,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=Sc(y),v=Rc(p),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof o){const e=o(t,0);if(null!=e)return e+""}if("string"==typeof o&&null!=t[o])return t[o]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}c.forEach((e,t)=>{const n=(_c(e,t,o)??e.id??t)+"",i=jc(_c(e,t,s)),r=jc(_c(e,t,a));if(null!=i&&null!=r){const e={x:i,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];i.forEach((e,t)=>{const n=A(_c(e,t,g)),i=A(_c(e,t,m)),r=Math.max(0,jc(_c(e,t,x))??0),o=Yl(d?_c(e,t,d):void 0),s=o.length?o:Yl(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${i}-${t}`)+"",link:e,index:t,source:n,target:i,throughput:r,rawPath:s})});const P=(j=S,"normalized"===(_=t)||"pixels"===_?_:j.length>0&&j.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var _,j;const C=new Map;for(const[e,t]of w)C.set(e,Hl(t,b,P));const I=[];for(const e of M){let t=e.rawPath.map(e=>Hl(e,b,P));if(2>t.length){const n=C.get(e.source),i=C.get(e.target);n&&i&&(t=[n,i])}else C.has(e.source)||C.set(e.source,t[0]),C.has(e.target)||C.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}const T=Ic(u,.12),R=Math.max(1,Math.round(r)),L=I.map(e=>Math.max(1,Math.round(e.throughput*T))),$=L.reduce((e,t)=>e+t,0),E=$>R?R/$:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(L[t]*E))});let z=I.reduce((e,t)=>e+t.packetCount,0);for(;z>R;){const e=I.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?n:e,-1);if(-1===e)break;I[e].packetCount-=1,z-=1}const D=new Map,B=new Map,F=[],N=Ic(n,90),O=Ic(l,4);I.forEach((e,t)=>{D.set(e.target,(D.get(e.target)??0)+e.throughput),B.set(e.source,(B.get(e.source)??0)+e.throughput);const n=Gl(e.path);for(let i=0;e.packetCount>i;i+=1){const r=(i+.5)/e.packetCount,o=f?r:Cc(.12+.84*r+.04*(v()-.5),.04,.98),s=f?o:Math.max(0,o-(.18+.12*v())),a=Xl(e.path,s),c=Xl(e.path,o),l=Vl(e.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*O*1.5;F.push({id:`${e.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*N+10*(v()-.5),vy:f?0:l.y*N+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+i/32,shape:{type:"circle",radius:O},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:i,packetCount:e.packetCount,routeProgress:o,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:N,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*O,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*O),q=Array.from(C,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+Tc(e),point:t})),Y=q.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),H=Object.fromEntries(q.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=Pc(p,[...jl({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...Y],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*O),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=R,G.eviction="oldest",G.observation={...G.observation,sensors:H};const X=Array.from(C,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Tc(e),incoming:D.get(e)??0,outgoing:B.get(e)??0})),V=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:F,projectionRows:X.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:P,particleCount:F.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:X,links:V}}}({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:o});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[700,380],s=oh({chartId:r.chartId,colorScheme:n,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:xe(we)??{},size:o,themeCategorical:we.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Mc(t||r.colorBy)}}}};function Gh(e){if(!e)return we;if("string"==typeof e){if("light"===e)return we;if("dark"===e)return ke;if("high-contrast"===e)return Se;return ga[e]||we}const t="dark"===e.mode?ke:we;return be({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function Xh(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function Vh(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Uh(e){if(!e||2>e.length)return;const t=Vh(e[0]),n=Vh(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function Kh(e){const{count:t,byType:n}=function(e){const t={};for(const n of e){const e="string"==typeof n?.type&&n.type.length>0?n.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,r=[...e.extraWarnings??[]];return i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:n,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:r}}var Zh=c(require("react")),Qh=c(require("react-dom/server")),Jh=require("d3-scale"),ef=require("react/jsx-runtime"),tf=14,nf=20,rf=6,of=8;function sf(e){return"left"===e?"start":"right"===e?"end":e??"start"}function af(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function cf(e,t,n,i){const r=af(i);return t+n+Math.ceil(e.length*r*.58)}function lf(e){const{categories:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p="top"===i||"bottom"===i,y=Math.max(c,r-s.left-s.right),g=Math.max(d,o-s.top-s.bottom),m=t.map(e=>cf(e,c,l,n));if(p){const e=Math.max(c,a?.maxWidth??y),n=[];let i=0,r=0;m.forEach((t,o)=>{const s=0===r?t:r+u+t;r>0&&s>e?(n.push({start:i,end:o,width:r}),i=o,r=t):r=s}),t.length>0&&n.push({start:i,end:t.length,width:r});const o=sf(a?.align),s=[];return n.forEach((n,i)=>{let r="center"===o?Math.max(0,(e-n.width)/2):"end"===o?Math.max(0,e-n.width):0;for(let e=n.start;n.end>e;e++)s.push({category:t[e],width:m[e],x:r,y:i*d}),r+=m[e]+u}),{items:s,width:Math.max(0,...n.map(e=>e.width)),height:n.length*d,swatchSize:c,labelOffset:h,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/d)),v=Math.max(1,Math.ceil(t.length/b));return{items:t.map((e,t)=>({category:e,width:m[t],x:Math.floor(t/b)*(x+u),y:t%b*d})),width:v*x+Math.max(0,v-1)*u,height:Math.min(t.length,b)*d,swatchSize:c,labelOffset:h,swatchRadius:f}}function uf(e){const{legendGroups:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p=Math.max(12,af(n)),y="top"===i||"bottom"===i,g=Math.max(c,r-s.left-s.right),m=Math.max(d,o-s.top-s.bottom);if(y){const i=Math.max(c,a?.maxWidth??g),r=sf(a?.align);let o=0,s=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=lf({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=r.label?p:0,h=r.label?cf(r.label,0,0,n):0,f=d>0?d+8:0,y=f+u.width,g=Math.max(u.height,h);l.push({group:r,x:o,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),o+=y+12,s=Math.max(s,g)}const u=l.length>0?o-12:0,d=u>i?0:"center"===r?Math.max(0,(i-u)/2):"end"===r?Math.max(0,i-u):0;return{groups:l.map(e=>({...e,x:e.x+d})),width:u,height:s,swatchSize:c,labelOffset:h,swatchRadius:f}}let x=0,b=0;const v=[];for(const e of t){const t=e.items.map(e=>e.label).map(e=>cf(e,c,l,n)),i=Math.max(0,...t),r=Math.max(1,Math.min(e.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),o=Math.max(1,Math.ceil(e.items.length/r)),s=e.items.map((e,n)=>({category:e.label,width:t[n],x:Math.floor(n/r)*(i+u),y:n%r*d})),a=o*i+Math.max(0,o-1)*u,h=Math.min(e.items.length,r)*d,f=e.label?cf(e.label,0,0,n):0,y=e.label?p+8:0,g=y+h+12,w=Math.max(a,f);v.push({group:e,x:0,y:x,itemOffsetX:0,itemOffsetY:y,width:w,height:g,items:s}),b=Math.max(b,w),x+=g}return{groups:v,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:h,swatchRadius:f}}function df(e){const t="top"===e.position||"bottom"===e.position,n=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??n,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function hf(e){const{categories:t,colorScheme:n,theme:i,position:r="right",totalWidth:o,totalHeight:s,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=function(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>E(e,t)??"#999"}const i=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:g;return(0,Jh.scaleOrdinal)().domain(e).range(i)}(t,n,i),u="top"===r||"bottom"===r,d=lf(e);let h,f;if("left"===r?(h=Math.max(4,a.left-d.width-10),f=a.top):"top"===r?(h=a.left,f=c?32:8):"bottom"===r?(h=a.left,f=Math.min(s-a.bottom+38,s-d.height-2)):(h=Math.min(o-d.width-4,o-a.right+10),f=a.top),u){const e=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:e})}const p=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:p})}function ff(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=n(t);null!=e&&i.add(e+"")}return Array.from(i)}var pf=require("react/jsx-runtime");function yf(e,t){return e.color||t.colors.annotation||t.colors.text}function gf(e,t,n){return null!=e.x&&t.x?t.x(e.x):n&&null!=e[n]&&t.x?t.x(e[n]):"number"==typeof e.x?e.x:null}function mf(e,t,n){return null!=e.y&&t.y?t.y(e.y):n&&null!=e[n]&&t.y?t.y(e[n]):"number"==typeof e.y?e.y:null}function xf(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=e.autoPlaceAnnotations?Mr({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;n.length>t;t++){const r=bf(n[t],t,e);r&&i.push({node:r,annotation:n[t]})}const r=Ui(i);return r.length>0?(0,pf.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function bf(e,t,n){const{scales:i,layout:r,theme:o,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===n.projection&&i.r){const n=i.r(s);return null==n?null:(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:n+4,y:12,textAnchor:"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}const h=i.y?i.y(s):i.r?i.r(s):null;return null==h?null:(0,pf.jsxs)("g",{children:[(0,pf.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}case"x-threshold":{const n=e.value;if(null==n||!i.x)return null;const s=i.x(n);if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"top";return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:s,y1:0,x2:s,y2:r.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&(0,pf.jsx)("text",{x:s>.6*r.width?s-4:s+4,y:"bottom"===l?r.height-4:"center"===l?r.height/2:12,textAnchor:s>.6*r.width?"end":"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:c})]},"ann-xthresh-"+t)}case"band":{const n=null!=e.y0&&i.y?i.y(e.y0):null,s=null!=e.y1&&i.y?i.y(e.y1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:0,y:a,width:r.width,height:c,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:r.width-4,y:Math.max(a,0)+13,textAnchor:"end",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-band-"+t)}case"x-band":{const n=null!=e.x0&&i.x?i.x(e.x0):null,s=null!=e.x1&&i.x?i.x(e.x1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:a,y:0,width:c,height:r.height,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:a+4,y:13,textAnchor:"start",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-xband-"+t)}case"category-highlight":{if(!e.category||!i.o)return null;const s=i.o(e.category);if(null==s)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=yf(e,o),l=e.opacity??.1;return(0,pf.jsx)("rect","horizontal"===n.projection?{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}:{x:s,y:0,width:a,height:r.height,fill:c,opacity:l},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:r}=function(e,t,n,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const n=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:gf(e,t,n),y:mf(e,t,i)}}(e,i,s,a);if(null==n||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),d=e.color||o.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,o="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return(0,pf.jsx)(Ai,{noteData:{x:n,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...o?{subject:o}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,pf.jsx)("g",{children:(0,pf.jsx)("text",{x:n+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||o.typography.labelSize,fill:d,fontFamily:o.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}var vf=require("react/jsx-runtime");function wf(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function kf(e,t){if(0===t.categories.length)return;const n=t.position||"right",i=function(e){const{width:t,height:n,swatchSize:i}=lf(e);return{width:t,height:n,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout});"right"===n?e.right=Math.max(e.right,i.width+14):"left"===n?e.left=Math.max(e.left,i.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+i.height+4):e.bottom=Math.max(e.bottom,38+i.height+4)}function Sf(e,t){const n=t.position||"right",i={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=oi(t.legend)?function(e){const{width:t,height:n,swatchSize:i}=uf(e);return{width:t,height:n,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):si(t.legend)?df({...i,gradient:t.legend.gradient}):null;r&&("right"===n?e.right=Math.max(e.right,r.width+14):"left"===n?e.left=Math.max(e.left,r.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+r.height+4):e.bottom=Math.max(e.bottom,38+r.height+4))}function Af(e,t){const n={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix};return oi(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,n)=>({group:e,item:t,itemIndex:n,label:t.label})))).length)return null;var t;const n=uf(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-n.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-n.height-2)):(o=Math.min(e.totalWidth-n.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=n.groups.flatMap((t,o)=>{const{group:s}=t,a=s.type??"fill",c=[];if(s.label&&c.push((0,ef.jsx)("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label}:{x:t.x,y:t.y+af(e.theme),fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label},"legend-group-label-"+o)),c.push(...t.items.map((i,r)=>{const c=s.items[r],l=s.styleFn(c,r),u="function"==typeof a?a(c):"line"===a?(0,ef.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):(0,ef.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return(0,ef.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[u,(0,ef.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${o}-${r}`)})),!i&&n.groups.length-1>o)c.push((0,ef.jsx)("line",{x1:0,y1:t.y+t.height-6,x2:n.width,y2:t.y+t.height-6,stroke:r},"legend-group-separator-"+o));else if(i&&n.groups.length-1>o){const e=t.x+t.width+6;c.push((0,ef.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:r},"legend-group-separator-"+o))}return c});return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...n,legendGroups:e.legendGroups}):si(e)?function(e){const t=df(e),n="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(e=>Math.round(100*e)/100+"");let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-t.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-t.height-2)):(o=Math.min(e.totalWidth-t.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=Array.from({length:17},(t,i)=>{const r=i/16;return(0,ef.jsx)("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(n?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(n){const n=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:l,width:t.width,height:n,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:0,y:l+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),(0,ef.jsx)("text",{x:t.width,y:l+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s+(e.gradient.label?12:0)})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),(0,ef.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}function Mf(e){return Math.round(100*e)/100+""}function Pf(e,t){const n=Xh(t.theme),i=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,o=r?i+"semiotic-title":void 0,s=t.description?i+"semiotic-desc":void 0,a=[o,s].filter(Boolean).join(" ")||void 0;return(0,vf.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":a,style:{fontFamily:n.fontFamily},children:[r&&(0,vf.jsx)("title",{id:o,children:r}),t.description&&(0,vf.jsx)("desc",{id:s,children:t.description}),t.defs&&(0,vf.jsx)("defs",{children:t.defs}),t.background&&"transparent"!==t.background&&(0,vf.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:t.background}),(0,vf.jsx)("g",{id:i+"data-area",transform:t.innerTransform,children:e}),r&&(0,vf.jsx)("text",{id:i+"chart-title",x:t.width/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:r}),t.legend&&(0,vf.jsx)("g",{id:i+"legend",children:t.legend}),t.outerElements]})}var _f=require("react/jsx-runtime");function jf(e,t){const n=Gh(e.theme),i=e.size||[500,300],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.groupAccessor):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d=e.colorScheme||n.colors.categorical,h={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:u?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:d,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Ot(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Qh.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:Uh(f.scales.x?.domain?.()),yDomain:Uh(f.scales.y?.domain?.()),legendItems:s.length>0?s.length:void 0}));const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const{grid:r}=Xh(n),o=i?i+"-":"",s=e.x.ticks(5),a=e.y.ticks(5);return(0,vf.jsxs)("g",{id:o+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((n,i)=>{const o=e.x(n);return(0,vf.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),a.map((n,i)=>{const o=e.y(n);return(0,vf.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(f.scales,{width:c,height:l},n,p):null,g=f.scene.map((e,t)=>so(e,t,p)).filter(Boolean),m=!1!==e.showAxes?function(e,t,n,i,r){const o=Xh(i),s=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(n.xFormat||n.tickFormatTime||Mf)(t)})),a=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(n.yFormat||n.tickFormatValue||Mf)(t)}));return(0,vf.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[(0,vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:o.border,strokeWidth:1}),s.map((e,n)=>(0,vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,vf.jsx)("line",{y2:5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"xtick-"+n)),n.xLabel&&(0,vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,children:n.xLabel}),(0,vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:o.border,strokeWidth:1}),a.map((e,t)=>(0,vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,vf.jsx)("line",{x2:-5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"ytick-"+t)),n.yLabel&&(0,vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:n.yLabel})]})}(f.scales,{width:c,height:l},e,n,p):null,x=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:n,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,b=e.svgPreRenderers&&f.scales?e.svgPreRenderers.map((e,t)=>{try{return(0,_f.jsx)(Zh.Fragment,{children:e(f.scene,f.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Zh.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v;return Qh.renderToStaticMarkup(Pf((0,_f.jsxs)(_f.Fragment,{children:[e.backgroundGraphics,b,y,g,m,x,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:w,idPrefix:e._idPrefix}))}var Cf=c(require("react")),If=c(require("react-dom/server")),Tf=require("d3-scale");function Rf(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,i=new Map;let r=0;return e=>{const o=t(e)+"",s=n?.[o];if(s)return s;let a=i.get(o);return a||(a=dt[r%dt.length],r++,i.set(o,a)),a}}function Lf(e,t,n,i,r,o,s){e.push(t?{type:"symbol",x:i,y:r,size:Math.PI*o*o,symbolType:t(n),style:s,datum:n}:{type:"point",x:i,y:r,r:o,style:s,datum:n})}function $f(e,t){const{columns:n,config:i,resolvePieceStyle:r}=e,o=[],s=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(n),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,y=r(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),o.push(x)}return o}var Ef=require("d3-array");function zf(e){const t=e.length,n=e[0],i=e[t-1];return{n:t,min:n,q1:(0,Ef.quantile)(e,.25)??n,median:(0,Ef.quantile)(e,.5)??(n+i)/2,q3:(0,Ef.quantile)(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}var Df=require("d3-scale"),Bf={bar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=r.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(i))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=o(n),i.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let i=0,r=0;for(const o of p){const l=t.get(o);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);const y=a(l.pieces[0],s?o:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?r:i+p),n=0>p?c(r+p)-c(r):c(i)-c(i+p);u.push(Qe(e.x,t,e.width,Math.abs(n),y,g,o)),0>p?r+=p:i+=p}else if(h){const t=c(0>p?r+p:i),n=0>p?c(r)-c(r+p):c(i+p)-c(i);u.push(Qe(t,e.x,Math.abs(n),e.width,y,g,o)),0>p?r+=p:i+=p}}}const y="vertical"===l,g=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const p=h.length||1;for(const e of Object.values(i)){const t=e.width/p,n=.2*t,i=t-n,r=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=o(r),f=a(r,h[s]);if(d){const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(o,Math.min(a,d),i,Math.abs(a-d),f,r,h[s]))}else{const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(Math.min(a,d),o,Math.abs(d-a),i,f,r,h[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=o(e.datum);y>0&&(e.roundedTop=y),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:i,getR:r,multiScales:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=o.length>0,f=Rf(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const n=t.__rIndex??0,i=t.__rValue??r(t),c=h&&o[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*p,n=c(i);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);Lf(l,f,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:n,columns:i,getR:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=Rf(e);for(const e of Object.values(i)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const i=e.pieceData[n],a=r(i),d=o(i,e.name),h=d.r||4,f=(7919*n%100/100-.5)*t*.8;Lf(c,u,i,l?e.middle+f:s(a),l?s(a):e.middle+f,h,d)}}return c},pie:$f,donut:$f,boxplot:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(i)){const n=t.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const i=n[0],r=n[n.length-1],c=(0,Ef.quantile)(n,.25)??i,h=(0,Ef.quantile)(n,.5)??(i+r)/2,f=(0,Ef.quantile)(n,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??i,x=[...n].reverse().find(e=>g>=e)??r,b=s(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const n=o(e);if(y>n||n>g){const i=u?t.middle:a(n),r=u?a(n):t.middle;v.push({px:i,py:r,value:n,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=hi(c,1),p=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const i=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/f*p} ${i}`}y+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/f*p}`;y+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/f*p}`;y+=" Z"}const g=s(e.pieceData[0],e.name);let m;if(h&&t.length>=4){const r=(0,Ef.quantile)(t,.25)??n,o=(0,Ef.quantile)(t,.5)??(n+i)/2,s=(0,Ef.quantile)(t,.75)??i;m={q1Pos:a(r),medianPos:a(o),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const x=u?{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))}:{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:zf(t),style:g,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,i]=di(t),r=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:i,p=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/p),l-1)]++;const g=t.length,m=hi(y,1),x=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/g:y[t]/m)*e.width*.9,i=a(r+t*p),o=a(r+(t+1)*p);c.push(Qe(Math.min(i,o),e.x+e.width-n,Math.abs(o-i),n,x,{bin:t,count:y[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),u-1)]++;const f=hi(c,1),p=s(e.pieceData[0],e.name),y=e.width*h;let g;if(d){const t=e.x+e.width;g=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)g+=` L ${a(n+(e+.5)*r)} ${t-c[e]/f*y}`;g+=` L ${a(i)} ${t} Z`}else{const t=e.x;g=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const i=a(n+(e+.5)*r);g+=` L ${t+c[e]/f*y} ${i}`}g+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:zf(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:i,getRawRange:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[i,a]=n,u=o(t,e.name);if(l){const n=s(Math.min(i,a)),r=s(Math.max(i,a));c.push(Qe(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(i,a)),r=s(Math.min(i,a));c.push(Qe(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of l){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}f.push({col:e,groups:t,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const e of f){let t=0,n=0;for(let i=0;u.length>i;i++){const r=e.groups.get(u[i]);r&&(i%2==0?t+=r.total:n+=r.total)}const i=Math.max(t,n);i>p&&(p=i)}if(0===p)return s;const y=new Map;for(const e of u){const t=f[0].groups.get(e);y.set(e,t?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,Df.scaleLinear)().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;f.length>t;t++){const n=f[t],i=n.col,r=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let e=0;for(const t of u){const i=n.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=o(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Qe(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const e=n.stepTotal,t=x(e),l=a-t/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=o(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:r,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(Qe(l,p,t,d,v,k,b)),m.set(h,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=h?u:[u[0]];for(const r of t){const t=v.get(r),a=m.get(r);if(!t||!a)continue;const c=(()=>{const e=n.groups.get(r);return o(e?e.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:n.groups.get(r)?.pieces[0]??i.pieceData[0],category:"_default"===r?i.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o,scales:s}=e,a=[],c=s.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const e of c)for(const t of e.pieceData){const e=r?r(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}h.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of l){const t=h[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,i=0===e,r=e>0?h[e-1]:null,s=n.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=r?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+c/2,k=p(g),S=p(0)-k,A=o(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Qe(w,k,u,S,A,M,d?h:n.name)),v>0){const e=p(g+v),t=k-e,i={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(Qe(w,e,u,t,i,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:i,getR:r,getStack:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:f.opacity??1,[n,r]=a.range(),o=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(i)){const i={fill:e,opacity:t},r=u?Qe(o,n.x,s,n.width,i,null,"__track__"):Qe(n.x,o,n.width,s,i,null,"__track__");l.push(r)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const n=l.length;for(const n of e.pieceData){const i=Math.abs(r(n));if(0===i)continue;const c=o?o(n):e.name,f=s(n,c);let p;if(u){const r=a(t),o=a(t+i);p=Qe(r,e.x,o-r,e.width,f,n,c)}else{const r=a(t+i),o=a(t);p=Qe(e.x,r,e.width,o-r,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),t+=i}if(p>0&&l.length>n){const e=l.slice(n),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},Ff=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nf=["scene-style","data-paint","accessibility","evidence"],Of=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Wf=new Set(["accessorRevision","axisExtent","categoryAccessor","chartType","extentPadding","groupBy","multiAxis","normalize","oAccessor","oExtent","oSort","rAccessor","rExtent","runtimeMode","stackBy","timeAccessor","valueAccessor"]),qf=new Set(["barColors","colorScheme","connectorStyle","pieceStyle","summaryStyle","themeCategorical","themeDiverging","themeSemantic","themeSequential"]),Yf=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Ff)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Nf):this.recordNoop("restyle")}recordConfig(e){if(0===e.length)return this.tracker.record({kind:"config",keys:e},[]);const t=new Set(Of);return e.some(e=>Wf.has(e))&&t.add("domain"),e.some(e=>qf.has(e))&&t.add("scene-style"),this.tracker.record({kind:"config",keys:e},t)}},Hf=require("d3-quadtree"),Gf=class{constructor(e){this.rExtent=new je,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Yf,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},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.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new _e(e.windowSize),this.getO=Re(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new je)):(this.getR=Ie(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Re(e.stackBy),this.getGroup=Re(e.groupBy),this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getConnector=Re(e.connectorAccessor),this.getDataId=Re(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,i=Ne(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:_t(t,i):null)}ingest(e){const t=Ne();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=jt(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,i=this.scales,r=this.multiScales,o=this.columns;if(0===n.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(d){f=(0,Tf.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=(0,Tf.scaleLinear)().domain(l).range([i,n])}else u?(f=(0,Tf.scaleBand)().domain(c).range([0,e.height]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([0,e.width])):(f=(0,Tf.scaleBand)().domain(c).range([0,e.width]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,r)=>{const o=this.rExtents[r];o.dirty&&o.recalculate(n,i);let[s,a]=o.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Tf.scaleLinear)().domain([s,a]).range([0,e.width]):(0,Tf.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=r,this.columns=o):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const o=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===i){const e=Math.max(50,3*r.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return o}if(!1===i)return o;if("function"==typeof i)return o.sort(i);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return o.sort("asc"===i?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:i,normalize:r,rExtent:o,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,f=s;if("radial"===i&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&r)p=0,y=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const i of t){const t=l(i),r=u(i);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>y&&(y=t);for(const e of n.values())p>e&&(p=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),i=u(n);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),i=Math.abs(u(n));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),p>t&&(p=t)}else{const e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}o&&(null!=o[0]&&(p=o[0]),null!=o[1]&&(y=o[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==o?.[0]&&null==o?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-p,t=e>0?e*f:1,i=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===n;null!=o?.[0]||i||(p-=t),null!=o?.[1]||r||(y+=t)}return[p,y]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,n,i,r){return function(e){const{data:t,oExtent:n,oScale:i,projection:r,layout:o,dynamicColumnWidth:s,getO:a,getR:c}=e,l={},u=new Map;for(const e of t){const t=a(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let i;i="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),h.set(t,i),e+=i}const t=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*n.length;if(e>0)for(const[n,i]of h)h.set(n,i/e*t)}let f=0,p=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let o,s;h?(o=p,s=h.get(e)||i.bandwidth(),p+=s+i.padding()*i.step()):(o=i(e)??0,s=i.bandwidth()),l[e]={name:e,x:o,y:0,width:s,middle:o+s/2,padding:i.padding()*i.step(),pieceData:t,pct:r,pctStart:f},f+=r}return l}({data:e,oExtent:t,oScale:n,projection:i,layout:r,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=vt("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const r=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return mt({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),i=Bf[this.config.chartType];let r=i?i(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:i,getConnector:r,getO:o}=e;if(!r||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let i,s;"point"===e.type?(i=e.x,s=e.y):(i=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:i,y:s,datum:t,category:o(t)})}const l=n.o.domain(),u=i.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;n.length-1>i;i++){const r=n[i],o=n[i+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:a,datum:r.datum,group:t})}}return s}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,i=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=iu(n.colorScheme,n.themeCategorical,R),o=this.scales;return{data:e,scales:{o:o.o,r:o.r,projection:o.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===o.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:[...r]},resolveColor:ru(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?{...n,fill:this.getColorFromScheme(t)}:n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||R,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,i),i}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const n="function"==typeof t,i=n?null:t||"category",r=new Map;for(let o=0;e.length>o;o++){const s=e[o],a=n?t(s):s[i],c=r.get(a);c?c.push(o):r.set(a,[o])}return r}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,n=0;for(const i of e)"point"===i.type&&(t++,i.r>n&&(n=i.r));if(500>=t)return{quadtree:null,maxRadius:n};const i=Array(t);let r=0;for(const t of e)"point"===t.type&&(i[r++]=t);return{maxRadius:n,quadtree:(0,Hf.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const n=t.length;if(1>=n)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=Ne()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const s of r(t)??[]){const t=n.get(s);null!=t&&(i=Math.max(i,qe(e,t,o)))}c=Ye(l,i,s)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const u=n.get(t);c=Ye(l,null==u?0:qe(e,u,o),s,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let i;for(let r=0;this.scene.length>r;r++){const o=this.scene[r],s=this.getNodeKey(o,e);s&&("rect"===o.type?this.prevPositionMap.set(s,n?{x:o.x,y:t,w:o.w,h:0,opacity:o.style.opacity??1}:{x:t,y:o.y,w:0,h:o.h,opacity:o.style.opacity??1}):"point"===o.type?this.prevPositionMap.set(s,{x:o.x,y:o.y,r:0,opacity:0}):"wedge"===o.type&&(void 0===i&&(i=o.startAngle),this.prevPositionMap.set(s,{x:o.cx,y:o.cy,startAngle:i,endAngle:i,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(n)||0;return t.set(n,i+1),`${n}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],i=this.getNodeKey(n,e);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const n=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],o=this.getNodeKey(r,i);if(!o)continue;r._transitionKey=o;const s=this.prevPositionMap.get(o);if("point"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.r),t=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(s)n.add(o),r._targetOpacity=r.style.opacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const e=r.startAngle;r.startAngle=e,r.endAngle=e,r.style={...r.style,opacity:0},this.prevPositionMap.set(o,{x:r.cx,y:r.cy,startAngle:e,endAngle:e,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,n={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:Ne(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=De(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=Fe(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n),void 0!==i.w&&(e.w=Fe(i.w,e._targetW,n),e.h=Fe(i.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:Fe(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=Fe(i.startAngle,e._targetStartAngle,n),e.endAngle=Fe(i.endAngle,e._targetEndAngle,n))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(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("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"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ze(e),n=this.getDataId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=ze(e),i=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("update",o.length),o}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}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&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ce(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Ce(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Re(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],o=Array.isArray(n)?n:[n];if(r=i.length!==o.length||i.some((e,t)=>!Ce(e,o[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new je)):(this.getR=Ie(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ce(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Re(this.config.stackBy):void 0),"groupBy"in e&&!Ce(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Re(this.config.groupBy):void 0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ce(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Re(this.config.connectorAccessor):void 0),(i||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}},Xf=require("react/jsx-runtime"),Vf=require("react/jsx-runtime");function Uf(e,t){const n=Gh(e.theme),i=e.size||[500,400],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.stackBy||e.groupBy):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u=e.projection||"vertical",d="radial"===u,h={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:u,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Gf(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),If.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));if(t){const n=f.scales.o?.domain?.();t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:Uh(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:o}=Xh(n),s=i?i+"-":"",a="vertical"===r.projection,c=r.r.ticks(5);return(0,vf.jsx)("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:o,strokeWidth:.5},"gr-"+n)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:o,strokeWidth:.5},"gr-"+n)})})}(f,{width:c,height:l},n,p):null;let g=null;if(f.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=function(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const n=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;n.length>e;e++)i=31*i+n.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}(e),i=new Set;for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");g=Array.from(i).map((e,i)=>function(e){const{id:t,background:n="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:o=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*o));return(0,Xf.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Xf.jsx)("rect",{width:a,height:a,fill:n}),(0,Xf.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:r}),(0,Xf.jsx)("line",{x1:o,y1:0,x2:o,y2:a,stroke:i,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((e,n)=>r.set(e,`funnel-hatch-${t}-${n}`));for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${r.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=f.scene.map((e,t)=>ao(e,t,p)).filter(Boolean),x=!1!==e.showAxes?function(e,t,n,i,r){const o=e.scales;if(!o)return null;if("radial"===o.projection)return null;const s=Xh(i),a="vertical"===o.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),f=o.r.ticks(5).map(e=>({pixel:o.r(e),label:(l||Mf)(e)}));return(0,Vf.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),d&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),d&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:u})]})}(f,{width:c,height:l},e,n,p):null,b=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:c,height:l},theme:n,projection:u,idPrefix:p}):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Cf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v,k=d?r.left+c/2:r.left,S=d?r.top+l/2:r.top;return If.renderToStaticMarkup(Pf((0,Vf.jsxs)(Vf.Fragment,{children:[e.backgroundGraphics,y,m,x,b,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:c,innerHeight:l,legend:w,defs:g,idPrefix:e._idPrefix}))}var Kf=c(require("react")),Zf=c(require("react-dom/server"));function Qf(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Jf(e,t){var n,i=[],r=[],o=[],s={},a=[];function c(e){o[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],o[t]&&c(t)})}function l(e){var t,i,d=!1;for(r.push(e),o[e]=!0,t=0;a[e].length>t;t++)(i=a[e][t])===n?(u(n,r),d=!0):o[i]||(d=l(i));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[i=a[e][t]];h||(s[i]=h={}),h[i]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):i.push(r)}function d(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,i=function(e){for(var t=e.length,n=Array(t),i=Array(t),r=Array(t),o=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,i[c]=0,r[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(t){var c=[t],l=[t];for(n[t]=i[t]=u,r[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var p=o[t];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=i[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(i[t]=0|Math.min(i[t],i[y])),0>s[y]||a[t].push(s[y])}o[t]=p}else{if(i[t]===n[t]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(r[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===t){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(e,t){return e-t}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=i.components.filter(function(e){return e.length>1}),o=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)o>r[s][a]&&(o=r[s][a],n=s);var c=r[n];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];o[+g]=!1,s[g]={}}l(n),n+=1}else n=h}return t?void 0:i}function ep(e){return e.y0-e.y1>0?"up":"down"}function tp(e,t){return t(e.source)==t(e.target)}function np(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 ip(e){return e.target.x0-e.source.x1}function rp(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1-i:e.y1+i}function op(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1+i:e.y1-i}function sp(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function ap(e,t){return t(e)}function cp(e){return up(e.source)}function lp(e){return up(e.target)}function up(e){return(e.y0+e.y1)/2}function dp(e){return e.virtual?0:e.value}function hp(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!tp(e,t)?n+1:n});var i=0;return e.targetLinks.forEach(function(e){i=e.circular&&!tp(e,t)?i+1:i}),n+i}function fp(e){return e.target.depth}function pp(e,t){return e.sourceLinks.length?e.depth:t-1}function yp(e,t){return e.y0-t.y0}function gp(e,t){return t.y0-e.y0}function mp(e,t){return e.y1-t.y1}function xp(e,t){return t.y1-e.y1}function bp(e,t){return wp(e.source,t.source)||e.index-t.index}function vp(e,t){return wp(e.target,t.target)||e.index-t.index}function wp(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function kp(e,t){return Sp(e)==Sp(t)?"bottom"==e.circularLinkType?gp(e,t):yp(e,t):Sp(t)-Sp(e)}function Sp(e){return e.target.column-e.source.column}function Ap(e,t){return Mp(e)==Mp(t)}function Mp(e){return e.y0-e.y1>0?"up":"down"}var Pp=require("d3-array");function _p(e,t,n,i,r){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,Pp.min)(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=o.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),jp(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),jp(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+i,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,tp(e,t)&&np(e))e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+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-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=o.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?gp:yp);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=o.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?xp:mp),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+r+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-r-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,i=e.target.x0,r=e.y1,o=(t+i)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(e)}),o}function jp(e,t,n){e.sort(kp);var i=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(tp(e,t)&&np(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Cp(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=c>o?c:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function Cp(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Ip=require("d3-array");function Tp(e){return function(){return e}}function Rp(e){return e.index}function Lp(e){return e.nodes}function $p(e){return e.links}function Ep(e,t,n){var i=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});i.forEach(function(r,o){var s=r.length;if(t)r.sort(t);else if(o>0){var a=new Map;r.forEach(function(e,t){var n,i,r,o=(i=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.source)*t,i+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.target)*t,i+=t}}),i>0?r/i:NaN);a.set(e,{bc:o,idx:t})}),r.sort(function(e,t){var n=a.get(e),i=a.get(t),r=n.bc,o=i.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(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?hp(t,n)-hp(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==i.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==hp(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function zp(e,t,n,i,r,o){var s=(0,Ip.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,c=o;c>0;--c)l(a*=.99,n),u();function l(t,n){var i=s.length;s.forEach(function(r){var o=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&hp(r,n)>0){var c=(0,Ip.mean)(r.sourceLinks,lp),l=(0,Ip.mean)(r.targetLinks,cp),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-up(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==i-1&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,Ip.mean)(r.sourceLinks,lp),f=(0,Ip.mean)(r.targetLinks,cp),p=((h&&f?(h+f)/2:h||f)-up(r))*t;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(n){var o,s,a,c=e.y0,l=n.length;for(n.sort(t||wp),a=0;l>a;++a)(s=c-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),c=o.y1+i;if((s=c-i-e.y1)>0)for(c=o.y0-=s,o.y1-=s,a=l-2;a>=0;--a)(s=(o=n[a]).y1+r-c)>0&&(o.y0-=s,o.y1-=s),c=o.y0})}}function Dp(e){e.nodes.forEach(function(e){e.sourceLinks.sort(vp),e.targetLinks.sort(bp)}),e.nodes.forEach(function(e){var t=e.y0,n=t,i=e.y1,r=i;e.sourceLinks.forEach(function(e){e.circular?(e.y0=i-e.width/2,i-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Bp(){var e=0,t=0,n=1,i=1,r=24,o=8,s=null,a=Rp,c=pp,l=void 0,u=32,d=2,h=Lp,f=$p;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=i,h.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,Ip.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 i=e.source,r=e.target;"object"!=typeof i&&(i=e.source=Qf(n,i)),"object"!=typeof r&&(r=e.target=Qf(n,r)),i.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var i=[],r=0;e.links.length>r;r++){var o=e.links[r],s=o.source.index,a=o.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=Jf(i);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,i=e.source.index;t===i||l[i]&&l[i][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++)})}(h,l),function(e,t){var n=0,i=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,e.nodes.forEach(function(e){ap(e,t)!=ap(r.source,t)&&ap(e,t)!=ap(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),tp(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Ip.sum)(e.sourceLinks,dp),(0,Ip.sum)(e.targetLinks,dp)),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)})})}(h),function(e,t,n){var i,r,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(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(h,l,c);var f=o;if(null!==s){var p=(0,Ip.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Ip.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(i-t)*s/(y-1)))}(function(e,t,n){var i=(0,Ip.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 r=(0,Ip.min)(i,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Ip.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var o=(0,Ip.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})})(h,f,r),Ep(h,l,a),zp(h,l,a,f,f,u),Dp(h),_p(h,a,d,10,8),Ep(h,l,a),zp(h,l,a,f,f,u),Dp(h),_p(h,a,d,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 i=n.links.filter(function(n){return ap(n.source,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ap(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=rp(t,e);return e.y1-n}if(t.target.column>e.target.column)return rp(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;i.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var i=n.links.filter(function(n){return ap(n.target,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ap(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=op(t,e);return e.y0-n}if(t.source.column>e.source.column)return op(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;i.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,i=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?i=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==i||0==r){let i=function(t){return(t-o)/(s-o)*(e.y1-e.y0)+e.y0};var o=(0,Ip.min)(t,function(e){return e.y0}),s=(0,Ip.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-o);1>a?(t.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1)}),n.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=i(e.y0)-e.y0;e.y0=i(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})})}}(h),_p(h,a,d,10,8)}(p),p}return p.update=function(e){return Dp(e),_p(e,a,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(o=+e,p):o},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Tp(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Tp(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Tp(e),p):a},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Tp(e),p):c},p.nodeSort=function(e){return arguments.length?(l=e,p):l},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],i=+r[1][1],p):[[e,t],[n,i]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],i=+r[1],p):[n-e,i-t]},p}var Fp=require("d3-interpolate"),Np=(require("d3-shape"),.5),Op=e=>{let t,n,i,r,o,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,i=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,o=e.source.x1,s=e.target.x0,a=(0,Fp.interpolateNumber)(o,s),c=a(Np),l=a(.5),`M${t},${o}C${t},${c} ${n},${l} ${n},${s}L${i},${s}C${i},${l} ${r},${c} ${r},${o}Z`;const u=e.sankeyWidth/2,d=(0,Fp.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=mc({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:d(Np),cp2X:d(.5)});return h};function Wp(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const n=i.sourceX,r=i.sourceY,o=i.targetX,s=i.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*(i.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${n},${r-t}L${n+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${o},${s-t}L${o-c},${s-t}L${o-c},${s+t}L${o},${s+t}Z`}const r=i.sourceX,o=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${o-d*t}L${c},${o-d*t}L${c+n},${o-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${o+d*t}L${r},${o+d*t}Z`}var qp=new Set,Yp=new WeakMap;function Hp(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Yp.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Yp.set(e,n);const i=new Proxy(e,{get(e,n,i){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;qp.has(e)||(qp.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,i)}});return n.set(t,i),i}var Gp={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(fp))-1:0},justify:pp};function Xp(e){return"string"==typeof e?e:e.id}var Vp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",o=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=Bp().extent(d).links(u).nodes(l).nodeAlign(Gp[o]||pp).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const i of l)e>i.x0&&(e=i.x0),i.x1>t&&(t=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,s=(i._circularWidth??i.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>r&&(r=o.verticalFullExtent+s)}const o=t-e,s=r-n,a=i[0],c=i[1];if(o>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/o,c/s),i=-e*t+(a-o*t)/2,r=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+i,e.x1=e.x1*t+i,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+i,n.targetX=n.targetX*t+i,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+i,n.leftFullExtent=n.leftFullExtent*t+i,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+i,n.leftInnerExtent=n.leftInnerExtent*t+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const p=new Map;for(const e of t)p.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=Xp(e.source),n=Xp(e.target),i=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=e.width??0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=r;const o=f.get(t),s=f.get(n);o&&(i.source=o),s&&(i.target=s)}}},buildScene(e,t,n,i){const r="vertical"===n.orientation?"down":"right",o=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],f=[],p=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 i=o?o(Hp(t,"nodeStyle")):{},s={fill:i.fill||u.get(t.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{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 y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?p.get(i.id)||u.get(i.id)||r:p.get(t.id)||u.get(t.id)||r;const o=s?s(Hp(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity: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 l;(l=e.circular&&e.circularPathData?Wp(e):Op(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:o.fill||r,fillOpacity:o.fillOpacity??a,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity},datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||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,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(i[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+o/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:h,labels:f}}},Up=require("d3-force"),Kp=require("d3-scale"),Zp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r=n.forceStrength??.1,o=i[0]/2,s=i[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const i=Qp(e.id,t,n);if(i.length>0){let t=0,n=0;for(const e of i)t+=e.x,n+=e.y;const r=Jp(e.id),o=r%360*(Math.PI/180),s=10+r%20;e.x=t/i.length+s*Math.cos(o),e.y=n/i.length+s*Math.sin(o)}else{const t=Jp(e.id),n=t%360*(Math.PI/180),i=15+t%30;e.x=o+i*Math.cos(n),e.y=s+i*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const i=e[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const e=10*Math.sqrt(n+.5),r=n*t;i.x=o+e*Math.cos(r),i.y=s+e*Math.sin(r)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=ey(n.nodeSize,n.nodeSizeRange,e),f=e=>h(e);if(d>0){const n=new Map,i=new Map;for(const t of e)n.set(t.id,0),i.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,i="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(i,(n.get(i)??0)+1)}const a=(0,Up.forceLink)().strength(e=>{const t=e.weight,i="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(i)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*o))}).distance(e=>{const t="string"==typeof e.source?i.get(e.source):e.source,n="string"==typeof e.target?i.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),c=(0,Up.forceSimulation)().force("charge",(0,Up.forceManyBody)().strength(e=>{const t=n.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,Up.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,Up.forceCenter)(o,s).strength(.8)).force("x",(0,Up.forceX)(o).strength(.06)).force("y",(0,Up.forceY)(s).strength(.06));if(c.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),c.force("link",a)}u?c.alpha(.3):.1>c.alpha()&&c.alpha(1),c.stop();for(let e=0;d>e;++e)c.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(i[0]-e,t.x)),t.y=Math.max(e,Math.min(i[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.edgeStyle,s=ey(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{},o={fill:i.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),i="object"==typeof e.target?e.target:h.get(e.target);if(!t||!i)continue;if(null==t.x||null==t.y)continue;if(null==i.x||null==i.y)continue;const r=o?o(Hp(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.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 i=s(Hp(n,"nodeSize"));d.push({x:n.x,y:n.y-i-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Qp(e,t,n){const i=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.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||i.push({x:e.x,y:e.y})}}return i}function Jp(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 ey(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 i=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>i[0];const[o,s]=di(r);if(o===s)return()=>(i[0]+i[1])/2;const a=(0,Kp.scaleLinear)().domain([o,s]).range(i).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?i[0]:a(n)}}var ty=require("d3-chord"),ny=require("d3-shape"),iy=g,ry={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,c=a-o,l=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>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),i=f.get(t);if(void 0===n||void 0===i)continue;const r=d(e);y[n][i]=r}const g=(0,ty.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,ny.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=i[0]+l,n.y=i[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=v.get("string"==typeof e.source?e.source:e.source.id),i=v.get(t);n&&(e.source=n),i&&(e.target=i)}const w=new Map;for(const e of t)w.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,i=e[t.target.index].id,r=w.get(`${n}\0${i}`)||w.get(`${i}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,i){const{groupWidth:r=20,edgeOpacity:o=.5}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,l=i[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:iy,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,ty.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],i=n.__arcData;if(!i)continue;let r;r=u?u(Hp(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const o=u?u(Hp(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:{fill:r,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 i=y(t);if(!i)continue;const r=oy(i,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Hp(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=d?d(Hp(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,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=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,i=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const o=(e.startAngle+e.endAngle)/2,s=o-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function oy(e,t,n){const i=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return e;const r=[];let o=0;for(;i.length>o;){const e=i[o];if("M"===e||"L"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;3>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;2>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+t+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===e||"z"===e?(r.push(e),o++):(r.push(i[o]),o++)}return r.join(" ")}var sy=require("d3-hierarchy"),ay=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function cy(e){const[t,n,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*i>150?"#222":"#fff"}function ly(e,t,n){const i=t.nodeIDAccessor;return"function"==typeof i?i(e.data)+"":"string"==typeof i&&void 0!==e.data[i]?e.data[i]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function uy(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 dy(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:ay}function hy(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 fy(e,t,n,i,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${i} ${n},${i}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+i)/2} T ${n},${i}`}{const r=(t+i)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${i}`}}var py={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;if(!r)return;const o=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,sy.hierarchy)(r,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=i;switch(o){case"tree":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.tree)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.cluster)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,i){const r=t.padding??4,o=t.paddingTop??0,s=(0,sy.treemap)().size([n,i]).tile(sy.treemapBinary).padding(r);o>0&&s.paddingTop(o),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,i){const r=t.padding??4;(0,sy.pack)().size([n,i]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,i){(0,sy.partition)().size([n,i]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const i=h[t],r={id:ly(i,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===o||"cluster"===o?yy(r,i,n):"treemap"===o||"partition"===o?gy(r,i):"circlepack"===o&&my(r,i),r.__hierarchyNode=i,e.push(r),f.set(i,r)}if("tree"===o||"cluster"===o)for(const e of h)if(e.parent){const n=f.get(e.parent),i=f.get(e);n&&i&&t.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,i,r,o){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,i=t.y;u&&(e+=d,i+=h);const o=r(Hp(t,"nodeStyle"));let a=o.fill||hy(n);if(n.colorByDepth&&void 0!==t.depth){const e=dy(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:i,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 y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=t.x,s=t.y,c=i.x,f=i.y;u&&(r+=d,s+=h,c+=d,f+=h);const p=fy(r,s,c,f,l),g=o(Hp(e,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:e})}if(!1!==n.showLabels){const t=uy(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let i,r,o,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(i=s+e/n*10,r=a+t/n*10,o=0>e?"end":"start"):(i=s,r=a-12,o="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(i=s-f-6,o="end"):(i=s+f+6,o="start"),r=a):(i=s,r=a+f+14,o="middle");c.push({x:i,y:r,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,i,r,o);case"treemap":case"partition":return function(e,t,n,i){const r=[],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=i(Hp(n,"nodeStyle"));let a=s.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);a=e[n.depth%e.length]}r.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=uy(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=i(Hp(a,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==a.depth){const e=dy(t);d=e[a.depth%e.length]}const h="string"==typeof d?cy(d):t.themeSemantic?.text??"#000";o.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:o}}(e,n,0,r);case"circlepack":return function(e,t,n,i){const r=[],o=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const o=i(Hp(n,"nodeStyle"));let s=o.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);s=e[n.depth%e.length]}r.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=uy(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=i(Hp(r,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==r.depth){const e=dy(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?cy(c):t.themeSemantic?.text??"#000";o.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else o.push({x:r.x,y:r.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:r,sceneEdges:[],labels:o}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function yy(e,t,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=t.x,i=t.y;e.x=i*Math.cos(n-Math.PI/2),e.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 gy(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 my(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 xy=require("d3-shape");function by(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var vy={sankey:Vp,force:Zp,chord:ry,tree:py,cluster:py,treemap:py,circlepack:py,partition:py,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;r&&function(e,t,n,i,r){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),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=by(n);h.metaMap.clear(),i.length=0,r.length=0;const f=new Map;function p(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=p(s(e));i.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,y,g){const m=o(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:t,parentId:n},M=g?f/u(A)*S:f*S,P=(0,xy.pie)().value(e=>{const t=o(e)?.length;return t?4:1}).sort(null)(w),_=d(A);for(let t=0;w.length>t;t++){const o=(P[t].startAngle+P[t].endAngle)/2,a=w[t],u=p(s(a)),d=c+M*Math.sin(o),f=l+M*Math.cos(o)*_;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:o,depth:y,parentId:n,eccentricity:_}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(r,i,n,e,t)},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.nodeSize,s="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=by(n),i=new Map;for(const t of e)i.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=i.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.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:i}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,l=(r+1)/o*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*i,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*i,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:i.fill||n.themeSemantic?.primary||"#6366f1",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Hp(n,"nodeSize"));if(4>=e)continue;const i="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,i,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=by(t),i=t.orbitSpeed??.25,r=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=i*(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 i=a.get(e.parentId);if(!i)continue;const c=e.angle+o*s*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(c),t.y=i.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},wy=require("react/jsx-runtime");function ky(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Sy=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ay(e,t){const n=Gh(e.theme),i=e.chartType||"force",r=()=>Kh({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),o=e.size||[500,500],s={top:20,right:20,bottom:20,left:20,...e.margin},a=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const i=B(e.nodes||[]);if(i.length>0)return ff(i,t);const r=Array.isArray(e.edges)?B(e.edges):[];if(0===r.length)return[];const o=ky(e.sourceAccessor,"source"),s=ky(e.targetAccessor,"target");return ff(Array.from(new Set(r.flatMap(e=>[o(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[],c=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(s,{legend:e.legend,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&kf(s,{categories:a,colorScheme:e.colorScheme,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout});const l=o[0]-s.left-s.right,u=o[1]-s.top-s.bottom,d=function(e){return vy[e]}(i);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,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,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||n.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let f,p;if(Sy.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));h.__hierarchyRoot=i,f=[],p=[]}else{const i=B(e.nodes||[]),a=Array.isArray(e.edges)?B(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=ky(t.sourceAccessor,"source"),i=ky(t.targetAccessor,"target"),r=ky(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:i(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,h),0===i.length&&p.length>0){const e=new Set;for(const t of p){const n=wf(t.source),i=wf(t.target);n&&e.add(n),i&&e.add(i)}f=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else f=function(e,t){const n=ky(t.nodeIDAccessor,"id");return e.map(e=>({id:n(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,h)}let y=[],m=[],x=[],b=null;if(h.customNetworkLayout){const e=h.colorScheme,t=iu(e,n.colors.categorical,g),i=ru(t,e),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:i,config:h.layoutConfig??{}},o=h.customNetworkLayout(r);y=o.sceneNodes??[],m=o.sceneEdges??[],x=o.labels??[],b=o.overlays??null}else if(d){d.computeLayout(f,p,h,[l,u]);const e=d.buildScene(f,p,h,[l,u]);y=e.sceneNodes,m=e.sceneEdges,x=e.labels}const v=Xh(n);for(const e of x)e.fill||(e.fill=v.text);t&&(t.evidence=Kh({frameType:"network",width:o[0],height:o[1],marks:[...y.map(e=>({type:"node:"+(e.type??"node")})),...m.map(e=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:y.length,edgeCount:m.length}));const w=m.map((e,t)=>function(e,t){switch(e.type){case"line":return(0,eo.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,eo.jsx)("path",{d:n.pathD,fill:no(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,eo.jsx)("path",{d:n.pathD,fill:no(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,eo.jsx)("path",{d:n.pathD,fill:no(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),k=y.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return(0,eo.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:no(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,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+t)}case"arc":{const n=e,i=(0,Ur.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(to)||"";return(0,eo.jsx)("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+t)}case"symbol":{const n=e,i=ht(n.symbolType,n.size,n.path);return(0,eo.jsx)("path",{d:i,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?no(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return ro(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),S=x.map((e,t)=>function(e,t){return(0,eo.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),A=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:l,height:u},theme:n,idPrefix:e._idPrefix}):null,M=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const r=ff(f.length>0?f.map(e=>e.data||{id:e.id}):Array.from(new Set(p.flatMap(e=>[wf(e.source),wf(e.target)]).filter(Boolean))).map(e=>({id:e})),t);return 0===r.length?null:hf({categories:r,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout})})():null,P=Kf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:o,margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||M;return Zf.renderToStaticMarkup(Pf((0,wy.jsxs)(wy.Fragment,{children:[e.backgroundGraphics,w,k,S,A,e.foregroundGraphics,b]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:P,idPrefix:e._idPrefix}))}var My=c(require("react")),Py=c(require("react-dom/server")),_y=require("d3-geo"),jy=require("d3-quadtree"),Cy=require("d3-geo"),Iy={mercator:Cy.geoMercator,equalEarth:Cy.geoEqualEarth,albersUsa:Cy.geoAlbersUsa,orthographic:Cy.geoOrthographic,naturalEarth:Cy.geoNaturalEarth1,equirectangular:Cy.geoEquirectangular};function Ty(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ry(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Ly(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function $y(e,t){if(2>e.length)return[e];const n=.4*t,i=[];let r=[e[0]];for(let t=1;e.length>t;t++){const o=e[t];Math.abs(o[0]-e[t-1][0])>n?(2>r.length||i.push(r),r=[o]):r.push(o)}return 2>r.length||i.push(r),i}function Ey(e,t,n=24){const i=t[0]-e[0],r=t[1]-e[1],o=Math.sqrt(i*i+r*r);if(0===o)return[e,t];const s=-r/o,a=i/o,c=Math.min(.3*o,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let i=0;n>=i;i++){const r=i/n,o=1-r;d.push([o*o*e[0]+2*o*r*l+r*r*t[0],o*o*e[1]+2*o*r*u+r*r*t[1]])}return d}function zy(e,t){if(2>e.length)return e;const n=t/2+1,i=[];for(let t=0;e.length>t;t++){const r=e[t];let o,s;0===t?(o=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(o=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(o*o+s*s)||1;i.push([r[0]+s/a*n,r[1]+-o/a*n])}return i}function Dy(e,t,n,i,r){const o=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(o*o+s*s);if(0===a)return[e,t];const c=s/a,l=-o/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var By=require("d3-scale"),Fy=class e{constructor(e){this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this._stylePaintPending=!1,this.config=e}updateConfig(e){this.config={...this.config,...e},"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e.slice()}initStreaming(e=500){this.pointBuffer=new _e(e),this.timestampBuffer=new _e(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=Ne();jt(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t}pushMany(e){this.pointBuffer||this.initStreaming();const t=Ne();for(const n of e)jt(this.pointBuffer,n,this.timestampBuffer,t);this.lastIngestTime=t}pushLine(e){null!=e&&"object"==typeof e&&(this.lineData.push(e),this.version++)}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){for(const e of t)this.lineData.push(e);this.version++}}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!i.has(n(e)+"")||(r.push(e),!1)),r.length>0&&this.version++,r}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(n(e)+"");Ct(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++}setLayoutSelection(e){this.config.layoutSelection=e}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){const t=this._customRestyle;if(t){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...i,...r}:i}this._stylePaintPending=!0}}computeScene(e){const{config:t}=this,n=this.projection,i=this.geoPath,r=this.scales,o=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,Cy.geoEqualEarth)();if("string"==typeof e){const t=Iy[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Cy.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Iy[e.type],n=t?t():(0,Cy.geoEqualEarth)();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=(0,_y.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,_y.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=i,this.scales=r,this.baseScale=o,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,i=[...this.areas],r=Ty(n.xAccessor,"lon"),o=Ty(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Ry(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(n.projectionExtent){const[[i,r],[o,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,r],[o,r],[o,s],[i,s],[i,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*i),t.translate([e.width/2,e.height/2])}else{const r={type:"FeatureCollection",features:i},o=n.fitPadding??0;1>o||"undefined"==typeof process||"production"===process.env.NODE_ENV||console.warn(`[semiotic] fitPadding=${o} looks like pixels, but it's a fraction of the plot (0–0.5). A value >= 1 collapses the projection off-canvas — use e.g. 0.06.`);const s=e.width*o,a=e.height*o;t.fitExtent([[s,a],[e.width-s,e.height-a]],r)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,r=this.scales,o=[...n.rotate()];n.rotate(e),this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(o),this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,n=0;for(const e of this.scene)"point"===e.type&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(i[r++]=e);this._quadtree=(0,jy.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,i=this.geoPath,r=Ty(t.xAccessor,"lon"),o=Ty(t.yAccessor,"lat");if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=iu(t.colorScheme,t.themeCategorical,R),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:ru(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let o;try{o=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,i=vt("geo",e,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=o.nodes??[];if(this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null,this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return mt({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap;const s=[],a=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),c=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),l=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const n=!0===t.graticule?{}:t.graticule,r=(0,_y.geoGraticule)();n.step&&r.step(n.step);const o=i(r())||"";o&&s.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:n.stroke||"#e0e0e0",strokeWidth:n.strokeWidth||.5,strokeDasharray:n.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const n=i(e);if(!n)continue;const r=i.centroid(e),o=i.bounds(e),c=i.area(e),l=Ly(t.areaStyle,e,a);s.push({type:"geoarea",pathData:n,centroid:r,bounds:o,screenArea:c,style:l,datum:e,interactive:!0})}const u=Ry(t.lineDataAccessor);for(const i of this.lineData){const a=u(i);if(!a||2>a.length)continue;let l=[];if("geo"===t.lineType){const e=Array(a.length);for(let t=0;a.length>t;t++)e[t]=[r(a[t]),o(a[t])];for(let t=0;e.length-1>t;t++){const i=e[t],r=e[t+1],o=(0,_y.geoDistance)(i,r)||0,s=Math.max(2,Math.ceil(o/(Math.PI/180))),a=(0,_y.geoInterpolate)(i,r);for(let e=0;s>=e;e++){if(t>0&&0===e)continue;const i=n(a(e/s));null!=i&&l.push(i)}}}else for(let e=0;a.length>e;e++){const t=a[e],i=n([r(t),o(t)]);null!=i&&l.push(i)}if(2>l.length)continue;const d=Ly(t.lineStyle,i,c),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==a.length||2>l.length||"arc"!==t.flowStyle?2!==a.length||2>l.length||"offset"!==t.flowStyle||(l="geo"===t.lineType?zy(l,h):Dy(l[0],l[l.length-1],0,0,h)):l=Ey(l[0],l[l.length-1]);const f=$y(l,e.width);if(f.length>1)for(const e of f){if(2>e.length)continue;const t={type:"line",path:e,style:{...d,_edgeFade:!0},datum:i};s.push(t)}else s.push({type:"line",path:2>l.length&&f[0]||l,style:d,datum:i})}const d=this.getPoints(),h=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,f=n.clipAngle?n.clipAngle()??0:0,p=f>0?f*Math.PI/180:null,y=n.rotate?n.rotate():[0,0,0],g="function"==typeof n.center?n.center():[0,0],m=[(g[0]??0)-y[0],(g[1]??0)-y[1]];for(let e=0;d.length>e;e++){const i=d[e],a=r(i),c=o(i);if(null!=p&&(0,_y.geoDistance)([a,c],m)>p)continue;const u=n([a,c]);if(!u)continue;const f=t.pointStyle?t.pointStyle(i):{...l},y={type:"point",x:u[0],y:u[1],r:f.r||4,style:f,datum:i,pointId:h?h(i)+"":void 0};s.push(y)}return s}applyCartogramTransform(e,t){const n=function(e,t,n,i){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const o=t.strength??1;if(0===o)return null;const s=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&s(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,u=c.y,d=hi(r.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),1),h=Math.min(n.width,n.height)/2,f=(0,By.scaleLinear)().domain([0,d]).range([0,h]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}for(const e of r){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-l),n=Math.sqrt((e.x-l)**2+(e.y-u)**2),i=a(e.datum),r=n+((isFinite(i)?f(i):n)-n)*o;e.x=l+Math.cos(t)*r,e.y=u+Math.sin(t)*r}const p=n.width/2,y=n.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const e of r)e.x+=g,e.y+=m;const x={cx:p,cy:y,maxCost:d,availableRadius:h},b=e.filter(e=>"line"===e.type);if(b.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of b){const n=t.datum?.source,i=t.datum?.target;if(n&&i){const r=e.get(n+""),o=e.get(i+"");r&&o&&(t.path=[r,o])}}}return x}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let i=0;n.length>i;i++){const r=Oe(e,i,t);n[i]._decayOpacity=r,n[i].style={...n[i].style,opacity:r}}}applyPulse(){const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const t=Ne(),n=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray();for(let r=0;n.length>r&&i.length>r;r++){const o=qe(e,i[r],t);o>0&&(n[r]._pulseIntensity=o,n[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",n[r]._pulseGlowRadius=e.glowRadius??4)}}get hasActivePulses(){return He(this.config.pulse??{},this.timestampBuffer)}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of i)if(e.pointId){const t=n.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(r=!0))}for(const e of i)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:Ne(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=De(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Fe(e.x,e._targetX,n),e.y=Fe(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Fy.QUADTREE_THRESHOLD=500;var Ny=Fy,Oy=require("react/jsx-runtime");function Wy(e,t){const n=Gh(e.theme),i=e.size||[e.width||600,e.height||400],r={top:10,right:10,bottom:10,left:10,...e.margin},o=Array.isArray(e.areas)?B(e.areas):e.areas,s=B(e.points),a=B(e.lines),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return ff(s.length>0?s:Array.isArray(o)&&o.length>0?"string"==typeof t?o.map(e=>({...e.properties||{},...e})):o:[],t)})():[],l=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&c.length>0&&kf(r,{categories:c,colorScheme:e.colorScheme,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const u=i[0]-(r.left??0)-(r.right??0),d=i[1]-(r.top??0)-(r.bottom??0),h={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,themeCategorical:n.colors.categorical,themeSemantic:xe(n)},f=new Ny(h);if(o){if("string"==typeof o)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${o}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${o}')\` before calling renderGeoToStaticSVG.`);f.setAreas(o)}if(e.points&&f.setPoints(s),e.lines&&f.setLines(a),f.computeScene({width:u,height:d}),t&&(t.evidence=Kh({frameType:"geo",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:c.length>0?c.length:void 0})),0===f.scene.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return Py.renderToStaticMarkup(Pf(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}))}const p=f.scene.map((e,t)=>function(e,t){switch(e.type){case"geoarea":{const n=e;return n.pathData?(0,eo.jsx)("path",{d:n.pathData,fill:no(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1},"geoarea-"+t):null}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const i="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,eo.jsx)("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return ro(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)).filter(Boolean),y=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,g=e.showLegend?0===c.length?null:hf({categories:c,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,m=My.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||g;return Py.renderToStaticMarkup(Pf((0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,p,y,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}function qy(e,t){const n=e.size??[e.width??600,e.height??400],i=new Fl(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=qu(i,{...e,width:n[0],height:n[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=Kh({frameType:"physics",width:n[0],height:n[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}var Yy=require("react/jsx-runtime");function Hy(e,t){switch(e){case"xy":return jf(t);case"ordinal":return Uf(t);case"network":return Ay(t);case"geo":return Wy(t);case"physics":return qy(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Gy(e){return jf(e)}function Xy(e){return Uf(e)}function Vy(e){return Ay(e)}function Uy(e){return Wy(e)}var Ky=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Zy(e,t,n){return Jy(e,t).svg}function Qy(e,t,n){const i={},{svg:r,frameType:o}=Jy(e,t,0,i),s=i.evidence??Kh({frameType:o,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=e,{svg:r,evidence:s}}function Jy(e,t,n,i){const{data:r,width:o=600,height:s=400,theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=t,w=[o,s],k={...v.frameProps||{},...function(e,t){const n={};for(const i of t)void 0!==e[i]&&(n[i]=e[i]);return n}(v,Ky),theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,size:w,...void 0!==g&&{margin:g},...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},S=Hh[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(r,x,m,k,v);let M=(0,{xy:jf,ordinal:Uf,network:Ay,geo:Wy,physics:qy}[S.frameType])(A,i);if("GaugeChart"===e&&A.__gauge){const e=A.__gauge,t=k.margin||{top:20,right:20,bottom:30,left:40},n=(o||300)-t.left-t.right,i=(s||300)-t.top-t.bottom,r=Math.min(n,i)/2*.85,c=t.left+n/2,l=t.top+i/2,d=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,h=Gh(a).colors.text,f=u.renderToStaticMarkup((0,Yy.jsxs)(Yy.Fragment,{children:[(0,Yy.jsx)("line",{x1:c,y1:l,x2:c+r*Math.cos(d),y2:l+r*Math.sin(d),stroke:h,strokeWidth:2.5,strokeLinecap:"round"}),(0,Yy.jsx)("circle",{cx:c,cy:l,r:4,fill:h})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function eg(e,t,n={}){const{format:i="png",scale:r=1,background:o}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(e)?Hy(e,t):Zy(e,t),o&&(s=s.replace(/<svg /,`<svg style="background:${o}" `));try{const e="sharp",t=await import(e);a=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=t.width||t.size?.[0]||600,l=t.height||t.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*r}).resize(Math.round(c*r),Math.round(l*r));return"jpeg"===i?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function tg(e,t={}){const{title:n,subtitle:i,theme:r,width:o=1200,height:s,layout:a={},background:c}=t,l=Xh(Gh(r)),d=a.columns||2,h=a.gap??16;let f=0;n&&(f+=30),i&&(f+=20),f>0&&(f+=10);const p=Math.floor((o-h-h*(d-1))/d),y=[];let g=0,m=f+h,x=0;for(const t of e){const e=Math.min(t.colSpan||1,d),n=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0),y.push({chart:t,x:h/2+g*(p+h),y:m,w:p*e+h*(e-1),h:n}),x=Math.max(x,n),g+=e}const b=s||m+x+h,v=y.map((e,t)=>{const{chart:n,x:i,y:o,w:s,h:a}=e,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=n.component?Zy(n.component,c):n.frameType?Hy(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Yy.jsx)("g",{transform:`translate(${i},${o})`,children:(0,Yy.jsx)("foreignObject",{width:s,height:a,children:(0,Yy.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return u.renderToStaticMarkup((0,Yy.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:b,role:"img","aria-label":n||"Dashboard",style:{fontFamily:l.fontFamily},children:[n&&(0,Yy.jsx)("title",{children:n}),c&&(0,Yy.jsx)("rect",{x:0,y:0,width:o,height:b,fill:c}),n&&(0,Yy.jsx)("text",{x:o/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:n}),i&&(0,Yy.jsx)("text",{x:o/2,y:n?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),v]}))}var ng=c(require("react-dom/server")),ig=require("react/jsx-runtime");function rg(e,t,n,i={}){const{stepSize:r,windowSize:o,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,p=n.height||400,y=Gh(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v={top:20,right:20,bottom:30,left:40,...n.margin},w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new Gf(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(ug(c.scene,f,p,y,g))}else for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),m={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new Ot(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(lg(b.scene,f,p,y,g,v)),l>0&&i>0&&b.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),S.push(lg(b.scene,f,p,y,g,v))}}return S}function og(e,t,n={}){return t.map(t=>{try{return Zy(e,{...n,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||t.width||600}" height="${n.height||t.height||400}"></svg>`}})}function sg(e,t,n){const i=t.size??[t.width??600,t.height??400],r=Gh(t.theme),o=Xh(r),s=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${n}`:void 0,l=t.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Ou(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),h=(0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:o.fontFamily},children:[t.title&&(0,ig.jsx)("title",{id:c,children:t.title}),t.description&&(0,ig.jsx)("desc",{id:l,children:t.description}),s&&"transparent"!==s?(0,ig.jsx)("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,(0,ig.jsx)("g",{id:`${a}-frame-${n}`,children:d.map((e,t)=>so(e,t,`${a}-${n}`))})]});return ng.renderToStaticMarkup(h)}function ag(e,t={}){const{fps:n=12,frameCount:i,durationSeconds:r=2,includeInitialFrame:o=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/l)),d=i??Math.max(1,Math.ceil(r*Math.max(1,n))),h=c?{...e,background:c}:e,f=new Fl(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(o&&(f.tick(0),p.push(sg(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(l);p.push(sg(f,h,p.length))}return p}function cg(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function lg(e,t,n,i,r,o){const s=Xh(i),a={top:20,right:20,bottom:30,left:40,...r.margin},c=t-a.left-a.right,l=n-a.top-a.bottom,u=cg(r,i),d=e.map((e,t)=>so(e,t)).filter(Boolean),h=function(e,t,n,i,r,o){if(!e||0===e.length)return null;const s=Xh(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(o)e=o(c.value);else if(r){const[t,i]=r,o=i-t;if(0===o)continue;e=n-(c.value-t)/o*n}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,ig.jsxs)("g",{children:[(0,ig.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,ig.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?(0,ig.jsx)(ig.Fragment,{children:a}):null}(r.annotations,c,l,i,r.yExtent,o?.y),f="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return ng.renderToStaticMarkup((0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&(0,ig.jsx)("title",{id:y,children:f}),p&&(0,ig.jsx)("desc",{id:g,children:p}),u&&(0,ig.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ig.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[h,d]}),f&&(0,ig.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]}))}function ug(e,t,n,i,r){const o=Xh(i),s={top:20,right:20,bottom:30,left:40,...r.margin},a="radial"===r.projection,c=a?s.left+(t-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=cg(r,i),d=e.map((e,t)=>ao(e,t)).filter(Boolean),h="string"==typeof r.title?r.title:void 0,f="string"==typeof r.description?r.description:void 0,p=h?"semiotic-title":void 0,y=f?"semiotic-desc":void 0,g=[p,y].filter(Boolean).join(" ")||void 0;return ng.renderToStaticMarkup((0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":g,style:{fontFamily:o.fontFamily},children:[h&&(0,ig.jsx)("title",{id:p,children:h}),f&&(0,ig.jsx)("desc",{id:y,children:f}),u&&(0,ig.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ig.jsx)("g",{transform:`translate(${c},${l})`,children:d}),h&&(0,ig.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:h})]}))}async function dg(e,t,n,i={}){const{fps:r=12,loop:o=!0,scale:s=1,background:a}=i,c=n.width||600,l=n.height||400,u=rg(e,t,a?{...n,background:a}:n,i);if(0===u.length)throw Error("No frames generated — check that data is not empty");return fg(u,c,l,{fps:r,loop:o,scale:s})}async function hg(e,t={}){const{fps:n=12,loop:i=!0,scale:r=1}=t,o=e.size??[e.width??600,e.height??400],s=ag(e,t);if(0===s.length)throw Error("No physics frames generated");return fg(s,o[0],o[1],{fps:n,loop:i,scale:r})}async function fg(e,t,n,i={}){const{fps:r=12,loop:o=!0,scale:s=1}=i,a=Math.round(t*s),c=Math.round(n*s);let l,u,d,h;try{const e="sharp",t=await import(e);l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await import(e);u=t.GIFEncoder??t.default?.GIFEncoder??t.default?.default?.GIFEncoder,d=t.quantize??t.default?.quantize??t.default?.default?.quantize,h=t.applyPalette??t.default?.applyPalette??t.default?.default?.applyPalette}catch{throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const f=Math.round(1e3/r),p=u();for(let t=0;e.length>t;t++){const n=e[t],i=await l(Buffer.from(n),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),r=new Uint8Array(i),u=d(r,256),y=h(r,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:o?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|