semiotic 3.10.0 → 3.10.2
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/README.md +73 -72
- package/ai/artifact-surface-inventory.json +4 -1
- package/ai/componentMetadata.cjs +3 -1
- package/ai/dist/mcp-server.js +47 -46
- package/ai/examples.md +95 -0
- package/ai/reference.md +80 -1
- package/ai/schema.json +7304 -1990
- package/ai/surface-manifest.json +26 -4
- package/ai/task-packets/compare-category-totals.json +7 -53
- package/ai/task-packets/compare-category-totals.md +4 -4
- package/ai/task-packets/correct-published-chart.json +7 -53
- package/ai/task-packets/correct-published-chart.md +4 -4
- package/ai/task-packets/index.json +9 -9
- package/ai/task-packets/update-live-chart.json +8 -54
- package/ai/task-packets/update-live-chart.md +4 -4
- package/dist/c-27DCB5T6.min.js +18 -0
- package/dist/c-2MONF2P6.min.js +1 -0
- package/dist/c-2TW5H5PD.min.js +1 -0
- package/dist/c-3AGX252H.min.js +1 -0
- package/dist/c-3B6JZEZT.min.js +1 -0
- package/dist/c-3BYZXCX3.min.js +4 -0
- package/dist/c-3DIPZJDO.min.js +1 -0
- package/dist/c-3FOUMWLR.min.js +1 -0
- package/dist/c-3NA6I656.min.js +2 -0
- package/dist/c-3OFVBWQY.min.js +1 -0
- package/dist/{c-QA3HMQJP.min.js → c-3PFVJFBK.min.js} +1 -1
- package/dist/c-3PPO7ZJF.min.js +4 -0
- package/dist/c-3YEW2PK6.min.js +1 -0
- package/dist/c-4JKDJUYD.min.js +1 -0
- package/dist/c-4LKK5YWB.min.js +1 -0
- package/dist/c-4MD53L2J.min.js +33 -0
- package/dist/c-4V3CD337.min.js +1 -0
- package/dist/c-4XLHPQTP.min.js +1 -0
- package/dist/c-5NYONM6V.min.js +5 -0
- package/dist/c-6IVBV5NO.min.js +1 -0
- package/dist/c-6ZU3QVLB.min.js +100 -0
- package/dist/c-72CBVNYX.min.js +209 -0
- package/dist/c-7APWCEPL.min.js +1 -0
- package/dist/c-7ASK4WBF.min.js +1 -0
- package/dist/{c-ORLEBW72.min.js → c-7FKPPCGN.min.js} +1 -1
- package/dist/c-7LY46QUI.min.js +41 -0
- package/dist/c-ABMGCCLT.min.js +1 -0
- package/dist/c-AINGQGUN.min.js +1 -0
- package/dist/c-AKLBQMQF.min.js +391 -0
- package/dist/c-AXJ2QI3F.min.js +1 -0
- package/dist/c-BQYD7T4E.min.js +1 -0
- package/dist/{c-V4XMSLC3.min.js → c-BYJJ7EMG.min.js} +1 -1
- package/dist/{c-JO2UGTCP.min.js → c-C4KIXUWU.min.js} +1 -1
- package/dist/c-C4SXYFXL.min.js +1 -0
- package/dist/c-CLDCKFBE.min.js +1 -0
- package/dist/c-CLJCJSFU.min.js +1 -0
- package/dist/c-CLLCX3PT.min.js +2 -0
- package/dist/c-ECHBKW7U.min.js +1 -0
- package/dist/c-EPJWM2UT.min.js +1 -0
- package/dist/c-F2GGJB2S.min.js +31 -0
- package/dist/c-FD2BXSRG.min.js +1 -0
- package/dist/c-FDUQDCBC.min.js +51 -0
- package/dist/c-FOTTQHOO.min.js +1 -0
- package/dist/c-FU7A5KSY.min.js +1 -0
- package/dist/c-G53AVC42.min.js +113 -0
- package/dist/c-GHN6IR4Y.min.js +1 -0
- package/dist/c-GSCO3FWL.min.js +1 -0
- package/dist/c-GYLOSK7M.min.js +1 -0
- package/dist/c-HK4OSLZA.min.js +1 -0
- package/dist/c-HLGTD5SJ.min.js +1 -0
- package/dist/c-HQ27AHMC.min.js +1 -0
- package/dist/{c-D6HAAPTX.min.js → c-IBRLFKWA.min.js} +1 -1
- package/dist/c-IHWZ2C6D.min.js +26 -0
- package/dist/c-IIV73MUW.min.js +1 -0
- package/dist/c-IPYGNVN6.min.js +116 -0
- package/dist/c-JJKRER47.min.js +1 -0
- package/dist/c-JO6AYCU4.min.js +1 -0
- package/dist/c-JWHPG6S2.min.js +1 -0
- package/dist/c-JXVYIXTV.min.js +1 -0
- package/dist/c-K2ZIYDI3.min.js +1 -0
- package/dist/c-K37JAIWA.min.js +4 -0
- package/dist/c-KGROWFT2.min.js +9 -0
- package/dist/c-MOP2NGLH.min.js +1 -0
- package/dist/c-MTX2AO5S.min.js +1 -0
- package/dist/c-N5WT7TXG.min.js +1 -0
- package/dist/c-NATWERHZ.min.js +1 -0
- package/dist/{c-42PLDTX7.min.js → c-O53GOO7H.min.js} +1 -1
- package/dist/c-OVQB75PE.min.js +1 -0
- package/dist/c-P3SKRNZN.min.js +1 -0
- package/dist/c-P5NXQWIM.min.js +1 -0
- package/dist/c-P7BQMVQQ.min.js +1 -0
- package/dist/{c-GNTXRXRN.min.js → c-PDQHLOKU.min.js} +1 -1
- package/dist/c-PKY4JFY5.min.js +1 -0
- package/dist/c-PQOZPM4G.min.js +1 -0
- package/dist/c-PZ3NEGNG.min.js +1 -0
- package/dist/c-QXLDCATV.min.js +1 -0
- package/dist/c-R2HUSWKB.min.js +1 -0
- package/dist/{c-HYW2XA4Q.min.js → c-RHDOOQ4X.min.js} +1 -1
- package/dist/c-RZPP5ERV.min.js +1 -0
- package/dist/c-SG2Y7EBY.min.js +46 -0
- package/dist/{c-WUWXGQYA.min.js → c-SJIB5RNI.min.js} +1 -1
- package/dist/c-SQNEVNWT.min.js +1 -0
- package/dist/c-STHZWF3D.min.js +1 -0
- package/dist/c-TIDKVMMZ.min.js +1 -0
- package/dist/c-TIMGODBG.min.js +1 -0
- package/dist/c-TR7OHUAO.min.js +2 -0
- package/dist/c-TTKWXGAI.min.js +61 -0
- package/dist/c-TVKZC4BY.min.js +1 -0
- package/dist/c-U5XVLSHN.min.js +1 -0
- package/dist/c-U6NLVFN4.min.js +1 -0
- package/dist/{c-VJTDST2R.min.js → c-UBHICVSC.min.js} +1 -1
- package/dist/c-UOPPO26M.min.js +1 -0
- package/dist/c-UUDAON4Z.min.js +1 -0
- package/dist/c-V32TPPY2.min.js +1 -0
- package/dist/c-V5KFJWQQ.min.js +1 -0
- package/dist/{c-P65V6HLO.min.js → c-VN557BQE.min.js} +1 -1
- package/dist/c-VXIYF7V2.min.js +1 -0
- package/dist/c-Y342FJ6K.min.js +1 -0
- package/dist/c-YM6CT4LJ.min.js +1 -0
- package/dist/{c-MVR3RWF3.min.js → c-YMFUIO54.min.js} +1 -1
- package/dist/c-YQVOKPKR.min.js +1 -0
- package/dist/c-YRJ3BJQZ.min.js +1 -0
- package/dist/c-YT5KPVNP.min.js +1 -0
- package/dist/components/ai/audienceProfile.d.ts +18 -1
- package/dist/components/ai/describeChart.d.ts +5 -1
- package/dist/components/ai/intentManifest.d.ts +16 -0
- package/dist/components/ai/intentRegistry.d.ts +12 -0
- package/dist/components/ai/intents.d.ts +6 -6
- package/dist/components/ai/streamSchema.d.ts +19 -0
- package/dist/components/ai/streamingTypes.d.ts +57 -11
- package/dist/components/ai/suggestCharts.d.ts +1 -1
- package/dist/components/ai/suggestStreamCharts.d.ts +43 -8
- package/dist/components/ai/suggestStreamDashboard.d.ts +35 -0
- package/dist/components/ai/variantDiscovery.d.ts +1 -1
- package/dist/components/charts/ordinal/BarChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/ordinal/PieChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeAccumulator.d.ts +14 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +6 -5
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -1
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -161
- package/dist/components/charts/realtime/RealtimeLineChart.types.d.ts +175 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +6 -5
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +6 -5
- package/dist/components/charts/realtime/aggregate.d.ts +11 -1
- package/dist/components/charts/realtime/resolveWindowSize.d.ts +1 -1
- package/dist/components/charts/shared/DirectLabelLayer.d.ts +25 -0
- package/dist/components/charts/shared/chartDataProps.d.ts +3 -0
- package/dist/components/charts/shared/chartSpecAtlasSchemas.d.ts +5 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecsAtlas.d.ts +2 -0
- package/dist/components/charts/shared/directLabels.d.ts +12 -0
- package/dist/components/charts/shared/hooks.d.ts +3 -1
- package/dist/components/charts/shared/knownChartComponents.d.ts +5 -2
- package/dist/components/charts/shared/lineSeriesSsr.d.ts +0 -12
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
- package/dist/components/charts/value/BigNumber.streamCapability.d.ts +2 -0
- package/dist/components/charts/value/GaugeChart.streamCapability.d.ts +2 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -1
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -1
- package/dist/components/charts/xy/LineChart.d.ts +4 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +7 -0
- package/dist/components/realtime/HyperLogLog.d.ts +19 -0
- package/dist/components/realtime/ReorderBuffer.d.ts +2 -2
- package/dist/components/realtime/TDigest.d.ts +22 -0
- package/dist/components/realtime/WindowAccumulator.d.ts +22 -5
- package/dist/components/realtime/applyChangelog.d.ts +38 -0
- package/dist/components/realtime/minHeap.d.ts +3 -0
- package/dist/components/recipes/atlas/DependencyForestChart.d.ts +20 -0
- package/dist/components/recipes/atlas/DependencyMatrix.d.ts +7 -0
- package/dist/components/recipes/atlas/FlowCircuitChart.d.ts +20 -0
- package/dist/components/recipes/atlas/MotifBraidChart.d.ts +17 -0
- package/dist/components/recipes/atlas/atlasChartOptions.d.ts +11 -0
- package/dist/components/recipes/atlas/braid.d.ts +62 -0
- package/dist/components/recipes/atlas/capsules.d.ts +18 -0
- package/dist/components/recipes/atlas/compare.d.ts +4 -0
- package/dist/components/recipes/atlas/completeness.d.ts +2 -0
- package/dist/components/recipes/atlas/dependencyForest.d.ts +32 -0
- package/dist/components/recipes/atlas/dependencyForestChartProps.d.ts +58 -0
- package/dist/components/recipes/atlas/dependencyForestLayout.d.ts +17 -0
- package/dist/components/recipes/atlas/dependencyQueries.d.ts +20 -0
- package/dist/components/recipes/atlas/dependencyTypes.d.ts +21 -0
- package/dist/components/recipes/atlas/directedGraph.d.ts +9 -0
- package/dist/components/recipes/atlas/entityCounts.d.ts +3 -0
- package/dist/components/recipes/atlas/flowCircuit.d.ts +32 -0
- package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +72 -0
- package/dist/components/recipes/atlas/flowCircuitChrome.d.ts +18 -0
- package/dist/components/recipes/atlas/flowCircuitGeometry.d.ts +11 -0
- package/dist/components/recipes/atlas/flowCircuitLayout.d.ts +20 -0
- package/dist/components/recipes/atlas/flowCircuitSemantics.d.ts +26 -0
- package/dist/components/recipes/atlas/flowCircuitTape.d.ts +22 -0
- package/dist/components/recipes/atlas/flowCircuitTypes.d.ts +144 -0
- package/dist/components/recipes/atlas/forests.d.ts +11 -0
- package/dist/components/recipes/atlas/ids.d.ts +6 -0
- package/dist/components/recipes/atlas/index.d.ts +26 -0
- package/dist/components/recipes/atlas/ledger.d.ts +7 -0
- package/dist/components/recipes/atlas/motifBraidChartProps.d.ts +51 -0
- package/dist/components/recipes/atlas/motifBraidGeometry.d.ts +5 -0
- package/dist/components/recipes/atlas/motifBraidLayout.d.ts +11 -0
- package/dist/components/recipes/atlas/motifs.d.ts +3 -0
- package/dist/components/recipes/atlas/prefixForest.d.ts +9 -0
- package/dist/components/recipes/atlas/prepare.d.ts +14 -0
- package/dist/components/recipes/atlas/prepareAsync.d.ts +7 -0
- package/dist/components/recipes/atlas/profile.d.ts +19 -0
- package/dist/components/recipes/atlas/publish.d.ts +10 -0
- package/dist/components/recipes/atlas/queries.d.ts +34 -0
- package/dist/components/recipes/atlas/requiredPaths.d.ts +9 -0
- package/dist/components/recipes/atlas/rootedForest.d.ts +4 -0
- package/dist/components/recipes/atlas/sections.d.ts +3 -0
- package/dist/components/recipes/atlas/support.d.ts +7 -0
- package/dist/components/recipes/atlas/types.d.ts +278 -0
- package/dist/components/recipes/atlas/validate.d.ts +12 -0
- package/dist/components/recipes/layout1d.d.ts +2 -20
- package/dist/components/recipes/minGapPlacement.d.ts +20 -0
- package/dist/components/semiotic-ai-core.d.ts +8 -3
- package/dist/components/semiotic-ai-stream.d.ts +10 -0
- package/dist/components/semiotic-ai.d.ts +4 -6
- package/dist/components/semiotic-atlas-core.d.ts +20 -0
- package/dist/components/semiotic-atlas.d.ts +8 -0
- package/dist/components/semiotic-realtime-core.d.ts +6 -2
- package/dist/components/semiotic-recipes-core.d.ts +9 -0
- package/dist/components/semiotic-stream-types.d.ts +14 -0
- package/dist/components/semiotic-xy.d.ts +1 -0
- package/dist/components/semiotic.d.ts +3 -11
- package/dist/components/server/encodeSvgFramesToGif.d.ts +2 -0
- package/dist/components/server/rasterizeSVG.d.ts +2 -0
- package/dist/components/server/registerServerXYPlugins.d.ts +2 -0
- package/dist/components/server/renderEvidence.d.ts +4 -0
- package/dist/components/server/serverChartConfigs.d.ts +8 -0
- package/dist/components/server/serverChartConfigsAtlas.d.ts +4 -0
- package/dist/components/server/serverChartConfigsRealtime.d.ts +6 -0
- package/dist/components/server/serverRealtimeCategoryColors.d.ts +3 -0
- package/dist/components/server/staticAnnotations.d.ts +9 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +1 -0
- package/dist/components/stream/SceneGraph.d.ts +3 -3
- package/dist/components/stream/StalenessBadge.d.ts +5 -2
- package/dist/components/stream/canvasSetup.d.ts +1 -2
- package/dist/components/stream/fontLoading.d.ts +4 -0
- package/dist/components/stream/networkCustomLayout.d.ts +8 -0
- package/dist/components/stream/networkCustomLayoutCache.d.ts +12 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +0 -7
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +2 -0
- package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +3 -1
- package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +2 -0
- package/dist/components/stream/pipelinePathJoin.d.ts +27 -0
- package/dist/components/stream/pipelineTransitionTypes.d.ts +43 -0
- package/dist/components/stream/pipelineTransitions.d.ts +5 -35
- package/dist/components/stream/seriesGeometry.d.ts +2 -1
- package/dist/components/stream/shallowEqual.d.ts +2 -0
- package/dist/components/stream/streamEncodingTypes.d.ts +9 -0
- package/dist/components/stream/types.d.ts +25 -2
- package/dist/components/stream/useEnsureCustomXYRenderers.d.ts +4 -2
- package/dist/components/text/axisLabelAssessment.d.ts +15 -0
- package/dist/components/text/browserAxisLabelAssessment.d.ts +1 -0
- package/dist/components/text/browserLabelMeasurement.d.ts +3 -0
- package/dist/components/text/labelMeasurement.d.ts +19 -0
- package/dist/components/text/labelPlacement.d.ts +71 -0
- package/dist/components/text/useAxisLabelAssessment.d.ts +6 -0
- package/dist/components/text/useLabelMeasurer.d.ts +3 -0
- package/dist/controls.module.min.js +71 -1
- package/dist/geo.min.js +231 -1
- package/dist/geo.module.min.js +31 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics-matter.module.min.js +1 -1
- package/dist/physics-rapier.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/rough.min.js +2 -1
- package/dist/rough.module.min.js +2 -1
- package/dist/semiotic-access.module.min.js +1 -1
- package/dist/semiotic-ai-artifact-policy-constants.module.min.js +1 -1
- package/dist/semiotic-ai-core.d.ts +8 -3
- package/dist/semiotic-ai-core.min.js +4 -1
- package/dist/semiotic-ai-core.module.min.js +4 -1
- package/dist/semiotic-ai-hash-primitives.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +4 -6
- package/dist/semiotic-ai.module.min.js +14 -1
- package/dist/semiotic-artifact-react.min.js +269 -1
- package/dist/semiotic-artifact-react.module.min.js +137 -1
- package/dist/semiotic-artifact.min.js +3 -1
- package/dist/semiotic-artifact.module.min.js +3 -1
- package/dist/semiotic-atlas-core.d.ts +20 -0
- package/dist/semiotic-atlas-core.min.js +2 -0
- package/dist/semiotic-atlas-core.module.min.js +1 -0
- package/dist/semiotic-atlas-selection.module.min.js +2 -0
- package/dist/semiotic-atlas.d.ts +8 -0
- package/dist/semiotic-atlas.min.js +2 -0
- package/dist/semiotic-atlas.module.min.js +12 -0
- package/dist/semiotic-client-cjs-shared.min.js +1529 -1
- package/dist/semiotic-client-glyph.module.min.js +3 -1
- package/dist/semiotic-client-responsive.module.min.js +1 -1
- package/dist/semiotic-client-shared.module.min.js +1 -1
- package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -1
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-evidence.min.js +3 -1
- package/dist/semiotic-evidence.module.min.js +3 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +8 -1
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +8 -1
- package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.min.js +1 -1
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-realtime-core.d.ts +6 -2
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +160 -1
- package/dist/semiotic-recipes-core.d.ts +9 -0
- package/dist/semiotic-recipes-core.module.min.js +72 -1
- package/dist/semiotic-recipes-geo-cjs.min.js +1 -1
- package/dist/semiotic-recipes-react.min.js +3 -1
- package/dist/semiotic-server-edge-node.module.min.js +391 -1
- package/dist/semiotic-server-edge.min.js +651 -1
- package/dist/semiotic-server-edge.module.min.js +372 -1
- package/dist/semiotic-server-node.min.js +651 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-text.min.js +1 -1
- package/dist/semiotic-text.module.min.js +1 -1
- package/dist/semiotic-themes-core.min.js +1 -1
- package/dist/semiotic-themes-core.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +11 -1
- package/dist/semiotic-utils-core.module.min.js +8 -1
- package/dist/semiotic-value.module.min.js +15 -1
- package/dist/semiotic-xy.d.ts +1 -0
- package/dist/semiotic.d.ts +3 -11
- package/dist/semiotic.module.min.js +10 -1
- package/dist/server.min.js +651 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +19 -3
- package/dist/c-2N7IU2NY.min.js +0 -1
- package/dist/c-2WK7YJLL.min.js +0 -1
- package/dist/c-33QOXEUG.min.js +0 -1
- package/dist/c-447VIMRO.min.js +0 -1
- package/dist/c-4FN7Q6VQ.min.js +0 -1
- package/dist/c-553QUDKA.min.js +0 -1
- package/dist/c-55BAJ333.min.js +0 -1
- package/dist/c-7242NXSG.min.js +0 -1
- package/dist/c-7EGHJU2F.min.js +0 -1
- package/dist/c-7HP7MB2I.min.js +0 -1
- package/dist/c-7NBU5ZKS.min.js +0 -1
- package/dist/c-AFBSWT77.min.js +0 -1
- package/dist/c-AJ7EC32V.min.js +0 -1
- package/dist/c-AQADQNY7.min.js +0 -1
- package/dist/c-ATM475SA.min.js +0 -1
- package/dist/c-AVO3Q7T7.min.js +0 -1
- package/dist/c-AZKPVBOC.min.js +0 -1
- package/dist/c-BNFJMDHN.min.js +0 -1
- package/dist/c-BNG5ECK5.min.js +0 -1
- package/dist/c-BOHCQILI.min.js +0 -1
- package/dist/c-CCTGN5CK.min.js +0 -1
- package/dist/c-CPSPZH6A.min.js +0 -1
- package/dist/c-CPV4N35K.min.js +0 -1
- package/dist/c-DE5Q3U2X.min.js +0 -1
- package/dist/c-DK662R77.min.js +0 -1
- package/dist/c-DY2676CR.min.js +0 -1
- package/dist/c-E32M6XW5.min.js +0 -1
- package/dist/c-E4JDJH4I.min.js +0 -1
- package/dist/c-E7I2L7CU.min.js +0 -1
- package/dist/c-EBOQ7ER7.min.js +0 -1
- package/dist/c-ELDWAO2V.min.js +0 -1
- package/dist/c-EUBTECGM.min.js +0 -1
- package/dist/c-GSZRZRD6.min.js +0 -1
- package/dist/c-GWX7JGMF.min.js +0 -1
- package/dist/c-GXV3C3MO.min.js +0 -1
- package/dist/c-HHTK2R75.min.js +0 -1
- package/dist/c-HLLFJYTY.min.js +0 -1
- package/dist/c-HPOYKCCG.min.js +0 -1
- package/dist/c-HXDKPIKR.min.js +0 -1
- package/dist/c-I4QJ6YLM.min.js +0 -1
- package/dist/c-IDJV3CZK.min.js +0 -1
- package/dist/c-ITKX3RC5.min.js +0 -1
- package/dist/c-JG2JCQLP.min.js +0 -1
- package/dist/c-JLGRHXGZ.min.js +0 -1
- package/dist/c-JUKIWTBJ.min.js +0 -1
- package/dist/c-KCRJGUHP.min.js +0 -1
- package/dist/c-LMGSSD2E.min.js +0 -1
- package/dist/c-LYQMZMZQ.min.js +0 -1
- package/dist/c-LYVKDBQJ.min.js +0 -1
- package/dist/c-MXCP7GNZ.min.js +0 -1
- package/dist/c-NG7BLZTR.min.js +0 -1
- package/dist/c-NYZ2QNAM.min.js +0 -1
- package/dist/c-OO5QLMJC.min.js +0 -1
- package/dist/c-OOVX2JPQ.min.js +0 -1
- package/dist/c-PP6VY3QU.min.js +0 -1
- package/dist/c-PRIKOLTE.min.js +0 -1
- package/dist/c-PSNI6KAZ.min.js +0 -1
- package/dist/c-PYNW54D2.min.js +0 -1
- package/dist/c-QAVFOEUY.min.js +0 -1
- package/dist/c-ROEHCIGV.min.js +0 -1
- package/dist/c-S3AZX5PP.min.js +0 -1
- package/dist/c-T2V7O2LO.min.js +0 -1
- package/dist/c-TIXX5CAU.min.js +0 -1
- package/dist/c-TKG2NP7G.min.js +0 -1
- package/dist/c-VXLOLYTO.min.js +0 -1
- package/dist/c-W4ZUKSEQ.min.js +0 -1
- package/dist/c-WH2O53VI.min.js +0 -1
- package/dist/c-WNGH47HF.min.js +0 -1
- package/dist/c-XDQKXPX4.min.js +0 -1
- package/dist/c-XSB27XPS.min.js +0 -1
- package/dist/c-YDECTEUW.min.js +0 -1
- package/dist/c-YF3YKVQI.min.js +0 -1
- package/dist/c-YLZIV3VS.min.js +0 -1
- package/dist/c-ZYPXQF7B.min.js +0 -1
|
@@ -1 +1,372 @@
|
|
|
1
|
-
function e(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function t(e){let t=6;for(let i=1;e.length>i;i++){let r=Math.abs(e[i]-e[i-1]);r>0&&Number.isFinite(r)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/r))+1))}let i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function i(...e){let t;for(let i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function a(e){return"string"==typeof e&&e.length>0}function n(e,t,i=!1){let r=i?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}function l(e,t){return n(e,a(t))}function s(e,t,i,r,o=8){let a=r,n="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",l=Math.max(t[a],Math.max(0,("left"===r||"right"===r?i[0]:i[1])-o)-e[n]);e[a]>l&&(e[a]=l)}function c(e){return Math.ceil(7*e.length)}function u(e,i){if(r(e)){let t=v(i),r=100;for(let i of e.legendGroups){i.label&&(r=Math.max(r,c(i.label)));for(let e of i.items)r=Math.max(r,t.swatchSize+t.labelGap+c(e.label))}return r}if(o(e)){let{gradient:i}=e,r=i.format||t(i.domain),o=Math.max(c(r(i.domain[0])),c(r(i.domain[1]))),a=i.label?c(i.label):0;return Math.max(100,19+o,a)}return 100}function d(e){return(r(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?sd:ld:0}function f(e){return Math.max(0,e?.edgeGutter??3)}function p(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function y(t){let{bottomAxis:i,topAxis:r,leftAxis:o,rightAxis:a}=e(t.axes),n=!(r&&!i||!1===i?.visible),l=!!r&&!i&&!1!==r.visible,s=!(a&&!o||!1===o?.visible),c=!!a&&!1!==a.visible,u=!1!==t.showAxes;return{hasAxis:u&&n,hasAxisLabel:u&&n&&!!(i?.label??t.xLabel),rotatedTicks:u&&n&&(t.rotatedTicks??!!i?.autoRotate),topAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!r?.autoRotate)}:void 0,leftAxis:s?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(a?.label??t.yLabelRight??t.yLabel)}:void 0}}function g(e,t,i){if(o(e))return e.gradient.label?46:26;if(!r(e))return 20;let a=v(i),n=Math.max(1,i?.maxWidth??t),l=a.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let r of t.items){let t=a.swatchSize+a.labelGap+c(r.label),o=0===i?t:i+a.itemGap+t;i>0&&o>n?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),l=Math.max(l,e*a.rowHeight,t.label?c(t.label):0)}return l+(e.legendGroups.length>1?16:0)}function m(e,t,i){return u(e,t)+d(e)+h(t,i)+f(t)}function x(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=g(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+p("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),a=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,a,m(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,a,m(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,a,o):e.bottom=Math.max(e.bottom,a,o)}function b(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),a=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??u(e,t.legendLayout)),n=d(e),l=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),s=f(t.legendLayout),c=g(e,o,t.legendLayout),y=p(t.axisChrome,t.legendLayout),m=p(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(s,t.margin.left-l-a-n),y:t.margin.top,width:a,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-m-n-c,width:a,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+n,Math.min(e+y+n,t.totalHeight-c)),width:a,height:c}}return{x:Math.min(t.totalWidth-a-s,t.totalWidth-t.margin.right+l+n),y:t.margin.top,width:a,height:c}}function v(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function w(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,a=i;i+=8,e&&(i+=16,o=i,i+=8);let n=i;return i+=r*t+8,{lineY:a,labelY:o,itemsY:n,endY:i}})}function k(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}function A(e){let t=0;for(;e.length>t;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(0>i)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;e.length>o;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(cd,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function S(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function M(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function _(e,t){for(let i of e.attributes.matchAll(cd))if(i[1]===t)return M(i[2]??i[3])}function P(e,t){let i=A(e);if(!i)return t;let r=e=>{let r=_(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function L(e,t){let i=A(e);return i?function(e,t){let i=A(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(cd,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${S(i)}"`)});for(let[e,t]of r)o+=` ${e}="${S(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}(e,{width:"100%",height:"100%",...void 0===_(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===_(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function $(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function T(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,a=!!i||void 0!==r,n=e&&"object"==typeof e?e:void 0;if(!1===e||!1===n?.enabled||void 0===e&&!o&&!a)return ud;let l=n??{};return{enabled:!0,tapToSelect:l.tapToSelect??!0,tapToLockTooltip:l.tapToLockTooltip??!0,clearSelection:l.clearSelection??"backgroundTap",targetSize:l.targetSize??r??44,snap:l.snap??"nearestDatum",brushHandleSize:l.brushHandleSize??44,standardControls:l.standardControls??!1}}function R(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function C(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function I(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[o+""]}function D(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function z(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=function(e){return function(e){return yd.has(e)}(e)?function(e){return yd.get(e)}(e):"BumpChart"===e?hd:void 0}(t);if(o){try{let t="function"==typeof o?o(i,e):function(e){let t=new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(I(e.yAccessor,"y",i,r))))return;let o=C(I(e.xAccessor,"x",i,r)),a=t.get(o)??new Set;a.add(I(e.lineBy,"series",i,r)+""),t.set(o,a)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},a=2>o.max;return a||2>o.contestedColumns||2>o.median?[{code:a?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:a?"error":"warning",message:a?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}(i);r=Array.from(t).filter(D)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function O(e,t,i){let r="function"==typeof t?t(e):e[(t??i)+""];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function F(e){if(!e)return xd;let t=!1;for(let i=0;e.length>i;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function N(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function E(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function W(e){let t=e.map(N),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){let[e,i,r]=t[0];return E(e,i,r)}if(e>=1){let[e,r,o]=t[i];return E(e,r,o)}let r=e*i,o=Math.floor(r),a=r-o,[n,l,s]=t[o],[c,u,d]=t[o+1];return E(Math.round(n+(c-n)*a),Math.round(l+(u-l)*a),Math.round(s+(d-s)*a))}}function j(e){return e&&Object.prototype.hasOwnProperty.call(Id,e)?Id[e]:wd}function B(e,t,i=Bd){if(e&&"object"==typeof e&&!Array.isArray(e)){let 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){let t=Object.prototype.hasOwnProperty.call(jd,e)?jd[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Y(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!function(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Vd.has(t)}(r)?i(r):r}let r=e?.[t]+"";return i?i(r):Bd[Math.abs(function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}(r))%Bd.length]}function X(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function G(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>X(e,t)??"#999"}let r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return bd().domain(r).range(i).unknown("#999");let a=Object.prototype.hasOwnProperty.call(jd,i)?jd[i]:jd.category10;if(o&&"function"==typeof a){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>a(0===e?0:Number(t)/e)}{let e=Array.isArray(a)?a:Bd;return bd().domain(r).range(e).unknown("#999")}}function V(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[a,n]=r,[l,s]=i;if(n===a)return(l+s)/2;let c=(o-a)/(n-a);return 0>c?c=0:c>1&&(c=1),l+c*(s-l)}function H(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function q(e,t){if(!H(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function U(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:a,fillArea:n,areaOpacity:l=.3,styleRules:s,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},f=!0===n||Array.isArray(n)&&null!=u&&n.includes(u);return a?d=a(e,u):i?r&&(d=Y(e,i,r)):d=o||Yd,void 0!==d&&(h.stroke=d,f&&(h.fill=d,h.fillOpacity=l)),s?.length&&Object.assign(h,fu(e,s,c?c(e,u):{value:void 0,category:u})),h}}function Z(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function K(e,t){return cu(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Z(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Q(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return K(e=>({fill:"A"===Z(e)?t:i,stroke:"none",fillOpacity:r}),o)}function J(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return K(e=>({stroke:"A"===Z(e)?t:i,strokeWidth:r,fill:"none"}),o)}function ee(e,t=Hd){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function te(e){return e?ee(e):void 0}function ie(e,t,i){return"function"==typeof e?e(i):i[e||t]}function re(e){return e instanceof Date?e.getTime():Number(e)}function oe(e,t){return Pd(1===t?.5:e/(t-1))}function ae(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function ne(e,t){let i=function(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function le(e){if(!e)return ou;if("string"==typeof e)return"light"===e?ou:"dark"===e?iu:"high-contrast"===e?ru:nu(e)||ou;let t="dark"===e.mode?iu:ou,i={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return au(i)}function se(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,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function ce(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function ue(e){return Math.round(100*e)/100}function de(e,t=2){let i=[],r=[],o=t+1;for(let t=0;o>t;t++){let a=0;for(let[i,r]of e)null!==r&&(a+=i**t*r);i.push(a);let n=[];for(let i=0;o>i;i++){let r=0;for(let[o,a]of e)null!==a&&(r+=o**(t+i));n.push(r)}r.push(n)}r.push(i);let a=function(e,t){let i=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;r+1>o;o++){let r=i[o][e];i[o][e]=i[o][t],i[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let a=e+1;r>a;a++)t+=i[a][e]*o[a];o[e]=(i[r][e]-t)/i[e][e]}return o}(r,o).map(ue);return{points:e.map(([e])=>[ue(e),ue(a.reduce((t,i,r)=>t+i*e**r,0))]),equation:[...a].reverse()}}function he(e){let t=e.length,i=0,r=0,o=0,a=0;for(let[t,n]of e)i+=t,r+=n,o+=t*t,a+=t*n;let n=t*o-i*i;if(1e-12>Math.abs(n))return null;let l=(t*a-i*r)/n,s=(r-l*i)/t;return e=>s+l*e}function fe(e,t){let i=e.length,r=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(i-2,1)),a=e.reduce((e,t)=>e+t[0],0)/i,n=e.reduce((e,t)=>e+(t[0]-a)**2,0);return{se:o,meanX:a,ssX:n}}function pe(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function ye(e,t,i,r){let o=t.uncertaintyOpacity,a=t.confidenceAccessor;if(!o&&!a)return;let n="object"==typeof o?o:{},l=n.min??.15,s=n.max??1;if(a){let t="function"==typeof a?a:e=>e[a];for(let i of e){let e=t(i);null!=e&&Number.isFinite(e)&&(i[Ud]=l+Math.max(0,Math.min(1,e))*(s-l))}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=nd(u),f=h-d;e.forEach((e,t)=>{let i=c[t];Number.isFinite(i)&&(e[Ud]=s-(f>0?(i-d)/f:0)*(s-l))})}function ge(e,t){return"function"==typeof t?t(e):!!e[t]}function me(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function xe(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,a=Array.isArray(e.data)?F(e.data).filter(e=>!!e&&"object"==typeof e):[],n=function(e,t,i){let r="function"==typeof t,o="function"==typeof i,a=r?Zd:t,n=o?Kd:i;return r||o?{xKey:a,yKey:n,rows:e.map(e=>{let a={...e};return r&&(a[Zd]=t(e)),o&&(a[Kd]=i(e)),a})}:{rows:e,xKey:a,yKey:n}}(a,t,i);a=n.rows;let l,s=n.xKey,c=n.yKey,u=Array.isArray(e.annotations)?[...e.annotations]:[],d="string"==typeof r||"function"==typeof r?r:void 0,h=e.baseLineStyle;if(e.forecast){let t=function(e,t,i,r,o){return(a=r).isTraining||a.isForecast||a.isAnomaly||a.upperBounds||a.lowerBounds?function(e,t,i,r,o){let{isTraining:a,isForecast:n,isAnomaly:l,upperBounds:s,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=r,y=e.map(e=>{let t="observed";return n&&ge(e,n)?t="forecast":a&&ge(e,a)&&(t="training"),{...e,[qd]:t}}),g=r._groupBy,m=[];if(g){let e=new Map;for(let t of y){let i=t[g]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}let t=[];for(let[,i]of e)for(let e=0;i.length-1>e;e++)i[e][qd]!==i[e+1][qd]&&(t.push({...i[e+1],[qd]:i[e][qd]}),t.push({...i[e],[qd]:i[e+1][qd]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][qd]!==y[e+1][qd]&&(m.push({...y[e+1],[qd]:y[e][qd]}),m.push({...y[e],[qd]:y[e+1][qd]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[qd]&&e.push({...t,[qd]:"training-base"});m.unshift(...e)}let x=[];if(s&&c){let e="string"==typeof s?s:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof s||"function"==typeof c)for(let i of m)"function"==typeof s&&(i[e]=s(i)),"function"==typeof c&&(i[t]=c(i));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=s?"function"==typeof s?s:e=>e[s]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};ye(m.filter(e=>"forecast"===e[qd]),r,e,t)}if(l){let e=r.anomalyStyle,t={type:"highlight",filter:e=>ge(e,l)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return o&&x.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label}),{processedData:m,annotations:x}}(e,0,0,r,o):function(e,t,i,r,o){let{trainEnd:a,steps:n=10,confidence:l=.95,color:s="#6366f1",bandOpacity:c=.15,label:u}=r;if(null==a)return{processedData:e,annotations:[]};let d=[],h=[];for(let i of e)i[t]>a?h.push({...i,[qd]:"observed"}):d.push({...i,[qd]:"training"});let f=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),p=[],y=[];if(f.length>=3){let o=f.length,a=he(f);if(a){let{se:d,meanX:h,ssX:g}=fe(f,a),m=pe(l),x=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),b=od(x),v=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;n>=e;e++){let r=b+e*v,n=a(r),l=d*Math.sqrt(1+1/o+(g>0?(r-h)**2/g:0))*m;y.push({[t]:r,[i]:n,[qd]:"forecast",__forecastUpper:n+l,__forecastLower:n-l})}ye(y,r,e=>e.__forecastUpper,e=>e.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:s,fillOpacity:c,label:u})}}p.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&p.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label});let g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[qd]:"observed"}),g.push(...h),y.length>0){let e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[qd]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(e,t,i,r,o);var a}(a,s,c,r&&"string"==typeof r&&"object"==typeof e.forecast?{...e.forecast,_groupBy:r}:e.forecast,e.anomaly);if(a=t.processedData,u.push(...t.annotations),l=function(e,t,i){let r=i.upperBounds,o=i.lowerBounds;if(!r&&!o)return;let a="function"==typeof r?r:"string"==typeof r?e=>e[r]:null,n="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,l=1/0,s=-1/0;for(let i of e){let e=Number(i[t]);if(Number.isFinite(e)&&(l>e&&(l=e),e>s&&(s=e)),a){let e=a(i);null!=e&&Number.isFinite(e)&&(e>s&&(s=e),l>e&&(l=e))}if(n){let e=n(i);null!=e&&Number.isFinite(e)&&(l>e&&(l=e),e>s&&(s=e))}}return Number.isFinite(l)&&Number.isFinite(s)?[l,s]:void 0}(a,c,e.forecast),r&&"string"==typeof r?(a=a.map(e=>({...e,[Qd]:`${e[r]}__${e[qd]||"observed"}`})),d=Qd):d=qd,e.baseLineStyle){let t=function(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",a=t.trainOpacity,n=t.forecastOpacity,l=t.trainStroke,s=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[qd];if("training"===d){let e=u.stroke;return"darken"===l?e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),a=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):l&&(e=l),{...u,stroke:e,strokeDasharray:i,...s&&{strokeLinecap:s},...null!=a&&{strokeOpacity:a}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),a=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[Ud]??n;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&u.push(...(f=e.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(e.gapStrategy){if("function"==typeof d){let e=d;a=a.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}let t=function(e,t,i,r,o){let a=new Map;for(let t of e){let e=o?(t[o]??"")+"":"__single";a.has(e)||a.set(e,[]),a.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of a)for(let o of t)me(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of a)for(let o of t)me(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let n=[],l="_gapSegment";for(let[e,t]of a){let o=0,a=[],s=()=>{if(0===a.length)return;let t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(let e of a)n.push({...e,[l]:t});a=[],o++};for(let e of t)me(e,i,r)?s():a.push(e);s()}return{rows:n,groupKey:l}}(a,e.gapStrategy,s,c,"string"==typeof d?d:void 0);a=t.rows,t.groupKey&&(d=t.groupKey)}let p;if(e.directLabel){let t=function(e,t,i,r,o,a,n,l){if(!t||!i)return{annotations:[]};let s="object"==typeof t?t:{},c=s.position||"end",u=s.fontSize||11,d="function"==typeof i?i:e=>e[i],h=new Map;for(let t of e){let e=d(t);if(null==e)continue;let i=e+"";""!==i&&(h.has(i)||h.set(i,[]),h.get(i).push(t))}let f=new Map;for(let[e,t]of h)t.sort((e,t)=>Number(e[r])-Number(t[r])),f.set(e,"end"===c?t[t.length-1]:t[0]);let p=G(Array.from(f.entries()).map(([e])=>({__lbl:e})),"__lbl",a??n),y=Array.from(f.entries()).map(([e,t])=>({type:"text",label:e,[r]:t[r],[o]:t[o],dx:"end"===c?6:-6,dy:0,color:p?Y({__lbl:e},"__lbl",p):l||Yd,fontSize:u}));y.sort((e,t)=>Number(e[o])-Number(t[o]));for(let e=1;y.length>e;e++){let t=y[e-1],i=y[e],r=Number(t[o])+t.dy;u+2>Math.abs(Number(i[o])+i.dy-r)&&(i.dy+=u+2)}let g=y.reduce((e,t)=>Math.max(e,(t.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===c?{right:g}:{left:g}}}(a,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,s,c,e.colorScheme,e.themeCategorical,e.color);u.push(...t.annotations),p=t.marginExtra}return{data:a,xAccessor:"function"==typeof t?s:t,yAccessor:"function"==typeof i?c:i,groupAccessor:d,colorAccessor:o,annotations:u,lineStyle:h,yExtent:l,marginExtra:p}}function be(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=le(r.theme).colors.categorical,l=i??r.colorScheme??n,s="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrScatterColorBy:t(e)})):a,u=t?G(c,s,l):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],f=d?a.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?nd(f):void 0,y=hu(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?Y(e,t,u):"string"==typeof o.color?o.color:Yd,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?V(e,d,h,p):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,fu(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function ve(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=le(r.theme).colors.categorical,l=i??r.colorScheme??n,s="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrBubbleColorBy:t(e)})):a,u=t?G(c,s,l):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],f=d?a.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?nd(f):void 0,y=hu(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?Y(e,t,u):"string"==typeof o.color?o.color:Yd,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?V(e,d,h,p):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,fu(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function we(e,t){return t?.length&&Object.defineProperty(e,lh,{configurable:!0,enumerable:!1,value:t}),e}function ke(e){return e?.[lh]}function Ae(e){return e.parentLine?we({...e.parentLine,...e},ke(e)):e}function Se(e){return we({...e[0]},e.map(Ae))}function Me(e){return!!e&&ke(e)?.[0]===e}function _e(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=X(i,r);if(e)return e}let a;if(Array.isArray(i))a=i;else if(t&&t.length>0)a=t;else if("string"==typeof i){let e=jd[i];Array.isArray(e)&&(a=e)}return a&&0!==a.length?null!=r?(o.has(r)||o.set(r,o.size),a[o.get(r)%a.length]):a[0]:Yd}function Pe(e,t,i){return"function"==typeof e?e(t,i):t[e]}function Le(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[C(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(C(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function $e(e,t,i,r,o){let a=1-o;return a*a*a*e+3*a*a*o*t+3*a*o*o*i+o*o*o*r}function Te(e,t,i,r,o){let a=1-o;return 3*a*a*(t-e)+6*a*o*(i-t)+3*o*o*(r-i)}function Re(e,t,i,r,o){let a=[],n=(e.x+t.x)/2;for(let l=0;o>=l;l++){let s,c,u,d,h=l/o;"linear"===r?(s=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(s=$e(e.x,n,n,t.x,h),c=$e(e.y,e.y,t.y,t.y,h),u=Te(e.x,n,n,t.x,h),d=Te(e.y,e.y,t.y,t.y,h)),a.push({x:s,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:.5>h?i:i+1})}return a}function Ce(e,t={}){let i=[],r=[],o=[];if(2>e.length)return{topPath:i,bottomPath:r,datumIndices:o};let a=t.curve??"smooth",n=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){let l=Re(e[t],e[t+1],t,a,n);for(let e=0===t?0:1;l.length>e;e++){let t=l[e],a=Math.hypot(t.dx,t.dy)||1,n=-t.dy/a,s=t.dx/a,c=Math.max(0,t.radius);i.push([t.x+n*c,t.y+s*c]),r.push([t.x-n*c,t.y-s*c]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:r,datumIndices:o}}function Ie({datum:e,x:t,y:i,side:r,color:o,highlighted:a,labelStyle:n}){let l=id(),s=l.isActive&&!l.predicate(e),c="function"==typeof n?n(e.__bumpRaw):n;return sh("text",{className:"semiotic-bump-label",x:t+("end"===r?8:-8),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:s?.16:1,fontWeight:a?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...c},children:e.__bumpSeries})}function De(e,t,i){let[r,o]=t,[a,n]=i;return o===r?(a+n)/2:a+(n-a)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function ze(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function Oe(e){let t=e.config,i=new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],a=[],n=[];for(let a of r){let r=(i.get(a)??[]).sort((e,t)=>e.x-t.x);if(2>r.length)continue;let l=r[0].__bumpHighlighted,s=(t.colorMap&&X(t.colorMap,a))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(l?s:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??s),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?De(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Ce(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:l?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,fu(r[0].__bumpRaw,t.styleRules,ze(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:a+" ranking trajectory",tableFields:r.map(e=>e.__bumpRaw)},group:a,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:l?1:.75};t.styleRules?.length&&Object.assign(r,fu(e.__bumpRaw,t.styleRules,ze(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${a}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${a}:${e.x}`})});let f=!0===t.showLabels?"end":t.showLabels,p=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);n.push({id:`${a}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:l,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===f||"both"===f)&&p(r[0],0,"start"),("end"===f||"both"===f||"auto"===f)&&p(r.at(-1),r.length-1,"end")}let l=function(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),a="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,n=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),l=[];for(let{candidate:e}of n){if(l.length>=a)break;l.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||l.push(e)}return new Set(l.map(e=>e.id))}(n,e.dimensions.plot.height,"auto"!==(!0===t.showLabels?"end":t.showLabels)||"auto",t.maxLabels);for(let e of n)l.has(e.id)&&a.push(sh(Ie,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:a.length?sh("g",{className:"semiotic-bump-labels",children:a}):void 0,restyle:(e,t)=>{let i=function(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function Fe(e,t){let i=du(e),r=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:du(e.yAccessor)}));return(e,t)=>{let o=(e[dh]??t??"")+"",a=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:a,x:i(e),y:a,category:o||void 0}}}function Ne(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=le(r.theme).colors.categorical,l=i??r.colorScheme??n,s="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrAreaColorBy:t(e)})):a,u=t?G(c,s,l):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=du(o.yAccessor),y=o.styleRules;return(e,i)=>{let r=t&&u?Y(e,t,u):"string"==typeof o.color?o.color:Yd,a={fill:r,fillOpacity:f,stroke:d?r:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(a,fu(e,y,{value:p(e),category:i})),void 0!==o.stroke&&(a.stroke=o.stroke),void 0!==o.strokeWidth&&(a.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(a.opacity=o.opacity),a}}function Ee(e,t,i,r,o){if(!o.showPoints)return;let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=le(r.theme).colors.categorical,l=i??r.colorScheme??n,s="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrPointColorBy:t(e)})):a,u=t?G(c,s,l):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?Y(e,t,u):"string"==typeof o.color?o.color:Yd;return{r:d,fill:i,stroke:"none"}}}function We(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function je(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function Be(e){return Math.max(0,Math.min(1,e))}function Ye(e){let 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)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Xe(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function Ge(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Be(e.offset),color:e.color??i,opacity:null==e.opacity?1:Be(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=Ye(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let a=Be(t);if(r[0].offset>=a)return o(r[0]);if(a>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;r.length-1>e;e++){let t=r[e],i=r[e+1];if(t.offset>a||a>i.offset)continue;let n=i.offset-t.offset,l=n>0?(a-t.offset)/n:0,s=Ye(t.color),c=Ye(i.color);if(!s||!c)return o(.5>l?t:i);let[u,d,h]=s,[f,p,y]=c,g=u+(f-u)*l,m=d+(p-d)*l,x=h+(y-h)*l,b=t.opacity+(i.opacity-t.opacity)*l;return 1===b?Xe(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(r[r.length-1])}function Ve(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function He(e=240){let t=360-e,i=180+t/2,r=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:r,offsetRad:-Math.PI/2+r}}function qe(e){return ee(e)}function Ue(e,t,i,r,o,a){let n=le(r.theme).colors.categorical,l=i??r.colorScheme,s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrColorBy:t(e)})):s,d=t?G(u,c,l??n):void 0,h=_e("string"==typeof o.color?o.color:void 0,n,l,void 0,new Map),f=a??du(o.valueAccessor??"value"),p=o.styleRules,y=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?Y(e,t,d):h};return p?.length&&Object.assign(r,fu(e,p,{value:f(e,i),category:i})),"function"==typeof y?Object.assign(r,y(e,i)||{}):y&&"object"==typeof y&&Object.assign(r,y),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function Ze(e,t,i,r,o,a="median",n=.8){let l=du(o.valueAccessor??"value"),s=Ue(e,t,i,r,o,e=>"number"==typeof e[a]?e[a]:l(e));return(e,t)=>{let i=s(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=n),void 0===i.stroke&&(i.stroke=i.fill),i}}function Ke(e,t,i,r,o){return Ze(e,t,i,r,o,"median",.6)}function Qe(e,t,i,r,o){let a=Ue(e,t,i,r,o),n="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:n,fillOpacity:.8,...a(e,t)})}function Je(e,t,i,r,o){let a=Ue(e,t,i,r,o),n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],l=o.sizeBy,s=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=l?n.map(e=>"function"==typeof l?l(e):Number(e[l])).filter(Number.isFinite):[],u=c.length?nd(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:l?V(e,l,s,u):d,fillOpacity:h,...a(e,t)})}function et(e="static"){return Kh[e]??Kh.static}function tt(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Qh.has(e.kind)?"fatal":"warn"}function it(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`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function rt(){return Object.create(null)}function ot(e,t){return t>e?-1:e>t?1:0}function at(e){return e.occupants.map(e=>e.id).sort(ot).join("\0")}function nt(e,t,i=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?i:t)}function lt(e,t){return e.map(e=>{let i=new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function st(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:a}=i,n=i.stackValueScale??a,l=nt(e,r,i.groupPadding??0),s=[r+e[0].peak.topPeak*n];for(let i=1;e.length>i;i++)s.push(s[i-1]+t[i-1]*n+l[i-1]);let c=s[s.length-1]+e[e.length-1].peak.botPeak*n+r;if(c>o&&c>0){let e=o/c;for(let t=0;s.length>t;t++)s[t]*=e}return s}function ct(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function ut(e,t,i,r,o,a){let n=a.adjacentClearance?[...a.adjacentClearance]:Eu(lt(r,i)).adjacentClearance,l=st(r,n,a),s="hug"===a.lanePlacement?function(e,t,i,r,o,a,n){let l=e.length;if(0===l)return[];let{padding:s,plotH:c,valueScale:u}=n,d=nt(e,s,n.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=s+e[0].peak.topPeak*u,p=c-s-e[l-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=p-f)return st(e,o,n);let y=1===l?[(f+p)/2]:[...a];for(let e=0;12>e;e++){let e=Array(l).fill(0),o=Array(l).fill(0);for(let a of i){let i=t[a.source],n=t[a.target];if(null==i||null==n||i===n)continue;let l=r[a.source]?.localAttachments.get(a.id),s=r[a.target]?.localAttachments.get(a.id);if(!l||!s)continue;let c=a.value>0&&Number.isFinite(a.value)?a.value:1,d=ct(l,u),h=ct(s,u);e[i]+=(y[n]+h-d)*c,o[i]+=c,e[n]+=(y[i]+d-h)*c,o[n]+=c}let a=y.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),n=ju({desired:a,minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:p}),s=0;for(let e=0;l>e;e++)s=Math.max(s,Math.abs(n[e]-y[e]));if(y=n,.01>s)break}return y}(r,o,t,i,n,l,a):[...l];if("hug"===a.lanePlacement){let i=t=>{let i=rt();for(let r of e)i[r.id]=t[o[r.id]];return i};dt(i(s),t)>dt(i(l),t)+1e-6&&(s=[...l])}let c=rt();for(let t of e)c[t.id]=s[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*a.valueScale),d=Math.max(d,e+r.botPeak*a.valueScale))}return{adjacentClearance:n,centerlines:c,slotCenter:s,stackCenter:l,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&a.plotH>0?Math.max(0,Math.min(1,(d-u)/a.plotH)):0}}function dt(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function ht(e,t){let i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let r=0,o=i.length-1,a=0;for(;o>=r;){let e=r+o>>>1;i[e].t>t?o=e-1:(a=e,r=e+1)}let n=i[a].boundaryOffset??0;return{top:i[a].topMass-n,bot:i[a].botMass+n}}function ft(e,t,i,r,o){let a=1-o;return a*a*a*e+3*a*a*o*t+3*a*o*o*i+o*o*o*r}function pt(e,t){let i=0,r=1;for(let o=0;28>o;o++){let o=(i+r)/2;ft(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function yt(e,t,i){let r=t+ct(e,i),o=e.value*i/2;return[r-o,r+o]}function gt(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function mt(e,t,i,r,o,a,n){let{valueScale:l,domain:s,mode:c="quality"}=n,u="source"===n.ribbonLane?.85:"target"===n.ribbonLane?.15:.5,d=0;for(let n of e){let e=r[n.source],h=r[n.target];if(null==e||null==h||2>Math.abs(e-h))continue;let f=t[n.source]?.localAttachments.get(n.id),p=t[n.target]?.localAttachments.get(n.id);if(!f||!p)continue;let y=Math.max(n.startTime,s?.[0]??-1/0),g=Math.min(n.endTime,s?.[1]??1/0);if(y>=g)continue;let[m,x]=yt(f,o[n.source],l),[b,v]=yt(p,o[n.target],l),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){let r=i[e];if(!r)continue;let s=[y,g];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>y&&g>i.t&&s.push(i.t);let h=e=>{let i=pt((e-y)/(g-y),u),s=ft(m,m,b,b,i),c=ft(x,x,v,v,i),d=0;for(let i of r.occupants){if(i.id===n.source||i.id===n.target)continue;let r=a[i.id];if(null!=r?.start&&r.start>e||null!=r?.end&&e>r.end)continue;let u=ht(t[i.id],e),h=o[i.id];d=Math.max(d,gt(s,c,h-u.top*l,h+u.bot*l))}return d},f=[...new Set(s)].sort((e,t)=>e-t),p=0;for(let e=0;f.length-1>e;e++){let t=f[e],i=f[e+1]-t;p+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=p/(g-y)*(n.value>0?n.value:1)}}return d}function xt(e,t,i,r,o,a,n,l,s,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:dt(n,i),transitOcclusion:mt(i,r,o,a,n,l,{valueScale:s,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function bt(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function vt(e,t){return e.map(e=>({t:bt(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function wt(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let a=r+t;return[a-o,a]}let a=e.sideMassAfter*i;if("top"===e.side){let e=r-a;return[e,e+o]}let n=r+a;return[n-o,n]}function kt(e,t,i,r,o="temporal"){let a=t.incoming[e.id],n=t.outgoing[e.id],l=[];for(let e of a)l.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of n)l.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{l.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(s[e.kind]??99)-(s[t.kind]??99)||((e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0})(e,t)||ot(e.edge?.id??"",t.edge?.id??"")||ot(e.side,t.side)||e.delta-t.delta)},u=l.length?ad(l.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;c();let f=null,p=0;for(let e of l)e.time!==f&&(f=e.time,p=0),e.sequence=p++;let y=e=>({time:e.time,phase:0,sequence:e.sequence??0}),g=[],m=0,x=0;for(let e of l)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?m:x);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?m:x);if(r>0){let o=y(e);g.push({...o,delta:-r,kind:"transfer-out",side:t}),g.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?m-=r:x-=r,"top"===e.side?m+=r:x+=r,i-=r}i>0&&null!==h&&(g.push({time:h,delta:+i,kind:"create",side:e.side}),"top"===e.side?m+=i:x+=i)}"top"===e.side?m-=t:x-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?m+=t:x+=t}l.push(...g),c();let b=0,v=0,w=0,k=0,A=0,S=0,M=[],_=new Map,P=e=>{M.push({t:e,topMass:b,botMass:v,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},L=()=>{k=Math.max(k,b+v),A=Math.max(A,b-w),S=Math.max(S,v+w)};for(let e of l){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&P(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?b:v;_.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===e.side?b+=e.delta:v+=e.delta,"transfer-in"===e.kind?(w+="top"===e.side?e.delta:-e.delta,L(),P(e.time)):"transfer-out"!==e.kind&&(L(),"out"===e.kind&&1e-12>=b+v&&(w=0),P(e.time))}let $=[],T=0;for(;M.length>T;){let e=T;for(;M.length>e+1&&M[e+1].t===M[T].t;)e++;$.push(M[T]);for(let t=T+1;e>=t;t++){let e=$[$.length-1];(M[t].topMass!==e.topMass||M[t].botMass!==e.botMass||(M[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&$.push(M[t])}T=e+1}let R=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,C=null;for(let e of n)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let I=null;for(let e of a)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===I||e.systemOutTime>I)&&(I=e.systemOutTime);if($.length>0){let e=$[$.length-1],t=Math.max(R??-1/0,I??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&$.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=$[0],o=$.find(e=>e.topMass+e.botMass>0),a=1/0;null!=d&&Number.isFinite(d)&&r.t>d&&r.topMass+r.botMass>0&&(a=d,i=r),o&&null!=C&&Number.isFinite(C)&&o.t>C&&a>C&&(a=C,i=o),i&&Number.isFinite(a)&&$.unshift({t:a,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let D=$;if("max"===o&&null!=d&&null!=R&&R>d){let e,t=0;for(let i of $){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};D=[...$.filter(e=>d>e.t),{t:d,...t},{t:R,...t},...$.filter(e=>e.t>R)]}}return{samples:D,peak:k,topPeak:A,botPeak:S,localAttachments:_}}function At(e){let t=rt();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function St(e,t,i){e.splice(0,e.length,...i);let r=At(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function Mt(e){let t=new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:at(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(at).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||ot(e.stableId,t.stableId))}function _t(e){return e.some(e=>e.group)?Mt(e).flatMap(e=>e.slots):[...e]}function Pt(e){return e.flatMap(e=>e.slots)}function Lt(e,t,i){let r=new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;let a=new Map;for(let t of e.slots)a.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;a.set(e.source,(a.get(e.source)??0)+n*t)}else if(i===o&&t!==o){let i=t>o?1:-1;a.set(e.target,(a.get(e.target)??0)+n*i)}}let n=[...e.slots].sort((e,t)=>(a.get(e)??0)-(a.get(t)??0)||i(e,t));return{...e,slots:n}})}function $t(e,t){e.some(e=>e.group)&&St(e,t,_t(e))}function Tt(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Rt(e,t){return _u(t,t=>[e[t.source],e[t.target]],Tt)}function Ct(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function It(e,t,i){let[r,o]=i.get(e.first),[a,n]=i.get(e.second);return 0>(t.get(r)-t.get(a))*(t.get(o)-t.get(n))?1:0}function Dt(e,t,i,r,o,a,n){let l=[...o],s=new Map(o.map(e=>[e,at(e)])),c=new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!Tt(t[e],t[i]))continue;let r=new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:r})}let f=new Map;for(let e of o)f.set(e,[]);for(let e of h)for(let t of e.involvedSlots)f.get(t)?.push(e);let p=new Uint32Array(h.length),y=0,g=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=n.plotH/Math.max(1,o.length),x=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,n.plotH)+m*Math.max(x,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=new Map,A=(e,t)=>{let r=k.get(e);r||(r=new Map,k.set(e,r));let o=r.get(t);if(null!=o)return o;let a=function(e,t,i){return Eu(lt([e,t],i)).adjacentClearance[0]??0}(e,t,i);return r.set(t,a),a},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{let t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),_=new Map;for(let e of t){let t=u.get(e);t&&_.set(e,{source:S.get(t[0]),target:S.get(t[1])})}let P=new Map,L=new Map,$=new Map,T=(e,t,i)=>{e.has(t)||e.set(t,new Set),e.get(t).add(i)};for(let e of t)T(P,e.source,e.target),T(L,e.target,e.source),T($,e.source,e.target),T($,e.target,e.source);let R=t.flatMap(e=>{if(!(e=>1===P.get(e.source)?.size&&P.get(e.source).has(e.target)||1===$.get(e.source)?.size||1===$.get(e.target)?.size)(e))return[];let t=_.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(let i of R)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},I=e=>{let t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return C(t)},D=h.map(e=>{let t=_.get(e.first),i=_.get(e.second);return[t.source,t.target,i.source,i.target]}),z=new Int16Array(o.length),O=new Float64Array(o.length),F=new Float64Array(o.length+1),N=e=>{for(let t=0;e.length>t;t++)z[S.get(e[t])]=t;let t=0;for(let[e,i,r,o]of D)0>(z[e]-z[r])*(z[i]-z[o])&&t++;if(e.length>0){let t=S.get(e[0]);O[t]=n.padding+e[0].peak.topPeak*n.valueScale;for(let t=1;e.length>t;t++){let i=S.get(e[t-1]),r=S.get(e[t]);O[r]=O[i]+A(e[t-1],e[t])*n.valueScale+n.padding}let i=S.get(e[e.length-1]),r=O[i]+e[e.length-1].peak.botPeak*n.valueScale+n.padding;if(r>n.plotH&&r>0){let e=n.plotH/r;for(let t=0;O.length>t;t++)O[t]*=e}}F[0]=0;for(let t=0;e.length>t;t++)F[t+1]=F[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of M){let t=z[e.source],a=z[e.target];if(i+=Math.abs(t-a)*e.weight,r+=Math.abs(O[e.source]-O[e.target])*e.weight,Math.abs(t-a)>=2){let i=Math.min(t,a)+1;o+=(F[Math.max(t,a)]-F[i])*e.weight}}return t*b+r+o*m+C(z)+1e-6*i},E=(e,i)=>{let r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],a=i[e.target];if(null==t||null==a||2>Math.abs(t-a))continue;let n=Math.min(t,a)+1;o+=(r[Math.max(t,a)]-r[n])*(e.value>0?e.value:1)}return o},W=r=>{let o=At(r),a=r.slice(0,-1).map((e,t)=>A(e,r[t+1])),l=ut(e,t,i,r,o,{plotH:n.plotH,padding:n.padding,valueScale:n.valueScale,lanePlacement:n.lanePlacement??"stack",groupPadding:n.groupPadding,adjacentClearance:a});return{map:o,geometry:l,weightedLength:Ct(o,t),pixelLength:dt(l.centerlines,t),transitOcclusion:E(r,o)}},j=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*b+t.pixelLength+t.transitOcclusion*m+I(i)+1e-6*t.weightedLength}),B=(e,t)=>{let i=t;if(null==i){let t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+It(i,t,u),0),w.fullCrossing++}return j(i,W(e),e)},Y=(e,o,a="quality")=>{let l=o;if(null==l){let t=new Map(e.map((e,t)=>[e,t]));l=h.reduce((e,i)=>e+It(i,t,u),0),w.fullCrossing++}let s=W(e);return j(l,{...s,transitOcclusion:mt(t,i,e,s.map,s.geometry.centerlines,r,{valueScale:n.valueScale,ribbonLane:n.ribbonLane,domain:n.domain,mode:a})},e)},X=[...l],G=(e,t)=>ot(s.get(e),s.get(t)),V=function(e){let t=new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}(X),H=e=>{let t=(e=>{let t=Fu(e,d,e=>B(e).cost,{passes:6,compare:G,maxEvaluations:tf}),i=B(t),r=tf;for(let e=0;6>e&&r>0;e++){let o=!1,a=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&a.reverse();for(let e of a){if(0>=r--)break;let a=t[e],n=t[e+1],l=new Map(t.map((e,t)=>[e,t])),s=0,c=[];y++;for(let e of[...f.get(a)??[],...f.get(n)??[]])p[e.index]!==y&&(p[e.index]=y,c.push(e),s+=It(e,l,u));[t[e],t[e+1]]=[n,a];let d=new Map(l);d.set(a,e+1),d.set(n,e);let h=0;for(let e of c)h+=It(e,d,u);w.localCrossing+=c.length;let g=B(t,i.crossings-s+h);i.cost>g.cost?(i=g,o=!0):[t[e],t[e+1]]=[a,n]}if(!o)break}return t})(e);if((e.length>8?1/0:Jh(e.length)*(e.length+M.length+D.length))>ef)return t;let i=Nu(e,N,{maxItems:8,maxEvaluations:5e4}),r=Y(i),o=Y(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?i:t},q="geometry-refine"===n.mode;if(q||"crossing-min"!==n.laneOrder&&"crossing-min+inside-out"!==n.laneOrder){if(!q&&"inside-out"===n.laneOrder)if(V){let e=Mt(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||ot(e.stableId,i.stableId)),r=Array(i.length),o=Math.floor((i.length-1)/2)-1,a=Math.floor((i.length-1)/2)+1;i.length>0&&(r[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>a||0>o?r[a++]=i[e]:r[o--]=i[e];X=Pt(r)}else{let e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t)),t=Array(e.length),i=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>i?t[r++]=e[o]:t[i--]=e[o];X=t}}else X=V?(e=>{let t=Mt(e);if(1>=t.length)return Pt(t);let i=e=>B(Pt(e)).cost;t=Mt(H(e)),t=Lt(t,d,G);let r=function(e,t){let i=new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,n=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,l=r.get(n);l?l.weight=(l.weight??0)+a:r.set(n,{source:t,target:o,weight:a})}return[...r.values()]}(t,d);if(t=Fu(t,r,i,{passes:6,compare:(e,t)=>ot(e.stableId,t.stableId),maxEvaluations:tf}),t=Hu(t,i,{passes:8,maxEvaluations:tf}),(t.length>8?1/0:Jh(t.length)*(t.length+M.length+D.length))<=ef){let e=Nu(t,e=>N(Pt(e)),{maxItems:8,maxEvaluations:5e4}),i=Pt(e),r=Pt(t),o=Y(i),a=Y(r);o.crossings!==a.crossings?t=a.crossings>o.crossings?e:t:a.cost>o.cost&&(t=e)}return t=Lt(t,d,G),Pt(t)})(X):H(X);if(!q&&"crossing-min+inside-out"===n.laneOrder&&X.length>1)if(V){let e=Mt(X),t=B(Pt(e)),i=Pt(e),r=t,o=Math.floor((e.length-1)/2),a=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,t)=>a(t)-a(e)||ot(e.stableId,t.stableId));for(let a of n){let n=e.indexOf(a);if(n===o)continue;e.splice(n,1),e.splice(o,0,a);let l=Pt(e),s=B(l);s.cost>t.cost?(e.splice(o,1),e.splice(n,0,a)):(t=s,r.cost>s.cost&&(i=l,r=s))}X=i}else{let e=B(X),t=[...X],i=e,r=Math.floor((X.length-1)/2),o=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t));for(let a of o){let o=X.indexOf(a);if(o===r)continue;X.splice(o,1),X.splice(r,0,a);let n=B(X);n.cost>e.cost?(X.splice(r,1),X.splice(o,0,a)):(e=n,i.cost>n.cost&&(t=[...X],i=n))}X=t}if((q||"crossing-min"===n.laneOrder||"crossing-min+inside-out"===n.laneOrder)&&X.length>1)if(V){let e=Mt(X),t=Y(Pt(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];let o=Pt(e),a=Y(o,void 0,"score");t.cost>a.cost?(X=o,t=a,i=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!i)break}e=Lt(Mt(X),d,G),X=Pt(e)}else{let e=Y(X,void 0,"score");for(let t=0;X.length-1>t;t++){let i=X[t],r=X[t+1],o=new Map(X.map((e,t)=>[e,t])),a=0,n=[];y++;for(let e of[...f.get(i)??[],...f.get(r)??[]])p[e.index]!==y&&(p[e.index]=y,n.push(e),a+=It(e,o,u));[X[t],X[t+1]]=[r,i];let l=new Map(o);l.set(i,t+1),l.set(r,t);let s=0;for(let e of n)s+=It(e,l,u);w.localCrossing+=n.length;let c=Y(X,e.crossings-a+s,"score");e.cost>c.cost?e=c:[X[t],X[t+1]]=[i,r]}}let U=_t(l);X=_t(X);let Z=Y(X),K=Y(U);if(q){let e=I(U),t=I(X);(Z.crossings>K.crossings||Z.crossings===K.crossings&&t>e+1e-9||Z.cost>K.cost)&&(X=U,Z=K)}else Z.cost>K.cost&&(X=U,Z=K);let Q=function({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:a,slotForNode:n,averageGap:l,evaluate:s}){let c=(i,o)=>{let a=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),n=e.indexOf(i),c=a[0],u=a[a.length-1];if(3>a.length||!a.includes(n)||u-c+1!==a.length||1>=Math.abs(2*n-c-u))return;let d=[...e];d.splice(n,1),d.splice(c+u>>1,0,i);let h=_t(d),f=s(h),p=new Set(i.occupants.map(e=>e.id)),y=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),g=r.reduce((e,t)=>p.has(t.source)&&y.has(t.target)||p.has(t.target)&&y.has(t.source)?e+(t.value>0?t.value:1):e,0);(function(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost})(f,t,Math.abs(2*n-c-u)*l*Math.max(1,g))&&(e=h,t=f)};for(let[e,t]of o)!a.has(e)&&t.size>=3&&c(n.get(e),[...t].map(e=>n.get(e)));for(let e of i){let t=n.get(e.id);!e.group&&t.group&&(a.get(e.id)?.size??0)>=3&&c(t,[...a.get(e.id)??[]].map(e=>n.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}({order:X,after:Z,nodes:e,edges:t,outgoingPartners:P,incomingPartners:L,slotForNode:c,averageGap:m,evaluate:Y});return X=Q.order,Z=Q.after,St(o,a,X),{before:K,after:Z,initialOrder:l.map(e=>s.get(e)),evaluations:w}}function zt(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,a=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),a=Math.max(a,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:a},...null!=e.group?{group:e.group}:{}}}),o=rt();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function Ot(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function Ft(e,t){return ot(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Nt(e){let t=new Map,i=new Map;for(let r of e)i.has(r.source)||i.set(r.source,new Set),t.has(r.target)||t.set(r.target,new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function Et(e){let t=new Map,i=new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=new Map,a=e=>{if(o.has(e))return;let r=t.get(e),a=i.get(e),n=new Map;for(let[e,t]of r??[])n.set(e,(n.get(e)??0)+t);for(let[e,t]of a??[])n.set(e,(n.get(e)??0)+t);if(1===n.size){let[t,i]=[...n][0];o.set(e,{partner:t,weight:i})}};for(let t of e)a(t.source),a(t.target);return o}function Wt(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function jt(e,t,i){return!!i.has(e)&&t.some(t=>!Wt(e,t,i))}function Bt(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function Yt(e,t,i,r){if(12>=e.length||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),a=Array.from({length:e.length},()=>new Map),n=Nt(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Bt(e,n);a[t].set(i,(a[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let l=Et(i),s=e.map(e=>l.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map),u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(l.has(e[i]))for(let r=i+1;e.length>r;r++){if(!l.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(s[i],s[r])||Math.max(s[i],s[r]),a=Wt(e[i],e[r],l)?o:-o;if(Math.abs(a)>af&&(c[i].set(r,a),c[r].set(i,a),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let f=(e,t,i)=>{let r=d[t],o=d[i],a=0,n=new Set;for(let l of[t,i])for(let[s,c]of e[l]){let e=s>l?`${l}:${s}`:`${s}:${l}`;if(n.has(e))continue;n.add(e);let u=(l===t?o:r)===(s===t?o:s===i?r:d[s]);d[l]===d[s]!==u&&(a+=u?c:-c)}return a},p=(e,t,i)=>{let r=0;for(let[o,a]of e[t]){let e=i===d[o];d[t]===d[o]!==e&&(r+=e?a:-a)}return r},y=(e,t)=>e>af||af>=Math.abs(e)&&t>af,g=(e,t,i,r)=>e>i+af||af>=Math.abs(e-i)&&t>r+af,m=0;for(let i=0;32>i&&of>m;i++){let i=null,r=-1,o=-1,n=-1,l=-1/0,s=-1/0;for(let u=0;e.length>u;u++){for(let f=0;h.length>f&&m++<of;f++){if(f===d[u]||!h[f].every(i=>!t.conflicts(e[u],e[i])))continue;let m=p(a,u,f),x=p(c,u,f);y(m,x)&&g(m,x,l,s)&&(i="move",r=u,o=-1,n=f,l=m,s=x)}if(m>=of)break}for(let u=0;e.length-1>u;u++){for(let p=u+1;e.length>p&&m++<of;p++){let m=d[u],x=d[p];if(m===x||!h[x].every(i=>i===p||!t.conflicts(e[u],e[i]))||!h[m].every(i=>i===u||!t.conflicts(e[p],e[i])))continue;let b=f(a,u,p),v=f(c,u,p);y(b,v)&&g(b,v,l,s)&&(i="swap",r=u,o=p,n=-1,l=b,s=v)}if(m>=of)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[n].push(r),d[r]=n;continue}let u=d[r],x=d[o];h[u].splice(h[u].indexOf(r),1,o),h[x].splice(h[x].indexOf(o),1,r),d[r]=x,d[o]=u}return d}function Xt(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])1e-9>=t.topMass+t.botMass||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),i>r?{start:null,end:null}:{start:i,end:r}):{start:null,end:null}}function Gt(e,t,i,r){let o=function(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,i,r),a=rf.get(o);if(a)return zt(a.slots,i,r);let n=rt();for(let t of e)n[t.id]=Xt(i[t.id],r[t.id]);let l=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||ot(e.id,i.id)).map(e=>e.id)}(e,n),s=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=Et(t),d=function(e,t,i,r,o,a){let n=new Set,l=new Map(e.map(e=>[e,new Set])),s=new Map(e.map(e=>[e,new Set]));for(let e of r)n.add(Ft(e.source,e.target)),l.get(e.target)?.add(e.source),s.get(e.source)?.add(e.target);let c=new Map,u=new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let r=i+1;e.length>r;r++){let o=Ft(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of s.values())d([...e],c);for(let e of l.values())d([...e],u);let h=new Set;for(let[e,[r,o]]of c)u.has(e)&&(Ot(t[r],t[o])||Ot(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),l=o.get(i);return!((null==r||null==l||r===l)&&(null!=r==(null!=l)||n.has(Ft(e,i))||a.has(e)&&a.has(i)&&Wt(e,i,a))&&!Ot(t[e],t[i])&&(!h.has(e)&&!h.has(i)||n.has(Ft(e,i))))}}}(l,n,r,t,c,u),h=function(e,t,i=new Map){let r=[],o=[];for(let a of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(a,e))&&!jt(a,e,i));-1===e&&!i.has(a)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(a,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(a),o.push(e)}return{assignment:o,slotCount:r.length}}(l,d,u),f=function(e,t,i,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),a=Array.from({length:e.length},()=>new Float64Array(e.length)),n=Array.from({length:e.length},()=>new Map),l=Array.from({length:e.length},()=>new Map),s=Nt(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Bt(e,s);a[t][i]+=r,a[i][t]+=r,l[t].set(i,(l[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let c=Et(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(let[e,r]of n[t])d[t][i]+=Math.min(r,n[i].get(e)??0);for(let[e,r]of l[t])d[t][i]+=Math.min(r,l[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=Wt(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],f=(t=>{let i=0,r=0;for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++)t[o]===t[n]&&(i+=a[o][n],r+=d[o][n]);return{flow:i,affinity:r}})(h),p=0,y=Array(e.length).fill(-1),g=Array.from({length:r.slotCount},()=>[]),m=(i,o,n,l)=>{if(p>=75e3)return;if(i===e.length)return p++,void((n>f.flow||n===f.flow&&l>f.affinity||n===f.flow&&l===f.affinity&&function(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}(y,h))&&(h=[...y],f={flow:n,affinity:l}));let s=Math.min(o+1,r.slotCount-1);for(let r=0;s>=r;r++){if(g[r].some(r=>t.conflicts(e[i],e[r])))continue;let s=0,c=0;for(let e of g[r])s+=a[i][e],c+=d[i][e];if(y[i]=r,g[r].push(i),m(i+1,Math.max(o,r),n+s,l+c),g[r].pop(),y[i]=-1,p>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}(l,d,t,{...h,assignment:Yt(l,d,t,h)}),p=new Map,y=f.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),g=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=rt();l.forEach((e,t)=>{let i=y[t],r=g[i];r.occupants.push({id:e,end:n[e].end??-1/0});let o=s.get(e)?.group;o&&(r.group=o),m[e]=i});for(let t of[...e].sort((e,t)=>ot(e.id,t.id)))null==m[t.id]&&(g[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(let e of g){e.occupants.sort((e,t)=>(n[e.id].start??1/0)-(n[t.id].start??1/0)||ot(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let x={slots:g,slotByNode:m};return function(e,t){for(rf.has(e)&&rf.delete(e),rf.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(rt(),t.slotByNode)});rf.size>12;){let e=rf.keys().next().value;if(null==e)break;rf.delete(e)}}(o,x),x}function Vt(e){return e.topMass+e.botMass}function Ht(e){let t=new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let a=t.get(o);if(a){let e=a.reduce((e,t)=>Vt(t)<Vt(e)?e:t,a[0]);return{exact:a,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:a,sample:e.samples[i-1]??null}}}function qt(e,t,i,r,o,a,n=0){let l=new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=l.get(i.group)??[];e.push(i),l.set(i.group,e)}if(0===l.size||0>=a)return t;let s=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(let[e,c]of l){let l=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===l.length)continue;let u=l[0].slot,d=l.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;let p=(h-u.peak.topPeak*a+(f+d.peak.botPeak*a))/2,y=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),g=new Map;for(let e of c)g.set(e.id,new Map);let m=new Map(c.map(e=>[e.id,Ht(t[e.id])]));for(let e of y){let t=new Map;for(let i of c){let{sample:o}=m.get(i.id)(e);if(!o||1e-9>=Vt(o))continue;let a=r[i.id];if(null==a)continue;let n=t.get(a)??[];n.push({node:i,sample:o}),t.set(a,n)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Vt(e)))}));if(0===i.length)continue;let l=p-(i.reduce((e,t)=>e+t.mass,0)*a+Math.max(0,n)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(l-o[i.id])/a+r.topMass-(r.boundaryOffset??0);g.get(i.id).set(e,t)}l+=t.mass*a+Math.max(0,n)}}for(let e of c){let i=t[e.id],r=s[e.id],o=g.get(e.id),a=m.get(e.id),n=[];for(let e of y){let t=o.get(e),{exact:i,sample:r}=a(e);i?n.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||1e-9>=Vt(r)||n.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=n,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return s}function Ut(e,t,i,r,o){let{plotH:a,padding:n,valueScale:l,packing:s,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=o,y=rt(),g=rt();for(let t of e)y[t.id]=i[t.id].topPeak||0,g[t.id]=i[t.id].botPeak||0;let m="half"===u,x=rt();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,a=null!=i&&Number.isFinite(i)?i:-1/0;for(let e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);let t=m?(e.startTime+e.endTime)/2:e.endTime;t>a&&(a=t)}for(let e of r.incoming[t.id]){let t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>a&&(a=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>a&&(a=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(a)?a:null}}let b=rt(),v=[],w=[];if(o.frozenSlots){let e=zt(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(at)}else if("reuse"===s){let r=Gt(e,t,i,x);v=r.slots,b=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:g[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});$t(v,b),0===w.length&&(w=v.map(at));let k=null;o.frozenSlots||(o.fixedSlotOrder?function(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));St(e,t,[...e].sort((e,t)=>(r.get(at(e))??1/0)-(r.get(at(t))??1/0)||ot(at(e),at(t))))}(v,b,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=Dt(e,t,i,x,v,b,{plotH:a,padding:n,valueScale:l,groupPadding:h,laneOrder:c,ribbonLane:f,domain:p}))),$t(v,b);let A=ut(e,t,i,v,b,{plotH:a,padding:n,valueScale:l,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,P=k?.before.weightedLength??null,L=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(at),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:L}}function Zt(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:a,tBot:n,cp1X:l,cp2X:s}=e,c=(i+r)/2,u=(a+n)/2;return{pathD:[`M${t},${i}`,`C${l},${i} ${s},${a} ${o},${a}`,`L${o},${n}`,`C${s},${n} ${l},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:l,y:c},{x:s,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}function Kt(e,t,i,r,o,a,n,l,s={}){let c,u,d,h,f=o,p=e=>l?Math.max(l[0],Math.min(l[1],e)):e,y=a(p(e.time)),g=a(p(i.time)),m=e.value*f,x=i.value*f,b=t+(e.boundaryOffset??0)*f,v=r+(i.boundaryOffset??0)*f,w=e.sideMassBefore*f,k=i.sideMassAfter*f;"top"===e.side?(c=b-w,u=c+m):(u=b+w,c=u-m),"top"===i.side?(d=v-k,h=d+x):(h=v+k,d=h-x);let A=s.sourceRunwayStart,S=s.minRun,M=Math.abs((d+h)/2-(c+u)/2),_=g-y,P="number"==typeof A&&Number.isFinite(A),L="number"==typeof S&&Number.isFinite(S)&&S>0;if(P&&M>1e-9&&_>0&&("auto"===S||L)){let t="source"===n?.85:"target"===n?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>_){let t=a(p(Math.min(A,e.time)));Number.isFinite(t)&&(y=Math.min(y,Math.max(Math.min(y,t),g-i)))}}let $="source"===n?y+.85*(g-y):"target"===n?y+.15*(g-y):(y+g)/2;return{sx:y,sTop:c,sBot:u,tx:g,tTop:d,tBot:h,cp1X:$,cp2X:$}}function Qt(e){return Math.max(18,11*e.length*.58)}function Jt(e){let t=1.22*Qt(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function ei(e,t){let i=e.labelX-Qt(e.labelText),r=t.labelX-Qt(t.labelText);return t.labelX+3>=i&&e.labelX+3>=r}function ti(e){return e.replace(nf,(e,t,i)=>`${i},${t}`)}function ii(e){if(!e)return;let t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function ri(e){return{...e,pathD:ti(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function oi(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}function ai(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function ni(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function li(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:a=6,angle:n=45,lineOpacity:l=1}=e,s=Math.max(8,Math.ceil(2*a));return cf("pattern",{id:t,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[i&&"transparent"!==i&&sf("rect",{width:s,height:s,fill:i}),sf("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o,strokeOpacity:l}),sf("line",{x1:a,y1:0,x2:a,y2:s,stroke:r,strokeWidth:o,strokeOpacity:l})]},t)}function si(e){let{nodes:t,edges:i,domain:r,plotW:o,plotH:a,ribbonLane:n,ribbonMinRun:l=0,edgeOpacity:s,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?a:o,w="vertical"===d?o:a,k=function(e,t,i,r={}){let o=et(r.usageMode??"static"),a=[],n=new Set;for(let t of e)n.has(t.id)&&a.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),n.add(t.id);let l=new Set,s=Array.isArray(i)&&2===i.length,c=s&&Number.isFinite(i[0])&&Number.isFinite(i[1]);(!s||!c||!c||i[0]>i[1])&&a.push({kind:"invalid-domain"});for(let 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]||a.push({kind:"invalid-node-time",id:t.id}));for(let e of t)l.has(e.id)&&a.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),l.add(e.id),n.has(e.source)||a.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),n.has(e.target)||a.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&a.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||0>=e.value)&&a.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&a.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):a.push({kind:"invalid-edge-time",id:e.id});return a}(t,i,r,{usageMode:b}),{fatal:A,warnings:S}=function(e){let t=[],i=[];for(let r of e)"fatal"===tt(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}(k),M=function(e,t,i="static"){if("strip"!==et(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}(i,k,b),_=Zh().domain(r).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};let P=function(e,t,i){let{plotH:r,pairing:o="temporal",packing:a="reuse",laneOrder:n="crossing-min",lifetimeMode:l="half",maxValueScale:s,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=i,p=Number.isFinite(d)?Math.max(0,d):0,y=function(e,t){let i=rt(),r=rt();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}(e,t),g=function(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||ot(e.id,t.id):(e,t)=>t.value-e.value||ot(e.id,t.id),a="temporal"===r?(e,t)=>e.startTime-t.startTime||ot(e.id,t.id):(e,t)=>t.value-e.value||ot(e.id,t.id),n=new Map;for(let e of t)n.set(e.id,{});let l=(e,t)=>{let i=new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}let n=[...i.values()];n.sort("temporal"===r?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||ot(e.partner,i.partner):e.latestEnd-i.latestEnd||ot(e.partner,i.partner):(e,t)=>t.total-e.total||ot(e.partner,t.partner));for(let e of n)e.edges.sort("target"===t?a:o);return n};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)l(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)n.get(t.id).sourceSide=i});else if(0===e.length)l(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)n.get(t.id).targetSide=i});else{let t=l(r,"source"),i=l(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)n.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)n.get(t.id).sourceSide=r}}}return n}(e,t,y,o),m=rt();for(let t of e)m[t.id]=kt(t,y,g,void 0,u);let x=Ut(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:n,lifetimeMode:l,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=new Set;for(let e of t){let t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=g.get(e.id);t!==i?t>i?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=y.outgoing[t.id],i=y.incoming[t.id],r=new Set(e.map(e=>g.get(e.id).sourceSide)),o=new Set(i.map(e=>g.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(g.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(g.get(i.id).sourceSide=t)}}(function(e,t,i){let r=new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||ot(e.edge.id,t.edge.id));let a=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},n=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let a=i-o;a>0&&(e[r]=Math.max(0,e[r]-a))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";a(r.target)[e]+=r.value;continue}let o=a(r.source),l=t.get(r.id),s=l.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?s=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(s=o.top>o.bot?"top":"bot"),l.sourceSide=s,l.targetSide=s}n(o,s,r.value)}})(t,g,x.slotByNode),function(e,t,i,r){for(let o of e){let e=t.incoming[o.id],a=t.outgoing[o.id];if(0===e.length||0===a.length)continue;let n=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of a)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},l=(e,t)=>{let o=n(),l="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=l||0>=s)return!1;let c=Math.min(l,s),u=a.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||ot(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},s=a.length+1;for(;s-- >0&&(l("top","bot")||l("bot","top")););}}(e,y,g,v),m=rt();for(let t of e)m[t.id]=kt(t,y,g,void 0,u);let w=Ut(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:n,lifetimeMode:l,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*p)/S),_=2*M+nt(w.slots,M,p).reduce((e,t)=>e+t,0),P=k>0?Math.max(0,(r-_)/k):1,L=Number.isFinite(s)&&s>0?Math.min(P,s):P,$=Ut(e,t,m,y,{plotH:r,padding:M,valueScale:L,packing:a,laneOrder:n,lifetimeMode:l,frozenSlots:b,lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P}),T=Number.isFinite(s)&&s>0&&P>s+1e-12;if("insertion"!==n&&("hug"===c||T)&&$.slots.length>1&&(Dt(e,t,m,$.laneLifetime,$.slots,$.slotByNode,{plotH:r,padding:M,valueScale:L,groupPadding:p,laneOrder:n,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),$=Ut(e,t,m,y,{plotH:r,padding:M,valueScale:L,packing:a,laneOrder:n,lifetimeMode:l,frozenSlots:$.slots,fixedSlotOrder:$.slots.map(at),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})),function(e,t){let i=(e,i)=>{for(let r of e){let e=new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,a="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,n=e.get(r);if(null!=n&&n!==a)return!0;e.set(r,a)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}(y,g)){let i=function(e,t,i,r){let o=new Map;for(let a of e){let e=t[a.source]?.localAttachments.get(a.id),n=t[a.target]?.localAttachments.get(a.id),l=i[a.source],s=i[a.target];if(!(e&&n&&Number.isFinite(l)&&Number.isFinite(s)))continue;let c=wt(e,l,r),u=wt(n,s,r);o.set(a.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}(t,m,$.centerlines,L);m=rt();for(let t of e)m[t.id]=kt(t,y,g,i,u);$=Ut(e,t,m,y,{plotH:r,padding:M,valueScale:L,packing:a,laneOrder:n,lifetimeMode:l,frozenSlots:$.slots,fixedSlotOrder:$.slots.map(at),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})}let R=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),C=[...$.slots].sort((e,t)=>(R.get(at(e))??1/0)-(R.get(at(t))??1/0)||ot(at(e),at(t))),I=rt();C.forEach((e,t)=>{for(let i of e.occupants)I[i.id]=t});let D=ut(e,t,m,C,I,{plotH:r,padding:M,valueScale:L,stackValueScale:P,lanePlacement:"stack",groupPadding:p}),z=qt(e,m,C,I,D.centerlines,L,p),O=xt(Rt(I,t),Ct(I,t),t,z,C,I,D.centerlines,$.laneLifetime,L,D.verticalUtilization,h,f);m=qt(e,m,$.slots,$.slotByNode,$.centerlines,L,p);let F=xt(Rt($.slotByNode,t),Ct($.slotByNode,t),t,m,$.slots,$.slotByNode,$.centerlines,$.laneLifetime,L,$.verticalUtilization,h,f);return{nodeData:m,sides:g,valueScale:L,padding:M,compressedPadding:12>M,centerlines:$.centerlines,laneLifetime:$.laneLifetime,slots:$.slots,slotByNode:$.slotByNode,crossingsBefore:"insertion"===n?null:O.crossings,crossingsAfter:"insertion"===n?null:F.crossings,lengthBefore:"insertion"===n?null:O.weightedLength,lengthAfter:"insertion"===n?null:F.weightedLength,layoutQualityBefore:O,layoutQuality:F}}(t,M,{plotH:w,...u,ribbonLane:n,domain:r}),{centerlines:L,nodeData:$,valueScale:T}=P,R=uu(m,x),C=[],I=[],D=0===l?new Map:function(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),a=new Map;for(let e of t){if(r.has(e.source))continue;let t=a.get(e.source)??[];t.push(e),a.set(e.source,t)}let n=new Map;for(let t of e){if(!t.group)continue;let e=n.get(t.group)??[];e.push(t),n.set(t.group,e)}let l=new Set;for(let[e,t]of n){let i=t.flatMap(e=>a.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(a.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&l.add(e)}let s=new Map;for(let[e,t]of a){let r=o.get(e);if(r?.group&&!l.has(r.group))continue;let a=r?.xExtent?.[0],n=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=n[0]?.startTime-1,u=null;for(let e=0;n.length>e;){let t=n[e].startTime,r=e+1;for(;n.length>r&&n[r].startTime===t;)r++;for(let t=e;r>t;t++){let e=n[t],r=Number.isFinite(a)&&e.startTime>a,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let l=i[0];r&&(l=Math.max(l,a)),o&&(l=Math.max(l,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(l=Math.max(l,c)),null!=u&&(l=Math.max(l,u)),e.startTime>l&&s.set(e.id,l)}u=t,e=r}}for(let[e,t]of n){if(!l.has(e))continue;let i=t.flatMap(e=>a.get(e.id)??[]);if(!i.every(e=>s.has(e.id))){for(let e of i)s.delete(e.id);continue}let r=Math.max(...i.map(e=>s.get(e.id)));for(let e of i)s.set(e.id,r)}return s}(t,M,r),z=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),O=new Map;for(let e of M){let t=$[e.source]?.localAttachments.get(e.id),i=$[e.target]?.localAttachments.get(e.id);!t||!i||O.set(e.id,Kt(t,L[e.source],i,L[e.target],T,_,n,r,{minRun:l,sourceRunwayStart:D.get(e.id)}))}let F=function(e,t,i,r,o,a){let n=new Map(t),l=new Map;for(let t of e){let e=a?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,r=l.get(i)??new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),l.set(i,r)}for(let e of l.values())for(let[a,l]of e){if(!l.some(e=>i.has(e.id)))continue;let e=l.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let s=r(a),c=Math.min(...e.map(e=>e.sx));if(c>=s-1e-9)continue;let u=Math.max(...l.map(e=>{let t=i.get(e.id);return null==t?s:Math.min(s,r(t))})),d=Math.min(s,Math.max(c,u));for(let e of l){let i=t.get(e.id),r=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);n.set(e.id,{...i,sx:d,cp1X:r,cp2X:r})}}return n}(M,O,D,_,n,z),N=function(e,t,i,r,o){let a=new Map;for(let n of e){if(!i.has(n.id))continue;let e=t.get(n.id);if(!e||e.sx>=r(n.startTime)-1e-9)continue;let l=o(e.sx);Number.isFinite(l)&&n.startTime>l&&a.set(n.id,l)}return a}(M,F,D,_,e=>r[0]+e/v*(r[1]-r[0])),E=function(e,t,i){let r=new Map,o=new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let a of e){let e=t.get(a.id);if(null==e||!Number.isFinite(e)||e>=a.startTime)continue;let n=i?.get(a.source),l=null==n?[a.source]:o.get(n)??[a.source];for(let t of l){let i=r.get(t)??new Map,o=i.get(a.startTime);i.set(a.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}(M,N,z);t.forEach((e,t)=>{let i=$[e.id];if(!i||0===i.samples.length)return;let o=(n=i.samples,(l=E.get(e.id))&&0!==l.size?n.map(e=>{let t=l.get(e.t);return null==t?e:{...e,t:t}}):n),a=function(e,t,i,r,o){if(0===e.length)return null;let a=vt(e,o),n=e=>t+(a[e].boundaryOffset??0)*i,l=e=>n(e)-a[e].topMass*i,s=e=>n(e)+a[e].botMass*i,c=`M${r(a[0].t)},${l(0)}`;for(let e=1;a.length>e;e++)c+=` L${r(a[e].t)},${l(e)}`;c+=` L${r(a[a.length-1].t)},${s(a.length-1)}`;for(let e=a.length-2;e>=0;e--)c+=` L${r(a[e].t)},${s(e)}`;return c+" Z"}(o,L[e.id],T,_,r);var n,l;if(!a)return;let s,u,h=vt(o,r),f=h.find(e=>e.topMass+e.botMass>0)||h[0],p=L[e.id]+(f.botMass-f.topMass+2*(f.boundaryOffset??0))*T/2,y=c(e.id,t),m=y,x=.5,b=e.__raw??e;if(g&&g.length>0){let e=fu(b,g,R(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&ai(e.fill)&&(u=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(x=e.strokeWidth),"number"==typeof e.fillOpacity&&(s=e.fillOpacity),"number"==typeof e.opacity&&null==s&&(s=e.opacity)}let v=function(e,t,i,r,o,a){let n=i.nodeData[e];if(!n||0===n.samples.length)return[];let l=i.valueScale,s=i.centerlines[e],c=vt(n.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),p=e=>r(bt(e,o)),y=[],g=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=n.localAttachments.get(i.id),t=a?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){let r=p(i.systemInTime),a=p(t),n=null!=o&&o[0]>i.systemInTime,c=n?r:r-20,u=n?Math.min(a,r+20):r,d=Math.max(h,c);if(a>d){let[t,i]=wt(e,s,l);y.push({pathD:g(d,t,a,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=n.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=p(i.systemOutTime),r=p(i.endTime),o=t+20,a=Math.min(f,o);if(a>r){let[i,n]=wt(e,s,l);y.push({pathD:g(r,i,a,n),x0:t,x1:o,from:1,to:0})}}}}return y}(e.id,M,P,_,r,N);C.push({id:e.id,pathD:a,fill:y,stroke:m,strokeWidth:x,...null!=s&&{fillOpacity:s},...u&&{hatchFill:u},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:_("vertical"===d&&e.xExtent?e.xExtent[0]:f.t)-4,labelY:p,labelText:e.label??e.id})});let W=new Map;t.forEach((e,t)=>W.set(e.id,t)),M.forEach(e=>{let t=F.get(e.id);if(!t)return;let i=W.get(e.source)??0,r=c(e.source,i),{pathD:o,bezier:a}=Zt(t),n=e.__raw??e,l="function"==typeof s?Number(s(n)):s,u=Number.isFinite(l)?Math.max(0,Math.min(1,l)):.35;I.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:n,bezier:a})});let j=function(e,t,i){let r=e.map(e=>({...e})),o=new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let a=e=>{if(2>e.length)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-Qt(r.labelText);t.length>0&&e>i+3&&(a(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}a(t)}return function(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)ei(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;i.length>t;t+=1)ei(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}(r,i),r}(C,P.slotByNode,w).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:ti(e.pathD),gradientStubs:e.gradientStubs?.map(ri),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),B="vertical"===d?function(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*Qt(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}let o=[],a=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of a){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=new Map;for(let i of e){let[e,o]=Jt(i),a=t.findIndex(t=>e>t+8);-1===a&&(a=t.length),t[a]=o,r.set(i,a)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,a=14*t.length+8>o;for(let t of e){let e=r.get(t)??0;t.labelY=a?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}(j,o,a):j,Y=new Map;if(null!=f)for(let e of t){let t=e.__raw??e,i="function"==typeof f?f(t):Number(t[f]);Number.isFinite(i)&&Y.set(e.id,i)}let X=function(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let a=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(a=Math.min(a,Math.floor(o.maxLabels)));let n=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Qt(e.labelText):Qt(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),l=new Set(n.slice(0,a).map(e=>e.band.id));return e.map(e=>l.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(B,o,a,h,{...Y.size>0&&{priorityById:Y},...null!=p&&{maxLabels:p}});return{layout:P,layoutConfig:{bands:X,ribbons:I.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:ti(e.pathD),bezier:ii(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function ci(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function ui(e,t,i){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,i))}function di(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function hi(e,t,i,r){if(e&&e.length>0)return e;let o=new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],a="function"==typeof r?r(e):e[r];o.add(t),o.add(a)}),Array.from(o).map(e=>({id:e}))}function fi(e,t,i={}){return q(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function pi(e,t,i){let[r,o]=i;if(!t)return r;let[a,n]=t,l=n>a?n-a:0,s=Number(e),c=Number.isFinite(s)?s:a;return r+Math.max(0,Math.min(1,l>0?(c-a)/l:0))*(o-r)}function yi(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:a,edgeLinecap:n,styleRules:l}=e,s=du(t);return cu(e=>({stroke:o(e),strokeWidth:pi(e[t],i,r),strokeLinecap:n,opacity:a,fillOpacity:0}),l,e=>({value:s(e)}))}function gi(e,t,i,r){let o,a,n=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?n:n.map(e=>({...e,__geoColorBy:t(e)}));o=G(r,e,i)}if(r.sizeBy){let e=n.map("function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(a=nd(e))}return e=>({fill:t&&o?Y(e,t,o):Yd,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?V(e,r.sizeBy,r.sizeRange,a):r.pointRadius??6})}function mi(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function xi(e,t,i,r){let{windowPlot:o,lidSegments:a}=e,n=a[t];return i&&!n?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&n?Math.min(o.y+o.height-r,Math.max(n.y1,n.y2)+2*r+4):o.y+r+2}function bi(e,t,i,r,o){let{windowPlot:a,windowCount:n,windowStart:l,windowSize:s}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=a.width/n,u=i?a.x:a.x+t*c,d=i?a.x+a.width:u+c,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,a.x+(e-l)/s*c))}function vi(e,t,i){let r=e.width/Math.max(1,t),o=Math.max(2,2*i),a=Math.min(.7*r,Math.max(3.2*o,o+8)),n=Math.max(1,Math.floor(a/o));return{laneWidth:r,tubeWidth:a,ballDiameter:o,perRow:n,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/n)*o}}function wi(e,t,i,r){let o=(t+i)/2,a=[];for(let n of e){let l=a.filter(e=>n.radius+e.radius+.5>Math.abs(n.x-e.x)),s=[o];for(let e of l){let t=Math.sqrt((n.radius+e.radius+.5)**2-(n.x-e.x)**2);s.push(e.y-t,e.y+t)}let c=.5>r()?-1:1;s.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=s.find(e=>e-n.radius>=t&&i>=e+n.radius&&l.every(t=>(n.x-t.x)**2+(e-t.y)**2>=(n.radius+t.radius+.5)**2-1e-6));if(null==u){let r=Math.max(...e.map(e=>e.radius)),a=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*a),overlapping:!0,entryOffset:0}}a.push({...n,y:u})}return{positions:a.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...a.map(e=>e.y-e.radius-t)))}}function ki(e){if(Array.isArray(e)&&e.length>=2){let t=Oc(e[0]),i=Oc(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=Oc(t.x),r=Oc(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function Ai(e){return Array.isArray(e)?e.map(ki).filter(e=>null!=e):[]}function Si(e,t,i){return"normalized"===i?{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 Mi(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function _i(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=Cc(t,0,1)*Mi(e),r=0;for(let t=1;e.length>t;t+=1){let o=e[t-1],a=e[t],n=Math.hypot(a.x-o.x,a.y-o.y);if(n>0){if(r+n>=i){let e=(i-r)/n;return{x:o.x+(a.x-o.x)*e,y:o.y+(a.y-o.y)*e}}r+=n}}return{...e[e.length-1]}}function Pi(e,t){let i=_i(e,Math.max(0,t-.02)),r=_i(e,Math.min(1,t+.02)),o=r.x-i.x,a=r.y-i.y,n=Math.hypot(o,a)||1;return{x:o/n,y:a/n}}function Li(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 $i(e,t,i){return B(e,t,i)}function Ti(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&X(i,e)||"#4e79a7":t=>{if(i){let e=X(i,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Ri(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],a=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...a.length>0&&{colliders:a}}}function Ci(e){let t=Fi(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Ii(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function Di(e){return`gauntlet:${e}:core`}function zi(e,t){return`gauntlet:${e}:positive:${t}`}function Oi(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function Fi(e){let t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return Bf;let i=Math.max(1,Math.min(e.width,t)),r=Math.max(2,.04*e.width);return{left:r,top:Math.max(2,.08*t),rightInset:r,thickness:Math.max(1,Math.min(4,.04*i))}}function Ni(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function Ei(e,t,i,r){let o=Fi(r),a=Math.max(2,i+2),n=o.top+o.thickness/2+a,l=r.floorY-a,s=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:s(e,o.left+o.thickness/2+a,r.width-o.rightInset-o.thickness/2-a),y:s(t,n,l)}}function Wi(e,t,i=1){let r=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,r.indexOf(t));return{angle:.82*-Math.PI+(r.length>1?o/(r.length-1):.5)*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function ji(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,a=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*a-1.2*e.delay-5*o))}function Bi(e){let t=function(e,t,i){let[r,o]=e,a=220>r||160>o,n=Math.round(.48*o),l=a?o-Math.max(3,Math.min(12,.1*o)):o-36,s=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,s.length),u=.22*r,d=c>1?(.78*r-u)/(c-1):0,h=a?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:l-(a?Math.min(i,Math.max(3,.22*o)):i),floorY:l,gates:s.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(a?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(a?.72:.84)),graveyardY:l-4,height:o,routeY:n,socketX:Math.round(r*(a?.82:.92)),startX:h,width:r}}(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),a={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{let l=function(e,t,i,r,o){let a=Ii(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=r.map(e=>e.id),l=[...Ii(e,t,i.positiveAccessor,n)],s=[...Ii(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:a,activePositiveIds:l,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Ii(e,t,i.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!l.includes(e)),negativeIds:s,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Ii(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Ii(e,t,i.initialViability,100)}}(t,n,a,i,o);return{...l,viability:e.viability?.(l,{negativeProperties:o,positiveProperties:r})??ji(l,r,o)}}),l=n.flatMap((i,a)=>{let n=function(e,t,i,r){let o=function(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}(i),a=r?.(e,t,i)??{};return{...o,...a,startY:a.startY??a.routeY??o.startY,socketY:a.socketY??a.routeY??o.socketY,graveyardY:a.graveyardY??o.graveyardY}}(i,a,t,e.projectPlacement);return function(e,t,i,r,o,a,n){let l=Ni(i),s=Math.max(3,28*l),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*l:0),d=n?.(e,t,i,r)??{},h=d.x??c,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:Di(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:p}],g=Ei(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||s,i);y[0].x=g.x,y[0].y=g.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let a=Wi(e.activePositiveIds,t,l),n=r.radius??Math.max(2,10*l),s=Ei(g.x+Math.cos(a.angle)*a.radius,g.y+Math.sin(a.angle)*a.radius,n,i);y.push({id:zi(e.id,t),x:s.x,y:s.y,vx:18*Math.cos(a.angle),vy:18*Math.sin(a.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:Di(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+a.index%2*4)*l),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=a.get(t);o&&y.push(function(e,t,i,r,o,a,n){let l=Ni(a),s=t.radius??Math.max(2,7.2*l),c=Ei(r+(i%4*12-12)*l,o+(54+12*Math.floor(i/4))*l,s,a);return{id:Oi(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:n,datum:{__gauntlet:!0,kind:jf,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Di(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*l),...t.spring??{}}]}}(e,o,r,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}(i,a,t,n,r,o,e.coreBody)});return{layout:t,states:n,initialSpawns:l,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:Ci(t)}}}function Yi(e=[]){let t=Object.create(null);for(let[i,r]of e)t[i]=r;return t}function Xi(...e){let t=Yi();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function Gi(e){return Xi(e)}function Vi(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function Hi(e){let t=Yi(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:Gi(t.initialMetrics),metrics:Gi(t.metrics),productIds:[...t.productIds],history:Vi(t.history)}])),i=Yi(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:Gi(t.metrics),sourceIds:[...t.sourceIds],history:Vi(t.history)}])),r=Yi(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?Gi(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:Gi(e.input.metrics)},metrics:Gi(e.metrics),loss:{amount:e.loss.amount,metrics:Gi(e.loss.metrics)},history:Vi(e.history)}}function qi(e,t){return t>e?-1:e>t?1:0}function Ui(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function Zi(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(qi)}function Ki(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[Ui("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Qi(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function Ji(e,t,i="selector"){let r=[],o=Object.values(e.components),a=new Set(o.map(e=>e.id)),n=(t.ids??[]).filter(e=>!a.has(e));if(n.length&&r.push(Ui("error","unknown-component",`Selector references unknown component id${1===n.length?"":"s"}: ${n.join(", ")}.`,i+".ids",n)),void 0!==t.count&&(!Number.isInteger(t.count)||0>t.count)&&r.push(Ui("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let l=t.ids?new Set(t.ids):null,s=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!l||l.has(e.id)).filter(e=>!s||s.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(qi);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(Ui("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function er(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function tr(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function ir(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(Ui("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function rr(e,t,i){let r=Zi(t);t.length||e.diagnostics.push(Ui("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(Ui("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(Ui("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let a=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);a.length&&e.diagnostics.push(Ui("error","source-already-assigned",`Source component${1===a.length?" is":"s are"} already assigned: ${a.join(", ")}.`,i,a));let n=t.filter(t=>"consumed"===e.state.components[t]?.status&&!a.includes(t));return n.length&&e.diagnostics.push(Ui("error","source-unavailable",`Consumed source component${1===n.length?" is":"s are"} unavailable: ${n.join(", ")}.`,i,n)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function or(e,t,i,r,o){let a=r?.amount??0;(!Number.isFinite(a)||0>a||a>t+Yf)&&e.diagnostics.push(Ui("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...Ki(r?.metrics,o+".metrics"));for(let[t,a]of Object.entries(r?.metrics??{}))(0>a||a>Number(i[t]??0)+Yf)&&e.diagnostics.push(Ui("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function ar(e,t,i,r,o,a,n){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:a&&void 0!==e.amount?e.amount:i,metrics:a&&e.metrics?Xi(r,e.metrics):Gi(r),status:a?"complete":"forming",sourceIds:[...t],outletId:a?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:a?o.event.id:void 0,completedAt:a?o.context.appliedAt:void 0,history:[n]}}function nr(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>Yf&&e.diagnostics.push(Ui("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function lr(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(Ui("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,r+".state")),e.diagnostics.push(...Ki(t.metricsDelta,r+".metricsDelta")),ir(e,t.outletId,r+".outletId");let i=Ji(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let a=i.ids.filter(e=>o.components[e].productIds.length);if(a.length&&e.diagnostics.push(Ui("error","source-already-assigned",`Assigned source components cannot be retargeted: ${a.join(", ")}.`,r+".select",a)),e.diagnostics.some(e=>"error"===e.severity))return;let n=er(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&Qi(i.metrics,t.metricsDelta),i.history.push(n)}return o.history.push(n),void(i.ids.length&&tr(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(Ui("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,r+".relation.id",[i.id]));let a=function(e,t,i){let r=Zi(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(Ui("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(Ui("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(Ui("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,i.sourceIds,r+".relation.sourceIds");if(e.diagnostics.push(...Ki(i.metrics,r+".relation.metrics")),!a||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?Gi(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let n=er(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(n),void tr(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=Zi(t.relationIds),a=t.relationIds.filter(e=>!o.relations[e]),n=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(Ui("error","duplicate-relation","Relation ids must be unique.",r+".relationIds",i)),a.length&&e.diagnostics.push(Ui("error","unknown-relation",`Unknown relation: ${a.join(", ")}.`,r+".relationIds",a)),n.length&&e.diagnostics.push(Ui("error","resolved-relation",`Relation is already resolved: ${n.join(", ")}.`,r+".relationIds",n)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let l=er(e,t,{relationIds:[...t.relationIds]});return o.history.push(l),void tr(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(Ui("error","unknown-product",`Product "${t.productId}" has no declared mold.`,r+".productId",[t.productId]));let a=o.products[t.productId];"combine"===t.type&&a&&e.diagnostics.push(Ui("error","duplicate-product",`Product "${t.productId}" has already been formed.`,r+".productId",[t.productId])),"contribute"===t.type&&(!a||"forming"!==a.status)&&e.diagnostics.push(Ui("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,r+".productId",[t.productId]));let n=rr(e,t.sourceIds,r+".sourceIds"),l="contribute"===t.type&&a?[...a.sourceIds,...t.sourceIds]:t.sourceIds,s=function(e,t,i,r){if(!t?.length)return[];let o=Zi(t),a=t.filter(t=>!e.state.relations[t]),n=t.filter(t=>"resolved"===e.state.relations[t]?.status),l=new Set(i),s=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!l.has(e)));return o.length&&e.diagnostics.push(Ui("error","duplicate-relation","Basis relations must be unique.",r,o)),a.length&&e.diagnostics.push(Ui("error","unknown-relation",`Unknown basis relation: ${a.join(", ")}.`,r,a)),n.length&&e.diagnostics.push(Ui("error","resolved-relation",`Basis relation is already resolved: ${n.join(", ")}.`,r,n)),s.length&&e.diagnostics.push(Ui("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${s.join(", ")}.`,r,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,l,r+".basisRelationIds");if(!n||!s||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=n.reduce((e,t)=>e+t.amount,0),u=function(e){let t=Yi();for(let i of e)Qi(t,i.metrics);return t}(n);if(!or(e,c,u,t.loss,r+".loss"))return;let d=c-(t.loss?.amount??0);!function(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}(e,u,t.loss);let h,f="combine"===t.type&&!1!==t.complete,p=er(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(f&&nr(e,i,d,r+".productId"),h=ar(i,t.sourceIds,d,u,e,f,p),f&&!ir(e,h.outletId,r+".productId"))return;o.products[t.productId]=h}else h=a,h.sourceIds.push(...t.sourceIds),h.amount+=d,Qi(h.metrics,u),h.history.push(p);for(let e of n)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),function(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;tr(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,s),tr(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(f&&tr(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void function(e,t,i,r,o,a){let n=e.productDefinitions.get(t.id),l=i??n?.outletId??(e.outletIds.has("product")?"product":void 0);if(!ir(e,l,a+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(Ui("error","product-already-complete",`Product "${t.id}" is already complete.`,a,[t.id]));n&&(nr(e,n,t.amount,a+".productId"),void 0!==n.amount&&(t.amount=n.amount),n.metrics&&(t.metrics=Xi(t.metrics,n.metrics))),t.status="complete",t.outletId=l,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let s=er(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:l?[l]:void 0});t.history.push(s),e.state.history.push(s),tr(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:l?[l]:void 0})}(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(Ui("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,r+".productId",[t.productId]))}if("split"===t.type){let i=rr(e,[t.sourceId],r+".sourceId");t.products.length||e.diagnostics.push(Ui("error","empty-split","A split requires at least one product allocation.",r+".products"));let a=t.products.map(e=>e.productId),n=Zi(a);n.length&&e.diagnostics.push(Ui("error","duplicate-product","Split product ids must be unique.",r+".products",n));let l=a.map(t=>e.productDefinitions.get(t)),s=a.filter((e,t)=>!l[t]),c=a.filter(e=>o.products[e]);s.length&&e.diagnostics.push(Ui("error","unknown-product",`Split references undeclared product molds: ${s.join(", ")}.`,r+".products",s)),c.length&&e.diagnostics.push(Ui("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,r+".products",c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||0>o.amount)&&e.diagnostics.push(Ui("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...Ki(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!or(e,u.amount,u.metrics,t.loss,r+".loss"))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??l[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(Ui("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",r+".products"));let p=f?h:t.products.map(()=>d/t.products.length),y=p.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>Yf)return void e.diagnostics.push(Ui("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,r+".products"));let g=Gi(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;let m=er(e,t,{sourceIds:[u.id],productIds:a});if(t.products.forEach((i,a)=>{let n=l[a],s=d>Yf?p[a]/d:1/t.products.length,c=Yi(Object.entries(g).map(([e,t])=>[e,t*s])),h=i.metrics??n.metrics??c,f=ar({...n,amount:p[a],metrics:h},[u.id],p[a],Gi(h),e,!0,m);ir(e,f.outletId,`${r}.products.${a}.productId`)&&(o.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=a,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),tr(e,{type:"split-source",sourceIds:[u.id],productIds:a});for(let t of a)tr(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){ir(e,t.outletId,r+".outletId");let i=Ji(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let a=i.ids.filter(e=>o.components[e].productIds.length);if(a.length&&e.diagnostics.push(Ui("error","source-already-assigned",`Assigned source components cannot be ejected: ${a.join(", ")}.`,r+".select",a)),e.diagnostics.some(e=>"error"===e.severity))return;let n=er(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(n)}return o.history.push(n),void(i.ids.length&&tr(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...Ki(t.metricsDelta,r+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,a;if("run"===t.target)Qi(o.metrics,t.metricsDelta);else if("components"in t.target){let a=Ji(o,t.target.components,r+".target.components");if(e.diagnostics.push(...a.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=a.ids;for(let e of a.ids)Qi(o.components[e].metrics,t.metricsDelta)}else{a=[...t.target.productIds];let i=Zi(a),n=a.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(Ui("error","duplicate-product","Metric target product ids must be unique.",r+".target.productIds",i)),n.length&&e.diagnostics.push(Ui("error","unknown-product-state",`Metric target product has not formed: ${n.join(", ")}.`,r+".target.productIds",n)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of a)Qi(o.products[e].metrics,t.metricsDelta)}return void o.history.push(er(e,t,{sourceIds:i,productIds:a}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(er(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(Ui("error","invalid-outcome","Outcome must be a non-empty string.",r+".outcome"))}function sr(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[Ui("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};let r=Hi(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(lr(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function cr(e,t){return t>e?-1:e>t?1:0}function ur(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function dr(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(cr)}function hr(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function fr(e,t,i,r,o,a){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push(ur("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,a)),r}}function pr(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(ur("error","invalid-metrics","Metrics must be a numeric object.",i)),Yi();let r=Yi();for(let[o,a]of Object.entries(e)){let e=hr(a);null!=e?r[o]=e:t.push(ur("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function yr(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function gr(e){let{id:t,orientation:i,fixed:r,start:o,end:a,openings:n,thickness:l,friction:s,restitution:c}=e,u=function(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+Hf).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],a=e;for(let[e,t]of r)e>a+Hf&&o.push([a,e]),a=Math.max(a,t);return t>a+Hf&&o.push([a,t]),o}(o,a,n);return u.map(([e,o],a)=>({id:1===u.length?t:`${t}:${a}`,friction:s,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:l}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:l}}))}function mr(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function xr(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?mr(e):1}function br(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:xr(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function vr(e){return"crucible:component:"+encodeURIComponent(e)}function wr(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let o=Math.min(...t,e),a=Math.max(...t,e);return a-o>Hf?r[0]+(r[1]-r[0])*Math.sqrt(Math.max(0,e-o)/(a-o)):(r[0]+r[1])/2}function kr(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,a=Math.max(1,Math.min(r,o));return[a,Math.max(a,Math.max(r,o))]}function Ar(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function Sr(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function Mr(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function _r(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>cr(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>cr(e.id,t.id)),a=[...o.map(e=>e.amount),...r.map(e=>e.amount)],n=kr(i.radiusRange,t),l=function(e,t){let i=new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||cr(e.id,t.id));let i=Ar(o.length,Mr(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}(r,t),s=r.map(e=>{let r=l.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*wr(e.amount,a,i.bodyRadius,n),s={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(c=e.id,"crucible:product:"+encodeURIComponent(c)),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:s};var c}),c=new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=Sr(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=new Map;for(let[e,i]of c){let r=Ar(i.length,Mr(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>l.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=mr(e.id)/4294967295*Math.PI*2,a=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*a,y:r.y+Math.sin(o)*a}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=wr(e.amount,a,i.bodyRadius,n),s={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:vr(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:s}}),...s]}function Pr(e){return Array.isArray(e)?e.map(Pr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>cr(e,t)).map(([e,t])=>[e,Pr(t)])):e}function Lr(e,t=e.duration){let i=function(e,t){let i=hr(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-Hf,a=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&e.end>r)??e.phases[0];return{elapsed:r,phaseId:a.id,phaseIndex:a.index,phaseElapsed:o?a.duration:Math.max(0,r-a.start),complete:o}}(e,t),r=Hi(e.initialState),o=[],a=[],n=[];for(let t of e.events){if(t.authoredAt>i.elapsed+Hf)break;let l=sr(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...l.diagnostics),a.push(...l.materializations),n.push(...l.observations),l.applied&&(r=l.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:a,observations:n}}function $r(e){let t=function(e){let t=[];e.length||t.push(ur("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=dr(e.map(e=>e.id));i.length&&t.push(ur("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=hr(e.duration),a=null!=o&&o>0?o:0;e.id.trim()||t.push(ur("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||0>=o)&&t.push(ur("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push(ur("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let n={...e,duration:a,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+a};return r=n.end,n}),diagnostics:t}}(e.phases),i=t.phases.at(-1)?.end??0,r=yr(e.outlets??Gf),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?Xi(e.metrics):void 0})),a=function(e,t,i){let r=[],o=dr(e.map(e=>e.id));o.length&&r.push(ur("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let a=[];return e.forEach((e,o)=>{let n,l,s;if(e.id.trim()||r.push(ur("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let a=hr(e.at.time);if(null==a||0>a||a>i+Hf)return void r.push(ur("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));n=Math.max(0,Math.min(i,a));let c=function(e,t,i){let r=e.find(e=>Hf>=Math.abs(e.start-i));if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:Hf>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,i,n);l=c.phase,s=c.boundaryRank}else{if(l=t.find(t=>t.id===e.at.phaseId),!l)return void r.push(ur("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void r.push(ur("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));n=l.start+l.duration*i,s=0===i?1:0}l?a.push({...e,index:o,authoredAt:n,phaseId:l.id,phaseIndex:l.index,boundaryRank:s}):r.push(ur("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),a.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:a,diagnostics:r}}(e.events??[],t.phases,i),n=function(e){let t=[],i=Yi(),r=[],o=0,a=Yi();e.data.forEach((n,l)=>{let s=(n.id??"component-"+l)+"",c=((fr(n,l,e.idAccessor,s,t,`data.${l}.id`)??s)+"").trim();if(!c)return void t.push(ur("error","invalid-component-id","Component ids may not be empty.",`data.${l}.id`));r.push(c);let u=hr(fr(n,l,e.amountAccessor,1,t,`data.${l}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(ur("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${l}.amount`,[c]));let h=pr(fr(n,l,e.metricsAccessor,{},t,`data.${l}.metrics`),t,`data.${l}.metrics`),f=fr(n,l,e.initialStateAccessor,"active",t,`data.${l}.status`),p=Vf.has(f)?f:"active";Vf.has(f)||t.push(ur("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${l}.status`,[c]));let y=fr(n,l,e.labelAccessor,(n.label??n.name??c)+"",t,`data.${l}.label`)+"",g=fr(n,l,e.categoryAccessor,"component",t,`data.${l}.category`)+"";Object.hasOwn(i,c)||(i[c]={id:c,label:y,category:g,datum:n,status:p,initialAmount:d,amount:d,initialMetrics:Xi(h),metrics:Xi(h),productIds:[],history:[]},o+=d,function(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}(a,h))});let n=dr(r);n.length&&t.push(ur("error","duplicate-component-id",`Component ids must be unique: ${n.join(", ")}.`,"data",n));let l=pr(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:Yi(),relations:Yi(),input:{amount:o,metrics:a},metrics:l,loss:{amount:0,metrics:Yi()},history:[]},diagnostics:t}}(e),l=function(e=Xf,t=Gf){let i=Math.max(1,hr(e[0])??900),r=Math.max(1,hr(e[1])??520),o=360>i||260>r,a=o?Math.max(4,.035*Math.min(i,r)):20,n=o?Math.max(10,.075*r):34,l={x:a,y:a,width:Math.max(1,i-2*a),height:n},s=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:a,y:r-a-s,width:Math.max(1,i-2*a),height:s},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=l.y+l.height+(o?12:38),h=c.y-(o?10:34),f={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,o?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(o?10:24),width:p,height:o?12:28},g=yr(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{let r=Math.max(8,u-1.5*a),n=f.height/Math.max(1,t.length);t.forEach((t,l)=>{x.push({...t,side:e,x:"left"===e?a:i-a-r,y:f.y+l*n,width:r,height:Math.max(8,n-(o?2:8))})})};b("left",m.left),b("right",m.right);let v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-f.y-f.height-(o?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:l,chamber:f,mouth:y,projection:c,outlets:x}}(e.size??Xf,r),s=function(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),a=Math.min(t.x+t.width,i.x+i.width),n={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},l=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:a,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];l.push(...gr({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:n.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...gr({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:n.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...gr({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:n.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)l.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return l}(l),c=function(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=dr(t.map(e=>e.id)),a=dr(e.map(e=>e.id));return o.length&&i.push(ur("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),a.length&&i.push(ur("error","duplicate-product-id",`Product ids must be unique: ${a.join(", ")}.`,"products",a)),t.forEach((e,t)=>{e.id.trim()||i.push(ur("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push(ur("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(ur("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||0>e.amount)&&i.push(ur("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push(ur("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),pr(e.metrics??{},i,`products.${t}.metrics`)}),i}(o,r),u=(m={seed:e.seed??1,components:Object.values(n.state.components).sort((e,t)=>cr(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:a,color:n,metrics:l})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:a,color:n,metrics:l})),products:o,outlets:r,events:a.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:a,boundaryRank:n,effects:l})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:a,boundaryRank:n,effects:l}))},JSON.stringify(Pr(m))),d=function(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>cr(e.id,t.id)),o=r.map(e=>e.amount),a=kr(i.radiusRange,t),n=function(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}}(xr(i.seed)),l=t.mouth.x+t.mouth.width/2,s=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(n()-.5),h=wr(e.amount,o,i.bodyRadius,a),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:vr(e.id),x:l+Math.cos(d)*c*(.45+.45*n()),y:s+Math.sin(d)*u*(.45+.45*n()),vx:24*(n()-.5),vy:18*(n()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(n.state,l,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...a.diagnostics,...n.diagnostics,...c],f={phases:t.phases,events:a.events,products:o,outlets:r,duration:i,initialState:n.state,terminalState:n.state,layout:l,colliders:s,config:br(e.seed,s),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},p=Lr(f),y=Object.values(p.state.products).filter(e=>"forming"===e.status).map(e=>e.id),g=y.length?[ur("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${y.join(", ")}.`,"events",y)]:[];var m;return f.terminalState=p.state,f.terminalSpawns=qf(p.state,l,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...h,...p.diagnostics,...g],f}function Tr(e,t){let i=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=i,[78,121,167]}let o=e.fillStyle;if(e.fillStyle=i,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];let a=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return a?[+a[1],+a[2],+a[3]]:[78,121,167]}function Rr(e){switch(e){case"monotoneX":return Zf;case"monotoneY":return Kf;case"cardinal":return Qf;case"catmullRom":return Jf;case"step":return ep;case"stepBefore":return tp;case"stepAfter":return ip;case"basis":return rp;case"natural":return op;default:return null}}function Cr(e,t,i){if(null==t)return i;if(ai(t)){let r=function(e,t){let i=e.background??"transparent",r=e.stroke??"#000",o="transparent"===i||"none"===i?i:tu(t,i)||i,a=tu(t,r)||r||"#000",n="u">typeof window&&window.devicePixelRatio||1,l=`${ni(e)}|${o}|${a}@${n}`,s=uf.get(l);if(void 0!==s)return s;let c=function(e={},t){let i,{background:r="transparent",stroke:o="#000",lineWidth:a=1.5,spacing:n=6,angle:l=45}=e,s={background:r,stroke:o,lineWidth:a,spacing:n,angle:l},c=Math.max(8,Math.ceil(2*n));try{i=function(e){return"u">typeof OffscreenCanvas?new OffscreenCanvas(e,e):(lf||(lf=document.createElement("canvas")),lf.width=e,lf.height=e,lf)}(c)}catch{return oi(s)}let u=i.getContext("2d");if(!u)return oi(s);r&&"transparent"!==r?(u.fillStyle=r,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=a,u.lineCap="square";let d=l*Math.PI/180;if(45===l||-45===l){let e=l>0?1:-1;for(let t=-c;2*c>=t;t+=n)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);let e=2*c;for(let t=-e;e>=t;t+=n)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(i,"repeat")}({background:o,stroke:a,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=ai(c)?null:c;return uf.set(l,u),u}(t,e);return r||t.background&&tu(e,t.background)||i}return"string"!=typeof t?t:tu(e,t)||i}function Ir(e,t,i){let r=Cr(e,t,i);if("string"==typeof r&&r.trim().startsWith("var(")){let t=tu(e,i);return t&&!t.trim().startsWith("var(")?t:i}return r}function Dr(e,t,i,r,o,a,n){let l=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>l.length)return null;let s=e.createLinearGradient(r,o,a,n);for(let t of l)s.addColorStop(Math.max(0,Math.min(1,t.offset)),zr(e,t,i));return s}function zr(e,t,i){let r=t.color??i,o=tu(e,r)||r;if(null==t.opacity)return o;let a=Math.max(0,Math.min(1,t.opacity)),[n,l,s]=Tr(e,o);return`rgba(${n},${l},${s},${a})`}function Or(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function Fr(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let a="circle"===e.shape.type?e.shape.radius:8,n="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",l="string"==typeof t.stroke?t.stroke:"#26323a",s="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:"crucible-body-"+i;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*a},${e.y+Math.sin(r)*a}`}).join(" "),i=u+"-glow";return np(Uf.Fragment,{children:[ap("defs",{children:ap("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:ap("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:n,floodOpacity:"0.8"})})}),ap("polygon",{points:t,fill:n,stroke:l,strokeWidth:s,opacity:c,filter:`url(#${i})`}),ap("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*a),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:s,opacity:.72*c})]},u)}return np(Uf.Fragment,{children:[ap("circle",{cx:e.x,cy:e.y,r:a,fill:n,stroke:l,strokeWidth:s,opacity:c}),ap("circle",{cx:e.x-.25*a,cy:e.y-.28*a,r:Math.max(1,.18*a),fill:"rgba(255,255,255,0.34)"})]},u)}function Nr(e){let{x:t,y:i,width:r,height:o}=e.chamber,a=Math.min(.14*r,48),n=i+o;return[`M ${t} ${i}`,`L ${t+a} ${n-.16*o}`,`Q ${t+r/2} ${n+.1*o} ${t+r-a} ${n-.16*o}`,`L ${t+r} ${i}`].join(" ")}function Er({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return cp("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[cp("defs",{children:[cp("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[sp("stop",{offset:"0",stopColor:hp,stopOpacity:"0.03"}),sp("stop",{offset:"0.66",stopColor:hp,stopOpacity:"0.1"}),sp("stop",{offset:"1",stopColor:fp,stopOpacity:"0.18"})]}),sp("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:sp("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:up,strokeOpacity:"0.08",strokeWidth:"1"})})]}),sp("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:up,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),sp("path",{d:Nr(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),sp("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:up,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:sp("g",{"data-testid":"crucible-phase-rail",children:t.map((r,a)=>{let n=t.slice(0,a).reduce((e,t)=>e+Math.max(0,t.duration),0),l=e.phaseRail.x+n/o*e.phaseRail.width,s=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>a||i.complete;return cp("g",{children:[sp("rect",{x:l,y:e.phaseRail.y,width:Math.max(1,s-2),height:e.phaseRail.height,rx:2,fill:c?r.color??hp:u?pp:up,fillOpacity:c?.68:u?.28:.09}),46>s?null:sp("text",{x:l+s/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?up:dp,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()})]},r.id)})}),e.outlets.map(e=>cp("g",{children:[sp("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?fp:pp),fillOpacity:"0.1",stroke:e.color??("left"===e.side?fp:pp),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:sp("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:dp,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function Wr({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",a=e.map(e=>Math.max(0,function(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}(e,o))),n=Math.max(1,...a),l=t.projection.width/Math.max(1,e.length),s=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-s-5);return sp("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=a[i],d=Math.max(u>0?2:0,u/n*c),h=t.projection.x+i*l+.18*l;return cp("g",{children:[sp("rect",{x:h,y:t.projection.y+c-d,width:Math.max(3,.64*l),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?fp:"complete"===e.status?hp:pp,fillOpacity:"0.68"}),s>4&&l>=34?cp(lp,{children:[sp("text",{x:h+.32*l,y:t.projection.y+c+10,fill:dp,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),cp("text",{x:h+.32*l,y:t.projection.y+c+19,fill:up,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Or(u),"amount"===o&&r?" "+r:""]})]}):null]},e.key)})})}function jr(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Br(e,t,i,r,o){let a=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==a.length)return({size:o})=>{let n=[Number(o[0])||700,Number(o[1])||420],l=Wc(n),s=Math.max(2,Math.round(t)),c=l.plot.width/s,u=l.plot.y+l.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==i,[f,p]=r?.valueExtent??[0,s],y=p===f?1:p-f,g=e.map((e,t)=>{let i=u-e.value/d*l.plot.height*.9;return`${0===t?"M":"L"} ${(l.plot.x+(t+.5)*c).toFixed(1)} ${i.toFixed(1)}`}).join(" ");return mp("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?mp(yp,{children:[Array.from({length:s+1},(e,t)=>{let i=l.plot.x+t*c;return gp("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:l.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),gp("line",{x1:l.plot.x,x2:l.plot.x+l.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),gp("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?gp("text",{x:l.plot.x+(t+.5)*c,y:Math.max(l.plot.y+10,u-e.value/d*l.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,a.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=l.plot.x+Math.max(0,Math.min(1,(i-f)/y))*l.plot.width,o=e.color??"var(--semiotic-warning, #f28e2b)",a="bottom"===e.labelPosition?Math.min(n[1]-8,u+16):l.plot.y+16;return mp("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[gp("line",{x1:r,x2:r,y1:l.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:gp("text",{x:Math.min(l.plot.x+l.plot.width-4,r+6),y:a,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function Yr(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=Wc(r),a=Math.max(1,t.windowCount),n=t.plot??o.plot,l=t.gutter??{x:n.x,y:n.y,width:0,height:n.height},s=t.windowPlot??n,c=s.width/a,u=n.y+n.height,d=n.y+.48*n.height,h=t.lidSegments[0]?.y1??d,f=t.windowStart,p=t.windowStart+a*t.windowSize,y=s.x+Math.max(0,Math.min(1,p===f?0:(t.watermarkValue-f)/(p-f)))*s.width;return mp("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[gp("rect",{x:n.x,y:n.y,width:n.width,height:n.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),l.width>0?mp("g",{children:[gp("rect",{x:l.x,y:h,width:l.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),mp("text",{x:l.x+l.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:a},(i,o)=>{let a=e[o],n=s.x+o*c,l=t.closedWindowCount>o;return mp("g",{children:[gp("rect",{x:n,y:d,width:c,height:u-d,fill:l?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:l?.08:.06}),l?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>gp("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,gp("text",{x:n+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:a?.value??0}),gp("text",{x:n+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:a?.label??""})]},"window-"+o)}),t.windowWalls?.map(({id:e,...t})=>gp("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>gp("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),gp("line",{x1:n.x,x2:n.x+n.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),gp("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:n.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),mp("text",{x:Math.min(n.x+n.width-4,y+6),y:n.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Xr(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],a=Wc(o),n=vi(a.plot,e.length,t),l=a.plot.y+a.plot.height;return mp("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[gp("line",{x1:a.plot.x,x2:a.plot.x+a.plot.width,y1:l,y2:l,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(a.plot.height,n.pileHeight(e.value/r)),s=n.tubeWidth,c=n.centerX(t),u=l-i;return mp("g",{children:[gp("rect",{x:c-s/2,y:u,width:s,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),gp("text",{x:c,y:Math.max(a.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),gp("text",{x:c,y:Math.min(o[1]-8,l+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),gp("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function Gr(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Vr(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=Wc(i),o=r.plot.y+r.plot.height,[a,n]=e.xExtent,l=a+(n-a)/2,s=[{label:Gr(a),x:e.xRange[0]},{label:Gr(l),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Gr(n),x:e.xRange[1]}];return mp("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?gp("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>i[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>mp("g",{children:[gp("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),gp("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),mp("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),gp("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),s.map(e=>mp("g",{children:[gp("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),gp("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function Hr(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:a,groups:n,groupCompletion:l}=e,s=new Map(o.stages.map(e=>[e.id,e])),c=new Map(l.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,l=Number(e[1])||o.height,u=a.map(e=>{let t=s.get(e.id),r=i["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=n.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return Xu({width:t,height:l,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function qr(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],a=Wc(o),n=Math.max(1,...e.map(e=>e.value)),l=Math.min(48,.18*a.plot.height),s=a.plot.y+6;return xp("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let a=r.get(t.id);if(!a)return null;let c=Math.max(2,o.value/n*l),u=Math.max(8,.35*a.width);return xp("rect",{x:a.x-u/2,y:s,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function Ur(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function Zr(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let a=[Number(t[0])||760,Number(t[1])||420],n=Math.max(1,...e.links.map(e=>e.throughput)),l=new Set(e.nodes.map(e=>e.sensorId));return vp("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/n*16,i=e.path[Math.floor(e.path.length/2)];return vp("g",{children:[bp("path",{d:Ur(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),bp("path",{d:Ur(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?bp("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(r=e.throughput,r.toLocaleString(void 0,1e3>Math.abs(r)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},e.id);var r}):null,e.nodes.map(e=>vp("g",{children:[r&&l.has(e.sensorId)?bp("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?bp("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?bp("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}function Kr({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);return kp(wp,{children:e.gates.map(a=>Ap("g",{children:[kp("rect",{x:a.x-a.width/2,y:r,width:a.width,height:o,rx:t?2:12,fill:a.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:a.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?kp("text",{x:a.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:a.label??a.id}):null]},a.id))})}function Qr({layout:e,states:t,compact:i=!1}){return i?kp("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:kp(Kr,{layout:e,compact:!0,showLabels:!1})}):Ap("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[kp("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-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),kp("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),kp("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),kp(Kr,{layout:e,compact:!1,showLabels:!0}),Ap("g",{children:[kp("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),kp("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),Ap("g",{children:[kp("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),kp("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),kp("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 Jr({states:e,layout:t}){let i=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(!i.length)return null;let r=Math.max(1,...i.map(e=>e.value)),o=Math.max(40,(t.width-80)/i.length);return Ap("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:[kp("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,a=Math.max(2,e.value/r*28),n=/kill|crash|block|grave/i.test(e.outcome);return Ap("g",{children:[kp("rect",{x:i+.18*o,y:28-a+22,width:Math.max(10,.45*o),height:a,rx:2,fill:n?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:n?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),kp("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function eo(e){return e.map(e=>({...e,spawnAt:void 0}))}function to(e,t){return e?t?i=>Of.createElement(Of.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function io(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}function ro(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return Mp[(t>>>0)%Mp.length]}function oo(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let i=Wp.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;let r=Date.parse(i);return Number.isFinite(r)?r:NaN}function ao(e){return e instanceof Date?e.getTime():"string"==typeof e?oo(e):+e}function no(e){return new Set(Array.isArray(e)?e:[e])}function lo(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function so(e,t){return Math.min((e-t.startTime)/t.duration,1)}function co(e,t,i){return e+(t-e)*i}function uo(){return"u">typeof performance?performance.now():Date.now()}function ho(e,t,i){if(1>=i)return 1;let r=i-1;return function(e){let 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;let i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function fo(e){let t=new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function po(e,t,i){let r=e.duration??500,o=i-t;return r>o?1-o/r:0}function yo(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function go(e,t,i=("u">typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&r>i-o}function mo(e,t,i){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){let i=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function xo(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function bo(e){jp[e.chartType]=e}function vo(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;wo(r)&&0===i.length&&ko(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&ko(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function wo(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(wo))}function ko(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Ao(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=function(e,t,i,r){let o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),a="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:a,message:`Semiotic ${e} ${a} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function So(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?NaN:+t}}function Mo(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=So(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=Xc(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:So(e.y1Accessor,"y1"),getBottom:So(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function _o(e,t,i,r,o,a=!1){let n=new Map;for(let l of e){let e=t(l),s=i(l);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;let c=Math.floor(e/r)*r,u=n.get(c);if(u||(u={start:c,end:c+r,total:0,categories:new Map,...a?{rows:[],categoryRows:new Map}:{}},n.set(c,u)),u.total+=s,u.rows?.push(l),o){let e=o(l);if(u.categories.set(e,(u.categories.get(e)||0)+s),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(l)}}}return n}function Po(e,t,i,r,o){let a=[];for(let n of e){let e=i(n),l=r(n),s=o?o(n):0;if(!Number.isFinite(e)||!Number.isFinite(l)||!Number.isFinite(s))continue;let c=t.x(e),u=t.y(l),d=o?t.y(s):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||a.push({x:c,y:u,bottom:d,raw:l,datum:n})}a.sort((e,t)=>e.x-t.x);let n=Array(a.length),l=o?Array(a.length):[],s=Array(a.length),c=Array(a.length);for(let e=0;a.length>e;e++){let t=a[e];n[e]=[t.x,t.y],o&&(l[e]=[t.x,t.bottom]),s[e]=t.raw,c[e]=t.datum}return{topPath:n,bottomPath:l,rawValues:s,datum:c}}function Lo(e,t,i,r,o,a){let{topPath:n,rawValues:l,datum:s}=Po(e,t,i,r);return{type:"line",path:n,rawValues:l,style:o,datum:s,group:a}}function $o(e,t,i,r,o,a,n,l){return{type:"area",...Po(e,t,i,r,l??(()=>o)),style:a,group:n}}function To(e,t,i,r){let o=new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){let a=e[r-1],n=e[r],l=0,s=0,c=0;for(let e of t){let t=i(e,n)||0;l+=(2*c+t)*(t-(i(e,a)||0)),s+=t,c+=t}let u=o.get(a)??0;o.set(n,u-(s>0?l/(2*s):0))}if(e.length>0){let r=0;for(let a of e){let e=0;for(let r of t)e+=i(r,a)||0;r+=(o.get(a)??0)+e/2}let a=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-a)}}else for(let t of e)o.set(t,0);return o}function Ro(e,t,i,r,o,a,n){let l=i(e),s=r(e);if(!Number.isFinite(l)||!Number.isFinite(s))return null;let c={type:"point",x:t.x(l),y:t.y(s),r:o,style:a,datum:e};return void 0!==n&&(c.pointId=n),c}function Co(e,t,i,r,o,a,n,l){let s=i(e),c=r(e);if(!Number.isFinite(s)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(s),y:t.y(c),size:o,symbolType:a,style:n,datum:e};return void 0!==l&&(u.pointId=l),u}function Io(e,t,i,r,o,a,n){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:a,group:n}}function Do(e,t,i,r,o,a,n){let l={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:a};return void 0!==n?.value&&(l.value=n.value),n?.showValues&&(l.showValues=!0,n.valueFormat&&(l.valueFormat=n.valueFormat)),l}function zo(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Oo(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return Gp().domain(e).range(i).clamp(!0)}return"symlog"===e?Vp().domain(t).range(i):"time"===e?Hp().domain([new Date(t[0]),new Date(t[1])]).range(i):Xp().domain(t).range(i)}function Fo(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?X(e,t):void 0}function No(e,t,i){e.capacity>=t||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Eo(e,t){let i=new Np(e.capacity);return e.forEach(()=>i.push(t)),i}function Wo(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function jo(e,t,i){if(!t||0===t.size)return;let r=new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}function Bo(){return this.updateResults.last}function Yo(){return this.updateResults.last}function Xo(e){return this.updateResults.subscribe(e)}function Go(e){this.config.layoutSelection=e}function Vo(){qp.set(this,!0)}function Ho(){let e=!0===qp.get(this);return qp.delete(this),e}function qo(e){Object.assign(e.prototype,{getLastUpdateResult:Bo,getUpdateSnapshot:Yo,subscribeUpdateResult:Xo,setLayoutSelection:Go,markStylePaintPending:Vo,consumeStylePaintPending:Ho})}function Uo(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function Zo(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:a,datum:n}=Po(t,e.scales,e.getX,r.getTop,r.getBottom);return 2>o.length?null:{type:"area",topPath:o,bottomPath:a,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Uo(e,r,i,Se(t)),datum:n,group:i,interactive:r.interactive}}function Ko(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function Qo(e,t,i){let r=[];for(let o of i){let i=Zo(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function Jo(e,t,i,r){let o=[];for(let a of r){let r=Zo(e,t,i,a);r&&o.push(r)}return o}function ea(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let a of r.data){let r=e.config.pointStyle(a);!r.fill&&t&&(r={...r,fill:t});let n=r.r??3,l=e.getPointId?e.getPointId(a)+"":void 0,s=Ro(a,e.scales,e.getX,o,n,r,l);s&&i.push(s)}}}function ta(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function ia(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ra(e,t,i=.3){ia(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function oa(e,t,i,r=.35){ia(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",i?e.fill(i):e.fill())}function aa(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?i.value>e&&(r=i.color):e>i.value&&(r=i.color);return r}function na(e,t,i,r){if(2>e.length||t.length!==e.length||0===i.length)return[];let o=[],a=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){let[n,l]=e[o-1],[s,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){let t=h[e-1],o=h[e];a(aa(u+d*((t+o)/2),i,r),[n+(s-n)*t,l+(c-l)*t],[n+(s-n)*o,l+(c-l)*o])}}return o}function la(e,t){let i=Rr(t.curve);if(!i||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1]);for(let i=t.bottomPath.length-1;i>=0;i--)e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]);e.closePath()}else{let r=hy().x(e=>e[0]).y0((e,i)=>t.bottomPath[i][1]).y1(e=>e[1]).curve(i).context(e);e.beginPath(),r(t.topPath)}}function sa(e,t){let i=Rr(t.curve);if(e.beginPath(),i)fy().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 i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1])}}function ca(e,t,i,r,o,a){if(2>t.length)return;let n=[0];for(let e=1;t.length>e;e++){let i=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];n.push(n[e-1]+Math.sqrt(i*i+r*r))}let l=n[n.length-1];if(0===l)return;let s=Math.min(.2*l,40);e.strokeStyle=i,e.lineWidth=r,e.lineCap=a;for(let i=0;t.length-1>i;i++){let r=(n[i]+n[i+1])/2,a=o;s>r&&(a*=r/s),s>l-r&&(a*=(l-r)/s),e.globalAlpha=Math.max(0,a),e.beginPath(),e.moveTo(t[i][0],t[i][1]),e.lineTo(t[i+1][0],t[i+1][1]),e.stroke()}}function ua(e){return ee(e)}function da(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],a=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)e>r&&(e=r),r>t&&(t=r);a=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let n=e.getColor?e.resolveColorMap(t):null,l=e.config.themeSemantic?.primary||"#4e79a7",s=e.getSymbol,c=s?zu(s,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:l,opacity:.8},s=t.r||r;if(a&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(s=a(t))}if(n&&e.getColor&&!t.fill){let i=e.getColor(o);i&&n.has(i)&&(t={...t,fill:n.get(i)})}let u=e.getPointId?e.getPointId(o)+"":void 0;if(c){let r=c(o),a=Co(o,e.scales,e.getX,e.getY,Math.PI*s*s,r,t,u);a&&i.push(a)}else{let r=Ro(o,e.scales,e.getX,e.getY,s,t,u);r&&i.push(r)}}return i}function ha(e,t,i,r,o,a){if(0>=t.size)return;let n=function(e,t,i){try{if(i)return $u(i);let r=`${e??"circle"}:${t}`,o=ky.get(r);return o||(o=new Path2D(ed(e,t)),ky.size>256&&ky.clear(),ky.set(r,o)),o}catch{return null}}(t.symbolType,t.size,t.path);if(!n)return;e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation);let l=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*l*(t.style.fillOpacity??1),e.fillStyle=Cr(e,t.style.fill,a),e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*l,e.strokeStyle=tu(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(n)),e.restore()}function fa(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function pa(e){let t=Object.prototype.hasOwnProperty.call(Id,e)?e:"blues",i=Ly.get(t);if(i)return i;i=Array(Py);let r=j(t);for(let e=0;Py>e;e++)i[e]=r(e/255);return Ly.set(t,i),i}function ya(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function ga(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),a=e.config.heatmapAggregation??"count",n=Xc(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[l,s]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(s-l||1)/r,h=(u-c||1)/o,f=r*o;if(f>1e6)return[];let p=new Int32Array(f),y=new Float64Array(f),g=e.config.trackHoverRows||Me(e.config.areaStyle)?new Map:void 0;for(let i=0;t.length>i;i++){let a=t[i],s=e.getX(a),u=e.getY(a);if(!isFinite(s)||!isFinite(u))continue;let f=Math.min(Math.floor((s-l)/d),r-1),m=Math.min(Math.floor((u-c)/h),o-1);if(0>f||0>m)continue;let x=m*r+f;p[x]++;let b=n(a);if(y[x]+=isFinite(b)?b:0,g){let e=g.get(x);e||(e=[],g.set(x,e)),e.push(a)}}let m=1/0,x=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(a){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}m>t&&(m=t),t>x&&(x=t)}if(!isFinite(m))return[];let b=e.config.heatmapColorScale,v=b?void 0:pa("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/r,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){let i=t*r;for(let n=0;r>n;n++){let r,s=i+n;if(0===p[s])continue;switch(a){case"sum":r=y[s];break;case"mean":r=y[s]/p[s];break;default:r=p[s]}let u=fa(r,m,x),f=b?b(r):v[u],_=A?{value:r,showValues:!0,valueFormat:S}:{value:r},P=we({xi:n,yi:t,value:r,count:p[s],sum:y[s],xCenter:l+(n+.5)*d,yCenter:c+(t+.5)*h,agg:a},g?.get(s));M.push(ya(Do(n*w,(o-1-t)*k,w,k,f,P,_),P,e))}}return M}function ma(e,t){let[i,r,o]=Tr(e,t);return.299*i+.587*r+.114*o>128?"#000":"#fff"}function xa(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}function ba(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function va(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}function wa(e,t){let{x:i,y:r,w:o,h:a}=t,{tl:n,tr:l,br:s,bl:c}=va(t);e.beginPath(),e.moveTo(i+n,r),e.lineTo(i+o-l,r),l>0&&e.arcTo(i+o,r,i+o,r+l,l),e.lineTo(i+o,r+a-s),s>0&&e.arcTo(i+o,r+a,i+o-s,r+a,s),e.lineTo(i+c,r+a),c>0&&e.arcTo(i,r+a,i,r+a-c,c),e.lineTo(i,r+n),n>0&&e.arcTo(i,r,i+n,r,n),e.closePath()}function ka(e,t){let i=Cr(e,t.style.fill,tu(e,"var(--semiotic-primary, #007bff)")),r=function(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}}}(t);return(t.fillGradient&&"string"==typeof i?Dr(e,t.fillGradient,i,r.x0,r.y0,r.x1,r.y1):null)||i}function Aa(e,t){if(!t.style.stroke||"none"===t.style.stroke)return!1;let i=t.style.strokeWidth??1;return i>0&&(e.strokeStyle=tu(e,t.style.stroke)||t.style.stroke,e.lineWidth=i,!0)}function Sa(e,t){let i=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;let a=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),a){let a=o+r,n=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=a)e.drawImage(i,n,r,o,o)}else{let a=o+r,n=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=a)e.drawImage(i,r,n,o,o)}e.restore()}function Ma(e,t,i,r,o){if(0>=t.size)return;let a=t.glyph;if(!a||!a.parts?.length)return;let n=Cu(a,t.size);if(0>=n.scale)return;let l=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=l)return;let s=t=>{let i=Cr(e,t,t);return"string"==typeof i?i:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation),e.translate(n.offsetX,n.offsetY),e.scale(n.scale,n.scale),e.globalAlpha=o*l*(t.style.fillOpacity??1);let u=Tu(a,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Pu(e,a,c,t.accent,t.ghostColor,s),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Pu(e,a,c,t.accent,void 0,s),e.restore()}function _a(){bo(xy),bo(by),bo(vy),bo(wy),bo(My),bo(_y),bo(Ty),bo(Cy),bo(Iy),bo(zy),bo(Fy),bo(Ny)}function Pa(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,a=Array.from(new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),n="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,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:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:n,warnings:a,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function La(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function $a(e){if(!e||2>e.length)return;let t=La(e[0]),i=La(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function Ta(e){let{count:t,byType:i}=function(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let a=Array.isArray(e.annotations)?e.annotations.length:0,n=e.margin,l=n?{x:n.left,y:n.top,width:e.width-n.left-n.right,height:e.height-n.top-n.bottom}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,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:e.annotationRender?.renderedCount??a,...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...n?{margin:n}:{},...l?{plot:l}:{}}}function Ra(e,t="#4e79a7"){return ai(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Ca(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Ia(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;let a=Cu(o,e.size);if(0>=a.scale)return null;let n=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${a.offsetX},${a.offsetY}) scale(${a.scale})`,l=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),s=Tu(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=s?Ca(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:Uu(i.fill,l,e.accent),a=t?i.stroke&&"none"!==i.stroke?t:void 0:Uu(i.stroke??"none",l,e.accent);return o||a?Yy("path",{d:i.d,fill:o??"none",stroke:a,strokeWidth:a?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});return Xy("g",{transform:n,opacity:1===u?void 0:u,children:[s&&c&&Yy("clipPath",{id:c,children:Yy("rect",{x:s.x,y:s.y,width:s.width,height:s.height})}),s&&e.ghostColor?Yy("g",{children:d(e.ghostColor)}):null,s&&c?Yy("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function Da(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>i.length?null:i.map((e,t)=>Yy("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function za(e,t,i){let r=ed(e.symbolType,e.size,e.path);return Yy("path",{d:r,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Ra(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function Oa(e,t,i){let r="point"===e.type,o=r?"circle":"rect",a=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},n=`${i?i+"-":""}${r?"point":"xyrect"}-${t}-hatch`,l=ai(e.style.fill)?li(e.style.fill,n):void 0;return Xy(By.Fragment,{children:[l&&Yy("defs",{children:l}),By.createElement(o,{...a,fill:l?`url(#${n})`:Ra(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function Fa(e){if(!1!==e?.interactive)return e?.style?.cursor}function Na(e,t,i){let r=Fa(t);return r&&null!=e&&!1!==e?Hy("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}function Ea(e,t,i,r){if(!e||2>t.length)return null;let o=Da(e.stops,r);return o?qy("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Wa(e,t,i,r=30){let o=function(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=Rr(r.curve),a=o?jy().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),n=Ca(`${i?i+"-":""}line-${t}-stroke-gradient`),l=Ea(r.strokeGradient,r.path,n,r.style.stroke||"#4e79a7");return Uy(Ey.Fragment,{children:[l&&qy("defs",{children:l}),qy("path",{d:a,fill:"none",stroke:l?`url(#${n})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{let o=e;if(0===o.topPath.length)return null;let a=Rr(o.curve),n=!a||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:Wy().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(a)(o.topPath)??"",l=`${i?i+"-":""}area-${t}-hatch`,s=ai(o.style.fill)?li(o.style.fill,l):void 0,c=Ca(`${i?i+"-":""}area-${t}-gradient`),u=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0;for(let[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(let[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;let a=Da(i.stops,Ra(e.style.fill));return a?qy("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:a}):null}(o,c),d=u?`url(#${c})`:s?`url(#${l})`:Ra(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,f=a?jy().x(([e])=>e).y(([,e])=>e).curve(a)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=Fa(o),y=p&&r>=0?qy("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,g=Ca(`${i?i+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=m||x?null:Ea(o.strokeGradient,o.topPath,g,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)w>e&&(w=e),e>k&&(k=e);let A=x?o.strokeColorBands.map((e,r)=>Ca(`${i?i+"-":""}area-${t}-stroke-band-${r}`)):[],S=x?o.strokeColorBands.map((e,t)=>qy("clipPath",{id:A[t],children:qy("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>qy("path",{d:f,fill:"none",stroke:e.color??Ra(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?na(o.topPath,o.rawValues,o.colorThresholds,Ra(o.style.stroke)).map((e,i)=>qy("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):qy("path",{d:f,fill:"none",stroke:b?`url(#${g})`:Ra(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?i+"-":""}area-clip-${t}`;return Uy("g",{children:[Uy("defs",{children:[u,!u&&s,b,S,qy("clipPath",{id:e,children:qy("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),Uy("g",{clipPath:`url(#${e})`,children:[qy("path",{d:n,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]})]},"area-"+t)}return Uy(Ey.Fragment,{children:[(u||s||b||S)&&Uy("defs",{children:[u,!u&&s,b,S]}),qy("path",{d:n,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]},"area-"+t)}case"point":case"rect":return Oa(e,t,i);case"symbol":return za(e,t);case"glyph":return Ia(e,e.x,e.y,`${i??""}glyph-${e.pointId??t}`);case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,a,n]=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)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(i.fill),l=.299*o+.587*a+.114*n>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return Uy("g",{children:[qy("rect",{...r}),qy("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:s+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},"heatcell-"+t)}return qy("rect",{...r},"heatcell-"+t)}case"candlestick":{let r=e,o=`${i?i+"-":""}candle-${t}-hatch`,a=ai(r.style?.fill)?li(r.style.fill,o):void 0,n=a?`url(#${o})`:void 0,{fill:l,...s}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=n??r.wickColor;return Uy(Ey.Fragment,{children:[a&&qy("defs",{children:a}),Uy("g",{style:s,children:[qy("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),qy("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),qy("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},"candle-"+t)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=n??d;return Uy(Ey.Fragment,{children:[a&&qy("defs",{children:a}),Uy("g",{style:s,children:[qy("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),qy("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:n?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},"candle-"+t)}default:return null}}(e,t,i,r);return"area"===e.type?o:Na(o,e,"xy-cursor-"+t)}function ja(e){let{node:t,index:i,renderMode:r,fallback:o}=e,a=function(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return(r=i)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?i:void 0;var r}(r,t);if(!a)return{element:o(),renderedByBackend:!1};let n=a.renderStaticSVG({node:t,style:t.style??{},key:`${a.id}-${i}`});return null!=n?{element:Na(n,t,`${a.id}-${i}-cursor`),renderedByBackend:!0}:(function(e,t){if("u">typeof process&&"production"===process.env?.NODE_ENV)return;let i=`${e}:${t}`;Zy.has(i)||(Zy.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}(a.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Ba(e){let t=[];return e.nodes.forEach((i,r)=>{let o=ja({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!=o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}function Ya(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>X(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:vd;return Ky().domain(e).range(r)}function Xa(e,t,i){if(0===e.length)return;let r=Ya(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function Ga(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Va(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Ha(e){return e.typography.legendFontFamily??e.typography.fontFamily}function qa(e){return e.typography.legendFontWeight}function Ua(e,t,i,r){let o=Va(r);return t+i+Math.ceil(e.length*o*.58)}function Za(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:a,legendLayout:n}=e,{swatchSize:l,labelGap:s,itemGap:c,rowHeight:u}=v(n),d=l+s,h="top"===r||"bottom"===r,f=Math.max(l,o-a.left-a.right),p=t.map(e=>Ua(e,l,s,i));if(h){let e=Math.max(l,n?.maxWidth??f),i=[],r=0,o=0;p.forEach((t,a)=>{let n=0===o?t:o+c+t;o>0&&n>e?(i.push({start:r,end:a,width:o}),r=a,o=t):o=n}),t.length>0&&i.push({start:r,end:t.length,width:o});let a=Ga(n?.align),s=[];return i.forEach((i,r)=>{let o="center"===a?Math.max(0,(e-i.width)/2):"end"===a?Math.max(0,e-i.width):0;for(let e=i.start;i.end>e;e++)s.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:s,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:l,labelOffset:d,swatchRadius:0}}let y=p.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:l,labelOffset:d,swatchRadius:0}}function Ka(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=new Set;for(let t of e){let e=i(t);null!=e&&r.add(e+"")}return Array.from(r)}function Qa(e){let{x:t,y:i,text:r,fill:o,fontSize:a=12,fontWeight:n,fontFamily:l,textAnchor:s="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}(u),f=e=>eg("text",{x:t,y:i,textAnchor:s,dominantBaseline:c,fill:o,fontSize:a,fontWeight:n,fontFamily:l,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??ig,strokeWidth:h.haloWidth??3});let p,y,g=h.padding??{x:6,y:3},m="number"==typeof g?g:g.x,x="number"==typeof g?g:g.y,b=function(e,t){return(e+"").length*t*.6}(r,a),v=a+2*x;return p="middle"===s?t-b/2-m:"end"===s?t-b-m:t-m,y="middle"===c||"central"===c?i-v/2:"hanging"===c||"text-before-edge"===c?i-x:i-.8*a-x,tg("g",{className:d,children:[eg("rect",{x:p,y:y,width:b+2*m,height:v,rx:h.radius??3,ry:h.radius??3,fill:h.fill??ig,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Ja(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};return rg("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}function en({ann:e,position:t,vertical:i,width:r,height:o,color:a,fontSize:n=12,fontFamily:l,bold:s,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,f=t>.6*r,p=i?t+(f?-4:4):"left"===h?4:"center"===h?r/2:r-4,y=i?"bottom"===h?o-4:"center"===h?o/2:16:20>t?Math.min(o-4,t+16):t-d,g=i?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",m=i?[t,0]:[0,t],x=i?[t,o]:[r,t];return ag("g",{opacity:e.opacity,children:[og("line",{x1:m[0],y1:m[1],x2:x[0],y2:x[1],stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),Ja(e.endCap,m,a),e.label&&og(Qa,{x:p,y:y,text:e.label,textAnchor:g,fill:a,fontSize:n,fontFamily:l,fontWeight:s?"bold":void 0,background:c??e.labelBackground??"halo"})]})}function tn(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function rn(e,t,i,r){if(!e)return ng("g",{className:"annotation-note"});let{label:o,title:a,orientation:n,align:l,wrap:s=120,noWrap:c}=e;if(!o&&!a)return ng("g",{className:"annotation-note"});let u=n;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,f=l;(!f||"dynamic"===f)&&(f=d?0>t?"right":"left":0>i?"bottom":"top");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=0>t?"end":"start";let y=e.useHTML||e.html,g=y?void 0:Ou(e),m=g?.lineHeight??16,x=g?.titleLines??(a?c?[a]:rd(a,s,8):[]),b=g?.labelLines??(o?c?[o]:rd(o,s,8):[]),v=x.length+b.length,w=h?"end"===p?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(y)k.push(ng("foreignObject",{className:"annotation-note-html",x:"end"===p?w-s:"middle"===p?w-s/2:w,y:-m,width:s,height:Math.max(m,v*m+(a&&o?2:0))+m,style:{overflow:"visible"},children:lg("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:m+"px",overflow:"visible",textAlign:"end"===p?"right":"middle"===p?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[a&&ng("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:a}),o&&ng("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"));else for(let e of[!0,!1]){let t=e?x:b;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(ng("text",{className:i,fill:A,textAnchor:p,fontWeight:e?g?.titleFontWeight??"bold":void 0,y:e?void 0:x.length*m,children:t.map((e,t)=>ng("tspan",{x:w,dy:0===t?0:m,children:e},t))},i))}let S=null;if((a||o)&&(0!==t||0!==i)){let e=d?g?g.width:Math.min(s,120):(x.length+b.length+(b.length>0?1:0))*m,t=d?p:f,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=ng("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*m,_=0;(d||h)&&(_=h&&"middle"===f?-(M+m+(b.length>0&&x.length>0?2:0))/2+m/2:0>i||h&&"bottom"===f?-(M+2):2+m);let P=0!==_?`translate(0,${_})`:void 0;return lg("g",{className:"annotation-note",transform:`translate(${t},${i})`,...g?.textProps,children:[ng("g",{className:"annotation-note-content",transform:P,children:k}),S]})}function on(e,t,i,r,o){let a=null,n=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(a=ng("circle",{r:e,fill:"none",stroke:n},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(a=ng("rect",{width:e,height:i,fill:"none",stroke:n},"subject-rect"));break}case"callout-custom":a=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,l=0,s=0,c=0,u=0;if(void 0!==t?.x)l=s=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,l=(t.x1||0)-e,s=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)l=(t.x1||0)-e,s=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}a=ng("line",{x1:l,y1:c,x2:s,y2:u,stroke:n,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(a=ng("path",{d:tn(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:n},"bracket-path"));break}}return ng("g",{className:"annotation-subject",children:a})}function an(e,t,i,r,o,a){let n,l,s=0,c=0;if("callout-circle"!==o&&"label"!==o||!a?.radius){if("callout-rect"===o&&a){let i=a.width||0,r=a.height||0;if(i>0||r>0){let o=i/2,a=r/2,n=e-o,l=t-a;if(0!==n||0!==l){let e=Math.abs(n),t=Math.abs(l),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;s=o+n*h,c=a+l*h}}}else if("bracket"===o&&a){let e=a.width,t=a.height,i=a.depth||30;void 0!==e?(s=e/2,c=i):void 0!==t&&(s=i,c=t/2)}}else{let i=(a.radius||0)+(a.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);s=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-s,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",a="curve"===i?.type,f=Math.atan2(d,u);if(a){let r=(s+e)/2,a=(c+t)/2,l=-d/h,p=u/h,y=(i?.curve??.25)*h,g=r+l*y,m=a+p*y;n=ng("path",{className:"connector-curve",d:`M${s},${c}Q${g},${m} ${e},${t}`,fill:"none",stroke:o},"connector-line"),f=Math.atan2(m-c,g-s)}else n=ng("line",{x1:s,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.2792526803190927;l=ng("path",{d:`M${s},${c}L${s+10*Math.cos(f+e)},${c+10*Math.sin(f+e)}L${s+10*Math.cos(f-e)},${c+10*Math.sin(f-e)}Z`,fill:o,stroke:"none"},"connector-arrow")}}return lg("g",{className:"annotation-connector",children:[n,l]})}function nn(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:a,ny:n,note:l,connector:s,subject:c,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(i)?i[0]??0:i,v=Array.isArray(f)?f:[],w=r||0,k=o||0;null!=a&&(w=a-x),null!=n&&(k=n-b);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return lg("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.includes("connector")&&an(w,k,s,d,A,c),!v.includes("subject")&&on(A,c,d,x,b),!v.includes("note")&&rn(l,w,k,d)]})}function ln(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),a=i.map((i,a)=>{let n=Object.assign({},t,{note:0===a?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});return ng(nn,{"data-testid":"semiotic-annotation",...n,type:r},"multi-annotation-"+a)});return ng("g",{children:a})}let a=t.note||{title:"none",label:t.label},n=`${a.label}-${a.title}-${t.i}`;return ng(nn,{"data-testid":"semiotic-annotation",events:o,...t,type:r},n)}function sn(e){return!0===e?._annotationDeferred}function cn(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function un(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function dn(e){return Math.max(.72,.95-.06*e)}function hn(e){let t=e.map((e,t)=>{return{p:e,i:t,emphasis:(i=e.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:un(e.annotation),readingOrder:null,rank:1};var i}),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>sn(e.annotation)),o=e.some(e=>null!=cn(e.annotation)),a=e.some(e=>"layer"===cn(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let n=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);n.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,n.length)});for(let e of t)e.emphasis&&(e.rank=cg[e.emphasis]);let l=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,a=sn(t.annotation),n=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;n=sg("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:dn(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+i)}let l=cn(t.annotation);return l&&(n=sg("g",{className:"annotation-cohesion--"+l,children:n},"annotation-cohesion-"+i)),a&&(n=sg("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:n},"annotation-deferred-"+i)),n});return r&&l.unshift(sg("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")),a&&l.unshift(sg("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 fn(e,t,i,r){let o=function(e,t,i="#4e79a7"){if(ai(e)){let i=function(e,t){let i=2166136261,r=ni(t);for(let e=0;r.length>e;e++)i^=r.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}(t,e);return{fill:`url(#${i})`,def:li(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}(e.fill??e.color,t,r);return function(e,t,i,r){if(!e||"object"!=typeof e)return;let o=e;if(!Array.isArray(o.stops))return;let a=o.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:i,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof i&&i?i:r,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);if(!a.length)return;let n="horizontal"===o.direction?"horizontal":"vertical"===o.direction?"vertical":i,l=t+"-gradient";return{fill:`url(#${l})`,def:sf("linearGradient",{id:l,x1:0,y1:0,x2:"horizontal"===n?"100%":0,y2:"vertical"===n?"100%":0,children:a.map((e,t)=>sf("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},l)}}(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r)??o}function pn(e,t,i){let r=e.position,o="string"==typeof r&&ug.has(r)?r:"bottom-left",a=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",n=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",l="top"===n?0:"bottom"===n?i:i/2;return{x:("left"===a?0:"right"===a?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:l+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===a?"start":"right"===a?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===n?"hanging":"bottom"===n?"auto":"middle"}}function yn(e,t,i,r){return{...pn(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function gn({annotation:e,width:t,height:i,defaults:r=hg}){let o=e.label??e.text;return null==o?null:dg("text",{...yn(e,t,i,r),children:o})}function mn(e,t={}){let i=function(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=function(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function xn(e,t){return e.color||t.colors.annotation||t.colors.text}function bn(e,t,i){let r=e.labelBackground,o=t.colors.background,a=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:a}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:a}:"box"===r?{type:"box",fill:a}:{fill:a,...r}}function vn(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function wn(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function kn(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=zc(t),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,a=!!r&&!e.scales.x&&!e.scales.y,n=e=>Number(e),l=e.scales.x??(a?n:void 0),s=e.scales.y??(a?n:void 0),c=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===e.projection?{x:e.scales.o??l,y:e.scales.r??s,time:e.scales.o??l,value:e.scales.r??s,o:e.scales.o}:"horizontal"===e.projection?{x:e.scales.r??l,y:e.scales.o??s,time:e.scales.r??l,value:e.scales.o??s,o:e.scales.o}:{x:l,y:s,time:l,value:s,o:e.scales.o},...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),...c?{projection:c}:{}},d=e.autoPlaceAnnotations?xu({annotations:o,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,h=function(e,t,i,r){let o=[];return e.forEach((e,a)=>{let n;n=i?i(e,a,r)??t(e,a,r):t(e,a,r),n&&o.push({node:n,annotation:e})}),{nodes:hn(o),renderedAnnotations:o.map(e=>e.annotation)}}(d,(t,i,r)=>function(e,t,i,r){let{scales:o,layout:a,theme:n,xAccessor:l,yAccessor:s}=i;switch(e.type){case"frame-text":return Lg(gn,{annotation:e,width:a.width,height:a.height,defaults:{fill:n.colors.text,fontSize:11,fontFamily:n.typography.fontFamily}},"ann-frame-text-"+t);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let l=xn(e,n),s=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:$g("g",{opacity:e.opacity,children:[Lg("line",{x1:i,y1:0,x2:i,y2:a.height,stroke:l,strokeWidth:u,strokeDasharray:c}),Ja(e.endCap,[i,0],l),s&&Lg(Qa,{x:i+4,y:Tg,textAnchor:"start",fontSize:n.typography.tickSize,fill:l,fontFamily:n.typography.fontFamily,text:s,background:bn(e,n,"halo")})]},"ann-ythresh-"+t)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:Lg(en,{ann:e,position:d,vertical:!1,width:a.width,height:a.height,color:l,fontSize:n.typography.tickSize,fontFamily:n.typography.fontFamily,background:bn(e,n,"halo"),dash:"6,4",labelGap:6},"ann-ythresh-"+t)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let l="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==l)return null;let s=xn(e,n);return Lg(en,{ann:e,position:l,vertical:!0,width:a.width,height:a.height,color:s,fontSize:n.typography.tickSize,fontFamily:n.typography.fontFamily,background:bn(e,n,"halo"),dash:"6,4"},"ann-xthresh-"+t)}case"band":{let i=o.y?.domain?.(),r=e.y0??i?.[0],l=e.y1??i?.[1],s=null!=r&&o.y?o.y(r):null,c=null!=l&&o.y?o.y(l):null;if(null==s||null==c)return null;let u=Math.min(s,c),d=Math.abs(c-s),h=fn(e,"ssr-band-"+t,"vertical",xn(e,n)),f=e.fillOpacity??.1;return $g("g",{opacity:e.opacity,children:[h.def&&Lg("defs",{children:h.def}),Lg("rect",{x:0,y:u,width:a.width,height:d,fill:h.fill,fillOpacity:f}),e.label&&Lg(Qa,{x:a.width-4,y:Math.max(u,0)+Tg,textAnchor:"end",fontSize:n.typography.tickSize,fill:e.color||xn(e,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:e.label,background:bn(e,n,"halo")})]},"ann-band-"+t)}case"x-band":{let i=o.x?.domain?.(),r=e.x0??i?.[0],l=e.x1??i?.[1],s=null!=r&&o.x?o.x(r):null,c=null!=l&&o.x?o.x(l):null;if(null==s||null==c)return null;let u=Math.min(s,c),d=Math.abs(c-s),h=fn(e,"ssr-xband-"+t,"horizontal",xn(e,n)),f=e.fillOpacity??.1;return $g("g",{opacity:e.opacity,children:[h.def&&Lg("defs",{children:h.def}),Lg("rect",{x:u,y:0,width:d,height:a.height,fill:h.fill,fillOpacity:f}),e.label&&Lg(Qa,{x:u+4,y:Tg,textAnchor:"start",fontSize:n.typography.tickSize,fill:e.color||n.colors.primary||xn(e,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:e.label,background:bn(e,n,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(e.category+"");if(null==r)return null;let l=o.o.bandwidth?o.o.bandwidth():40,s=xn(e,n),c=e.opacity??.1,u=e.label;return $g("g","horizontal"===i.projection?{children:[Lg("rect",{x:0,y:r,width:a.width,height:l,fill:s,opacity:c}),u&&Lg(Qa,{x:12,y:r+l/2,dominantBaseline:"middle",fill:s,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:bn(e,n,"none")})]}:{children:[Lg("rect",{x:r,y:0,width:l,height:a.height,fill:s,opacity:c}),u&&Lg(Qa,{x:r+l/2,y:Tg,textAnchor:"middle",fill:s,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:bn(e,n,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=function(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:vn(e,t,i),y:wn(e,t,r)}}(e,o,l,s),a=null==i.x||null==i.y?qu(e,t,r):null,c=i.x??a?.x??null,u=i.y??a?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),f=e.dy??(d?0:-30),p=e.color||n.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return Lg(ln,{noteData:{x:c,y:u,dx:h,dy:f,note:bu(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:p,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return Lg("g",{children:Lg("text",{x:c+h,y:u+f,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||n.typography.labelSize,fill:p,fontFamily:n.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}(t,i,e,r)??function(e,t,i){switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:Ku({...e,type:"point"},i),y:Qu({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=fg(r),a=e.padding||10;return _g("g",{children:[Mg("circle",{cx:o.x,cy:o.y,r:o.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Mg(Qa,{x:o.x,y:o.y-o.r-a-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:Ku({...e,type:"point"},i),y:Qu({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=e.padding||10,[a,n]=nd(r.map(e=>e.x)),[l,s]=nd(r.map(e=>e.y)),c=a-o,u=n+o,d=l-o;return _g("g",{children:[Mg("rect",{x:c,y:d,width:u-c,height:s+o-d,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Mg(Qa,{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],a={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return Mg("g",{children:o.map((t,r)=>{let o=Ku(t,i),n=Qu(t,i);if(null==o||null==n)return null;let l="function"==typeof e.r?e.r(t):e.r||6,s="function"==typeof e.style?e.style(t):e.style||a;return Mg("circle",{cx:o,cy:n,r:l,...s},"hl-"+r)})},"ann-"+t)}case"bracket":{let r=Ku(e,i),o=Qu(e,i);return Mg(ln,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:bu(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{let r=i.data||[];if(2>r.length)return null;let o,a=i.xAccessor||"x",n=i.yAccessor||"y",l="ordinal"===i.frameType,s="horizontal"===i.projection,c=l?a:null,u=l?n:null,d=[],h=new Map;if(l&&c&&u){for(let e of r){let t=e[c];if(null==t)continue;let i=t+"";h.has(i)||(h.set(i,d.length),d.push(i))}o=r.map(e=>{let t=e[c],i=e[u];if(null==t||null==i)return null;let r=h.get(t+"");return null!=r?[r,+i]:null}).filter(e=>null!==e)}else o=r.map(e=>[e[a],e[n]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>o.length)return null;let f=i.scales?.x??i.scales?.time,p=i.scales?.y??i.scales?.value;if(!f||!p)return null;let y,g=e=>t=>{let i=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,i+1),o=t-i,a=e(d[i]);return a+(e(d[r])-a)*o},m=f,x=p;if(l)if(s){let e=g(x);y=(t,i)=>[m(i),e(t)]}else{let e=g(m);y=(t,i)=>[e(t),x(i)]}else y=(e,t)=>[m(e),x(t)];let b=e.method||"linear",v="loess"===b?function(e,t=.3){let i=e.length;if(2>i)return e.slice();let r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),a=r.map(e=>e[1]),n=Math.min(i,Math.max(2,Math.ceil(t*i))),l=Number.isFinite(n)&&o.every(Number.isFinite),s=0,c=n-1,u=[];for(let e=0;i>e;e++){let t,r=o[e],d=0,h=i-1;if(l){for(;i-1>c&&Math.abs(o[s]-r)>=Math.abs(o[c+1]-r);)s++,c++;let e=Math.max(Math.abs(o[s]-r),Math.abs(o[c]-r));t=e||1,e>0&&(d=s,h=c)}else t=o.map(e=>Math.abs(e-r)).sort((e,t)=>e-t)[n-1]||1;let f=0,p=0,y=0,g=0,m=0;for(let e=d;h>=e;e++){let i=Math.abs(o[e]-r)/t,n=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==n&&(f+=n,p+=n*o[e],y+=n*a[e],g+=n*o[e]*o[e],m+=n*o[e]*a[e])}if(0===f){u.push([r,a[e]]);continue}let x=f*g-p*p;if(1e-12>Math.abs(x))u.push([r,y/f]);else{let e=(f*m-p*y)/x;u.push([r,(y-e*p)/f+e*r])}}return u}(o,e.bandwidth??.3):("polynomial"===b?de(o,e.order||2):function(e){let t=[0,0,0,0],i=0;for(let[r,o]of e)null!==o&&(i++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);let r=i*t[2]-t[0]*t[0],o=0===r?0:ue((i*t[3]-t[0]*t[1])/r),a=ue(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[ue(e),ue(o*e+a)]),equation:[o,a]}}(o)).points,w=v.map(([e,t])=>{let[i,r]=y(e,t);return`${i},${r}`}).join(" "),k=e.color||"#6366f1",A=v[v.length-1],[S,M]=y(A[0],A[1]);return _g("g",{children:[Mg("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Mg("text",{x:S+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"envelope":{let r=i.data||[];if(2>r.length)return null;let o=i.xAccessor||"x",a=i.scales?.x??i.scales?.time,n=i.scales?.y??i.scales?.value;if(!a||!n)return null;let l=e.upperAccessor||"upperBounds",s=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[l]&&null!=e[s]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;let d=Pg[i.curve||"linear"]||xg,h=pg().x(e=>a(e[o])).y0(e=>n(e[s])).y1(e=>n(e[l])).curve(d)(u);if(!h)return null;let f=e.fill||"#6366f1",p=u[u.length-1];return _g("g",{children:[Mg("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&Mg("text",{x:a(p[o])+4,y:n(p[l])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{let r=i.data||[];if(2>r.length)return null;let o=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,n=i.scales?.y??i.scales?.value;if(!a||!n)return null;let l=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;let s=l.reduce((e,t)=>e+t,0)/l.length,c=l.reduce((e,t)=>e+(t-s)**2,0)/l.length,u=Math.sqrt(c),d=e.threshold??2,h=s-d*u,f=n(s+d*u),p=n(h),y=e.fill||"#6366f1",g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=r.filter(e=>{let t=e[o];return null!=t&&Math.abs(t-s)>d*u});return _g("g",{children:[!1!==e.showBand&&Mg("rect",{x:0,y:Math.min(f,p),width:i.width||0,height:Math.abs(p-f),fill:y,fillOpacity:e.fillOpacity??.1}),x.map((e,t)=>{let r=Ku(e,i),o=Qu(e,i);return null==r||null==o?null:Mg("circle",{cx:r,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&Mg("text",{x:(i.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{let r=i.data||[];if(3>r.length)return null;let o=i.xAccessor||"x",a=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,l=i.scales?.y??i.scales?.value;if(!n||!l)return null;let s,c=r.map(e=>[e[o],e[a]]).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;if("polynomial"===e.method){let t=de(c,e.order||2).equation;s=e=>t.reduce((t,i,r)=>t+i*Math.pow(e,r),0)}else{let e=he(c);if(!e)return null;s=e}let{se:u,meanX:d,ssX:h}=fe(c,s),f=c.length,p=pe(e.confidence??.95),y=c[f-1][0],g=(y-c[0][0])/Math.max(f-1,1),m=Array.from({length:e.steps??5},(e,t)=>{let i=y+(t+1)*g,r=s(i),o=u*Math.sqrt(1+1/f+(h>0?(i-d)**2/h:0))*p;return{x:i,center:r,upper:r+o,lower:r-o}}),x=m.map(e=>`${n(e.x)},${l(e.upper)}`).join(" L"),b=m.slice().reverse().map(e=>`${n(e.x)},${l(e.lower)}`).join(" L"),v=m.map(e=>`${n(e.x)},${l(e.center)}`).join(" "),w=e.strokeColor||"#6366f1",k=m[m.length-1];return _g("g",{children:[Mg("path",{d:`M${x} L${b} Z`,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),Mg("polyline",{points:`${n(y)},${l(s(y))} ${v}`,fill:"none",stroke:w,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k&&Mg("text",{x:n(k.x)+4,y:l(k.center)-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let a=qu(e,t,i);if(!a)return null;r=a.x,o=a.y}if(!Du(r,o,i))return null;let a=e.width??32,n=e.height??32,l=e.content??Mg("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return Mg("foreignObject",{x:r+(e.dx??0)-a/2,y:o+(e.dy??0)-n/2,width:a,height:n,style:{overflow:"visible",pointerEvents:"auto"},children:Mg("div",{...mn(e),style:{width:a,height:n,display:"flex",alignItems:"center",justifyContent:"center"},children:l})},"ann-"+t)}default:return null}}(t,i,r),e.svgAnnotationRules,u),f=h.nodes,p=new Map;for(let e of h.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";p.set(t,(p.get(t)??0)+1)}let y=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=p.get(t)??0;i>0?p.set(t,i-1):y.push(t)}return e.onRender?.({inputCount:t.length,eligibleCount:d.length,renderedCount:h.renderedAnnotations.length,unrenderedCount:y.length,unrenderedTypes:y}),f.length>0?Lg("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:f}):null}function An(e,t,i,r="right",o,a){if(null==e||!1===e)return null;let{x:n,y:l}=b(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:a});return Rg("g",{transform:`translate(${n}, ${l})`,children:e})}function Sn(e){let t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:"c"+t,r=i+"-semiotic-title",o=i+"-semiotic-desc";return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function Mn(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function _n(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function Pn(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)t>r.pixel&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function Ln(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function $n(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Ln(e)}}}function Tn(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,a=Math.ceil(t/8),n="M0,"+r;for(let e=0;a>e;e++){let i=8*(e+1);n+=`L${Math.min(8*e+4,t)},${r+4*o}`,n+=`L${Math.min(i,t)},${r}`}return n}let r="bottom"===e?0:t,o="bottom"===e?1:-1,a=Math.ceil(i/8),n=`M${r},0`;for(let e=0;a>e;e++){let t=8*(e+1);n+=`L${r+4*o},${Math.min(8*e+4,i)}`,n+=`L${r},${Math.min(t,i)}`}return n}function Rn(e,t,i){return"exact"===i?function(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],a=r instanceof Date,n=r instanceof Date?r.getTime():r,l=o instanceof Date?o.getTime():o;if(2>t||n===l)return a?[new Date(n),new Date(l)]:[n,l];let s=(l-n)/(t-1),c=Array(t);for(let e=0;t>e;e++){let i=e===t-1?l:n+e*s;c[e]=a?new Date(i):i}return c}(e,t):e.ticks(t)}function Cn(e){return"string"==typeof e||"number"==typeof e}function In(e){let{label:t,x:i,y:r,textAlign:o,fontSize:a,fontFamily:n,color:l}=e;return Ig("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:Ig("div",{style:{color:l,fontFamily:n,fontSize:a,textAlign:o,userSelect:"none"},children:t})})}function Dn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function zn(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):function(e,t){let i=Dn(e);if(!i)return!1;let r=Dn(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}(t.value,i>0?r[i-1].value:void 0))}function On(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${Dg[t.getUTCMonth()]} ${t.getUTCDate()}`}function Fn(e){let t=Math.abs(e[1]-e[0]);return 864e5>t?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(r+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(r+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),r}:3156e7>t?On:1578e8>t?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${Dg[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function Nn(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function En(e){let{scale:i,axis:r,size:o,horizontal:a=!1,axisExtent:n}=e,l=r?.extent??n,s=i.domain(),c=function(e){return e?.ticks??e?.tickCount??5}(r),u=Math.max(2,Math.floor(o/(a?70:30))),d="exact"===l?Math.max(2,c):Math.min(c,u),h=r?.tickValues??Rn(i,d,l),f=h.map(e=>e.valueOf()),p=r?.tickFormat||e.format||(s[0]instanceof Date||h[0]instanceof Date?Fn([s[0].valueOf(),s[s.length-1].valueOf()]):t(f)),y=(e,t)=>a?p(e,t,f):p(e),g=h.map((e,t)=>({value:e,pixel:i(e),label:y(e,t)})),m=22;if(a){let e=g.reduce((e,t)=>Math.max(e,Nn(t.label)),0);m=r?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=function(e,t){if(2>=e.length)return e;let i=[e[0]];for(let r=1;e.length-1>r;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return t>Math.abs(r.pixel-i[i.length-1].pixel)?i[i.length-1]=r:i.push(r),i}(g,m);if(x.length>1&&(x=x.filter((e,t)=>{return 0===t||(r=x[t-1].label,!!("string"!=typeof(i=e.label)&&"number"!=typeof i||"string"!=typeof r&&"number"!=typeof r||i+""!=r+""));var i,r})),r?.includeMax&&x.length>0&&"exact"!==l&&!r.tickValues){let e=s[s.length-1];if(null!=e){let t=i(e),r=Math.abs(t-x[x.length-1].pixel);if(r>1){let i=y(e,x.length);m>r&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:t,label:i}]}}}return x}function Wn(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.id;return null==t?null:t+""}return null}function jn(e){let t=e._idPrefix||e.chartId;if(t){let e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;i.length>e;e++)r=31*r+i.charCodeAt(e)|0;return"c"+(r>>>0).toString(36)}function Bn(e,t,r){return i(e.showLegend&&!e.__legendIncludesAutomatic?Xa(t,e.colorScheme,r):void 0,e.legend)}function Yn(e,t){if(e.__autoLegendMargin)return Fg[t]}function Xn(e,i){let a={theme:i.theme,position:i.position||"right",totalWidth:i.size[0],totalHeight:i.size[1],margin:i.margin,hasTitle:i.hasTitle,legendLayout:i.legendLayout,idPrefix:i.idPrefix,reservedWidth:i.reservedWidth,axisChrome:i.axisChrome,legendDistance:r(e)||o(e)?e.legendDistance:void 0};return r(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,i)=>({group:e,item:t,itemIndex:i,label:t.label})))).length)return null;var t;let i=function(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:a,legendLayout:n}=e,{swatchSize:l,labelGap:s,rowHeight:c}=v(n),u=l+s,d=Math.max(12,Va(i)),h="top"===r||"bottom"===r,f=Math.max(l,o-a.left-a.right);if(h){let r=Math.max(l,n?.maxWidth??f),o=Ga(n?.align),a=0,s=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=Za({...e,categories:t,legendLayout:{...n,maxWidth:Math.max(l,r-d-8),align:"start"}}),h=o.label?d:0,f=o.label?Ua(o.label,0,0,i):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);c.push({group:o,x:a,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),a+=y+12,s=Math.max(s,g)}let h=c.length>0?a-12:0,p=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:h,height:s,swatchSize:l,labelOffset:u,swatchRadius:0}}let p=w(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c),y=0;return{groups:t.map((e,t)=>{let r=e.items.map(e=>Ua(e.label,l,s,i)),o=Math.max(0,...r,e.label?Ua(e.label,0,0,i):0);return y=Math.max(y,o),{group:e,x:0,y:p[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:o,height:e.items.length*c,items:e.items.map((e,t)=>({category:e.label,width:r[t],x:0,y:t*c}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:l,labelOffset:u,swatchRadius:0}}(e),r="top"===e.position||"bottom"===e.position,o={legendGroups:e.legendGroups,legendDistance:e.legendDistance},a=e.reservedWidth??u(o,e.legendLayout),n=e.theme.colors.grid||e.theme.colors.textSecondary,{x:l,y:s}=b(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:a});if(!r){let t=w(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,o)=>{let n=t[o],l=r.type??"fill",s=[Qy("line",{x1:0,y1:n.lineY,x2:a,y2:n.lineY,stroke:"gray"},"legend-group-neatline-"+o)];return r.label&&null!=n.labelY&&s.push(Qy("text",{y:n.labelY,fontSize:Va(e.theme),fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:r.label},"legend-group-label-"+o)),s.push(Qy("g",{transform:`translate(0,${n.itemsY})`,children:r.items.map((t,a)=>{let n=r.styleFn(t,a),s="function"==typeof l?l(t):"line"===l?Qy("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:n}):Qy("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:n});return Jy("g",{transform:`translate(0,${a*Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[s,Qy("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Va(e.theme),fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:t.label})]},`legend-${o}-${a}`)})},"legend-group-"+o)),s});return Qy("g",{className:"semiotic-legend",transform:`translate(${l},${s})`,"data-orientation":"vertical",fontWeight:qa(e.theme),children:r})}let c=i.groups.flatMap((t,o)=>{let{group:a}=t,l=a.type??"fill",s=[];if(a.label&&s.push(Qy("text",r?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Va(e.theme),fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:a.label}:{x:t.x,y:t.y+Va(e.theme),fontSize:Va(e.theme),fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:a.label},"legend-group-label-"+o)),s.push(...t.items.map((r,n)=>{let s=a.items[n],c=a.styleFn(s,n),u="function"==typeof l?l(s):"line"===l?Qy("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:c}):Qy("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:c});return Jy("g",{transform:`translate(${t.x+t.itemOffsetX+r.x},${t.y+t.itemOffsetY+r.y})`,children:[u,Qy("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Va(e.theme),fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:r.category})]},`legend-${o}-${n}`)})),r&&i.groups.length-1>o){let e=t.x+t.width+6;s.push(Qy("line",{x1:e,y1:0,x2:e,y2:i.height,stroke:n},"legend-group-separator-"+o))}return s});return Qy("g",{className:"semiotic-legend",transform:`translate(${l},${s})`,"data-orientation":r?"horizontal":"vertical",fontWeight:qa(e.theme),children:c})}({...a,legendGroups:e.legendGroups}):o(e)?function(e){let i=function(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}(e),r="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},a=u(o),n=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",l=e.gradient.format||t(e.gradient.domain),{x:s,y:c}=b(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:a}),d=Array.from({length:17},(t,i)=>{let o=i/16;return Qy("stop",{offset:o,stopColor:e.gradient.colorFn(r?e.gradient.domain[0]+o*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-o*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(r){let t=e.gradient.label?12:void 0,r=e.gradient.label?18:0;return Jy("g",{className:"semiotic-legend",transform:`translate(${s},${c})`,fontWeight:qa(e.theme),children:[Qy("defs",{children:Qy("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),e.gradient.label&&Qy("text",{x:i.width/2,y:t,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:e.gradient.label}),Qy("rect",{x:0,y:r,width:i.width,height:12,fill:`url(#${n})`,rx:2}),Qy("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ha(e.theme),children:l(e.gradient.domain[0])}),Qy("text",{x:i.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ha(e.theme),children:l(e.gradient.domain[1])})]})}let h=e.gradient.label?12:void 0,f=e.gradient.label?18:0;return Jy("g",{className:"semiotic-legend",transform:`translate(${s},${c})`,fontWeight:qa(e.theme),children:[Qy("defs",{children:Qy("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.gradient.label&&Qy("text",{x:0,y:h,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ha(e.theme),children:e.gradient.label}),Qy("rect",{x:0,y:f,width:14,height:100,fill:`url(#${n})`,rx:2}),Qy("text",{x:19,y:f+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ha(e.theme),children:l(e.gradient.domain[1])}),Qy("text",{x:19,y:f+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ha(e.theme),children:l(e.gradient.domain[0])})]})}({...a,gradient:e.gradient}):null}function Gn(e,t){let{props:i,categories:r,theme:o,size:a,hasTitle:n}=t,l=i.legendPosition||"right",c={...e},u={theme:o,position:l,size:a,hasTitle:n,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:Yn(i,l)};if(null!=i.legend){let t=Bn(i,r,o);null!=t&&!1!==t&&function(e,t){x(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,legend:t})}else i.showLegend&&r.length>0&&function(e,t){if(0===t.categories.length)return;let i=t.position||"right";x(e,{legend:Xa(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,categories:r,colorScheme:i.colorScheme});return s(e,c,a,l),l}function Vn(e){let{props:t,categories:i,theme:a,size:n,margin:l,hasTitle:s}=e,c=t.legendPosition||"right",d={theme:a,position:c,size:n,margin:l,hasTitle:s,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){let e=Bn(t,i,a);return Cg.isValidElement(e)?An(e,n,l,c,t.legendLayout,t.axisChrome):Xn(e,d)||(r(e)||o(e)?null:An(e??null,n,l,c,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?function(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:a,totalHeight:n,margin:l}=e;if(!t||0===t.length)return null;let s=Ya(t,i,r),c="top"===o||"bottom"===o,d=Za(e),h={...Xa(t,i,r),legendDistance:e.legendDistance},f=e.reservedWidth??u(h,e.legendLayout),{x:p,y:y}=b(h,{totalWidth:a,totalHeight:n,margin:l,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:f});if(c){let e=d.items.map((e,t)=>Jy("g",{transform:`translate(${e.x},${e.y})`,children:[Qy("rect",{width:d.swatchSize,height:d.swatchSize,fill:s(e.category),rx:d.swatchRadius}),Qy("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Va(r),fill:r.colors.text,fontFamily:Ha(r),children:e.category})]},"legend-"+t));return Qy("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:qa(r),children:e})}let g=w([{hasLabel:!1,itemCount:t.length}],Math.max(d.swatchSize,e.legendLayout?.rowHeight??22))[0],m=d.items.map((e,t)=>Jy("g",{transform:`translate(${e.x},${e.y+g.itemsY})`,children:[Qy("rect",{width:d.swatchSize,height:d.swatchSize,fill:s(e.category),rx:d.swatchRadius}),Qy("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Va(r),fill:r.colors.text,fontFamily:Ha(r),children:e.category})]},"legend-"+t));return Jy("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:qa(r),children:[Qy("line",{x1:0,y1:g.lineY,x2:f,y2:g.lineY,stroke:"gray"}),m]})}({categories:i,colorScheme:t.colorScheme,theme:a,position:c,totalWidth:n[0],totalHeight:n[1],margin:l,hasTitle:s,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function Hn(e,t){let i=se(t.theme),r=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",a="string"==typeof t.title?t.title:void 0,n=t.idPrefix?Sn(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},l=a?n.titleId:void 0,s=t.description?n.descId:void 0,c=[l,s].filter(Boolean).join(" ")||void 0;return Og("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[a&&zg("title",{id:l,children:a}),t.description&&zg("desc",{id:s,children:t.description}),t.defs&&zg("defs",{children:t.defs}),r&&"transparent"!==r&&zg("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),zg("g",{id:o+"data-area",transform:t.innerTransform,children:e}),a&&zg("text",{id:o+"chart-title",x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:a}),t.legend&&zg("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function qn(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}function Un(t,i){let r=le(t.theme),o=t.size||[500,300],n=l({...Wg,...t.margin},t.title),s=a(t.title),c=function(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}(F(t.data),t.lineDataAccessor),u=t.showLegend?Ka(c,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[],d=y({showAxes:t.showAxes,xLabel:t.xLabel,yLabel:t.yLabel,yLabelRight:t.yLabelRight,axes:t.axes});Gn(n,{props:{...t,axisChrome:d},categories:u,theme:r,size:o,hasTitle:s});let f=Vn({props:{...t,axisChrome:d},categories:u,theme:r,size:o,margin:n,hasTitle:s}),p=o[0]-n.left-n.right,g=o[1]-n.top-n.bottom,m="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),x=t.colorScheme||r.colors.categorical,b=(t.axes?.find(e=>"left"===e.orient)??t.axes?.find(e=>"right"===e.orient))?.extent??t.axisExtent,v={chartType:t.chartType,runtimeMode:m?"streaming":"bounded",windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:m?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:t.xAccessor,yAccessor:t.yAccessor,timeAccessor:m?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor||(t.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,invertY:t.invertY,axisExtent:t.axisExtent,yAxisExtent:b,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,baseline:t.baseline,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,band:t.band,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:ee(t.gradientFill),lineGradient:te(t.lineGradient),semanticLineStops:t.semanticLineStops,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:x,themeCategorical:r.colors.categorical,themeSequential:r.colors.sequential,themeDiverging:r.colors.diverging,themeSemantic:lu(r),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat,heatmapColorScale:t.heatmapColorScale,heatmapAggregation:t.heatmapAggregation,heatmapXBins:t.heatmapXBins,heatmapYBins:t.heatmapYBins,pointIdAccessor:t.pointIdAccessor,onLayoutError:t.onLayoutError},w=new dy(v);t.data&&w.ingest({inserts:c,bounded:!0}),w.computeScene({width:p,height:g});let k=qn(t.backgroundGraphics,o,n,w.scales),A=qn(t.foregroundGraphics,o,n,w.scales);if(!w.scales){let e,a=t.annotations?kn({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{},layout:{width:p,height:g},theme:r,idPrefix:t._idPrefix,onRender:t=>{e=t}}):null;return i&&(i.evidence=Ta({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,extraWarnings:w.scales?[]:["NO_SCALES"],margin:n})),Fp.renderToStaticMarkup(Hn(k||A||t.annotations?qg(Vg,{children:[k,a,A]}):null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:r,innerTransform:`translate(${n.left},${n.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:t._idPrefix}))}let S,M=t._idPrefix,_=Ba({nodes:w.scene,renderMode:t.renderMode,fallback:(e,i)=>Wa(e,i,M,t.hoverRadius??30)}),P=!w.xIsDate||t.xFormat||t.tickFormatTime?t:{...t,xFormat:Fn(w.scales.x.domain().map(e=>e.valueOf()))},L=t.showGrid?function(e,t,i,r,o,a,n){let{grid:l}=se(i),s=r?r+"-":"",c=a?.find(e=>"bottom"===e.orient),u=a?.find(e=>"top"===e.orient),d=a?.find(e=>"left"===e.orient),h=a?.find(e=>"right"===e.orient),f=c??u,p=d??h,y=En({scale:e.x,axis:f,size:t.width,horizontal:!0,format:n?.xFormat||n?.tickFormatTime,axisExtent:o}),g=En({scale:e.y,axis:p,size:t.height,format:n?.yFormat||n?.tickFormatValue,axisExtent:o}),m=!1!==f?.grid,x=!1!==p?.grid,b=Ln(f?.gridStyle),v=Ln(p?.gridStyle),w=$n(f?.gridStyle,{stroke:l,strokeWidth:.5}),k=$n(p?.gridStyle,{stroke:l,strokeWidth:.5});return Eg("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>Ng("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+i)),x&&g.map((e,i)=>Ng("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}(w.scales,{width:p,height:g},r,M,t.axisExtent,t.axes,P):null,$=_.map(e=>e.element),T=jn(t)+"-plot-clip",R=!1!==t.showAxes,C=R?function(t,i,r,o,a,n,l,s=!1){let c=se(o),u=r.legendPosition??"right",d=h(r.legendLayout,l?.leftAxis),f=h(r.legendLayout,l?.rightAxis),p=s&&"left"===u&&d>0?d:n?.left??r.margin?.left??40,y=s&&"right"===u&&f>0?f:n?.right??r.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=e(r.axes),v="top"===x?0:i.height,w="right"===b?i.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=En({scale:t.x,axis:g,size:i.width,horizontal:!0,format:r.xFormat||r.tickFormatTime,axisExtent:r.axisExtent}),M=En({scale:t.y,axis:m,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),_=!(!g?.autoRotate||!function(e){for(let t=1;e.length>t;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(Nn(i.label)+Nn(r.label))/2+8)return!0}return!1}(S)),P=Pn(S),L=Pn(M),$=g?.label??r.xLabel,T=m?.label??("right"===b?r.yLabelRight??r.yLabel:r.yLabel),R=$n(g?.axisStyle,{stroke:c.border,strokeWidth:1}),C=$n(m?.axisStyle,{stroke:c.border,strokeWidth:1}),I="right"===b?i.width+y-15:15-p;return Og("g",{id:(a?a+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&Og("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==g?.baseline&&!g?.jaggedBase&&zg("line",{x1:0,y1:v,x2:i.width,y2:v,...R}),g?.jaggedBase&&zg("path",{d:Tn(x,i.width,i.height),fill:"none",...R}),S.map((e,t)=>{let i=zn(g?.landmarkTicks,e,t,S);return Og("g",{transform:`translate(${e.pixel},${v})`,children:[zg("line",{y2:5*k,...R}),Cn(e.label)?zg("text",{y:k*(_?12:18),textAnchor:_?"end":Mn(g?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,transform:_?"top"===x?"rotate(45)":"rotate(-45)":void 0,children:e.label}):In({label:e.label,x:-30,y:"top"===x?-30:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"xtick-"+t)}),$&&zg("text",{x:i.width/2,y:"top"===x?-(_?58:40):i.height+(_?58:40),textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:$})]}),!1!==m?.visible&&Og("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&zg("line",{x1:w,y1:0,x2:w,y2:i.height,...C}),m?.jaggedBase&&zg("path",{d:Tn(b,i.width,i.height),fill:"none",...C}),M.map((e,t)=>{let i=zn(m?.landmarkTicks,e,t,M);return Og("g",{transform:`translate(${w},${e.pixel})`,children:[zg("line",{x2:5*A,...C}),Cn(e.label)?zg("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:_n(m?.tickAnchor,e.pixel===L.min,e.pixel===L.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):In({label:e.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"ytick-"+t)}),T&&zg("text",{x:I,y:i.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${I}, ${i.height/2})`,children:T})]})]})}(w.scales,{width:p,height:g},P,r,M,n,d,!!f):null,I=R?function(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:a,rightAxis:n,margin:l,axisChrome:s,hasRenderedLegend:c}=e;if(!a||!n||!1===n.visible)return null;let u=se(o),d=En({scale:t.y,axis:n,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),f=Pn(d),p=n.label??r.yLabelRight,y=$n(n.axisStyle,{stroke:u.border,strokeWidth:1}),g=r.legendPosition??"right",m=h(r.legendLayout,s?.rightAxis),x=i.width+(c&&"right"===g&&m>0?m:l.right)-15;return Gg("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==n.baseline&&!n.jaggedBase&&Xg("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...y}),n.jaggedBase&&Xg("path",{d:Tn("right",i.width,i.height),fill:"none",...y}),d.map((e,t)=>{let r=zn(n.landmarkTicks,e,t,d);return Gg("g",{transform:`translate(${i.width},${e.pixel})`,children:[Xg("line",{x2:5,...y}),Cn(e.label)?Xg("text",{x:8,textAnchor:"start",dominantBaseline:_n(n.tickAnchor,e.pixel===f.min,e.pixel===f.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):In({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),p&&Xg("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:p})]})}({scales:w.scales,layout:{width:p,height:g},props:t,theme:r,leftAxis:t.axes?.find(e=>"left"===e.orient),rightAxis:t.axes?.find(e=>"right"===e.orient),margin:n,axisChrome:d,hasRenderedLegend:!!f}):null,D=t.annotations?kn({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{x:w.scales.x,y:w.scales.y},layout:{width:p,height:g},theme:r,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:M,onRender:e=>{S=e}}):null;i&&(i.evidence=Ta({frameType:"xy",width:o[0],height:o[1],marks:_.map(e=>e.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:S,xDomain:$a(w.scales.x?.domain?.()),yDomain:$a(w.scales.y?.domain?.()),legendItems:u.length>0?u.length:void 0,margin:n}));let z=t.svgPreRenderers&&w.scales?t.svgPreRenderers.map((e,t)=>{try{return Hg(Op.Fragment,{children:e(w.scene,w.scales,{width:p,height:g})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return Fp.renderToStaticMarkup(Hn(qg(Vg,{children:[k,z,L,Hg("defs",{children:Hg("clipPath",{id:T,children:Hg("rect",{x:0,y:0,width:p,height:g})})}),Hg("g",{clipPath:`url(#${T})`,children:$}),C,I,D,A,w.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:r,innerTransform:`translate(${n.left},${n.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:t._idPrefix}))}function Zn({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:a,height:n,seed:l,reduced:s,onSelectTask:c}){let u=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);return Kg("svg",{"aria-hidden":"true",width:a,height:n,viewBox:`0 0 ${a} ${n}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Zg("defs",{children:Zg("filter",{id:"chain-shadow-"+l,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Zg("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;return Kg("g",{children:[Zg("line",{x1:r,x2:r,y1:h,y2:n-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Zg("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),a=r.has(e.targetID)||r.has(e.sourceID),n=e.points.map(e=>`${e.x},${e.y}`).join(" ");return Zg("polyline",{points:n,fill:"none",stroke:a?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:a?4:o?3:2,strokeOpacity:t||o||a?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);return Kg("g",{children:[Zg("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&Zg("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let a=t.taskByID.get(e.id);if(!a)return null;let n=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,f=r.has(e.id),p=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(e,i),y=a.x-a.width/2,g=a.y-a.height/2,m=Math.max(2,a.height*e.progress);return Kg("g",{children:[Kg("g",{style:{transform:`rotate(${n?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:s?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+l+")"},children:[Zg("rect",{x:y,y:g,width:a.width,height:a.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),Zg("rect",{x:y+3,y:g+a.height-m+1,width:a.width-6,height:Math.max(0,m-4),rx:2,fill:p,opacity:n?.86:.46})]}),u&&Kg("g",{opacity:d?.28:1,children:[Zg("line",{x1:y-8,x2:y+14,y1:a.y+9,y2:a.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Zg("circle",{cx:y-8,cy:a.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),Kg("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Zg("rect",{x:y,y:g,width:a.width,height:a.height,fill:"transparent"}),Zg("text",{x:a.x,y:a.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),Kg("text",{x:a.x,y:a.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",n?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function Kn(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function Qn(e){if(null==e.completionTime)return null;let t=Kn(e.completionTime,NaN);return Number.isFinite(t)?t:null}function Jn(e,t,i,r){let o=new Set;for(let a of e.nodes){let n=e.incoming.get(a.id)??[];(r.has(a.id)||!i.has(a.id)&&n.every(e=>t.has(e.id)))&&o.add(a.id)}return o}function el(e,t,i){return function(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}(i,e,t)}function tl(e,t){return t>e?-1:e>t?1:0}function il(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function rl(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function ol(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function al(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=wu(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),a=[...Vu(o,t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),n=Array.from(new Set(a.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:a.length,affectedLaneCount:n.length,downstreamTaskIDs:a.map(e=>e.id),affectedLanes:n}}function nl(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function ll(e){return e.__composite}function sl(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function cl(e,t){return Math.max(1,Math.floor(sl(e,t)))}function ul(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function dl(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}function hl(e,t){return("function"==typeof t?t(e):e[t])+""}function fl(e,t,i){let{scales:r,config:o,getConnector:a,getO:n}=e;if(!a||!r)return[];let l=[],{projection:s}=r,c=new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=a(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===s?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:n(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},f=(e,t,i)=>{var r;l.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:(r=e.datum,"function"==typeof d?d(r):d||h),datum:e.datum,group:i})};for(let[e,t]of c)if(t.length>=2){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;t.length-1>i;i++)f(t[i],t[i+1],e);"radial"===s&&t.length>=3&&f(t[t.length-1],t[0],e)}return l}function pl(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function yl(e){let t=e.getSymbol;return t?zu(t,e.config.symbolMap):null}function gl(e,t,i,r,o,a,n){e.push(t?{type:"symbol",x:r,y:o,size:Math.PI*a*a,symbolType:t(i),style:n,datum:i}:{type:"point",x:r,y:o,r:a,style:n,datum:i})}function ml(e,t){let{columns:i,config:r,resolvePieceStyle:o}=e,a=[],n=Math.min(t.width,t.height)/2-4,l="donut"===r.chartType?r.innerRadius||60:0,s=-Math.PI/2+(r.startAngle||0)*Math.PI/180,c=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI,u=null!=r.sweepAngle&&360>r.sweepAngle,d=Object.values(i),h=d.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(r.cornerRadius??0)>0;for(let e=0;d.length>e;e++){let t=d[e],i=t.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h=s+u*c,p=s+(u+("number"==typeof i?._pct?i._pct:t.pct))*c,y=o(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:n,startAngle:h,endAngle:p,...r.cornerRadius&&{cornerRadius:r.cornerRadius},style:y,datum:i?._nonInteractive?null:t.pieceData,category:t.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),a.push(x)}return a}function xl(e,t,i){return{...e[0],...i,category:t,data:e}}function bl(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:hm(e,.25)??i,median:hm(e,.5)??(i+r)/2,q3:hm(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function vl(e,t,i,r,o){let a=Array(o).fill(0);for(let n of e)t>n||n>i||a[Math.min(Math.floor((n-t)/r),o-1)]++;return a}function wl(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,a=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(a){let e=Cm(i,r),t=Cm(i,o);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}let e=Cm(i,r),n=Cm(i,o),l=Cm(t,o),s=Cm(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${n.x},${n.y} L${l.x},${l.y} A${t},${t} 0 ${c} 0 ${s.x},${s.y} Z`}let n=Math.max(0,Math.min(e.cornerRadius??0,(i-t)/2));if(0===n)return wl({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let l=Math.asin(Math.min(1,n/Math.max(1e-9,i-n))),s=a?0:Math.asin(Math.min(1,n/Math.max(1e-9,t+n))),c=o-r,u=e.roundStart&&e.roundEnd?c/2:c,d=!!e.roundStart&&u>l,h=!!e.roundEnd&&u>l;if(!d&&!h)return wl({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let f=r+(d?l:0),p=o-(h?l:0),y=r+(d?s:0),g=o-(h?s:0),m=Cm(i,f),x=Cm(i,p),b=(i-n)*Math.cos(l),v=Cm(b,r),w=Cm(b,o),k=a?null:Cm(t,g),A=a?null:Cm(t,y),S=a?0:(t+n)*Math.cos(s),M=a?null:Cm(S,r),_=a?null:Cm(S,o),P=p-f>Math.PI?1:0,L=a?0:g-y>Math.PI?1:0,$="";if(d)$+=`M${v.x},${v.y}`,$+=` A${n},${n} 0 0 1 ${m.x},${m.y}`;else{let e=Cm(i,r);$+=`M${e.x},${e.y}`}if(h)$+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,$+=` A${n},${n} 0 0 1 ${w.x},${w.y}`;else{let e=Cm(i,o);$+=` A${i},${i} 0 ${P} 1 ${e.x},${e.y}`}if(a)$+=" L0,0";else{if(h)$+=` L${_.x},${_.y}`,$+=` A${n},${n} 0 0 1 ${k.x},${k.y}`;else{let e=Cm(t,o);$+=` L${e.x},${e.y}`}if(d)$+=` A${t},${t} 0 ${L} 0 ${A.x},${A.y}`,$+=` A${n},${n} 0 0 1 ${M.x},${M.y}`;else{let e=Cm(t,r);$+=` A${t},${t} 0 ${L} 0 ${e.x},${e.y}`}}return $+=" Z",$}function kl(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Al(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,a=Number(i.__funnelStepLabelX),n=Number(i.__funnelStepLabelY),l=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(a)&&Number.isFinite(n)&&(!Number.isFinite(l)||l>=8.4*o.length+16)&&r.push(Im("text",{x:a,y:n+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));let s=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(s)&&0!==s&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${kl(s)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:kl(s);7.8*o.length+16>d&&(o=kl(s)),d>=7.8*o.length+16&&r.push(Im("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return r.length?Im("g",{children:r},t+"-funnel-labels"):null}function Sl(e){return"connector"===e.node.type}function Ml(e,t,i,r){if(2>e.length)return null;let o=e[0].node,a=o.style.fill;if(!a||"none"===a)return null;let n=Ca(`${t?t+"-":""}connector-${i}-${r}-hatch`),l=ai(a)?li(a,n):null,s=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Na(Om($m.Fragment,{children:[l&&zm("defs",{children:l}),zm("polygon",{points:s,fill:l?`url(#${n})`:Ra(a,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function _l(e,t,i){let r=new Map;for(let t of e){if(!Sl(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>Om("g",{children:[Ml(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),a=e[0],n=Sl(a)?null:a.element;for(let e of r.values())for(let t of e)t.element=null;a.element=Om($m.Fragment,{children:[o,n]},"ordinal-connector-run-"+i)}function Pl(e){let t=Ba({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>function(e,t,i){return Na(function(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,a=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=Ca(a)+"-grad",n=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,a=e.x,n=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,n=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,a=e.x,n=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,a=e.x+e.w,n=e.y);let l=Da(i.stops,Ra(e.style.fill));return l?Yy("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:a,y2:n,children:l}):null}(r,o);if(n)i=`url(#${o})`;else if(ai(r.style.fill)){let e=Ca(a)+"-hatch";t=li(r.style.fill,e),i=`url(#${e})`}else i=Ra(r.style.fill);let l=n||t?Dm("defs",{children:[n,t]}):null;if(r.cornerRadii&&ba(r.cornerRadii)){let e=function(e){let{x:t,y:i,w:r,h:o}=e,{tl:a,tr:n,br:l,bl:s}=va(e),c=`M${t+a},${i}`;return c+=` L${t+r-n},${i}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+r},${i+n}`),c+=` L${t+r},${i+o-l}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t+r-l},${i+o}`),c+=` L${t+s},${i+o}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t},${i+o-s}`),c+=` L${t},${i+a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+a},${i}`),c+=" Z",c}(r);return Dm(Tm.Fragment,{children:[l,Im("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:n,w:s,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${n} L${o+s-t},${n} A${t},${t} 0 0 1 ${o+s},${n+t} L${o+s},${n+c-t} A${t},${t} 0 0 1 ${o+s-t},${n+c} L${o},${n+c} Z`;break;case"left":e=`M${o+s},${n} L${o+t},${n} A${t},${t} 0 0 0 ${o},${n+t} L${o},${n+c-t} A${t},${t} 0 0 0 ${o+t},${n+c} L${o+s},${n+c} Z`;break;case"bottom":e=`M${o},${n} L${o+s},${n} L${o+s},${n+c-t} A${t},${t} 0 0 1 ${o+s-t},${n+c} L${o+t},${n+c} A${t},${t} 0 0 1 ${o},${n+c-t} Z`;break;default:e=`M${o},${n+c} L${o},${n+t} A${t},${t} 0 0 1 ${o+t},${n} L${o+s-t},${n} A${t},${t} 0 0 1 ${o+s},${n+t} L${o+s},${n+c} Z`}return Dm(Tm.Fragment,{children:[l,Im("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}return Dm(Tm.Fragment,{children:[l,Im("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),Al(r,a)]},a)}case"point":{let t=e;return Im("circle",{cx:t.x,cy:t.y,r:t.r,fill:Ra(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}case"symbol":return za(e,t,i);case"glyph":return Ia(e,e.x,e.y,`${i??""}ord-glyph-${e.pointId??t}`);case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=Ca(`${i?i+"-":""}gauge-grad-${o.category||a}-${t}`),{clipPath:r,slices:n}=function(e){let t=wl({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)i.push({d:wl({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,slices:i}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return Dm("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[Im("defs",{children:Im("clipPath",{id:e,children:Im("path",{d:r})})}),Im("g",{clipPath:`url(#${e})`,children:n.map((e,t)=>Im("path",{d:e.d,fill:Ra(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&Im("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},a)}if(o.roundedEnds)r=wl({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=Rm().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(Gy)||""}return Im("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Ra(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},a)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;return Dm("g","vertical"===t.projection?{children:[Im("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Ra(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),Im("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]}:{children:[Im("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Ra(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),Im("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),Im("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},a)}case"violin":{let t=e,i=[Im("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Ra(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth??1},o("path"))];if(t.iqrLine&&t.bounds){let e=t.bounds,r=e.x+e.width/2,a=e.y+e.height/2;t.iqrLine.isVertical?i.push(Im("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),Im("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(Im("line",{x1:t.iqrLine.q1Pos,y1:a,x2:t.iqrLine.q3Pos,y2:a,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),Im("circle",{cx:t.iqrLine.medianPos,cy:a,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}return Im("g",{children:i},a)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?Ra(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";return Im("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},a)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return Im("polygon",{points:i,fill:Ra(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}default:return null}}(e,t,i),e,"ordinal-cursor-"+t)}(t,i,e.idPrefix)}),i=0;for(let r=0;t.length>r;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;t.length>o&&!t[o].renderedByBackend;)o++;_l(t.slice(r,o),e.idPrefix,i++),r=o}return t}function Ll(e,i){let r=le(e.theme),o=e.size||[500,400],n=l({...Wg,...e.margin},e.title),s=a(e.title),c=F(e.data),u=e.showLegend?Ka(c,e.colorAccessor||e.stackBy||e.groupBy):[],d=function(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Gn(n,{props:{...e,axisChrome:d},categories:u,theme:r,size:o,hasTitle:s});let f=Vn({props:{...e,axisChrome:d},categories:u,theme:r,size:o,margin:n,hasTitle:s}),p=o[0]-n.left-n.right,y=o[1]-n.top-n.bottom,g=e.projection||"vertical",m="radial"===g,x=e.colorScheme||r.colors.categorical,b={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:g,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,axisExtent:e.axisExtent,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,gradientFill:ee(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:x,themeCategorical:r.colors.categorical,themeSemantic:lu(r),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:n,layoutSelection:e.layoutSelection,barColors:e.barColors},v=new Lm(b);e.data&&v.ingest({inserts:c,bounded:!0}),v.computeScene({width:p,height:y});let w=qn(e.backgroundGraphics,o,n,v.scales),k=qn(e.foregroundGraphics,o,n,v.scales);if(!v.scales){let t,a=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:p,height:y},theme:r,projection:g,idPrefix:e._idPrefix,onRender:e=>{t=e}}):null;return i&&(i.evidence=Ta({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,extraWarnings:v.scales?[]:["NO_SCALES"],margin:n})),sm.renderToStaticMarkup(Hn(w||k||e.annotations?jm(Em,{children:[w,a,k,v.customLayoutOverlays]}):null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:`translate(${n.left},${n.top})`,innerWidth:p,innerHeight:y,legend:f,idPrefix:e._idPrefix}))}let A=e._idPrefix,S=e.showGrid?function(e,t,i,r,o,a){let n=e.scales;if(!n||"radial"===n.projection)return null;let{grid:l}=se(i),s=r?r+"-":"",c="vertical"===n.projection,u=a??Rn(n.r,5,o);return zg("g",c?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=n.r(e);return zg("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:l,strokeWidth:.5},"gr-"+i)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=n.r(e);return zg("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:l,strokeWidth:.5},"gr-"+i)})})}(v,{width:p,height:y},r,A,e.axisExtent,e.rTickValues):null,M=null;if(v.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=jn(e),i=new Set;for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");M=Array.from(i).map((e,i)=>function(e){let{id:t,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:a=6,angle:n=45}=e,l=Math.max(8,Math.ceil(2*a));return Nm("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[i&&"transparent"!==i&&Fm("rect",{width:l,height:l,fill:i}),Fm("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o}),Fm("line",{x1:a,y1:0,x2:a,y2:l,stroke:r,strokeWidth:o})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===r.colors.background?"#fff":r.colors.background,lineWidth:1.5,spacing:5,angle:45}));let o=new Map;Array.from(i).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}let _,P=Pl({nodes:v.scene,renderMode:e.renderMode,idPrefix:A}),L=P.map(e=>e.element),$=!1!==e.showAxes?function(e,i,r,o,a,n,l,s=!1){let c=e.scales;if(!c||"radial"===c.projection)return null;let u=se(o),d="vertical"===c.projection,f=e.columns,p=r.categoryFormat||r.oFormat,y=r.valueFormat||r.rFormat,g=r.categoryLabel||r.oLabel,m=r.valueLabel||r.rLabel,x=r.legendPosition??"right",b=h(r.legendLayout,l?.leftAxis),v=s&&"left"===x&&b>0?b:n?.left??r.margin?.left??40,w=Object.values(f).map((e,t)=>({pixel:e.middle,label:p?p(e.name,t):e.name})),k=r.rTickValues??Rn(c.r,5,r.axisExtent),A=y||t(k),S=k.map(e=>({pixel:c.r(e),label:A(e)}));return jm("g",d?{id:(a?a+"-":"")+"axes",className:"ordinal-axes",children:[Wm("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>jm("g",{transform:`translate(${e.pixel},${i.height})`,children:[Wm("line",{y2:5,stroke:u.border,strokeWidth:1}),Cn(e.label)?Wm("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):In({label:e.label,x:-30,y:6,textAlign:"center",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oxtick-"+t)),g&&Wm("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:g}),Wm("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>jm("g",{transform:`translate(0,${e.pixel})`,children:[Wm("line",{x2:-5,stroke:u.border,strokeWidth:1}),Wm("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oytick-"+t)),m&&Wm("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:m})]}:{id:(a?a+"-":"")+"axes",className:"ordinal-axes",children:[Wm("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>jm("g",{transform:`translate(${e.pixel},${i.height})`,children:[Wm("line",{y2:5,stroke:u.border,strokeWidth:1}),Wm("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oxtick-"+t)),m&&Wm("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:m}),Wm("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>jm("g",{transform:`translate(0,${e.pixel})`,children:[Wm("line",{x2:-5,stroke:u.border,strokeWidth:1}),Cn(e.label)?Wm("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):In({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&Wm("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:g})]})}(v,{width:p,height:y},e,r,A,n,d,!!f):null,T=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{o:v.scales.o,r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:p,height:y},theme:r,projection:g,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:A,onRender:e=>{_=e}}):null;if(i){let t=v.scales.o?.domain?.();i.evidence=Ta({frameType:"ordinal",width:o[0],height:o[1],marks:P.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:_,yDomain:$a(v.scales.r?.domain?.()),categories:Array.isArray(t)?t.map(String):void 0,margin:n})}let R=m&&e.centerContent?function(e,t,i){if(!am.isValidElement(e)||!lm.has(e.type))return null;let r=e,o="text"===r.type?am.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;return nm("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}(e.centerContent,n.left+p/2,n.top+y/2):null,C=m&&e.centerContent?R??Wm("foreignObject",{x:n.left,y:n.top,width:p,height:y,pointerEvents:"none",children:Wm("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,I=jm(Em,{children:[S,L,$,T,k,v.customLayoutOverlays]});return sm.renderToStaticMarkup(Hn(jm(Em,m?{children:[w?Wm("g",{transform:`translate(${-p/2},${-y/2})`,children:w}):null,I]}:{children:[w,I]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:m?`translate(${n.left+p/2},${n.top+y/2})`:`translate(${n.left},${n.top})`,innerWidth:p,innerHeight:y,legend:f,defs:M,outerElements:C,idPrefix:e._idPrefix}))}function $l(e,t){Ym[e]=t}function Tl(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function Rl(e,t){function i(e){c[e]=!1,u.hasOwnProperty(e)&&Object.keys(u[e]).forEach(function(t){delete u[e][t],c[t]&&i(t)})}function r(e){var t,a,l=!1;for(s.push(e),c[e]=!0,t=0;d[e].length>t;t++)(a=d[e][t])===n?(o(n,s),l=!0):c[a]||(l=r(a));if(l)i(e);else for(t=0;d[e].length>t;t++){var h=u[a=d[e][t]];h||(u[a]=h={}),h[a]=!0}return s.pop(),l}function o(e,i){var r=[].concat(i).concat(e);t?t(r):l.push(r)}function a(t){!function(t){for(var i=0;e.length>i;i++)(t>i||!e[i])&&(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}(t);for(var i,r=function(e){function t(t){var i=[t],c=[t];for(r[t]=o[t]=d,a[t]=!0,d+=1;c.length>0;){var u=e[t=c[c.length-1]];if(u.length>n[t]){for(var p=n[t];u.length>p;++p){var y=u[p];if(0>r[y]){r[y]=o[y]=d,a[y]=!0,d+=1,i.push(y),c.push(y);break}a[y]&&(o[t]=0|Math.min(o[t],o[y])),l[y]>=0&&s[t].push(l[y])}n[t]=p}else{if(o[t]===r[t]){var g=[],m=[],x=0;for(p=i.length-1;p>=0;--p){var b=i[p];if(a[b]=!1,g.push(b),m.push(s[b]),x+=s[b].length,l[b]=h.length,b===t){i.length=p;break}}h.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];f.push(v)}c.pop()}}}for(var i=e.length,r=Array(i),o=Array(i),a=Array(i),n=Array(i),l=Array(i),s=Array(i),c=0;i>c;++c)r[c]=-1,o[c]=0,a[c]=!1,n[c]=0,l[c]=-1,s[c]=[];var u,d=0,h=[],f=[];for(c=0;i>c;++c)0>r[c]&&t(c);for(c=0;f.length>c;c++){var p=f[c];if(0!==p.length){p.sort(function(e,t){return e-t}),u=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&u.push(p[y]);f[c]=u}}return{components:h,adjacencyList:f}}(e),o=r.components.filter(function(e){return e.length>1}),a=1/0,n=0;o.length>n;n++)for(var l=0;o[n].length>l;l++)a>o[n][l]&&(a=o[n][l],i=n);var s=o[i];return!!s&&{leastVertex:a,adjList:e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})})}}var n,l=[],s=[],c=[],u={},d=[];n=0;for(var h=e.length;h>n;){var f=a(n);if(n=f.leastVertex,d=f.adjList){for(var p=0;d.length>p;p++)for(var y=0;d[p].length>y;y++){var g=d[p][y];c[+g]=!1,u[g]={}}r(n),n+=1}else n=h}if(!t)return l}function Cl(e){return e.y0-e.y1>0?"up":"down"}function Il(e,t){return t(e.source)==t(e.target)}function Dl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),!(t>1||i>1)}function zl(e){return e.target.x0-e.source.x1}function Ol(e,t){var i=Nl(e),r=zl(t)/Math.tan(i);return"up"==Cl(e)?e.y1-r:e.y1+r}function Fl(e,t){var i=Nl(e),r=zl(t)/Math.tan(i);return"up"==Cl(e)?e.y1+r:e.y1-r}function Nl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function El(e,t){return t(e)}function Wl(e){return Bl(e.source)}function jl(e){return Bl(e.target)}function Bl(e){return(e.y0+e.y1)/2}function Yl(e){return e.virtual?0:e.value}function Xl(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!Il(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!Il(e,t)?r+1:r}),i+r}function Gl(e){return e.target.depth}function Vl(e,t){return e.sourceLinks.length?e.depth:t-1}function Hl(e,t){return e.y0-t.y0}function ql(e,t){return t.y0-e.y0}function Ul(e,t){return e.y1-t.y1}function Zl(e,t){return t.y1-e.y1}function Kl(e,t){return Jl(e.source,t.source)||e.index-t.index}function Ql(e,t){return Jl(e.target,t.target)||e.index-t.index}function Jl(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function es(e,t){return ts(e)==ts(t)?"bottom"==e.circularLinkType?ql(e,t):Hl(e,t):ts(t)-ts(e)}function ts(e){return e.target.column-e.source.column}function is(e,t){return rs(e)==rs(t)}function rs(e){return e.y0-e.y1>0?"up":"down"}function os(e,t,i,r,o){let a=e;var n=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,n))});var l=Xm(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=a.links.filter(function(e){return e.circular});return s.sort(function(e,t){return t.value-e.value}),s.forEach(function(e,t){e._circularStub=t>=4}),as(a.links.filter(function(e){return"top"==e.circularLinkType}),t,i),as(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Il(e,t)&&Dl(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var n=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==n&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?ql:Hl);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),n=e.target.column,(c=a.links.filter(function(e){return e.target.column==n&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?Zl:Ul),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,i=e.y0,r=e.target.x0,o=e.y1,a=(t+r)/2;return"M"+t+","+i+"C"+a+","+i+" "+a+","+o+" "+r+","+o}(e)}),a}function as(e,t,i){e.sort(es);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var a=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Il(e,t)&&Dl(e))e.circularPathData.verticalBuffer=a+e._circularWidth/2;else{for(var n=0;r.length>n;n++){var l=r[n];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&ns(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+i;a=s>a?s:a}}e.circularPathData.verticalBuffer=a+e._circularWidth/2}}),e}function ns(e,t){return!(t.target.column>e.source.column||e.target.column>t.source.column)}function ls(e){return function(){return e}}function ss(e){return e.index}function cs(e){return e.nodes}function us(e){return e.links}function ds(e,t,i){var r=Zm(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,a){var n=o.length;if(t)o.sort(t);else if(a>0){var l=new Map;o.forEach(function(e,t){var i,r,o,a=(r=0,o=0,(i=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Bl(e.source)*t,r+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Bl(e.target)*t,r+=t}}),r>0?o/r:NaN);l.set(e,{bc:a,idx:t})}),o.sort(function(e,t){var i=l.get(e),r=l.get(t),o=i.bc,a=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?i.idx-r.idx:1:-1:o-a})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Xl(t,i)-Xl(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==n||0==t.depth&&1==n?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Xl(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/n*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-n/2+o,t.y1=t.y0+t.value*e.ky)})})}function hs(e,t,i,r,o,a){function n(t,i){var r=s.length;s.forEach(function(o){var a=o.length,n=o[0].depth;o.forEach(function(o){var l;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Xl(o,i)>0){var s=qm(o.sourceLinks,jl),c=qm(o.targetLinks,Wl),u=s&&c?(s+c)/2:s||c;if(u){var d=(u-Bl(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==n&&1==a)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(n==r-1&&1==a)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)l=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+l;else{var h=qm(o.sourceLinks,jl),f=qm(o.targetLinks,Wl),p=((h&&f?(h+f)/2:h||f)-Bl(o))*t;o.y0+=p,o.y1+=p}})})}function l(){s.forEach(function(i){var a,n,l,s=e.y0,c=i.length;for(i.sort(t||Jl),l=0;c>l;++l)(n=s-(a=i[l]).y0)>0&&(a.y0+=n,a.y1+=n),s=a.y1+r;if((n=s-r-e.y1)>0)for(s=a.y0-=n,a.y1-=n,l=c-2;l>=0;--l)(n=(a=i[l]).y1+o-s)>0&&(a.y0-=n,a.y1-=n),s=a.y0})}var s=Zm(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});l();for(var c=1,u=a;u>0;--u)n(c*=.99,i),l()}function fs(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Ql),e.targetLinks.sort(Kl)}),e.nodes.forEach(function(e){var t=e.y0,i=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function ps(){function e(){var e={nodes:p.apply(null,arguments),links:y.apply(null,arguments)};return function(e){e.x0=t,e.y0=i,e.x1=r,e.y1=o,e.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=function(e,t){var i=new Map;return Um(e,t).forEach(function(e,t){i.set(t,e[0])}),i}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=Tl(i,r)),"object"!=typeof o&&(o=e.target=Tl(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(e,s),function(e,t){var i=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var a=e.links[o],n=a.source.index,l=a.target.index;r[n]||(r[n]=[]),r[l]||(r[l]=[]),-1===r[n].indexOf(l)&&r[n].push(l)}var s=Rl(r);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}(e,u),function(e,t){var i=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>i?"top":"bottom","top"==o.circularLinkType?i++:r++,e.nodes.forEach(function(e){(El(e,t)==El(o.source,t)||El(e,t)==El(o.target,t))&&(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Il(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(e,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Hm(e.sourceLinks,Yl),Hm(e.targetLinks,Yl)),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)})})}(e),function(e,t,i){var r,o,a;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var n=0,l=t(e.nodes[0]);e.nodes.forEach(function(e){n=t(e)==l?n:n+1,l=t(e)==l?l:t(e),e.column=n})}for(r=e.nodes,o=[],a=0;r.length;++a,r=o,o=[])r.forEach(function(e){e.depth=a,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],a=0;r.length;++a,r=o,o=[])r.forEach(function(e){e.height=a,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?i(e,a):e.column})}(e,u,c);var p=n;if(null!==l){var y=Zm(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=Vm(y,function(e){return e.length});g>1&&(p=Math.max(1,(o-i)*l/(g-1)))}(function(e,t,i){var r=Zm(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=Gm(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Hm(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var a=Vm(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/a),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})})(e,p,a),ds(e,u,s),hs(e,u,s,p,p,d),fs(e),os(e,s,h,f,8),ds(e,u,s),hs(e,u,s,p,p,d),fs(e),os(e,s,h,f,8),function(e,t){let i=e;i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var r=i.links.filter(function(i){return El(i.source,t)==El(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!is(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=Ol(t,e);return e.y1-i}if(t.target.column>e.target.column)return Ol(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 a=e.y0;r.forEach(function(e){e.y0=a+e.width/2,a+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var a=i+1,n=0;o>a;a++)n+=r[a].width;t.y0=e.y1-n-t.width/2}})})}(e,s),function(e,t){let i=e;i.nodes.forEach(function(e){var r=i.links.filter(function(i){return El(i.target,t)==El(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!is(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=Fl(t,e);return e.y0-i}if(t.source.column>e.source.column)return Fl(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 a=e.y0;r.forEach(function(e){e.y1=a+e.width/2,a+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var a=i+1,n=0;o>a;a++)n+=r[a].width;t.y1=e.y1-n-t.width/2}})})}(e,s),function(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-a)/(n-a)*(e.y1-e.y0)+e.y0};var a=Gm(t,function(e){return e.y0}),n=Vm(t,function(e){return e.y1}),l=(e.y1-e.y0)/(n-a);1>l?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}(e),os(e,s,h,f,8)}(e),e}var t=0,i=0,r=1,o=1,a=24,n=8,l=null,s=ss,c=Vl,u=void 0,d=32,h=2,f=10,p=cs,y=us;return e.update=function(e){return fs(e),os(e,s,h,f,8),e},e.nodeWidth=function(t){return arguments.length?(a=+t,e):a},e.nodePadding=function(t){return arguments.length?(n=+t,e):n},e.nodePaddingRatio=function(t){return arguments.length?(l=+t,e):l},e.nodes=function(t){return arguments.length?(p="function"==typeof t?t:ls(t),e):p},e.links=function(t){return arguments.length?(y="function"==typeof t?t:ls(t),e):y},e.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:ls(t),e):s},e.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ls(t),e):c},e.nodeSort=function(t){return arguments.length?(u=t,e):u},e.iterations=function(t){return arguments.length?(d=+t,e):d},e.circularLinkGap=function(t){return arguments.length?(h=+t,e):h},e.extent=function(a){return arguments.length?(t=+a[0][0],i=+a[0][1],r=+a[1][0],o=+a[1][1],e):[[t,i],[r,o]]},e.size=function(a){return arguments.length?(t=i=0,r=+a[0],o=+a[1],e):[r-t,o-i]},e}function ys(e){let t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r||"down"===e.direction)return null;if(e._circularStub){let i=r.sourceX,o=r.sourceY,a=r.targetX,n=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;let l=Math.max(15,Math.min(40,.33*(r.rightFullExtent-i))),s=Math.max(15,Math.min(40,.33*(a-r.leftFullExtent)));return`M${i},${o-t}L${i+l},${o-t}L${i+l},${o+t}L${i},${o+t}ZM${a},${n-t}L${a-s},${n-t}L${a-s},${n+t}L${a},${n+t}Z`}let o=r.sourceX,a=r.sourceY,n=r.targetX,l=r.targetY,s=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${a-d*t}L${s},${a-d*t}L${s+i},${a-d*t+d*h}L${s+i},${u+d*i-d*h}L${s+i-h},${u+d*i}L${c-i+h},${u+d*i}L${c-i},${u+d*i-d*h}L${c-i},${l-d*t+d*h}L${c-i+h},${l-d*t}L${n},${l-d*t}L${n},${l+d*t}L${c+i},${l+d*t}L${c+i},${u-d*i}L${s-i},${u-d*i}L${s-i},${a+d*t}L${o},${a+d*t}Z`}function gs(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=ix.get(e);if(i){let e=i.get(t);if(e)return e}else i=new Map,ix.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;tx.has(e)||(tx.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,r)}});return i.set(t,r),r}function ms(e,t,i){let r=[];for(let o of t){let t=Hc(o.source),a=Hc(o.target),n=null;if(t===e?n=a:a===e&&(n=t),n){let e=i.get(n);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function xs(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function bs(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],a=0;for(;r.length>a;){let e=r[a];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),a++;r.length>a&&!isNaN(Number(r[a]));)o.push(Number(r[a])+t+""),a++,r.length>a&&!isNaN(Number(r[a]))&&(o.push(Number(r[a])+i+""),a++);else if("A"===e)for(o.push(e),a++;r.length>a&&!isNaN(Number(r[a]));)o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&(o.push(Number(r[a])+t+""),a++),r.length>a&&(o.push(Number(r[a])+i+""),a++);else"Z"===e||"z"===e?(o.push(e),a++):(o.push(r[a]),a++)}return o.join(" ")}function vs(e){let[t,i,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}let 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*i+.114*r>150?"#222":"#fff"}function ws(e,t,i){let r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+i}function ks(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function As(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Mx}function Ss(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 Ms(e,t,i,r,o){if("horizontal"===o){let o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${i},${r}`}if("radial"===o){let o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${i},${r}`}{let o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${r}`}}function _s(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ps(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 Ls(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function $s(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"u">typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function Ts(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Rs(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=Ru(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,td(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Cs(e){if(!e)return;let t=[];for(let i of e){let e=Rs(i);e&&t.push({pointId:Ts(i),...e})}return t}function Is(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ds(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function zs(e,t){let i=le(e.theme),r=e.chartType||"force",o=e.size||[500,500],n=function(e){return Yg.has(e)?Bg:jg}(r),s=l({...n,...e.margin},e.title),c=a(e.title),u=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=F(e.nodes||[]);if(o.length>0)return Ka(o,t);if(zx.has(r)&&e.data)return Ka(di(e.data,e.childrenAccessor||"children"),t);let a=Array.isArray(e.edges)?F(e.edges):[];if(0===a.length)return[];let n=Is(e.sourceAccessor,"source"),l=Is(e.targetAccessor,"target");return Ka(Array.from(new Set(a.flatMap(e=>[n(e),l(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Gn(s,{props:e,categories:u,theme:i,size:o,hasTitle:c});let d=Vn({props:e,categories:u,theme:i,size:o,margin:s,hasTitle:c}),h=o[0]-s.left-s.right,f=o[1]-s.top-s.bottom,p=qn(e.backgroundGraphics,o,s,null),y=qn(e.foregroundGraphics,o,s,null),g=()=>{let r,a=e=>Number(e),n=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:a,y:a},layout:{width:h,height:f},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=(t=>Ta({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:s}))(r)),Bm.renderToStaticMarkup(Hn(p||y||e.annotations?Dx(Ix,{children:[p,n,y]}):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:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))},m=function(e){return Ym[e]}(r);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let x,b,v={chartType:r,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,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};if(zx.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return g();v.__hierarchyRoot=t,x=[],b=[]}else{let t=F(e.nodes||[]),i=Array.isArray(e.edges)?F(e.edges):[];if(0===t.length&&0===i.length)return g();if(b=function(e,t){let i=Is(t.sourceAccessor,"source"),r=Is(t.targetAccessor,"target"),o=Is(t.valueAccessor,"value");return e.map((e,t)=>{let a=Number(o(e)),n=i(e)+"",l=r(e)+"";return{source:n,target:l,value:Number.isFinite(a)?a:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${n}\0${l}\0${t}`}})}(i,v),0===t.length&&b.length>0){let e=new Set;for(let t of b){let i=Wn(t.source),r=Wn(t.target);i&&e.add(i),r&&e.add(r)}x=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 x=function(e,t){let i=Is(t.nodeIDAccessor,"id");return e.map(e=>({id:i(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}))}(t,v)}let w=[],k=[],A=[],S=null,M=null;if(v.customNetworkLayout){let e=v.colorScheme,t=$i(e,i.colors.categorical,vd),r=Ti(t,e),o={nodes:x,edges:b,dimensions:{width:h,height:f,plot:{x:0,y:0,width:h,height:f}},theme:{semantic:i.colors,categorical:[...t]},resolveColor:r,config:v.layoutConfig??{}},a=v.customNetworkLayout(o);w=a.sceneNodes??[],k=a.sceneEdges??[],A=a.labels??[],S=a.backgrounds??null,M=a.overlays??null}else if(m){m.computeLayout(x,b,v,[h,f]);let e=m.buildScene(x,b,v,[h,f]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}let _=se(i);for(let e of A)e.fill||(e.fill=_.text);let P,L=Ba({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Na(function(e,t){switch(e.type){case"line":return Rx("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":{let i=e,r=`net-bezier-${t}-hatch`,o=ai(i.style.fill)?li(i.style.fill,r):void 0;return Cx($x.Fragment,{children:[o&&Rx("defs",{children:o}),Rx("path",{d:i.pathD,fill:o?`url(#${r})`:Ra(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=ai(i.style.fill)?li(i.style.fill,r):void 0;return Cx($x.Fragment,{children:[o&&Rx("defs",{children:o}),Rx("path",{d:i.pathD,fill:o?`url(#${r})`:Ra(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"curved":{let i=e;return Rx("path",{d:i.pathD,fill:Ra(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth??1,opacity:i.style.opacity},"net-edge-"+t)}default:return null}}(e,t),e,"network-edge-cursor-"+t)}(e,t)}),$=Ba({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Na(function(e,t){switch(e.type){case"circle":{let i=e,r=ai(i.style.fill)?li(i.style.fill,`net-circle-${t}-hatch`):void 0;return Cx($x.Fragment,{children:[r&&Rx("defs",{children:r}),Rx("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:r?`url(#net-circle-${t}-hatch)`:Ra(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{let i=e,r=ai(i.style.fill)?li(i.style.fill,`net-rect-${t}-hatch`):void 0;return Cx($x.Fragment,{children:[r&&Rx("defs",{children:r}),Rx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:r?`url(#net-rect-${t}-hatch)`:Ra(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{let i=e,r=Tx().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Gy)||"",o=ai(i.style.fill)?li(i.style.fill,`net-arc-${t}-hatch`):void 0;return Cx($x.Fragment,{children:[o&&Rx("defs",{children:o}),Rx("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Ra(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-arc-"+t)}case"symbol":{let i=e,r=ed(i.symbolType,i.size,i.path);return Rx("path",{d:r,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?Ra(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},"net-symbol-"+t)}case"glyph":return Ia(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t),e,"network-node-cursor-"+t)}(e,t)}),T=L.map(e=>e.element),R=$.map(e=>e.element),C=A.map((e,t)=>function(e,t){return Rx("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),I=e=>Number(e),D=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:I,y:I},layout:{width:h,height:f},theme:i,frameType:"network",annotationData:Ds(w),pointNodes:Cs(w),idPrefix:e._idPrefix,onRender:e=>{P=e}}):null;return t&&(t.evidence=Ta({frameType:"network",width:o[0],height:o[1],marks:[...$.map(({node:e})=>({type:"node:"+(e.type??"node")})),...L.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:P,nodeCount:$.length,edgeCount:L.length,margin:s})),Bm.renderToStaticMarkup(Hn(Dx(Ix,{children:[p,S,T,R,C,D,y,M]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}function Os(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Fs(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Ns(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function Es(e,t){if(2>e.length)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;e.length>t;t++){let a=e[t];Math.abs(a[0]-e[t-1][0])>i?(o.length>=2&&r.push(o),o=[a]):o.push(a)}return o.length>=2&&r.push(o),r}function Ws(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],a=Math.sqrt(r*r+o*o);if(0===a)return[e,t];let n=-o/a,l=r/a,s=Math.min(.3*a,80),c=(e[0]+t[0])/2+n*s,u=(e[1]+t[1])/2+l*s,d=[];for(let r=0;i>=r;r++){let o=r/i,a=1-o;d.push([a*a*e[0]+2*a*o*c+o*o*t[0],a*a*e[1]+2*a*o*u+o*o*t[1]])}return d}function js(e,t){if(2>e.length)return e;let i=t/2+1,r=[];for(let t=0;e.length>t;t++){let o,a,n=e[t];0===t?(o=e[1][0]-n[0],a=e[1][1]-n[1]):t===e.length-1?(o=n[0]-e[t-1][0],a=n[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],a=e[t+1][1]-e[t-1][1]);let l=Math.sqrt(o*o+a*a)||1;r.push([n[0]+a/l*i,n[1]+-o/l*i])}return r}function Bs(e,t,i,r,o){let a=t[0]-e[0],n=t[1]-e[1],l=Math.sqrt(a*a+n*n);if(0===l)return[e,t];let s=n/l,c=-a/l,u=o/2+1;return[[e[0]+s*u,e[1]+c*u],[t[0]+s*u,t[1]+c*u]]}function Ys(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}function Xs(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=Ru(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}function Gs({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:a,layout:n},ringStyle:l,ringValues:s,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===n,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...l};return pb("g",h?{children:[fb("line",{x1:i,y1:r,x2:i+a,y2:r,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),fb("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&s.map(n=>{let l=i+(o>0?n/o*a:0);return pb("g",{children:[fb("line",{x1:l,y1:r-2.5,x2:l,y2:r+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&pb("text",{x:l,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[n,t?" "+t:""]})]},n)})]}:{children:[s.map(e=>{let n=e/o*a;return pb("g",{children:[fb("circle",{cx:i,cy:r,r:n,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&pb("text",{x:i+n+3,y:r-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?" "+t:""]})]},e)}),c&&pb("g",{transform:"translate(24, 24)",children:[fb("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),fb("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),fb("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),fb("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),fb("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),fb("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Vs(e,t){let i=le(e.theme),r=e.size||[e.width||600,e.height||400],o=l({top:10,right:10,bottom:10,left:10,...e.margin},e.title),n=a(e.title),s=Array.isArray(e.areas)?F(e.areas):e.areas,c=F(e.points),u=F(e.lines),d=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return Ka(c.length>0?c:Array.isArray(s)&&s.length>0?"string"==typeof t?s.map(e=>({...e.properties||{},...e})):s:[],t)})():[];Gn(o,{props:e,categories:d,theme:i,size:r,hasTitle:n});let h=Vn({props:e,categories:d,theme:i,size:r,margin:o,hasTitle:n}),f=r[0]-(o.left??0)-(o.right??0),p=r[1]-(o.top??0)-(o.bottom??0),y={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:lu(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new cb(y);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);g.setAreas(s)}e.points&&g.setPoints(c),e.lines&&g.setLines(u),g.computeScene({width:f,height:p});let m=qn(e.backgroundGraphics,r,o,g.scales),x=qn(e.foregroundGraphics,r,o,g.scales),b=Ba({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Na(function(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=ai(i.style.fill)?li(i.style.fill,`geoarea-${t}-hatch`):void 0;return hb(ub.Fragment,{children:[r&&db("defs",{children:r}),db("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:Ra(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:i._decayOpacity??1})]},"geoarea-"+t)}case"point":{let i=e,r=ai(i.style.fill)?li(i.style.fill,`geopoint-${t}-hatch`):void 0;return hb(ub.Fragment,{children:[r&&db("defs",{children:r}),db("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:Ra(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+t)}case"line":{let i=e;if(2>i.path.length)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");return db("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+t)}case"glyph":return Ia(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t),e,"geo-cursor-"+t)}(e,t)});if(0===b.length){let a,n=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:Xs(g.scene),idPrefix:e._idPrefix,onRender:e=>{a=e}}):null;return t&&(t.evidence=Ta({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:a,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Ox.renderToStaticMarkup(Hn(m||x||e.annotations||g.customLayoutOverlays?mb(yb,{children:[m,n,x,g.customLayoutOverlays]}):null,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}let v,w=b.map(e=>e.element),k=e.cartogramChrome,A=g.cartogramLayout&&k?gb(Gs,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:Hs(g.cartogramLayout.maxCost,k.showRings),showRings:k.showRings??!0,showNorth:k.showNorth??!0,showRingLabels:k.showRingLabels??!0,costLabel:"string"==typeof k.costLabel?k.costLabel:void 0}):null,S=e.annotations?kn({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:Xs(g.scene),idPrefix:e._idPrefix,onRender:e=>{v=e}}):null;return t&&(t.evidence=Ta({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:v,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Ox.renderToStaticMarkup(Hn(mb(yb,{children:[m,w,S,A,x,g.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}function Hs(e,t){if(!1===t||0>=e)return[];if(Array.isArray(t))return t.filter(t=>t>0&&e>=t);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;i>=e;e++)o.push(Math.round(r*e*10)/10);return o}function qs(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}:{}}))}function Us(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Zs(e,t,i){let r="function"==typeof t?t(e,i):t;return{...bb,...r??{}}}function Ks(e,t={},i="settled"){return e.map((e,r)=>function(e,t={},i={index:0,simulationState:"settled"}){let r=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??Us(e)},a={style:Zs(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_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,...a}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...a}}(e,t,{index:r,simulationState:i}))}function Qs(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function Js(e,t={}){let{element:i,scene:r,evidence:o}=function(e,t={}){let{width:i=640,height:r=360,title:o,description:a,background:n,backgroundGraphics:l,backgroundGraphicsBackdrop:s,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:y,...g}=t,m=function(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot(),a=Ks(r,t,o.simulationState),n=function(e,t={}){let i=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),r=i.filter(e=>e.sleeping).length,o=e.queue.length,a=e.sediment.reduce((e,t)=>e+t.count,0),n="settled"===e.simulationState&&0===o&&r===i.length,l=[];n||l.push("PHYSICS_NOT_SETTLED"),o>0&&l.push("PHYSICS_QUEUE_UNDRAINED");let s=null!=t.charge&&Number.isFinite(t.charge)?function(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}(t.charge,i.length,o,a):void 0;return s&&!s.balanced&&l.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:n,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:qs(t.projectionRows),queuedCount:o,sedimentedCount:a,...s?{ledger:s}:{},warnings:l}}(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge});return{snapshot:o,bodies:r,sceneNodes:a,evidence:n,stepsRun:i}}(e,g),x={...kb,...h},b=[i,r],v=Qs(l,b,x),w=Qs(u,b,x),k=function(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(d),A=o?k+"-title":void 0,S=a?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,_=x.left||x.top?`translate(${x.left},${x.top})`:void 0,P=Math.max(1,i-x.left-x.right),L=Math.max(1,r-x.top-x.bottom),$=k+"-plot-clip",T=_&&null!=v?vb("g",{transform:_,children:v}):v;return{element:wb("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:f,children:[o&&vb("title",{id:A,children:o}),a&&vb("desc",{id:S,children:a}),vb("defs",{children:vb("clipPath",{id:$,children:vb("rect",{width:P,height:L})})}),s&&"transparent"!==s?vb("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:s}):null,!l&&n&&"transparent"!==n?vb("rect",{x:0,y:0,width:i,height:r,fill:n}):null,T,vb("g",{id:k+"-data-area",transform:_,clipPath:`url(#${$})`,children:m.sceneNodes.map((e,t)=>{let i=m.bodies[t],r=i&&p?p(i,e.style??{},t,k):void 0;return null!=r?Na(r,e,t):Na("point"===e.type||"rect"===e.type?Oa(e,t,k):null,e,"xy-cursor-"+t)})}),w,y?.(m)]}),scene:m,evidence:m.evidence}}(e,t);return{svg:xb.renderToStaticMarkup(i),scene:r,evidence:o}}function ec(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function tc(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,ec(e.thickness)??ec(i)??ec(t.thickness)??4)}function ic(e){return e.sensorId??"stream-region-"+e.id}function rc(e){let t=ic(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,a=e.shape.x+e.shape.width/2,n=e.shape.y-e.shape.height/2,l=e.shape.y+e.shape.height/2;return[{...i,id:t+"-top",shape:{type:"segment",x1:o,y1:n,x2:a,y2:n,thickness:r}},{...i,id:t+"-right",shape:{type:"segment",x1:a,y1:n,x2:a,y2:l,thickness:r}},{...i,id:t+"-bottom",shape:{type:"segment",x1:a,y1:l,x2:o,y2:l,thickness:r}},{...i,id:t+"-left",shape:{type:"segment",x1:o,y1:l,x2:o,y2:n,thickness:r}}]}return e.collider?[{...i,id:t+"-collider",shape:e.shape}]:[]}function oc({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?Ab("foreignObject",{x:0,y:0,width:t,height:i,children:e}):Ab("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}function ac(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function nc(e,t){let i=e.size??[e.width??600,e.height??400],r=le(e.theme),o=void 0===e.theme?{}:su(r),a=e.bodyStyle,l=!1,c=e.legendPosition??"right",u=n({...Pb,...e.margin},l,!!e.legend&&"top"===c);if(e.legend){let t={...u};x(u,{legend:e.legend,position:c,size:i,hasTitle:l,legendLayout:e.legendLayout}),s(u,t,i,c)}let d,h=function({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:a,seed:n,size:l}){let s=function(e=[],t={}){let i=t.idPrefix?t.idPrefix+"-":"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,a=o.axis??t.defaultAxis??"x",n=tc(o,t),l=o.colliderId??`${i}${o.id}`;if("x"===a){let i=ec(o.x),r=ec(o.y1)??ec(t.plotBounds?.y)??ec(o.y),a=ec(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??ec(o.y);if(null==i||null==r||null==a)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:a,thickness:n}}else{let i=ec(o.y),r=ec(o.x1)??ec(t.plotBounds?.x)??ec(o.x),a=ec(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??ec(o.x);if(null==i||null==r||null==a)continue;e={type:"segment",x1:r,y1:i,x2:a,y2:i,thickness:n}}r.push({id:l,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:ec(o.restitution)??ec(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:ec(o.friction)??ec(t.barrierFriction)}})}return r}((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?t+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:l[0],height:l[1]}}),c=void 0===n||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:n}},u=a.flatMap(e=>[{id:ic(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...rc(e)]),d=Object.fromEntries(a.map(e=>[ic(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,f=a.length>0;return f||u.length>0||s.length>0||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...s],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{f&&o(e),h?.onObservation?.(e)}}}:c}({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),f=new yu(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&f.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));let p=Js(f,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof a?a(e,t):a}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:u,renderChrome:t=>{let o=function(e,t,i,r,o){let a=Math.max(1,i[0]-r.left-r.right),n=Math.max(1,i[1]-r.top-r.bottom),l=function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(t.annotations),s=function(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:Sb().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:Sb().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}({width:a,height:n,pointNodes:(d=e.bodies,d.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,ac(e))})))}),c=s.scales?.x,u=s.scales?.y;var d;if(!c||!u)throw Error("Physics annotation context requires pixel scales");let h,f=kn({annotations:l,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:a,height:n},theme:o,frameType:"network",xAccessor:s.xAccessor,yAccessor:s.yAccessor,pointNodes:s.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{h=e}}),p=t.legend?Xn(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??An(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:h,node:_b("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Mb("g",{transform:`translate(${r.left},${r.top})`,children:f}),Mb(oc,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),p]})}}(t,e,i,u,r);return d=o.annotationRender,o.node}});return t&&(t.evidence=Ta({frameType:"physics",width:i[0],height:i[1],marks:p.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:d,extraWarnings:[...0===p.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...p.scene.evidence.warnings]})),p.svg}function lc(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function sc(e,t,i){return Cb[e](t,i)}function cc(e,t){switch(e){case"xy":return Un(t);case"ordinal":return Ll(t);case"network":return zs(t);case"geo":return Vs(t);case"physics":return nc(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function uc(e){return Un(e)}function dc(e){return Ll(e)}function hc(e){return zs(e)}function fc(e){return Vs(e)}function pc(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":o+""}function yc(e,t){let i=function(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}(t);return void 0===i?e:function(e){let t=A(e)?.start??0;return e.slice(0,t)+e.slice(t).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,t)=>t?e.replace(cd,(e,t,r,o)=>{let a=((e,t)=>{if(Nb.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return function(e,t){let i,r=RegExp(Eb.source,Eb.flags),o="",a=0,n=!1;for(;i=r.exec(e);){let r=e.slice(a,i.index);o+=n&&0===r.length?" ":r,o+=pc(i[0],t),a=i.index+i[0].length,n=!0}return o+e.slice(a)}(t,i)})(t,M(r??o));return void 0===a?e:` ${t}="${S(a)}"`}):e)}(e)}function gc(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function mc(e,t,i){return bc(e,t,i).svg}function xc(e,t,i){let r={},{svg:o,frameType:a}=bc(e,t,i,r),n=r.evidence??Ta({frameType:a,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"]});if(n.component=e,n.sceneHashVersion=2,n.sceneHash=function(e,t){return Jc({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories})}(o,n),z(n,e,t),i?.artifactContract){let r=Qc(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(n.artifactContract=r.contract),n.artifactTransfer=r.transfer,n.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?Ic(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:n}}function bc(e,t,i,r){if(Object.prototype.hasOwnProperty.call(Cb,e))return{svg:yc(sc(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(om,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,a=om[e],n=function(e,t,i){let r=dd[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,a=e&&"primary"!==e||!i?.height?r.height:i.height,n=function(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){let{when:i}=e,r=t.width,o=t.height,a=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),n=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof i.minWidth&&i.minWidth>r||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof a||i.minAspectRatio>a)||"number"==typeof i.maxAspectRatio&&("number"!=typeof a||a>i.maxAspectRatio)||i.orientation&&n!==i.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])$(e[r])&&$(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??a}).props,l=n.mode||e||"primary",s=dd[l],c="context"===l||"sparkline"===l,u="primary"===l&&i?.width?i.width:s.width;return{mode:l,width:n.width??u,height:n.height??("primary"===l&&i?.height?i.height:s.height),showAxes:n.showAxes??s.showAxes,showGrid:n.showGrid??s.showGrid,enableHover:n.enableHover??(!!n.linkedHover||s.enableHover),showLegend:n.showLegend??s.showLegend,showLabels:n.showLabels??s.showLabels,title:c?void 0:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,xLabel:c?void 0:n.xLabel,yLabel:c?void 0:n.yLabel,categoryLabel:c?void 0:n.categoryLabel,valueLabel:c?void 0:n.valueLabel,marginDefaults:R(s.marginDefaults,n.showCategoryTicks,n.orientation),compactMode:c,mobileInteraction:T(n.mobileInteraction,{mode:l,width:n.width??u,mobileSemantics:n.mobileSemantics}),mobileSemantics:n.mobileSemantics}}(a.layout?.mode??("string"==typeof(z=t.mode)&&Object.prototype.hasOwnProperty.call(dd,z)?t.mode:void 0),{...a.layout?.modeDefaults,...gc(t,jb)},a.layout?.primarySize),{data:l,theme:s,background:c,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:y,...g}=t,{width:m,height:x}=n,b=[m,x],v=g.frameProps||{},w=a.layout?.margin,A="function"==typeof w?w(t,n):w??n.marginDefaults,S="xy"===a.frameType?k(A,g.axes??v.axes,!!n.title):A,M=void 0!==h?h:v.margin,_=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(M),P="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},L=gc(g,Wb),C=e=>v[e]??n[e],I={...v,...L,theme:s,title:n.title,description:n.description,showAxes:C("showAxes"),showLegend:C("showLegend"),showLabels:C("showLabels"),showGrid:C("showGrid"),xLabel:C("xLabel"),yLabel:C("yLabel"),categoryLabel:C("categoryLabel"),valueLabel:C("valueLabel"),background:c,className:u,annotations:d,size:b,margin:P,__compactMode:n.compactMode,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},D=a.buildProps(l,p,f,I,g);var z;if(a.renderStatic)o=a.renderStatic(D,r);else switch(a.frameType){case"xy":o=Un(D,r);break;case"ordinal":o=Ll(D,r);break;case"network":o=zs(D,r);break;case"geo":o=Vs(D,r);break;case"physics":o=nc(D,r)}let O=a.renderOverlay?.(D,{theme:le(s)});if(null!=O){let e=gd.renderToStaticMarkup(Fb(Ob,{children:O})),t=o.lastIndexOf("</svg>");o=0>t?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:yc(o,i?.precision),frameType:a.frameType}}function vc(e,t={}){return function(e,t,i){let{title:r,subtitle:o,theme:a,width:n=1200,height:l,layout:s={},background:c}=t,u=se(le(a)),d=s.columns||2,h=s.gap??16,f=0;r&&(f+=30),o&&(f+=20),f>0&&(f+=10);let p=Math.floor((n-h-h*(d-1))/d),y=[],g=0,m=f+h,x=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=p*e+h*(e-1),o=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0);let n=h/2+g*(p+h),l={...t.props,width:r,height:o,theme:a,_idPrefix:"chart-"+y.length},s=t.component?i.chart(t.component,l):t.frameType?i.frame(t.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=P(s,{width:r,height:o}),u=Math.max(o,c.height);y.push({x:n,y:m,width:r,height:u,svg:s,svgDimensions:c}),x=Math.max(x,u),g+=e}let b=l||m+x+h,v=y.map((e,t)=>Db("g",{transform:`translate(${e.x},${e.y})`,children:Db("foreignObject",{width:e.width,height:e.height,children:Db("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:L(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return Ib.renderToStaticMarkup(zb("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&Db("title",{children:r}),c&&Db("rect",{x:0,y:0,width:n,height:b,fill:c}),r&&Db("text",{x:n/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&Db("text",{x:n/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}(e,t,{chart:mc,frame:cc})}function wc(e,t,i,r={}){let{stepSize:o,windowSize:a,frameCount:n,xExtent:s,yExtent:c,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:f}=r,p=i.width||600,y=i.height||400,g=le(i.theme),m={...i,...s&&{xExtent:s},...c&&{yExtent:c}};if(!t||0===t.length)return[];let x=o||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=x;t.length>=e;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);let v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=l({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=p-w.left-w.right,A=y-w.top-w.bottom,S=[];if(v)for(let r=0;b.length>r;r++){let o=b[r],n=t.slice(a?Math.max(0,o-a):0,o),l={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...f&&{decay:f}},s=new Lm(l);s.ingest({inserts:n,bounded:!0}),s.computeScene({width:k,height:A}),s.scene.length>0&&S.push($c(s.scene,p,y,g,m,S.length))}else for(let r=0;b.length>r;r++){let o=b[r],n=t.slice(a?Math.max(0,o-a):0,o),l={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:s,yExtent:c,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...f&&{decay:f},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},x=new dy(l);if(x.ingest({inserts:n,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;let v=x.scales?{y:x.scales.y}:void 0;if(S.push(Lc(x.scene,p,y,g,m,v,S.length)),u>0&&r>0&&x.activeTransition){let e=u*(1e3/d);for(let t=1;u>=t;t++)x.advanceTransition(x.activeTransition.startTime+t/u*e),S.push(Lc(x.scene,p,y,g,m,v,S.length))}}return S}function kc(e,t,i={}){return t.map(t=>{try{return mc(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function Ac(e,t,i,r){let o=Sn(`${e}-${t}`),a="string"==typeof i&&i.length>0?i:void 0,n="string"==typeof r&&r.length>0?r:void 0,l=a?o.titleId:void 0,s=n?o.descId:void 0;return{titleText:a,descText:n,titleId:l,descId:s,labelledBy:[l,s].filter(Boolean).join(" ")||void 0}}function Sc(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:jn(e)||t}function Mc(e,t,i){let r=t.size??[t.width??600,t.height??400],o=le(t.theme),a=se(o),n=t.background||o.colors.background,l=t.idPrefix??"physics-gif",s=Ac(l,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=s,h=Ks(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),f=Gb("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:a.fontFamily},children:[t.title&&Xb("title",{id:c,children:t.title}),t.description&&Xb("desc",{id:u,children:t.description}),n&&"transparent"!==n?Xb("rect",{x:0,y:0,width:r[0],height:r[1],fill:n}):null,Xb("g",{id:`${l}-frame-${i}`,children:h.map((e,t)=>Wa(e,t,`${l}-${i}`))})]});return Bb.renderToStaticMarkup(f)}function _c(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:a=!0,stepDt:n,stepsPerFrame:l,background:s}=t,c=Math.max(.001,n??e.config?.fixedDt??1/120),u=l??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=s?{...e,background:s}:e,f=new yu(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);let p=[];for(a&&(f.tick(0),p.push(Mc(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(c);p.push(Mc(f,h,p.length))}return p}function Pc(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Lc(e,t,i,r,o,a,n=0){let s=se(r),c=l({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-c.left-c.right,d=i-c.top-c.bottom,h=Pc(o,r),f=o.renderMode,p=e.map((e,t)=>ja({node:e,index:t,renderMode:f,fallback:()=>Wa(e,t)}).element).filter(Boolean),y=function(e,t,i,r,o,a){if(!e||0===e.length)return null;let n=se(r),l=[];for(let r=0;e.length>r;r++){let s=e[r];if("y-threshold"===s.type&&null!=s.value){let e=null;if(a)e=a(s.value);else if(o){let[t,r]=o,a=r-t;if(0===a)continue;e=i-(s.value-t)/a*i}if(null==e)continue;let c=s.color||n.primary,u=s.labelPosition||"right";l.push(Gb("g",{children:[Xb("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:s.strokeWidth??1.5,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&Xb("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:n.tickSize,fill:c,fontFamily:n.fontFamily,children:s.label})]},"ann-"+r))}}return l.length>0?Xb(Yb,{children:l}):null}(o.annotations,u,d,r,o.yExtent,a?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=Ac(Sc(o,"xy-gif"),n,o.title,o.description);return Bb.renderToStaticMarkup(Gb("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:s.fontFamily},children:[g&&Xb("title",{id:x,children:g}),m&&Xb("desc",{id:b,children:m}),h&&Xb("rect",{x:0,y:0,width:t,height:i,fill:h}),Gb("g",{transform:`translate(${c.left},${c.top})`,children:[y,p]}),g&&Xb("text",{x:t/2,y:22,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:g})]}))}function $c(e,t,i,r,o,a=0){let n=se(r),s=l({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c="radial"===o.projection,u=c?s.left+(t-s.left-s.right)/2:s.left,d=c?s.top+(i-s.top-s.bottom)/2:s.top,h=Pc(o,r),f=Pl({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:p,descText:y,titleId:g,descId:m,labelledBy:x}=Ac(Sc(o,"ordinal-gif"),a,o.title,o.description);return Bb.renderToStaticMarkup(Gb("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":x,style:{fontFamily:n.fontFamily},children:[p&&Xb("title",{id:g,children:p}),y&&Xb("desc",{id:m,children:y}),h&&Xb("rect",{x:0,y:0,width:t,height:i,fill:h}),Xb("g",{transform:`translate(${u},${d})`,children:f}),p&&Xb("text",{x:t/2,y:22,textAnchor:"middle",fontSize:n.titleFontSize,fontWeight:n.titleFontWeight,fill:n.text,fontFamily:n.titleFontFamily,children:p})]}))}import{accessorsEquivalent as Tc,baseConfig as Rc,clampNumber as Cc,compareArtifactIdentity as Ic,createPhysicsSourceState as Dc,filterAnnotationsByStatus as zc,finiteNumber as Oc,generateGaltonMechanicalSamples as Fc,generatePhysicsPileMechanicalSamples as Nc,normalizedFiniteExtent as Ec,physicsChartArea as Wc,physicsPileUnitCount as jc,positiveNumber as Bc,readAccessor as Yc,resolveAccessor as Xc,resolveEventDropAdmissions as Gc,resolveLabelFn as Vc,resolveNodeRefId as Hc,resolveRawAccessor as qc,resolveStringAccessor as Uc,safeIdPart as Zc,seededRandom as Kc,serializeArtifactContract as Qc,stableEvidenceHash as Jc,styleFromColorAccessor as eu}from"./c-E32M6XW5.min.js";import{resolveCSSColor as tu}from"./c-OOVX2JPQ.min.js";import{DARK_THEME as iu,HIGH_CONTRAST_THEME as ru,LIGHT_THEME as ou,applyThemeAccessibility as au,resolveThemePreset as nu,resolveThemeSemanticColors as lu,themeToCSSVariables as su}from"./c-42PLDTX7.min.js";import{composeStyleRules as cu,makeNodeRuleContext as uu,makeRuleValueResolver as du,makeXYRuleContext as hu,resolveStyleRules as fu,styleRulesToNodeStyle as pu}from"./c-I4QJ6YLM.min.js";import{PhysicsPipelineStore as yu,UpdateResultTracker as gu,absorbRegion as mu,annotationLayout as xu,annotationNote as bu,bodyGroupSpec as vu,buildDirectedAdjacency as wu,calendarLayout as ku,capacitatedRegion as Au,collidersFromPlotBounds as Su,collidersFromXScaleBins as Mu,countPairwiseCrossings as _u,drawGlyphParts as Pu,forceFieldRegion as Lu,getGlyphPath2D as $u,glyphFractionClipRect as Tu,glyphHitGeometry as Ru,glyphPlacement as Cu,groupCompletionRows as Iu,isInBounds as Du,makeSymbolResolver as zu,measureAnnotationNote as Ou,orderByBarycenter as Fu,orderExactSmall as Nu,packBandsBySilhouette as Eu,parallelCoordinatesLayout as Wu,placeWithMinGap as ju,portalRegion as Bu,pressureFieldRegion as Yu,processChrome as Xu,processStageLayout as Gu,reachableFrom as Vu,refineByAdjacentSwaps as Hu,resolveAnchoredPosition as qu,resolveGlyphPaint as Uu,resolveNodeSizeFn as Zu,resolveX as Ku,resolveY as Qu,routeSurfaceRegion as Ju,symbolPathString as ed,symbolRadius as td,useCustomLayoutSelection as id,wrapAnnotationText as rd}from"./c-JG2JCQLP.min.js";import{getMax as od,getMin as ad,getMinMax as nd}from"./c-QA3HMQJP.min.js";var ld=34,sd=70,cd=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,ud={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},dd={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}}},hd={kind:"rank-competition"},fd=Symbol.for("semiotic.semantic-viability"),pd=globalThis,yd=pd[fd]??(pd[fd]=new Map);import*as gd from"react-dom/server";import*as md from"react";var xd=Object.freeze([]);import{scaleOrdinal as bd}from"d3-scale";var vd=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],wd=W(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),kd=W(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Ad=W(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Sd=W(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Md=W(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),_d=W(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Pd=W(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Ld=W(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),$d=W(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Td=W(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Rd=W(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Cd=W(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Id={blues:wd,reds:kd,greens:Ad,viridis:Pd,oranges:Sd,purples:Md,greys:_d,plasma:Ld,inferno:$d,magma:Td,cividis:Rd,turbo:Cd},Dd=W(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),zd=W(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Od=W(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Fd=W(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Nd=W(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Ed=W(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Wd=W(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),jd={category10:vd,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Id},Bd=vd,Yd="#007bff",Xd=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Gd=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Vd=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"]),Hd={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},qd="__forecastSegment",Ud="__forecastOpacity",Zd="__semiotic_resolvedX",Kd="__semiotic_resolvedY",Qd="__compoundGroup",Jd={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=xe({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:le(r.theme).colors.categorical}),n=ne(a.annotations,o.regression);return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...n&&n.length>0&&{annotations:n},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||be(e,t,i,r,o),showLegend:r.showLegend??!!t}}},eh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=ne(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...a&&{annotations:a},pointStyle:r.pointStyle||ve(e,t,i,r,o),showLegend:r.showLegend??!!t}}};import{useMemo as th,useCallback as ih,useState as rh,useId as oh,useEffect as ah,useRef as nh}from"react";var lh="__semioticSelectionData";import{jsx as sh}from"react/jsx-runtime";var ch={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,r,o)=>{let a=function(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",a=t.rankDirection??"descending",n=[],l=new Map,s=new Map,c=[],u=new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let a=Pe(i,e,t),f=C(a),p=l.get(f);null==p&&(p=n.length,l.set(f,p),n.push(a),s.set(p,[]));let y=Pe(o,e,t)+"";u.has(y)||(u.set(y,c.length),c.push(y));let g=Number(Pe(r,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),s.get(p)?.push({datum:e,inputIndex:t,series:y,value:g}))});let f=[],p=new Map,y=new Map;for(let e=0;n.length>e;e++){let t=s.get(e)??[];t.sort((e,t)=>("descending"===a?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;f.push({datum:t.datum,xIndex:e,xValue:n[e],series:t.series,value:t.value,rank:r}),p.set(t.series,(p.get(t.series)??0)+r),y.set(t.series,(y.get(t.series)??0)+1)})}let g=c.length+1,m=[...c].sort((e,t)=>{let i=y.get(e)??0,r=y.get(t)??0;return((p.get(e)??0)+(n.length-i)*g)/Math.max(1,n.length)-((p.get(t)??0)+(n.length-r)*g)/Math.max(1,n.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:f.map(e=>{let t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:n,seriesOrder:c,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),n=Math.max(1,a.seriesOrder.length),l=le(r.theme),s=function(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:a,neutralColor:n,themeCategorical:l,themeNeutral:s}=e;if(null==r&&null==o)return a;let c=new Set(i.slice(0,null==r?i.length:Math.max(0,Math.floor(r)))),u=new Map,d={};for(let e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(c.has(e)?_e(void 0,l,a,e,u):n??s??"#b8bec8")});return d}({seriesOrder:a.seriesOrder,overallOrder:a.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:l.colors.categorical,themeNeutral:l.colors.textSecondary}),c={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:a.valueExtent,seriesOrder:a.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:s&&"object"==typeof s&&!Array.isArray(s)?s:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=r.xFormat,d=(e,t)=>{if(0===a.xValues.length)return"";let i=a.xValues[Math.max(0,Math.min(a.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=a.xValues.map((e,t)=>t),f=Array.from({length:n},(e,t)=>t+1),p=r.axes??[{orient:"left",tickValues:f,tickFormat:e=>e+"",label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:r.xLabel,tickAnchor:"edges"}];return{...r,chartType:"custom",data:a.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,a.xValues.length-1)],yExtent:[n+.5,.5],customLayout:Oe,layoutConfig:c,colorAccessor:"__bumpSeries",colorScheme:s,xFormat:d,axes:p,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:Le(r.annotations,a.xValues)}}},uh="__ma_unitized",dh="__ma_series",hh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=Array.isArray(o.series)?o.series:[],l=function(e,t,i){let r=B(t,i,Bd),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||"Series "+(t+1),a=o?.[i];return"string"==typeof a&&a.length>0?a:r[t%r.length]})}(n,i,le(r.theme).colors.categorical),s=2===n.length,c=n.map(e=>e.extent||function(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(r>e&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}(a,e.yAccessor)),u=[];for(let e of a)n.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),a=c[i],n=a[1]-a[0]||1;u.push({...e,[uh]:s?(o-a[0])/n:o,[dh]:t.label||"Series "+(i+1)})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?r+"":r.toFixed(1)},h=s?[{orient:"left",label:n[0].label,tickFormat:d(c[0],n[0].format)},{orient:"right",label:n[1].label,tickFormat:d(c[1],n[1].format)},{orient:"bottom"}]:void 0,f=new Map;n.forEach((e,t)=>{f.set(e.label||"Series "+(t+1),l[t])});let p=q(U({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>f.get((e[dh]??"")+"")||l[0],styleRules:o.styleRules,ruleContext:Fe(o.xAccessor,n)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:uh,groupAccessor:dh,colorAccessor:dh,...h&&{axes:h},...s&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:l,lineStyle:p}}},fh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=o.xAccessor||"x",l="function"==typeof n?n:e=>e[n],s=a.some(e=>{let t=l(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=s?a.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(l(e)??t)+""})):a,u=o.styleRules?cu(void 0,o.styleRules,hu(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:s?"__waterfallX":n,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...s&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=a[Number(e)]?l(a[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},ph={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.lineBy,n=o.fillArea,l=Array.isArray(n)?"mixed":n?"area":"line",s=le(r.theme).colors.categorical,c=function(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=le(r.theme).colors.categorical,l=i??r.colorScheme??n,s="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrLineColorBy:t(e)})):a,u=t?G(c,s,l):void 0,d=hu(o.xAccessor,o.yAccessor);return q(U({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:d}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}(e,a,i,r,o),u=xe({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:a,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:r.annotations,themeCategorical:s,baseLineStyle:c}),d=r.pointStyle||Ee(u.data,u.colorAccessor,i,r,o),h=r.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let f=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:l,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(n)&&{areaGroups:n},...n&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},yh={frameType:"xy",layout:{margin:(e,t)=>function(e,t,i,r=!1){let o=y({axes:t,showAxes:i});return{...k(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}(t.marginDefaults,ce(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?F(e):[],n=o.timeAccessor||"time",l=o.valueAccessor||"value",s=o.categoryAccessor,c=o.valueExtent||r.yExtent,u={...ae(o),...void 0!==o.cursor&&{cursor:o.cursor}},d={...u,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},h=cu(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:a,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,a.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>O(e,n,"time")??NaN,valueAccessor:e=>O(e,l,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:c,invertY:"down"===o.direction,axes:ce({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:s,barColors:o.colors||r.barColors,colorScheme:o.colors||r.colorScheme,barStyle:r.barStyle||d,areaStyle:r.areaStyle||(e=>({...h(e),...!s&&void 0!==o.fill&&{fill:o.fill},...u})),showLegend:r.showLegend??!!s}}},gh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.areaBy,n=xe({data:Array.isArray(e)?F(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:le(r.theme).colors.categorical}),l=function({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,a=void 0!==t[0]?.[r];if(!a&&!i)return t;if(a)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],a=o+"";if(!e[a]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[a]=t}return e[a][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}({data:e,safeData:n.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),s=function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}(o.semanticGradient),c=s?.stops.length?{stops:s.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:ee(r.gradientFill),u=!1!==o.semanticLine?function(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}(s):void 0,d=r.pointStyle||Ee(l,a,i,r,o);return{chartType:"area",data:l,xAccessor:n.xAccessor,yAccessor:n.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:a,colorScheme:i,...r,...n.annotations.length>0&&{annotations:n.annotations},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||Ne(l,a,i,r,o),...d&&{pointStyle:d}}}},mh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.xAccessor||"x",n=o.seriesAAccessor||"a",l=o.seriesBAccessor||"b",s=e=>re(ie(a,"x",e)),c=e=>re(ie(n,"a",e)),u=e=>re(ie(l,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,y=!1!==o.showLines,g=!1!==r.showLegend,m=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=r.legendPosition||"right",v=function(e,t,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),a=[],n=0,l=null,s=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${n}-${e}`,h=e=>a.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;o.length>e;e++){let a=o[e],p=t(a),y=i(a),g=r(a);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;let m=u(y,g);if(null!==m){if(null==l){l=m;for(let e of c)f(e,l);c=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(l),__diffWinner:l,__valA:y,__valB:g,__sourceDatum:a}),s={x:p,a:y,b:g,w:m};continue}if(s&&s.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=y-s.a-(g-s.b);if(0!==i){let r=Math.max(0,Math.min(1,(s.b-s.a)/i));e=s.x+r*(p-s.x),t=s.a+r*(y-s.a)}else e=s.x,t=s.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(l),__diffWinner:l,__valA:t,__valB:t}),n++,l=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(l),__diffWinner:l,__valA:t,__valB:t});for(let e=1;c.length>e;e++)f(c[e],l)}else for(let e of c)f(e,l);c=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(l),__diffWinner:l,__valA:y,__valB:g,__sourceDatum:a}),s={x:p,a:y,b:g,w:m}}else c.push({x:p,y:y,datum:a})}for(let e of c)f(e,l??"A");return a}(Array.isArray(e)?e:[],s,c,u),w=[];if(y&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(s(e))).sort((e,t)=>s(e)-s(t));for(let e of t){let t=s(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:Q({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:o.styleRules}),lineStyle:J({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},xh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.areaBy,n="string"==typeof a&&Array.isArray(e)?G(e,a,i):void 0,l="number"==typeof o.areaOpacity?o.areaOpacity:.7,s=r.lineStyle||(e=>{let t=null==a?void 0:Y(e,a,n),i=o.showLine??!0,r={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:l,...null==o.opacity?{}:{opacity:o.opacity}},s=o.styleRules;if(s?.length){let t=du(o.yAccessor),i=a?("function"==typeof a?a(e)??"":e[a]??"")+"":void 0;Object.assign(r,fu(e,s,{value:t(e),category:i}))}return r}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||Ee(e,a,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:a,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:s,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!a}}},bh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[a]=r.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...r,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:cu(void 0,o.styleRules,hu(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(a/40))),extentPadding:r.extentPadding??(a>200?.1:.02)}}},vh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.xCenter,n=o.yCenter,l=o.quadrants,s=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=s.stroke||"#999",h=s.strokeWidth??1,f=Array.isArray(s.strokeDasharray)?s.strokeDasharray.join(","):s.strokeDasharray,p=md.createElement,y=l?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,s=null!=a?t.x(a):r/2,y=null!=n?t.y(n):o/2;if(null!=a&&!Number.isFinite(s)||null!=n&&!Number.isFinite(y))return null;let g=Math.max(0,Math.min(r,s)),m=Math.max(0,Math.min(o,y)),x=[{c:l.topLeft,x:0,y:0,w:g,h:m},{c:l.topRight,x:g,y:0,w:r-g,h:m},{c:l.bottomLeft,x:0,y:m,w:g,h:o-m},{c:l.bottomRight,x:g,y:m,w:r-g,h:o-m}],b=c?[p("text",{key:"ltl",x:8,y:8+u,fill:l.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},l.topLeft.label),p("text",{key:"ltr",x:r-8,y:8+u,fill:l.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},l.topRight.label),p("text",{key:"lbl",x:8,y:o-8,fill:l.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},l.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:l.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},l.bottomRight.label)]:[];return p(md.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("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),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:o,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:r,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:r.pointStyle||o.pointStyle||be(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...y&&{svgPreRenderers:y}}}},wh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:re(ie(t.orderAccessor,"order",e))-re(ie(t.orderAccessor,"order",i))):e,a=new WeakMap,n=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=re(ie(i,"x",e)),o=re(ie(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n++}let l=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=re(ie(i,"x",e)),o=re(ie(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a.set(e,{idx:l++,total:n})}return{data:o,orderMap:a}}(e,o),n=xe({data:a.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:le(r.theme).colors.categorical}),l=ne(n.annotations,o.regression),s=o.pointRadius??4,c=hu(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;let i=[];for(let e=0;t.length-1>e;e++){let r=t[e],o=t[e+1],a=oe(e,t.length);100>t.length&&i.push(md.createElement("line",{key:"halo-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),i.push(md.createElement("line",{key:"segment-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:a,strokeWidth:s,strokeLinecap:"round"}))}return md.createElement(md.Fragment,null,...i)}];return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:q(e=>{let t=a.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?oe(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1};return u?.length&&Object.assign(o,fu(e,u,c(e))),o},ae(o)),...r,...l&&l.length>0&&{annotations:l},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},svgPreRenderers:d}}},kh={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,n=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,l=cu(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:n}),o.styleRules,function(e,t,i){let r=du(e),o=du(t),a=du(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?We(e.value):a(e),x:t?We(e.xCenter):r(e),y:t?We(e.yCenter):o(e)}}}(o.xAccessor,o.yAccessor,o.valueAccessor)),s=("string"==typeof a?.colorScheme?a.colorScheme:void 0)??i,c=null!=a&&Object.hasOwn(a,"heatmapColorScale"),u=a?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===s&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:l,...r,...void 0!==s&&{colorScheme:s},...d&&{heatmapColorScale:d}}}};import{useMemo as Ah,useCallback as Sh,useRef as Mh}from"react";var _h={RdBu:Dd,PiYG:zd,PRGn:Od,BrBG:Fd,RdYlBu:Nd,RdYlGn:Ed,Spectral:Wd},Ph="__likert_neutral_neg",Lh="__likert_neutral_pos",$h={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,r,o,a)=>{let n=Array.isArray(a.levels)&&a.levels.length>=2?a.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],l="vertical"!==a.orientation,s=function(e,t,i,r,o,a,n={}){let l=new Map,s=new Set(t);for(let n of e){let e=i(n);l.has(e)||l.set(e,new Map);let c=l.get(e);if(r){let e=r(n);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}let i=e-1;if(0>i||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&a){let e=o(n),t=a(n);if(!s.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of l){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;t.length>o;o++){let a=t[o],l=i.get(a)||0,s={};n.category&&(s[n.category]=e),n.level&&(s[n.level]=a),n.count&&(s[n.count]=l),n.score&&(s[n.score]=o+1),c.push({...s,__likertCategory:e,__likertLevel:a,__likertLevelLabel:a,__likertCount:l,__likertPct:l/r*100,__likertLevelIndex:o})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n,je(a.categoryAccessor,"question"),a.levelAccessor?null:je(a.valueAccessor,"score"),a.levelAccessor?je(a.levelAccessor,"level"):null,a.levelAccessor?je(a.countAccessor,"count"):null,{category:"string"==typeof a.categoryAccessor?a.categoryAccessor:void 0,level:"string"==typeof a.levelAccessor?a.levelAccessor:void 0,count:"string"==typeof a.countAccessor?a.countAccessor:void 0,score:a.levelAccessor||"string"!=typeof a.valueAccessor?void 0:a.valueAccessor});l&&(s=function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),a=new Map;for(let t of e){let e=a.get(t.__likertCategory)||[];e.push(t),a.set(t.__likertCategory,e)}let n=[];for(let[,e]of a){let t,a,l=new Map;for(let i of e)i.__likertLevel===Ph?t=i:i.__likertLevel===Lh?a=i:l.set(i.__likertLevelIndex,i);r&&t&&n.push(t);for(let e=o-1;e>=0;e--){let t=l.get(e);t&&n.push(t)}r&&a&&n.push(a);for(let e=r?o+1:o;i>e;e++){let t=l.get(e);t&&n.push(t)}}return n}(function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),a=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;a.push({...t,__likertLevel:Ph,__likertPct:-e}),a.push({...t,__likertLevel:Lh,__likertPct:e})}else a.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return a}(s,n),n));let c=le(o.theme).colors.diverging,u=Array.isArray(r)&&r.length>=n.length?r:function(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(_h,t)){let i=_h[t];if(1===e)return[i(.5)];let r=[];for(let t=0;e>t;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let a=e%2!=0,n=Math.floor(e/2),l=[];for(let e=0;n>e;e++)l.push(i[Math.min(Math.floor(e*i.length/n),i.length-1)]);a&&l.push(o);for(let e=0;n>e;e++)l.push(r[Math.min(Math.floor(e*r.length/n),r.length-1)]);return l}(n.length,c),d=new Map(n.map((e,t)=>[e,u[t]||"#888"])),h=n.length%2&&d.get(n[Math.floor(n.length/2)])||"#888",f="function"==typeof a.valueFormat?a.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",p=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:n.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),y=a.styleRules,g=o.pieceStyle;return{chartType:"bar",data:s,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:l?"horizontal":"vertical",barPadding:a.barPadding,showGrid:o.showGrid,oLabel:a.categoryLabel,rLabel:a.valueLabel||(l?void 0:"Percentage"),rFormat:f,...a.categoryFormat&&{oFormat:a.categoryFormat},...a.valueExtent&&{rExtent:a.valueExtent},...o,pieceStyle:q((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,a={fill:i===Ph||i===Lh?h:d.get((r||i)+"")||"#888"};return y?.length&&Object.assign(a,fu(e,y,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:r+"")})),"function"==typeof g?Object.assign(a,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(a,g),a},ae(a)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}};import{jsx as Th,jsxs as Rh}from"react/jsx-runtime";import{Fragment as Ch,jsx as Ih,jsxs as Dh}from"react/jsx-runtime";var zh={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=(i.startAngleDeg+(i.gMax===i.gMin?0:(Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin))-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,o=i.needleColor||t.colors.text,a=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];return Dh(Ch,{children:[i.showNeedle&&Dh(Ch,{children:[Ih("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(r),y2:i.centerY+i.needleLength*Math.sin(r),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),Ih("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:o})]}),null!=i.contextValue&&Ih("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:o,children:i.contextValue}),a.map((e,r)=>{let o=(i.startAngleDeg+(i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,a=i.innerRadius-1,n=i.radius+1,l=i.radius+10,s=((o+Math.PI/2)/(2*Math.PI)*12+12)%12,c=s>=11||1>s?"middle":5>s?"start":7>s?"middle":"end",u=s>=11||1>s?"auto":5>s?"middle":7>s?"hanging":"middle";return Dh("g",{children:[Ih("line",{x1:i.centerX+Math.cos(o)*a,y1:i.centerY+Math.sin(o)*a,x2:i.centerX+Math.cos(o)*n,y2:i.centerY+Math.sin(o)*n,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),Ih("text",{x:i.centerX+Math.cos(o)*l,y:i.centerY+Math.sin(o)*l,textAnchor:c,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+r)})]})},buildProps:(e,t,i,r,o)=>{let a=o.min??0,n=o.max??100,l=o.sweep??240,s=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=He(l),h=o.thresholds,f=te(r.gradientFill),p=function(e){let{min:t,max:i,value:r,thresholds:o,fillColor:a,backgroundColor:n,fillZones:l,showScaleLabels:s,gradientFill:c,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,r))-t)/d,f=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:a||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});let p=!!c&&c.stops.length>=2,y=[],g=new Map,m=[];if(p){let e=l?h:1,t=Ve("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:n,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;i>t;t++)r.push(Ge(c.stops,e*(t+.5)/i,a||f[0]?.color||"#007bff"));let o=Ve("fill",0);y.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),g.set(o,{fill:r[0]||n})}}else{let e=t;for(let i=0;f.length>i;i++){let r=f[i],o=(r.value-e)/d,a=(e-t)/d,s=(r.value-t)/d,c=Math.max(0,(l?Math.min(h,s):s)-a),u=l?Math.max(0,o-c):0;if(c>0){let e=Ve("fill",i);y.push({category:e,value:c,_zone:r.label||"Zone "+(i+1),_isFill:!0}),g.set(e,{fill:r.color})}if(u>0){let e=Ve("bg",i);y.push({category:e,value:u,_zone:r.label||"Zone "+(i+1),_isFill:!1}),g.set(e,{fill:n,opacity:.4})}e=r.value}}if(s&&o&&o.length>0)for(let e of o)e.value>t&&i>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:n},gaugeAnnotations:m}}({min:a,max:n,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:f}),y=o.styleRules,[g,m]=r.size||[300,250],x=function(e=240){let{sweepRad:t,offsetRad:i}=He(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)t+.001>=((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),a=r.map(e=>e[1]),[n,l]=nd(o),[s,c]=nd(a);return{minX:n,maxX:l,minY:s,maxY:c,width:l-n,height:c-s,cx:(n+l)/2,cy:(s+c)/2}}(l),b=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-s))),k=g/2-x.cx*v,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(a,Math.min(n,o.value??a)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",P=o.centerContent??r.centerContent,L=null!=P?"function"==typeof P?P(M,a,n):P:"sparkline"===o.mode||"context"===o.mode?void 0:function({value:e,min:t,max:i,radius:r,showScaleLabels:o}){let a=Math.max(16,.3*r);return Rh("g",{textAnchor:"middle",children:[Th("text",{y:0,dominantBaseline:"central",fontSize:a,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&Rh("text",{y:.7*a+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}({value:_,min:a,max:n,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:l,startAngle:d,oSort:!1,pieceStyle:q((e,t)=>{let i={...p.pieceStyle(e,t)};return y?.length&&Object.assign(i,fu(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},ae(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=L&&{centerContent:L},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:a,gMax:n,sweep:l,arcWidth:s,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:c,needleColor:o.needleColor,..."context"===o.mode&&null==P&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},Oh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=ne(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...a&&{annotations:a},gradientFill:qe(r.gradientFill),pieceStyle:Ue(e,t,i,r,o)}}},Fh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:a,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:qe(r.gradientFill),pieceStyle:Ue(e,a,i,r,o),showLegend:r.showLegend??!!a}}},Nh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:a,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:qe(r.gradientFill),pieceStyle:Ue(e,a,i,r,o),showLegend:r.showLegend??!!a}}},Eh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.categoryAccessor,n=du(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:a,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Ue(e,a,i,r,o,e=>{let t=n(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!a}}},Wh={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,r,o)=>{let a=t||o.categoryAccessor,n=du(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:r.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:a,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Ue(e,a,i,r,o,e=>{let t=n(e);return null==t?void 0:Math.abs(t)})}}},jh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=o.valueAccessor||"value",l=a.map(e=>Number("function"==typeof n?n(e):e[n])).filter(Number.isFinite),s=l.length?[Math.min(...l),Math.max(...l)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:n,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:s?{rExtent:s}:{},...r,summaryStyle:Ze(e,t,i,r,o,"count")}}},Bh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:Ze(e,t,i,r,o)})},Yh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...r,summaryStyle:Ke(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},Xh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:Je(e,t,i,r,o),showLegend:r.showLegend??!!t})},Gh={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let a=ne(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...a&&{annotations:a},pieceStyle:Qe(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},Vh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=o.seriesAccessor||t||"__radar",n=t||("__radar"===a?void 0:a),l=Qe(e,n,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:n,colorScheme:i,connectorAccessor:a,connectorStyle:e=>{let t=l(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:l,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!n}}},Hh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:a,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:qe(r.gradientFill),pieceStyle:Ue(e,a,i,r,o),showLegend:r.showLegend??!!a,barPadding:o.barPadding??40}}},qh={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:Ze(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},Uh={frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a="vertical"===o.orientation,n=t||o.categoryAccessor;return{chartType:a?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:n,categoryAccessor:o.categoryAccessor,projection:a?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!a&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:a?40:0,colorScheme:i,...r,showAxes:a&&!1!==r.showAxes,showGrid:a,pieceStyle:Ue(e,n,i,r,o),showLabels:o.showLabels??!0}}};import{scaleTime as Zh}from"d3-scale";var Kh={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},Qh=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),Jh=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},ef=828*Jh(8),tf=3e3,rf=new Map,of=1e5,af=1e-9,nf=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,lf=null;import{jsx as sf,jsxs as cf}from"react/jsx-runtime";var uf=new Map;import{Fragment as df,jsx as hf,jsxs as ff}from"react/jsx-runtime";var pf="var(--semiotic-grid, #94a3b8)",yf="var(--semiotic-text-secondary, #475569)",gf="var(--semiotic-text-secondary, #94a3b8)",mf=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,a=e.selection??null,n=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!ui(t,a,o);n.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!ui({__kind:"band",data:e.rawDatum,id:e.id},a,o);for(let i=0;e.gradientStubs.length>i;i++){let r=e.gradientStubs[i];n.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},r=!ui(i,a,o);n.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?.22:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let l=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&a?.isActive&&ui({__kind:"band",data:e.rawDatum,id:e.id},a,o),n=i?e.labelText:r?e.labelFullText:"";return n.trim()?[{x:e.labelX,y:e.labelY,text:n,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"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:n,labels:l}},xf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||r.nodeStyle||o.nodeStyle||H(ae(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let a=Array.isArray(o.edges)?o.edges:[],n=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:hi([],a,o.sourceAccessor||"source",o.targetAccessor||"target"),l=le(r.theme).colors.categorical,s=B(i,l),c="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?n.map(e=>({...e,__ssrChordColorBy:t(e)})):n,d=t?G(u,c,i??r.colorScheme??l):void 0,h=new Map,f=o.nodeIdAccessor||o.nodeIDAccessor||"id",p=(e,i)=>{let r,a=e?.data||e;if(t)r=Y(a,t,d);else{let t=(e.id??a?.[f]??"")+"";h.has(t)||h.set(t,h.size);let o=e.index??i??h.get(t);r=s[o%s.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=pu(o.styleRules,t,o.valueAccessor);return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:q(o.nodeStyle||(y?(e,t)=>({...p(e,t),...y(e,t)}):p),ae(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},bf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=function(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?a=>{let n=a?.data||a,l=o;if("number"==typeof t)l=t;else if("function"==typeof t)l=t(n);else if("string"==typeof t){let e=n?.[t],i="number"==typeof e?e:Number(e);l=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:l,opacity:r??e.opacity??.6}}:void 0}(o),n=le(r.theme).colors.categorical,l=new Map,s=o.nodeStyle??(e=>({fill:t?Y(e?.data||e,t,void 0):_e(void 0,n,i,void 0,l),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),c=pu(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=q(c?(e,t)=>({...s(e),...c(e,t)}):s,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:a,...r,showLegend:(r.showLegend??!!t)&&!!t}}},vf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=le(r.theme).colors.categorical,n=new Map,l=di(e??null,o.childrenAccessor),s="function"==typeof t?t:null,c=s?l.map(e=>({__ssrCirclePackColorBy:s(e)})):l,u=s?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?G(c,u,i??r.colorScheme??a):void 0,h=o.showLabels??r.showLabels,f=r.nodeStyle||o.nodeStyle,p=cu(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Gd[Number(e?.depth||0)%Gd.length]:t?s?Y({__ssrCirclePackColorBy:s(r)},"__ssrCirclePackColorBy",d??void 0):Y(r,t,d??void 0):_e(void 0,a,i,void 0,n),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,uu(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fi(p,f,ae(o))}}},wf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=e??o.data,n=o.childrenAccessor||"children",l=o.nodeIdAccessor||o.nodeIDAccessor||"name",s=le(r.theme).colors.categorical,c=i??r.colorScheme??s,u=B(c,s),d=di(a,n),h="__ssrOrbitColorBy",f="function"==typeof t?t:null,p=t?G(f?d.map(e=>({[h]:f(e)})):d,f?h:t,c):void 0,y=cu(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:Gd[r%Gd.length]:t?f?Y({[h]:f(i)},h,p):Y(i,t,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,uu(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:a,childrenAccessor:n,nodeIDAccessor:l,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?l:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:q(y,ae(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},kf={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,r,o,a)=>{let n=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),l=a.sourceAccessor||"source",s=a.targetAccessor||"target",c=a.valueAccessor||"value",u=a.nodeIdAccessor||"id",d=a.startTimeAccessor||"startTime",h=a.endTimeAccessor||"endTime",f=a.systemInTimeAccessor,p=a.systemOutTimeAccessor,y=a.xExtentAccessor||"xExtent",g=a.groupBy,m=a.edgeIdAccessor||"id",x=(e,t)=>"function"==typeof e?e(t):t[e],b=Array.isArray(a.edges)?a.edges:[],v=Array.isArray(a.nodes)?a.nodes:[],w=v.length>0?v:hi([],b,l,s),k=[n(a.domain?.[0]),n(a.domain?.[1])],A=w.map(e=>{let t=x(u,e)+"",i=x(y,e),r=a.nodeLabel?x(a.nodeLabel,e):t,o={id:t,label:null==r?t:r+"",__raw:e},l=g?x(g,e):null;if(null!=l&&l+""!=""&&(o.group=l+""),Array.isArray(i)&&2===i.length){let e=n(i[0]),t=n(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=b.map((e,t)=>{let i=x(m,e),r={id:null!=i?i+"":`${x(l,e)}-${x(s,e)}-${t}`,source:x(l,e)+"",target:x(s,e)+"",value:Number(x(c,e)),startTime:n(x(d,e)),endTime:n(x(h,e)),__raw:e};if(f){let t=n(x(f,e));Number.isFinite(t)&&(r.systemInTime=t)}if(p){let t=n(x(p,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[M,_]=o.size??[600,400],P=o.margin,L="vertical"===a.orientation?"vertical":"horizontal",$={...ci(!!o.title,!!a.showQualityReadout,Array.isArray(a.axisTicks)&&a.axisTicks.length>0,L),...P},T=(o.showLegend??!!t)&&!!t,R=o.legendPosition??"right";T&&("right"===R?$.right=Math.max($.right,140):"left"===R?$.left=Math.max($.left,140):"top"===R?$.top=Math.max($.top,50):"bottom"===R&&($.bottom=Math.max($.bottom,80)));let C=$,I=M-C.left-C.right,D=_-C.top-C.bottom,z=B(r,le(o.theme).colors.categorical,vd),O="function"==typeof t?t:null,F=O?w.map(e=>({_cat:O(e)})):w,N=O?"_cat":"string"==typeof t?t:void 0,E=r??[...z],W=N?G(F,N,E):null,j=new Map;for(let e of A)j.set(e.id,e.__raw);let X=(e,i)=>{if(t&&j.has(e)){let i=j.get(e);return O?Y({_cat:O(i)},"_cat",W??void 0):Y(i,"string"==typeof t?t:"id",W??void 0)}return z[i%z.length]},V=i(T&&t?(()=>{let e=new Map;w.forEach((i,r)=>{let o=x(t,i),a=null==o?"":o+"";!a||e.has(a)||e.set(a,{label:a,color:X(x(u,i)+"",r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),H=!1!==a.showLabels&&("auto"!==a.showLabels||"auto"),{layout:q,layoutConfig:U,issues:Z,xScale:K}=si({nodes:A,edges:S,domain:k,plotW:I,plotH:D,orientation:L,ribbonLane:a.ribbonLane||"both",ribbonMinRun:"auto"===a.ribbonMinRun||"number"==typeof a.ribbonMinRun?a.ribbonMinRun:0,edgeOpacity:"number"==typeof a.edgeOpacity?a.edgeOpacity:.35,colorOf:X,showLabels:H,styleRules:a.styleRules,colorBy:t,valueAccessor:c,layoutOpts:{pairing:a.pairing||"temporal",packing:a.packing||"reuse",laneOrder:a.laneOrder||"crossing-min",lifetimeMode:a.lifetimeMode||"half",maxValueScale:"number"==typeof a.maxValueScale?a.maxValueScale:void 0,lanePlacement:a.lanePlacement||"stack",nodeSizing:a.nodeSizing||"temporal",groupPadding:"number"==typeof a.groupPadding?a.groupPadding:0}});if(Z.length>0){let e=Z.map(it).join("; ");throw Error("ProcessSankey: data invalid — "+e)}let Q=q?function(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,a=e.plotH,n=e.timelineExtent,l=e.axisTicks,s=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,f=e.toTime,p=e.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null;for(let e of i){let t=g[e.id];if(!t||null===t.start||null===t.end)continue;let i=p(t.start),r=p(t.end);(null===S||S>i)&&(S=i),(null===M||r>M)&&(M=r)}let _=e=>Math.max(0,Math.min(n,e)),P=_(S??0),L=Math.max(P,_(M??n)),$=l.map((e,t)=>({tick:e,index:t,coordinate:p(f(e.date))})).filter(({coordinate:e})=>e>=P-.5&&L+.5>=e),T=null!==(w??null)&&null!=k&&null!=A,R=s&&(T||u.length>0)?ff("g",{fill:gf,fontSize:10,textAnchor:"end",children:[T&&ff(df,{children:[ff("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),ff("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),u.map((e,t)=>ff("text",{x:o,y:T?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,C=b?hf("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:gf,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,I=(e,t)=>h?h(e,t):pf;return ff("g","vertical"===r?{children:[R,C,$.map(({index:e,coordinate:t})=>hf("line",{x1:0,y1:t,x2:o,y2:t,stroke:pf,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},a=y[e.id]+(o.botPeak-o.topPeak)*x/2,n=p(i.start),l=p(i.end),s=I(e.id,t);return ff("g",{children:[hf("line",{x1:a,y1:n,x2:a,y2:l,stroke:s,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),hf("line",{x1:a-4,y1:n,x2:a+4,y2:n,stroke:s,strokeOpacity:.5}),hf("line",{x1:a-4,y1:l,x2:a+4,y2:l,stroke:s,strokeOpacity:.5})]},"lane-"+e.id)}),hf("line",{x1:-4,y1:P,x2:-4,y2:L,stroke:pf}),$.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return ff("g",{transform:`translate(-4,${i})`,children:[hf("line",{x2:-6,stroke:pf}),hf("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:yf,children:o})]},t)})]}:{children:[R,C,$.map(({index:e,coordinate:t})=>hf("line",{x1:t,y1:0,x2:t,y2:a,stroke:pf,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},a=y[e.id]+(o.botPeak-o.topPeak)*x/2,n=p(i.start),l=p(i.end),s=I(e.id,t);return ff("g",{children:[hf("line",{x1:n,y1:a,x2:l,y2:a,stroke:s,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),hf("line",{x1:n,y1:a-4,x2:n,y2:a+4,stroke:s,strokeOpacity:.5}),hf("line",{x1:l,y1:a-4,x2:l,y2:a+4,stroke:s,strokeOpacity:.5})]},"lane-"+e.id)}),hf("line",{x1:P,y1:a+4,x2:L,y2:a+4,stroke:pf}),$.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return ff("g",{transform:`translate(${i},${a+4})`,children:[hf("line",{y2:6,stroke:pf}),hf("text",{y:20,textAnchor:"middle",fontSize:11,fill:yf,children:o})]},t)})]})}({layout:q,nodes:A,orientation:L,plotW:I,plotH:D,timelineExtent:"vertical"===L?D:I,axisTicks:Array.isArray(a.axisTicks)?a.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!a.showQualityReadout,showLaneRails:!!a.showLaneRails,timeFormat:"function"==typeof a.timeFormat?e=>a.timeFormat(e):void 0,colorOf:X,toTime:e=>n(e),xScale:e=>Number(K(e))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:mf,layoutConfig:U,sourceAccessor:l,targetAccessor:s,valueAccessor:c,nodeIDAccessor:u,colorBy:t,colorScheme:r,...Q&&{backgroundGraphics:Q},...o,showLegend:T,...V&&{legend:V,legendPosition:R},__legendIncludesAutomatic:!0,margin:C}}},Af={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,r,o)=>{let a=Array.isArray(o.nodes)?o.nodes:hi([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),n=le(r.theme).colors.categorical,l=new Map,s="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrSankeyColorBy:t(e)})):a,u=t?G(c,s,i??r.colorScheme??n):void 0,d=e=>({fill:t?Y(e?.data||e,t,u):_e(void 0,n,i,void 0,l),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=pu(o.styleRules,t,o.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=function({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:a={}}){return n=>{let l={fillOpacity:o,...a};if("function"==typeof e)l.fill=e(n);else if("source"===e){let e="object"==typeof n.source?n.source:null;t&&e?l.fill=Y(e.data||e,t,i):e&&(l.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof n.target?n.target:null;t&&e?l.fill=Y(e.data||e,t,i):e&&(l.fill=r(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*o);return l}}({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:f,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:q(o.nodeStyle||f,ae(o)),edgeStyle:q(o.edgeStyle||p,ae(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},Sf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=le(r.theme).colors.categorical,n=new Map,l=di(e??null,o.childrenAccessor),s="function"==typeof t?t:null,c=s?l.map(e=>({__ssrTreeColorBy:s(e)})):l,u=s?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?G(c,u,i??r.colorScheme??a):void 0,h=!1!==o.showLabels,f=r.nodeStyle||o.nodeStyle,p=cu(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Gd[Number(e?.depth||0)%Gd.length]:t?s?Y({__ssrTreeColorBy:s(r)},"__ssrTreeColorBy",d??void 0):Y(r,t,d??void 0):_e(void 0,a,i,void 0,n),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,uu(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fi(p,f,ae(o))}}},Mf={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=le(r.theme).colors.categorical,n=new Map,l=di(e??null,o.childrenAccessor),s="function"==typeof t?t:null,c=s?l.map(e=>({__ssrTreemapColorBy:s(e)})):l,u=s?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?G(c,u,i??r.colorScheme??a):void 0,h=o.showLabels??r.showLabels,f=o.labelMode,p=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=r.nodeStyle||o.nodeStyle,m=cu(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Gd[Number(e?.depth||0)%Gd.length]:t?s?Y({__ssrTreemapColorBy:s(r)},"__ssrTreemapColorBy",d??void 0):Y(r,t,d??void 0):_e(void 0,a,i,void 0,n),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,uu(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:f,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=y&&{paddingTop:y},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fi(m,g,ae(o))}}},_f={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as Pf}from"d3-scale";var Lf={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a="string"==typeof i?i:"blues",n=function(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,a=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(o>e&&(o=e),e>a&&(a=e))}let n=[Number.isFinite(o)?o:0,Number.isFinite(a)?a:1],l=Pf(j(i)).domain(n);return{domain:n,colorScale:e=>l(e),valueAccessor:r}}(o.areas,o.valueAccessor,a),l=o.areaStyle??function(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}(n,o.areaOpacity??1),s=o.styleRules?cu(l,o.styleRules,e=>{return{value:(t=e,"function"==typeof o.valueAccessor?o.valueAccessor(t):null!=o.valueAccessor?t?.properties?.[o.valueAccessor]??t?.[o.valueAccessor]:void 0)};var t},mi):l,c=!1!==r.showLegend&&n?{gradient:{colorFn:n.colorScale,domain:n.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:s,valueAccessor:o.valueAccessor,colorScheme:a,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&c?{legend:c}:{}}}},$f={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=e||o.points,n=o.pointStyle??gi(a,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),l=o.styleRules?cu(n,o.styleRules,uu(t,o.sizeBy)):n;return{points:a,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||_f,pointStyle:l,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},Tf={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=e||o.points,n=o.pointStyle??gi(a,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),l=o.nodeIdAccessor||"id",s=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),c="sparkline"===o.mode,u="strip"===s,d=o.styleRules?cu(n,o.styleRules,uu(t)):n;return{points:a,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof d?d(e):d,i="function"==typeof l?l(e):e[l],r=null!=i&&i+""==o.center+"",a="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*a:a}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:l,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:s},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!c),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},Rf={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=(Array.isArray(e)?e:null)||o.flows||[],n=o.nodeIdAccessor||"id",l=o.valueAccessor||"value",s=o.xAccessor||"lon",c=o.yAccessor||"lat",u="function"==typeof s?s:e=>e[s],d="function"==typeof c?c:e=>e[c],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(let e of h)f.set(e[n]+"",e);let p=o.edgeColorBy??t,y="function"==typeof p,g=a.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=f.get(e.source+""),i=f.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?G(g.map(e=>({[m]:p(e)})),m,i||"category10"):G(g,p,i||"category10"):null,b=g.map(e=>Number(e[l]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?nd(b):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||_f,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:yi({valueAccessor:l,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>p&&x?Y(e,p,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}},Cf={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},If={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},Df={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...If.buildProps(e,t,i,r,o),customLayout:Wu,showAxes:!1})},zf={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Cf.buildProps(e,t,i,r,o),customLayout:ku,showAxes:!1})};import*as Of from"react";import{scaleLinear as Ff}from"d3-scale";import{scaleLinear as Nf}from"d3-scale";import{scaleLinear as Ef}from"d3-scale";import{scaleLinear as Wf}from"d3-scale";var jf="gauntlet-negative",Bf={left:28,top:76,rightInset:30,thickness:8},Yf=1e-9,Xf=[900,520],Gf=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Vf=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Hf=1e-9,qf=_r;import*as Uf from"react";import{curveMonotoneX as Zf,curveMonotoneY as Kf,curveCardinal as Qf,curveCatmullRom as Jf,curveStep as ep,curveStepBefore as tp,curveStepAfter as ip,curveBasis as rp,curveNatural as op}from"d3-shape";import{jsx as ap,jsxs as np}from"react/jsx-runtime";import{Fragment as lp,jsx as sp,jsxs as cp}from"react/jsx-runtime";var up="var(--semiotic-text, #26323a)",dp="var(--semiotic-text-secondary, #6c7377)",hp="var(--semiotic-primary, #b8792d)",fp="var(--semiotic-danger, #9f3d35)",pp="var(--semiotic-success, #356b63)";import{Fragment as yp,jsx as gp,jsxs as mp}from"react/jsx-runtime";import{jsx as xp}from"react/jsx-runtime";import{jsx as bp,jsxs as vp}from"react/jsx-runtime";import{Fragment as wp,jsx as kp,jsxs as Ap}from"react/jsx-runtime";var Sp={margin:(e,t)=>t.compactMode?"sparkline"===e.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},Mp=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],_p={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n=o.bins??21,l=o.seed??1,s=Math.max(1,Math.round(o.pegRows??n-1)),c="mechanical"===(o.simulationMode??o.mode),u=function(e){let{data:t,valueAccessor:i,bins:r,ballRadius:o,seed:a,size:n,valueExtent:l}=e,{rows:s}=Dc(t,"galton"),c=Wc(n),u=s.map((e,t)=>Oc(Yc(e,t,i))).filter(e=>null!=e),d=Ec(l),h=d?.[0]??(u.length?Math.min(...u):0),f=d?.[1]??(u.length?Math.max(...u):1),p=f===h?1:f-h,y=Ff().domain([0,r]).range([c.plot.x,c.plot.x+c.plot.width]),g=Array.from({length:r},()=>0),m=[];s.forEach((e,t)=>{let a=Oc(Yc(e,t,i));if(null==a)return;let n=Math.max(0,Math.min(r-1,Math.floor((a-h)/p*r)));g[n]+=1,m.push({id:(e.id??"galton-"+t)+"",x:y(n+.5),y:c.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:a,bin:n}})});let x=c.plot.y+c.plot.height,b=[...Su({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Mu({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:y,yTop:c.plot.y-400,yBottom:x,wallThickness:6})];return{config:Rc(a,b,"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:r,plot:c.plot,valueExtent:[h,f]}}}({data:c?Fc({bins:n,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:s,seed:l}):Array.isArray(e)?e:[],valueAccessor:o.valueAccessor||"value",bins:n,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:l,size:a,valueExtent:c?[0,s]:o.valueExtent});return{...r,config:u.config,initialSpawns:eo(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:to(Br(u.projectionRows,n,io(r,o,"showProjection"),u.metadata,o.referenceLines),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},Pp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n=function(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:a,watermarkAtArrivalAccessor:n,ballRadius:l,seed:s,size:c,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:f}=Gc({data:t,timeAccessor:i,arrivalAccessor:r,watermark:a,watermarkAtArrivalAccessor:n,windowSize:o.size}),p=Wc(c),y=h.map(e=>e.eventTime),g=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=Oc(u?.[0]),x=Oc(u?.[1]),b=y.length?Math.min(...y):0,v=y.length?Math.max(...y):b+o.size,w=Math.min(m??b,b),k=Math.max(x??v,v),A=Math.floor(w/o.size)*o.size,S=Math.max(1,Math.ceil((k-A+o.size)/o.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(e,t)=>t).reduce((e,t)=>A+(t+1)*o.size>f?e:e+1,0))),_=function(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(p,l),P=A+S*o.size,L=Nf().domain([A,P]).range([_.windowPlot.x,_.windowPlot.x+_.windowPlot.width]),$=Array.from({length:S},()=>({value:0,secondary:0})),T=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:a,late:n})=>{let s=Math.max(0,Math.min(S-1,Math.floor((i-A)/o.size)));$[s].value+=n?0:1,$[s].secondary+=n?1:0,T.push({id:(e.id??"event-"+t)+"",x:bi(i,s,n,{windowStart:A,windowSize:o.size,gutter:_.gutter,closedWindowCount:M,windowPlot:_.windowPlot,windowCount:S},l),y:p.plot.y+l+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:l},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:s,watermarkAtArrival:a,late:n}})});let R=p.plot.y+p.plot.height,C={closedWindowCount:M,gutter:_.gutter,plot:p.plot,windowCount:S,windowPlot:_.windowPlot,windowSize:o.size,windowStart:A},I=function(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,a=Nf().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),n=a(e.windowStart+i*e.windowSize),l=e.windowPlot.x,s=t+Math.max(18,Math.min(.3*e.windowPlot.height,n-l)),c=e=>n===l?t:s+(e-l)/(n-l)*(t-s),u=[];for(let t=0;i>t;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=a(i),n=a(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:c(o),x2:n,y2:c(n)})}return u}(C,p.plot.y+.28*p.plot.height);for(let e of T){let t=e.datum;e.y=xi({...C,lidSegments:I},t.windowIndex,t.late,l)}let D=function(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:a,yTop:n,yTopForIndex:l}=e;return Array.from({length:t+1},(e,t)=>{let s=Math.min(a-1,l?.(t)??n),c=Math.max(1,a-s);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:s+c/2,width:r,height:c}}})}({idPrefix:"eventdrop-window",count:S,xScale:e=>L(A+e*o.size),yTop:_.wallTop,yTopForIndex:e=>{let t=(e=>{if(0>e||e>M)return null;let 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?_.wallTop:t+1.25*l},yBottom:R,wallThickness:6}),z=[...Su({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...D,...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*l)},friction:.02,restitution:.01}))];return{config:Rc(s,z,"EventDropChart",{friction:.08}),initialSpawns:T,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=M>t.windowIndex;return i&&!t.late||!i&&t.late?g:t.arrivalTime},timeScale:d},projectionRows:$.map((e,t)=>({label:`${A+t*o.size}-${A+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:_.gutter,lidSegments:I,lateCount:$.reduce((e,t)=>e+t.secondary,0),plot:p.plot,windowPlot:_.windowPlot,windowWalls:D.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:f,windowCount:S,windowSize:o.size,windowStart:A}}}({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:a,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:n.config,initialSpawns:eo(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:to(Yr(n.projectionRows,n.metadata,io(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},Lp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n="mechanical"===(o.simulationMode??o.mode),l=function(e){function t(e){let t=f.get(e);return null==t&&(t=h.length,h.push(e),f.set(e,t)),t}let{data:i,categoryAccessor:r,valueAccessor:o,unitValue:a,ballRadius:n,seed:l,size:s}=e,c=Bc(a,1),{rows:u}=Dc(i,"pile"),d=Wc(s),h=[],f=new Map,p=new Map,y=[];u.forEach((e,i)=>{t((Yc(e,i,r)??"unknown")+"")});let g=Math.max(1,h.length),m=vi(d.plot,g,n),x=Math.max(0,m.tubeWidth/2-n-1),b=h.map(()=>[]);u.forEach((e,i)=>{let a=(Yc(e,i,r)??"unknown")+"",l=t(a),s=o?Oc(Yc(e,i,o)):1,u=Math.max(0,s??0);p.set(a,(p.get(a)??0)+u);let h=jc(u,c),f=m.centerX(l);for(let t=0;h>t;t+=1){let r=b[l].length,o=t===h-1?u-t*c:c,s=Math.min(1,o/c);b[l].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:f+(m.perRow>1?((m.perRow>1?r%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+n+2,vx:(t%3-1)*n/2,vy:0,mass:1,shape:{type:"circle",radius:n*Math.sqrt(s)},datum:{...e,category:a,unitIndex:t,unitValue:c,representedValue:o,unitFraction:s}})}});let v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(let t of b)t.length>e&&y.push(t[e]);let w=d.plot.y+d.plot.height,k=[...Su({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;g>e;e+=1){let t=m.centerX(e);for(let i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:Rc(l,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:p.get(e)??0}))}}({data:n?Nc({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(n?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:a});return{...r,config:l.config,initialSpawns:eo(l.initialSpawns),projectionRows:l.projectionRows,foregroundGraphics:to(Xr(l.projectionRows,o.ballRadius??8,io(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy||(n?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},$p={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,360],n=function(e){let{data:t,xAccessor:i,groupAccessor:r,radiusAccessor:o,pointRadius:a,seed:n,size:l,xExtent:s,collisionIterations:c,settle:u}=e,{rows:d}=Dc(t,"collision-swarm"),h=Wc(l),f=Kc(n),p=[],y=[],g=new Map;d.forEach((e,t)=>{let n=Oc(Yc(e,t,i));if(null==n)return;let l=r?(Yc(e,t,r)??"All")+"":"All",s=o?Oc(Yc(e,t,o)):null,c=Cc(null!=s&&s>0?s:a,2,18);(function(e){let t=g.get(e);null==t&&(t=y.length,y.push(e),g.set(e,t))})(l),p.push({datum:e,index:t,value:n,group:l,radius:c})});let m=p.map(e=>e.value),x=s?Oc(s[0]):null,b=s?Oc(s[1]):null,v=m.length?Math.min(...m):0,w=m.length?Math.max(...m):1,k=x??v,A=b??w;if(k===A&&(k-=.5,A+=.5),k>A){let e=A;A=k,k=e}let S=Math.max(a,...p.map(e=>e.radius)),M=h.plot.x+S+8,_=h.plot.x+h.plot.width-S-8,P=Ef().domain([k,A]).range([M,_]),L=h.plot.height/Math.max(1,y.length),$=Math.min(6,.05*L),T=e=>h.plot.y+((g.get(e)??0)+.5)*L,R=new Map,C=new Set,I=new Map;for(let e of y){let t=p.filter(t=>t.group===e),i=T(e),r=t.map(e=>({x:P(e.value),radius:e.radius})),o=wi(r,i-L/2+$,i+L/2-$,f);R.set(e,t.length),o.overlapping&&C.add(e),t.forEach((e,t)=>I.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let D=p.map((e,t)=>{let i=I.get(e.index),r=i.x,o=i.y,a=C.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:r,y:o-(u?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!a,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:a},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}}),z=Su({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20});return{config:Rc(n,z,"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(c??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:D,projectionRows:y.map(e=>({label:e,value:R.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[k,A],xRange:[M,_],groups:y.map(e=>({label:e,y:T(e),count:R.get(e)??0,overlapping:C.has(e)})),plot:h.plot}}}({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:a,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:n.config,initialSpawns:eo(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:to(Vr(n.metadata,io(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},Tp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,420],n=Array.isArray(o.stages)?o.stages:[],l=function(e){let t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=Wc(i),o=Cc(e.ballRadius??6,2,18),a=e.seed??1,n=Kc(a),l=e.idAccessor,s=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(c?"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=Gu({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.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],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{let t=v.get(e.id)??k;return function(e,t){let i={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 mu({...i,kind:e.kind??"sink",force:Li(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return Bu({...i,kind:e.kind??"force-field",force:Li(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}})}if(e.capacity){let t=Math.max(.1,e.capacity.unitsPerSecond);return Au({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Li(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return Yu({...i,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:Li(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Ju({...i,kind:e.kind??"force-field",force:Li(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):Lu({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(Ju({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}));let M=new Map;for(let e of x.stages)M.set(e.id,0);let _=[];e.data.forEach((e,t)=>{let i=(l?Yc(e,t,l)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(Yc(e,t,s)??w)+"",a=b.has(r)?r:w;M.set(a,(M.get(a)??0)+1);let n=c?(Yc(e,t,c)??"")+"":void 0,f=n&&u?(Yc(e,t,u)??n)+"":n,p=d?Oc(Yc(e,t,d))??1:1,y=h?Oc(Yc(e,t,h)):null,g=Cc(null!=y&&y>0?y:o,2,18);_.push({datum:e,id:i,stageId:a,groupId:n||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});let P=new Map,L=new Map;for(let e of _){if(!e.groupId)continue;let t=P.get(e.groupId)??[];t.push(e.id),P.set(e.groupId,t),e.groupLabel&&L.set(e.groupId,e.groupLabel)}let $=Cc(e.groupAnchorAlong??.55,.15,.9),T=x.left+(x.right-x.left)*$,R=Array.from(P.keys()),C=R.map((e,i)=>{let r=P.get(e)??[],o=R.length>1?x.topY+28+i/Math.max(1,R.length-1)*(x.bottomY-x.topY-56):x.midY;return vu({id:e,label:L.get(e)??e,bodyIds:r,anchor:{x:T,y:o},x:T,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),I=_.filter(e=>A.has(e.stageId)).map(e=>e.id),D=Iu(C,I),z=new Map(C.map(e=>[e.id,e])),O=_.map((e,t)=>{let i=v.get(e.stageId)??k,r=i.x+(n()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(r,"top")+e.radius+10,a=x.boundaryY(r,"bottom")-e.radius-10,l=a>o?o+n()*Math.max(1,a-o):x.midY,s=g?r:x.left+18+t%7*4,c=g?l:x.midY+(n()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:l},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){let t=z.get(e.groupId);t?.anchor&&!A.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:s,y:c,vx:g?0:40+40*n(),vy:g?0:20*(n()-.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}}}),F={kernel:{seed:a,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},N=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),E=t.map(e=>{let 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:F,initialSpawns:O,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:N,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:E,groups:C,groupCompletion:D,regionEffects:S}}}({data:Array.isArray(e)?e:[],stages:n,size:a,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),s=l.metadata;return{...r,config:l.config,initialSpawns:eo(l.initialSpawns),projectionRows:l.projectionRows,regionEffects:s?.regionEffects,backgroundGraphics:to(Hr(l.metadata,io(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:to(qr(l.projectionRows,l.metadata,io(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},Rp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,520],n=Bi({data:Array.isArray(e)?e:[],size:a,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...r,config:n.config,initialSpawns:eo(n.initialSpawns),projectionRows:[],backgroundGraphics:to(io(r,o,"showChrome")?Of.createElement(Qr,{layout:n.layout,states:n.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:to(io(r,o,"showProjection")?Of.createElement(Jr,{layout:n.layout,states:n.states}):void 0,r.foregroundGraphics),bodyStyle:eu(t||o.colorBy)}}},Cp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,520],n=$r({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:a,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),l="snapshot"===o.playback?function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,hr(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,hr(t.progress??0)??0));return i.start+i.duration*r}(n,o.snapshotAt):n.duration,s=Lr(n,l).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},u=function(e,t={}){let i=t.groupBy??"outlet",r=new Map,o=e=>{let t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void Qi(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:Gi(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let a=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(a.get(e.key)??Number.MAX_SAFE_INTEGER)-(a.get(t.key)??Number.MAX_SAFE_INTEGER)||qi(e.key,t.key))}(s,c),d=c.measure??"count",h=function(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let a=e.map(e=>{let i=o.get(e.id)??[],a=Math.max(0,Math.floor(e.count??i.length)),n=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??jr(e),datum:e.datum}));return{id:e.id,label:e.label,count:a,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:n,metadata:e.metadata}}),n=a.reduce((e,t)=>e+t.count,0);return a.map(e=>({...e,share:n>0?e.count/n:0}))}(u.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===d||"amount"===d?e.amount:Number(e.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?o.amountLabel??"amount":d,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),f={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},p=t??o.colorBy??"category",y=!1===o.showChrome?null:Of.createElement(Er,{layout:n.layout,phases:n.phases,state:s,compact:520>a[0]||360>a[1]}),g=!1===o.showProjection?null:Of.createElement(Wr,{rows:u,layout:n.layout,projection:c,amountLabel:o.amountLabel});return{...r,config:n.config,initialSpawns:eo(_r(s,n.layout,f)),projectionRows:h,bodyStyle:e=>function(e,t,i,r){let o=e.datum,a={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...a,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...a,fill:r.color??e?.color??ro(e?.id??o.semanticId)}}let n,l=t.components[o.semanticId];return l?(n="status"===i?l.status:"outlet"===i?l.outletId??"in chamber":"product"===i?l.productIds[0]??"unalloyed":"category"===i||null==i?l.category:"function"==typeof i?(i(l.datum)??"unassigned")+"":(l.datum[i+""]??"unassigned")+"",{...a,fill:r.color??ro(n)}):{...a,fill:r.color??"#356b63"}}(e,s,p,o),getBodyLabel:e=>function(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}(e,s),renderBodySVG:Fr,backgroundGraphics:to(y,r.backgroundGraphics),foregroundGraphics:to(g,r.foregroundGraphics)}}},Ip={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[760,420],n=function(e){function t(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof n){let e=n(t,0);if(null!=e)return e+""}if("string"==typeof n&&null!=t[n])return t[n]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}let{coordinateMode:i,flowSpeed:r,links:o,maxParticles:a,nodeIdAccessor:n,nodeXAccessor:l,nodeYAccessor:s,nodes:c,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:f="path",reducedMotion:p,seed:y,size:g,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=e,v=Wc(g),w=Kc(y),k=new Map,A=new Map,S=[];c.forEach((e,t)=>{let i=(Yc(e,t,n)??e.id??t)+"",r=Oc(Yc(e,t,l)),o=Oc(Yc(e,t,s));if(null!=r&&null!=o){let e={x:r,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});let M=[];o.forEach((e,i)=>{let r=t(Yc(e,i,m)),o=t(Yc(e,i,x)),a=Math.max(0,Oc(Yc(e,i,b))??0),n=Ai(h?Yc(e,i,h):void 0),l=n.length?n:Ai(e.path??e.points??e.route);l.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${r}-${o}-${i}`)+"",link:e,index:i,source:r,target:o,throughput:a,rawPath:l})});let _=($=S,"normalized"===(L=i)||"pixels"===L?L:$.length>0&&$.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels"),P=new Map;var L,$;for(let[e,t]of k)P.set(e,Si(t,v,_));let T=[];for(let e of M){let t=e.rawPath.map(e=>Si(e,v,_));if(2>t.length){let i=P.get(e.source),r=P.get(e.target);i&&r&&(t=[i,r])}else P.has(e.source)||P.set(e.source,t[0]),P.has(e.target)||P.set(e.target,t[t.length-1]);2>t.length||0>=e.throughput||(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),T.push({...e,path:t,packetCount:0}))}let R=Bc(d,.12),C=Math.max(1,Math.round(a)),I=T.map(e=>Math.max(1,Math.round(e.throughput*R))),D=I.reduce((e,t)=>e+t,0),z=D>C?C/D:1;T.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(I[t]*z))});let O=T.reduce((e,t)=>e+t.packetCount,0);for(;O>C;){let e=T.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>T[e].packetCount)?i:e,-1);if(-1===e)break;T[e].packetCount-=1,O-=1}let F=new Map,N=new Map,E=[],W=Bc(r,90),j=Bc(u,4);T.forEach((e,t)=>{F.set(e.target,(F.get(e.target)??0)+e.throughput),N.set(e.source,(N.get(e.source)??0)+e.throughput);let i=Mi(e.path);for(let r=0;e.packetCount>r;r+=1){let o=(r+.5)/e.packetCount,a=p?o:Cc(.12+.84*o+.04*(w()-.5),.04,.98),n=p?a:Math.max(0,a-(.18+.12*w())),l=_i(e.path,n),s=_i(e.path,a),c=Pi(e.path,n),u={x:-c.y,y:c.x},d=(w()-.5)*j*1.5;E.push({id:`${e.id}-packet-${r}`,x:l.x+u.x*d,y:l.y+u.y*d,vx:p?0:c.x*W+10*(w()-.5),vy:p?0:c.y*W+10*(w()-.5),mass:.8,spawnAt:p?0:.04*t+r/32,shape:{type:"circle",radius:j},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:a,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:W,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==f&&p?[{target:{type:"point",x:s.x,y:s.y},restLength:.7*j,stiffness:26,damping:4.25}]:void 0})}});let B=Math.max(18,5*j),Y=Array.from(P,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+Zc(e),point:t})),X=Y.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:B,height:B}})),G=Object.fromEntries(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),V=[...Su({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...X],H=Rc(y,V,"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*j),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});H.bodyLimit=C,H.eviction="oldest",H.observation={...H.observation,sensors:G};let q=Array.from(P,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Zc(e),incoming:F.get(e)??0,outgoing:N.get(e)??0})),U=T.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:H,initialSpawns:E,projectionRows:q.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:E.length,totalThroughput:T.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:q,links:U}}}({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:a});return{...r,config:n.config,initialSpawns:eo(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:to(Zr(n.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:eu(t||o.colorBy||"source")}}},Dp={frameType:"physics",layout:Sp,buildProps:(e,t,i,r,o)=>{let a=r.size??[700,380],n=le(r.theme),l=function(e){let t=function(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}(e.config,e.chartId,e.onObservation),i=$i(e.colorScheme,e.themeCategorical,vd),r=Wc(e.size),o={data:e.data,scales:{x:Wf().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:Wf().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Ti(i,e.colorScheme),config:e.layoutConfig??{},world:new yu(t)},a=e.skipLayout?{}:e.layout(o)??{},n=function(e,t){if(!t?.length)return e;let i=new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...a.initialSpawns??a.bodies??[]],a.constraints);return{config:Ri(t,a),context:o,initialSpawnPacing:a.initialSpawnPacing,initialSpawns:n,result:a}}({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:lu(n)??{},size:a,themeCategorical:n.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:l.config,initialSpawns:eo(l.initialSpawns),projectionRows:[],bodyStyle:l.result.bodyStyle??eu(t||o.colorBy),backgroundGraphics:to(r.backgroundGraphics,l.result.backgroundOverlays),foregroundGraphics:to(r.foregroundGraphics,l.result.overlays)}}};import*as zp from"react-dom/server";import*as Op from"react";import*as Fp from"react-dom/server";var Np=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){let t=[];for(let i of e){let e=this.push(i);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){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){let a=(r+o)%this._capacity,n=this.buffer[a];if(e(n)){let e;e="object"!=typeof n||null===n?n:Array.isArray(n)?[...n]:{...n},i.push(e),this.buffer[a]=t(n)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);return i}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}},Ep=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(let i of e){let e=t?t(i):i;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}},Wp=/^\d{4}-\d{1,2}$/,jp=Object.create(null),Bp=typeof window>"u"||typeof document>"u",Yp=new Set;import{scaleLinear as Xp,scaleLog as Gp,scaleSymlog as Vp,scaleTime as Hp}from"d3-scale";var qp=new WeakMap,Up=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Zp=["scene-style","data-paint","accessibility","evidence"],Kp=(e,t)=>({retainedData:e,invalidations:t}),Qp=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Jp=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ey=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ty=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],iy=["scene-geometry","data-paint","accessibility","evidence"],ry=["scene-style","data-paint","accessibility","evidence"],oy=[],ay={chartType:Kp("rebuild",Qp),runtimeMode:Kp("rebuild",Qp),xAccessor:Kp("rebuild",Qp),yAccessor:Kp("rebuild",Qp),timeAccessor:Kp("rebuild",Qp),valueAccessor:Kp("rebuild",Qp),y0Accessor:Kp("rebuild",Qp),boundsAccessor:Kp("rebuild",Qp),band:Kp("rebuild",Qp),openAccessor:Kp("rebuild",Qp),highAccessor:Kp("rebuild",Qp),lowAccessor:Kp("rebuild",Qp),closeAccessor:Kp("rebuild",Qp),candlestickRangeMode:Kp("rebuild",Qp),accessorRevision:Kp("rebuild",Qp),groupAccessor:Kp("rebuild",Jp),categoryAccessor:Kp("rebuild",Jp),lineDataAccessor:Kp("rebuild",Jp),colorAccessor:Kp("rebuild",ry),sizeAccessor:Kp("rebuild",iy),symbolAccessor:Kp("rebuild",iy),pointIdAccessor:Kp("rebuild",iy),xScaleType:Kp("preserve",ey),yScaleType:Kp("preserve",ey),xExtent:Kp("preserve",ey),invertY:Kp("preserve",ey),yExtent:Kp("preserve",ey),extentPadding:Kp("preserve",ey),scalePadding:Kp("preserve",ey),axisExtent:Kp("preserve",ey),yAxisExtent:Kp("preserve",ey),binSize:Kp("preserve",ey),normalize:Kp("preserve",ey),heatmapAggregation:Kp("preserve",ey),heatmapXBins:Kp("preserve",ey),heatmapYBins:Kp("preserve",ey),arrowOfTime:Kp("preserve",ty),baseline:Kp("preserve",ty),stackOrder:Kp("preserve",ty),sizeRange:Kp("preserve",ty),curve:Kp("preserve",ty),areaGroups:Kp("preserve",ty),customLayout:Kp("preserve",ty),layoutConfig:Kp("preserve",ty),layoutMargin:Kp("preserve",ty),symbolMap:Kp("preserve",iy),showValues:Kp("preserve",iy),heatmapValueFormat:Kp("preserve",iy),trackHoverRows:Kp("preserve",iy),lineStyle:Kp("preserve",ry),pointStyle:Kp("preserve",ry),areaStyle:Kp("preserve",ry),barStyle:Kp("preserve",ry),swarmStyle:Kp("preserve",ry),waterfallStyle:Kp("preserve",ry),candlestickStyle:Kp("preserve",ry),boundsStyle:Kp("preserve",ry),gradientFill:Kp("preserve",ry),lineGradient:Kp("preserve",ry),semanticLineStops:Kp("preserve",ry),colorScheme:Kp("preserve",ry),themeCategorical:Kp("preserve",ry),themeSemantic:Kp("preserve",ry),themeSequential:Kp("preserve",ry),themeDiverging:Kp("preserve",ry),barColors:Kp("preserve",ry),decay:Kp("preserve",ry),pulse:Kp("preserve",ry),staleness:Kp("preserve",ry),layoutSelection:Kp("preserve",ry),annotations:Kp("preserve",["overlay","accessibility","evidence"]),windowSize:Kp("preserve",oy),windowMode:Kp("preserve",oy),maxCapacity:Kp("preserve",oy),clock:Kp("preserve",oy),transition:Kp("preserve",oy),introAnimation:Kp("preserve",oy),onLayoutError:Kp("preserve",oy)},ny=Kp("preserve",ty),ly=class{constructor(){this.tracker=new gu}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Up)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Zp):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=ay[r]??ny;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t?new Set([...i.invalidations,...iy]):i.invalidations)}};import{quadtree as sy}from"d3-quadtree";var cy=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 i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=i)return void(this.tree=null);let o=Array(i),a=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[a++]=e);this.tree=sy().x(e=>e.x).y(e=>e.y).addAll(o)}},uy=class e{constructor(e){if(this.xExtent=new Ep,this.yExtent=new Ep,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 ly,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 cy,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,a=("u">typeof performance?performance.now():Date.now())){let n=e.color??"rgba(255,255,255,0.6)",l=e.glowRadius??4,s=!1,c=o??(()=>{let e=new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,l=!1;for(let i of t){let t=c.get(i);if(null==t)continue;l=!0;let n=r.get(t);if(null==n)continue;let s=po(e,n,a);s>o&&(o=s)}l&&(s=yo(i,o,n)||s);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);s=yo(i,null==o?0:po(e,o,a),n,l)||s}return s}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new Np(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Xc(e.timeAccessor||e.xAccessor,"time"),this.getY=Xc(e.valueAccessor||e.yAccessor,"value")):(this.getX=Xc(e.xAccessor,"x"),this.getY=Xc(e.yAccessor,"y")),this.getGroup=Uc(e.groupAccessor),this.getCategory=Uc(e.categoryAccessor),this.getSize=e.sizeAccessor?Xc(e.sizeAccessor,"size"):void 0,this.getColor=Uc(e.colorAccessor),this.getSymbol=Uc(e.symbolAccessor),this.getY0=e.y0Accessor?Xc(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Mo(e),this.getPointId=Uc(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?Xc(e.openAccessor,"open"):void 0,this.getHigh=Xc(e.highAccessor,"high"),this.getLow=Xc(e.lowAccessor,"low"),this.getClose=i?Xc(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new Np(e.windowSize))}currentTime(){return this.config.clock?.()??uo()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Eo(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let 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;let t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();let i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?Xc(this.config.timeAccessor||this.config.xAccessor,"time"):Xc(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){let t=e.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(t):t[i||"x"],o=r instanceof Date,a="string"==typeof r&&Number.isFinite(oo(r));if(this.xIsDate=o||a,a){let e="string"==typeof i?i:void 0;this.getX=e?t=>ao(t[e]):e=>ao(i(e))}}No(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Wo(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let 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&&this.growingCap>=5e4&&(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.`)))}let e=Wo(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),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){let{config:t,buffer:i}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let a=this.getBufferArray(),n=this.xExtent.extent,l=this.yExtent.extent,s="waterfall"===t.chartType&&i.size>0?function(e,t,i,r,o){let a=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>a.length)return zo(i,r);let n=a[0],l=a[1],s=a[a.length-1],c=a[a.length-2];return zo("log"===o&&n>0?[n/Math.sqrt(l/n),s*Math.sqrt(s/c)]:[n-(l-n)/2,s+(s-c)/2],r)}(a,this.getX,n,t.xExtent,t.xScaleType):zo(n,t.xExtent),c=zo(l,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=function(e){let{config:t,groups:i,getX:r,getY:o}=e,a="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,a?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let n=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===n)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let l=new Map,s=new Set,c=0,u=new Map,d=new Map;for(let e of i){let t=new Map,i=0;for(let a of e.data){let e=r(a),n=o(a);if(!Number.isFinite(e)||!Number.isFinite(n))continue;t.set(e,(t.get(e)||0)+n),s.add(e),i+=n;let l=(u.get(e)||0)+n;u.set(e,l),l>c&&(c=l)}l.set(e.key,t),d.set(e.key,i)}let h,f,p=t.stackOrder??"key",y=(e,t)=>t>e?-1:e>t?1:0;if("input"===p)h=i.map(e=>e.key);else if("insideOut"===p){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}),t=[],r=[],o=0,a=0;for(let i of e)a>o?(t.push(i),o+=d.get(i)??0):(r.push(i),a+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:y(e,t)}):"desc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}):i.map(e=>e.key).sort(y);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(s).sort((e,t)=>e-t),i=To(e,h,(e,t)=>l.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,a=u.get(t)??0;r>e&&(r=e),e+a>o&&(o=e+a)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let n=o-r,c=a?0:n>0?n*t.extentPadding:1;f=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(s).sort((e,t)=>e-t),[i,r]=function(e,t,i){let r=0,o=0;for(let a of e){let e=0,n=0;for(let r of t){let t=i(r,a)||0;0>t?n+=t:e+=t}r>n&&(r=n),e>o&&(o=e)}return[r,o]}(e,h,(e,t)=>l.get(e)?.get(t)||0),o=r-i,n=a?0:o>0?o*t.extentPadding:1;f=[i-n,r+n]}else f=[0,c+(a?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:n,yDomain:f}}}({config:t,groups:this.groupData(a),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=function(e,t,i,r,o,a,n){let[,l]=function(e,t,i,r,o){let a=_o(e,t,i,r,o);if(0===a.size)return[0,0];let n=0;for(let e of a.values())e.total>n&&(n=e.total);return[0,n]}(e,t,i,r,o);return[0,n?l:l+l*a]}(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!u&&i.size>0?c=function(e,t,i,r){let[o,a]=function(e,t){let i=0,r=0,o=0;for(let a of e){let e=t(a);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(e,t),n=a-o,l=r?0:n>0?n*i:1;return[Math.min(0,o-Math.abs(l)),Math.max(0,a+Math.abs(l))]}(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=function(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),a=t.getBottom(e);Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i)),Number.isFinite(a)&&(r>a&&(r=a),a>o&&(o=a))}return[r,o]}(c,a,this.resolvedRibbons),c=function(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:l}));c=function(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}(c,t.yExtent,!!u),({xDomain:s,yDomain:c}=function(e,t,i){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===i){let e=Date.now();r=[e-864e5,e]}else r=[0,1];return(o[0]===1/0||o[1]===-1/0)&&(o=[0,1]),{xDomain:r,yDomain:o}}(s,c,t.xScaleType)),this.scales=function(e){let{config:t,layout:i,xDomain:r}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,a="streaming"===t.runtimeMode,n=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(a){let e="left"===t.arrowOfTime?[i.width-n,n]:[n,i.width-n];return{x:Xp().domain(r).range(e),y:Oo(t.yScaleType,o,[i.height-n,n])}}return{x:Oo(t.xScaleType,r,[n,i.width-n]),y:Oo(t.yScaleType,o,[i.height-n,n])}}({config:t,layout:e,xDomain:s,yDomain:c}),this._customLayoutFailedThisBuild=!1;let f=this.buildSceneNodes(e,a);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,a),this.config.pulse&&this.applyPulse(this.scene,a,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){let t=e.width/this.lastLayout.width,i=e.height/this.lastLayout.height;for(let e of this.scene)switch(e.type){case"line":for(let r of e.path)r[0]*=t,r[1]*=i;break;case"area":for(let r of e.topPath)r[0]*=t,r[1]*=i;for(let r of e.bottomPath)r[0]*=t,r[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}let r=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),n=this.scales.y.range(),l=Oo,s=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=n[1]>n[0];this.scales={x:l(this.config.xScaleType,r,a[0]>a[1]?[e.width-s,s]:[s,e.width-s]),y:l(this.config.yScaleType,o,c?[s,e.height-s]:[e.height-s,s])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??Xd},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},a=Ao({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let n=a.result;this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null;let l=n.nodes??[];if(this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of l)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(l,i.layoutSelection??null)}return vo({label:"customLayout",nodes:l,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),l}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];let o={scales:r,config:i,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},a=(n=i.chartType,jp[n]?.buildScene);var n;if(!a)return function(e){(function(e){return jp[e]})(e)||Bp&&(Yp.has(e)||(Yp.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}(i.chartType),[];let l=(s=a(o,t,e),Array.isArray(s)?{nodes:s,binBoundaries:[]}:{nodes:s.nodes,binBoundaries:s.binBoundaries});var s;return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=l.binBoundaries),l.nodes}resolveBoundsStyle(e,t){return function(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let a=r(t,i);return{fill:a.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=a.opacity&&{opacity:a.opacity},stroke:"none",cursor:a.cursor}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?ho(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=fo(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,i,r=fo(i)){let o=i.length;if(o>1)for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;let a=Array(t.length),n=!1;for(let i=0;t.length>i;i++){let l=r.get(t[i]);null!=l?(a[i]=ho(e,l,o),1>a[i]&&(n=!0)):a[i]=1}n&&(i._decayOpacities=a);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],a=i.topPath?i.topPath.length:t.length;if(2>a)continue;if(t.length===a){let n=Array(a),l=!1;for(let i=0;t.length>i;i++){let a=r.get(t[i]);null!=a?(n[i]=ho(e,a,o),1>n[i]&&(l=!0)):n[i]=1}l&&(i._decayOpacities=n)}else{let n=1;for(let i of t){let t=r.get(i);if(null!=t){let i=ho(e,t,o);n>i&&(n=i)}}if(1>n){let e=Array(a);e.fill(n),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let a=ho(e,t,o);"candlestick"===i.type?i._decayOpacity=a:i.style={...i.style,opacity:(i.style?.opacity??1)*a}}}(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&&go(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,i,r){i.clear(),r.clear();for(let o=0;t.length>o;o++){let a=t[o],n=mo(e,a,o);n&&("point"===a.type?i.set(n,{x:a.x,y:a.y,r:a.r,opacity:xo(a.style)}):"glyph"===a.type?i.set(n,{x:a.x,y:a.y,r:a.size,opacity:xo(a.style),glyph:a.glyph}):"rect"===a.type||"heatcell"===a.type?i.set(n,{x:a.x,y:a.y,w:a.w,h:a.h,opacity:xo(a.style)}):"candlestick"===a.type?i.set(n,{x:a.x,y:a.openY,w:a.bodyWidth,openY:a.openY,closeY:a.closeY,highY:a.highY,lowY:a.lowY,opacity:xo(a.style)}):"line"===a.type?r.set(n,{path:a.path.map(e=>[e[0],e[1]]),opacity:a.style?.opacity}):"area"===a.type&&r.set(n,{topPath:a.topPath.map(e=>[e[0],e[1]]),bottomPath:a.bottomPath.map(e=>[e[0],e[1]]),opacity:a.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=mo(this.transitionContext,i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;let e=function(e,t,i,r,o,a=uo()){if(0===r.size&&0===o.size)return i;let n=t.duration??300;if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let l=!1,s=new Set,c=new Set;for(let t=0;i.scene.length>t;t++){let a=i.scene[t],n=mo(e,a,t);if(!n)continue;if(a._transitionKey=n,"line"===a.type||"area"===a.type){let e=o.get(n);if(e){if(c.add(n),"line"===a.type&&e.path&&e.path.length===a.path.length){a._targetPath=a.path.map(e=>[e[0],e[1]]),a._prevPath=e.path;for(let t=0;a.path.length>t;t++)a.path[t]=[e.path[t][0],e.path[t][1]];l=!0}else if("area"===a.type&&e.topPath&&e.bottomPath&&e.topPath.length===a.topPath.length&&e.bottomPath.length===a.bottomPath.length){a._targetTopPath=a.topPath.map(e=>[e[0],e[1]]),a._targetBottomPath=a.bottomPath.map(e=>[e[0],e[1]]),a._prevTopPath=e.topPath,a._prevBottomPath=e.bottomPath;for(let t=0;a.topPath.length>t;t++)a.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;a.bottomPath.length>t;t++)a.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];l=!0}a._targetOpacity=a.style.opacity??1,a._startOpacity=e.opacity??a.style.opacity??1}else a._targetOpacity=a.style.opacity??1,a._startOpacity=0,a.style={...a.style,opacity:0},l=!0;continue}let u=r.get(n);if("point"===a.type)if(u){s.add(n);let e={x:a.x,y:a.y,r:a.r};a._targetOpacity=xo(a.style),(u.x!==e.x||u.y!==e.y||u.r!==e.r)&&(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=u.x,a.y=u.y,a.r=u.r??a.r,l=!0)}else a._targetOpacity=xo(a.style),a.style={...a.style,opacity:0},l=!0;else if("glyph"===a.type)if(u){s.add(n);let e={x:a.x,y:a.y,size:a.size};a._targetOpacity=xo(a.style),(u.x!==e.x||u.y!==e.y||u.r!==e.size)&&(a._targetX=e.x,a._targetY=e.y,a._targetR=e.size,a.x=u.x,a.y=u.y,a.size=u.r??a.size,l=!0)}else a._targetOpacity=xo(a.style),a.style={...a.style,opacity:0},l=!0;else if("rect"===a.type)if(u){s.add(n);let e={x:a.x,y:a.y,w:a.w,h:a.h};a._targetOpacity=xo(a.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=u.x,a.y=u.y,a.w=u.w??a.w,a.h=u.h??a.h,l=!0)}else a._targetOpacity=xo(a.style),a.style={...a.style,opacity:0},l=!0;else if("heatcell"===a.type)if(u){s.add(n);let e={x:a.x,y:a.y,w:a.w,h:a.h};a._targetOpacity=xo(a.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=u.x,a.y=u.y,a.w=u.w??a.w,a.h=u.h??a.h,l=!0)}else a._targetOpacity=xo(a.style),a.style={...a.style||{},opacity:0},l=!0;else if("candlestick"===a.type)if(u&&null!=u.openY){s.add(n);let e={x:a.x,openY:a.openY,closeY:a.closeY,highY:a.highY,lowY:a.lowY};a._targetOpacity=xo(a.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(a._targetX=e.x,a._targetOpenY=e.openY,a._targetCloseY=e.closeY,a._targetHighY=e.highY,a._targetLowY=e.lowY,a.x=u.x,a.openY=u.openY,a.closeY=u.closeY??a.closeY,a.highY=u.highY??a.highY,a.lowY=u.lowY??a.lowY,l=!0)}else a._targetOpacity=xo(a.style),a.style={...a.style||{},opacity:0},l=!0}for(let[e,t]of o)if(!c.has(e))if(e.startsWith("l:")&&t.path){let r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};i.exitNodes.push(r),l=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){let r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};i.exitNodes.push(r),l=!0}for(let[e,t]of r)if(!s.has(e)){if(e.startsWith("p:"))i.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)i.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:"))i.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:"))i.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:")){let r=t.openY??t.y;i.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}l=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),l&&(i.activeTransition={startTime:a,duration:n}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;let t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(e,t,i,r){if(!i.activeTransition)return!1;let o=so(e,i.activeTransition),a=lo(o,"linear"===t.easing?"linear":"ease-out-cubic");for(let e of i.scene){let t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=co(i?i.opacity??1:0,e._targetOpacity,a)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=co(i.x,e._targetX,a),e.y=co(i.y,e._targetY,a),void 0!==e._targetR&&void 0!==i.r&&(e.r=co(i.r,e._targetR,a))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=co(i?i.opacity??1:0,e._targetOpacity,a)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=co(i.x,e._targetX,a),e.y=co(i.y,e._targetY,a),void 0!==e._targetR&&void 0!==i.r&&(e.size=co(i.r,e._targetR,a))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=co(i?i.opacity??1:0,e._targetOpacity,a)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=co(i.x,e._targetX,a),e.y=co(i.y,e._targetY,a),void 0!==i.w&&(e.w=co(i.w,e._targetW,a)),void 0!==i.h&&(e.h=co(i.h,e._targetH,a))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:co(i?i.opacity??1:0,e._targetOpacity,a)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=co(i.x,e._targetX,a),e.y=co(i.y,e._targetY,a),void 0!==i.w&&(e.w=co(i.w,e._targetW,a)),void 0!==i.h&&(e.h=co(i.h,e._targetH,a))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:co(i?i.opacity??1:0,e._targetOpacity,a)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=co(i.x,e._targetX,a),void 0!==i.openY&&(e.openY=co(i.openY,e._targetOpenY,a)),void 0!==i.closeY&&(e.closeY=co(i.closeY,e._targetCloseY,a)),void 0!==i.highY&&(e.highY=co(i.highY,e._targetHighY,a)),void 0!==i.lowY&&(e.lowY=co(i.lowY,e._targetLowY,a))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:co(e._startOpacity??0,e._targetOpacity,a)}),void 0!==e._introClipFraction&&(e._introClipFraction=a);let t=e._prevPath,i=e._targetPath;if(t&&i&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=co(t[r][0],i[r][0],a),e.path[r][1]=co(t[r][1],i[r][1],a)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:co(e._startOpacity??0,e._targetOpacity,a)}),void 0!==e._introClipFraction&&(e._introClipFraction=a);let t=e._prevTopPath,i=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let i=0;e.topPath.length>i;i++)e.topPath[i][0]=co(t[i][0],r[i][0],a),e.topPath[i][1]=co(t[i][1],r[i][1],a);if(i&&o&&i.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=co(i[t][0],o[t][0],a),e.bottomPath[t][1]=co(i[t][1],o[t][1],a)}}if(o>=1){for(let e of i.scene){if(void 0!==e._targetOpacity){let 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){let t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){let t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.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,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)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("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(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)void 0!==t._targetX&&(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||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=function(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=function(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let a=new Set;if(t)for(let i of e){let e=t(i);e&&a.add(e)}let n=Array.from(a).sort(),l=n.join("\0");if(o&&o.key===l){let e={...o,version:r};return{map:e.map,cache:e}}let s=B(i.colorScheme,i.themeCategorical,Xd),c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],Fo(i.colorScheme,n[e])??s[e%s.length]);return{map:c,cache:{key:l,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return function(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let a=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||a||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||a||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let a=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||a||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||a||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let n=r(t)||a||"#4e79a7";return{fill:n,fillOpacity:.7,stroke:n,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){let{color:i,groupColorCounter:r}=function(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:a}=e,{groupColorCounter:n}=e,l=Fo(a.colorScheme,t);if(l)return{color:l,groupColorCounter:n};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:n}}let s=r.get(t);if(s)return{color:s,groupColorCounter:n};let c=B(a.colorScheme,a.themeCategorical,Xd);if(0===c.length)return{color:null,groupColorCounter:n};let u=c[n%c.length];if(n++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:n}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,i}getBufferArray(){return(this._bufferDirty||!this._bufferArrayCache)&&(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=no(e),i=this.getPointId,r=e=>t.has(i(e));jo(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");let i=no(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let a=this.buffer.update(e=>i.has(r(e)),t);if(0===a.length)return this.updateResults.recordNoop("update"),a;for(let e of a)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",a.length),a}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let a="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,n=e&&t.valueAccessor||t.yAccessor,l=a||!Tc(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),s=a||!Tc(i,n);(l||s)&&(e?(this.getX=Xc(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Xc(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Xc(this.config.xAccessor,"x"),this.getY=Xc(this.config.yAccessor,"y")),s&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Mo(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!Tc(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Uc(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!Tc(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Uc(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!Tc(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Xc(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!Tc(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Uc(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!Tc(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Uc(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!Tc(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Xc(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!Tc(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Mo(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!Tc(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Uc(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in e&&!Tc(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Tc(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Tc(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Tc(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Xc(this.config.openAccessor,"open"):void 0,this.getHigh=Xc(this.config.highAccessor,"high"),this.getLow=Xc(this.config.lowAccessor,"low"),this.getClose=t?Xc(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&Me(t.areaStyle)!==Me(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};uy.GROUP_COLOR_MAP_CAP=1e3;var dy=uy;qo(dy);import{area as hy,line as fy}from"d3-shape";var py=(e,t,i,r)=>{let o=t.filter(e=>"area"===e.type);for(let t of o){if(2>t.topPath.length)continue;let i=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),i=!0);let o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());let a=Cr(e,t.style.fill,"#4e79a7"),n=t._decayOpacities,l=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),s=!!t.strokeColorBands?.length;if(n&&n.length===t.topPath.length&&!l&&!s){let i=t.style.fillOpacity??.7;e.fillStyle=a;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(n[r]+n[r+1])*i,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();let r=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&r>0){e.strokeStyle=tu(e,t.style.stroke)||t.style.stroke,e.lineWidth=r,e.setLineDash([]);for(let i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(n[i]+n[i+1]),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.stroke()}e.globalAlpha=1;continue}let c=t.style.opacity??1;if(la(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&t.fillGradient){let i=1/0;for(let e of t.topPath)i>e[1]&&(i=e[1]);let r=-1/0;for(let e of t.bottomPath)e[1]>r&&(r=e[1]);let o=Dr(e,t.fillGradient,"string"==typeof a?a:"#4e79a7",0,i,0,r);e.fillStyle=o||a,e.globalAlpha=c}else e.globalAlpha=(t.style.fillOpacity??.7)*c,e.fillStyle=a;e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(la(e,t),oa(e,t));let u=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&u>0){e.globalAlpha=c;let i=tu(e,t.style.stroke)||t.style.stroke,r=l||s||!t.strokeGradient||2>t.topPath.length?null:Dr(e,t.strokeGradient,i,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=u,e.setLineDash([]),s){let r=1/0,o=-1/0;for(let[e]of t.topPath)r=Math.min(r,e),o=Math.max(o,e);let a=e.lineWidth;for(let n of t.strokeColorBands){e.save(),e.beginPath(),e.rect(r-a,n.y,o-r+2*a,n.height),e.clip();let l=n.color??i;e.strokeStyle=tu(e,l)||l,e.globalAlpha=c*(n.opacity??1),sa(e,t),e.stroke(),e.restore()}}else if(l){let r=na(t.topPath,t.rawValues,t.colorThresholds,i);for(let t of r){e.beginPath(),e.strokeStyle=tu(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}else e.strokeStyle=r||i,sa(e,t),e.stroke()}void 0!==o&&1>o&&e.restore(),i&&e.restore(),e.globalAlpha=1}};import{line as yy}from"d3-shape";var gy=(e,t,i,r)=>{let o=t.filter(e=>"line"===e.type);for(let t of o){if(2>t.path.length)continue;let i=t._introClipFraction;void 0!==i&&1>i&&(e.save(),e.beginPath(),e.rect(0,0,r.width*i,r.height),e.clip());let o=t.style.stroke||"#007bff",a=tu(e,o)||o,n=t.style.strokeWidth??2,l=t.colorThresholds,s=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),n>0&&(e.lineWidth=n),e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade&&n>0){ca(e,t.path,a,n,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}let c=Rr(t.curve),u=l&&l.length>0&&s&&s.length===t.path.length,d=t._decayOpacities;if(n>0&&d&&d.length===t.path.length&&!u){e.strokeStyle=a;let i=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(d[r]+d[r+1])*i,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(n>0&&!u){e.beginPath();let i=t.strokeGradient&&t.path.length>=2?Dr(e,t.strokeGradient,a,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=i||a,c)yy().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}e.stroke()}else if(n>0){let i=na(t.path,s,l,a);for(let t of i){e.beginPath(),e.strokeStyle=tu(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Cr(e,t.style.fill,t.style.fill),c&&!u)yy().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}let i=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(i,r.height),e.closePath(),e.fill()}void 0!==i&&1>i&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}},my=(e,t,i,r)=>{let o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{let t=e.globalAlpha,i=[],r="",a=i=>{e.beginPath(),e.arc(i.x,i.y,i.r,0,2*Math.PI),e.globalAlpha=t*(i.style.opacity??i.style.fillOpacity??1),e.fillStyle=Cr(e,i.style.fill,"#4e79a7"),e.fill();let r=i.style.strokeWidth??1;i.style.stroke&&"none"!==i.style.stroke&&r>0&&(e.strokeStyle=Cr(e,i.style.stroke,i.style.stroke),e.lineWidth=r,e.stroke()),function(e,t,i=.6){if(!ia(t))return;let r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,a=t.cy??t.y??0;e.beginPath(),e.arc(o,a,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*i,e.stroke()}(e,i)},n=()=>{if(0===i.length)return;if(1===i.length)return a(i[0]),i=[],void(r="");let o=i[0];e.globalAlpha=t*(o.style.opacity??o.style.fillOpacity??1),e.beginPath();for(let t of i)e.moveTo(t.x+t.r,t.y),e.arc(t.x,t.y,t.r,0,2*Math.PI);e.fillStyle=Cr(e,o.style.fill,"#4e79a7"),e.fill();let n=o.style.strokeWidth??1;o.style.stroke&&"none"!==o.style.stroke&&n>0&&(e.strokeStyle=Cr(e,o.style.stroke,o.style.stroke),e.lineWidth=n,e.stroke()),i=[],r=""};for(let e of o){let t=e.style.opacity??e.style.fillOpacity??1,o=e.style.fill;if(ia(e)||null!=o&&"string"!=typeof o||1>t){n(),a(e);continue}let l=e.style.strokeWidth??1,s=`${o??"#4e79a7"}\0${e.style.stroke&&"none"!==e.style.stroke&&l>0?e.style.stroke+"":""}\0${l}\0${e.r}\0${t}`;i.length>0&&s!==r&&n(),r=s,i.push(e),i.length>=2048&&n()}n()}finally{e.restore()}}},xy={chartType:"line",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(ta).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=Ko(e.ribbons);if(a.length>0&&r.push(...Qo(e,t,a)),o.length>0)for(let t of i)r.push(...Jo(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,Se(t.data)),a=Lo(t.data,e.scales,e.getX,e.getY,i,t.key);o&&o.length>0&&(a.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(a.curve=e.config.curve),e.config.lineGradient&&(a.strokeGradient=e.config.lineGradient),r.push(a)}return ea(e,i,r),r}(e,t),canvasRenderers:[py,gy,my]},by={chartType:"area",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=Ko(e.ribbons);if(a.length>0&&r.push(...Qo(e,t,a)),o.length>0)for(let t of i)r.push(...Jo(e,t.data,t.key,o))}let o=e.scales.y.domain(),a=o[0],n=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),l=n&&n.length>0?(()=>{let t=n.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let a=e.scales.y(t),n=e.scales.y(i);return{y:Math.min(a,n),height:Math.abs(n-a),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,s=e.getY0?t=>e.getY0(t)??a:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,Se(t.data)),o=$o(t.data,e.scales,e.getX,e.getY,a,i,t.key,s),c=ua(e.config.gradientFill);c&&(o.fillGradient=c),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n&&n.length>0&&(o.colorThresholds=n,o.strokeColorBands=l),r.push(o)}return ea(e,i,r),r}(e,t),canvasRenderers:[py,my]},vy={chartType:"stackedarea",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],a=[],n=0,l=0;for(let i of e)l>n?(r.push(i),n+=t.get(i.key)??0):(a.push(i),l+=t.get(i.key)??0);i.length=0,i.push(...a.reverse(),...r)}}else o();let a=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,n=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:l,stackedTops:s}=function(e,t,i,r,o,a,n,l="zero"){let s=new Set,c=new Map;for(let t of e){let e=new Map;for(let o of t.data){let t=i(o),a=r(o);if(!Number.isFinite(t)||(s.add(t),!Number.isFinite(a)))continue;let n=e.get(t);n?(n.value+=a,n.sources?n.sources.push(o):n.sources=[n.datum,o]):e.set(t,{value:a,datum:o})}c.set(t.key,e)}let u,d=Array.from(s).sort((e,t)=>e-t);if(a){u=new Map;for(let t of d){let i=0;for(let r of e)i+=c.get(r.key)?.get(t)?.value||0;u.set(t,i||1)}}let h=To(d,e.map(e=>e.key),(e,t)=>c.get(e)?.get(t)?.value||0,l),f="diverging"===l&&!a,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(let e of d)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(let i of e){let e=c.get(i.key),r=new Map,l=[],s=[],h=[],b=[],v=[],w=!1,k=()=>{if(0!==l.length){if(l.length>=2){let e=w?l.map((e,t)=>t).sort((e,t)=>l[e][0]-l[t][0]):void 0,t={type:"area",topPath:e?e.map(e=>l[e]):l,bottomPath:e?e.map(e=>s[e]):s,rawValues:e?e.map(e=>h[e]):h,style:o(i.key,Se(i.data)),datum:e?e.map(e=>b[e]):b,accessibleDatum:e?e.map(e=>v[e]):v,group:i.key};n&&(t.curve=n),p.push(t)}l=[],s=[],h=[],b=[],v=[],w=!1}};for(let o of d){let n,c,d=e.get(o),p=void 0!==d,y=d?.value??0;if(a&&p&&(y/=u.get(o)),!p||!Number.isFinite(y)||0===y){k();continue}f?y>0?(n=m.get(o),c=n+y,m.set(o,c)):(n=x.get(o),c=n+y,x.set(o,c)):(n=g.get(o),c=n+y,g.set(o,c));let A=t.x(o),S=t.y(n),M=t.y(c);if(!Number.isFinite(A)||!Number.isFinite(S)||!Number.isFinite(M)){k();continue}let _=d.sources,P=d.value,L=_?{..._[0],__aggregateValue:P,__aggregateCount:_.length,__aggregateRows:_}:d.datum;l.length>0&&l[l.length-1][0]>A&&(w=!0),l.push([A,M]),s.push([A,S]),b.push(L),h.push(P),v.push(_?{x:o,value:P,group:i.key,observations:_.length}:L),r.set(o,c)}k(),y.set(i.key,r)}return{nodes:p,stackedTops:y}}(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,a,n),c=l;if(e.config.pointStyle){let t=new WeakMap;for(let r of i){let i=s.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),a=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=a&&!Number.isNaN(a)&&i.has(r)&&t.set(o,i.get(r))}}ea(e,i,c,i=>t.get(i)??e.getY(i))}return c}(e,t),canvasRenderers:[py,my]},wy={chartType:"mixed",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=Ko(e.ribbons);if(a.length>0&&r.push(...Qo(e,t,a)),o.length>0)for(let t of i)r.push(...Jo(e,t.data,t.key,o))}let a=e.scales.y.domain()[0],n=e.getY0?t=>e.getY0(t)??a:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,Se(t.data)),o=$o(t.data,e.scales,e.getX,e.getY,a,i,t.key,n),l=ua(e.config.gradientFill);l&&(o.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,Se(t.data)),o=Lo(t.data,e.scales,e.getX,e.getY,i,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return ea(e,i,r),r}(e,t),canvasRenderers:[py,gy,my]},ky=new Map,Ay=(e,t)=>{let i=e.globalAlpha;for(let r of t)"symbol"===r.type&&ha(e,r,r.x,r.y,i,"#4e79a7");e.globalAlpha=i},Sy=[my,Ay],My={chartType:"scatter",buildScene:(e,t)=>da(e,t),canvasRenderers:Sy},_y={chartType:"bubble",buildScene:(e,t)=>da(e,t),canvasRenderers:Sy},Py=256,Ly=new Map,$y=(e,t,i,r)=>{let o=t.filter(e=>"heatcell"===e.type);e.save();try{let t=tu(e,"var(--semiotic-font-family, sans-serif)")||"sans-serif";for(let i of o){let r=i.style;null!=r?.opacity&&(e.globalAlpha=r.opacity);let o=Ir(e,i.fill,"#4e79a7");e.fillStyle=o,e.fillRect(i.x,i.y,i.w,i.h);let a=Math.max(0,r?.strokeWidth??1);if(a>0&&(e.strokeStyle=tu(e,r?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=a,e.strokeRect(i.x,i.y,i.w,i.h)),ra(e,i),e.globalAlpha=1,i.showValues&&null!=i.value){if(20>i.w||20>i.h)continue;let r=i.valueFormat?i.valueFormat(i.value):xa(i.value),a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h))),n=i.x+i.w/2,l=i.y+i.h/2;e.fillStyle=ma(e,"string"==typeof o?o:"#4e79a7"),e.font=`${a}px ${t}`,e.textAlign="center",e.textBaseline="middle",e.fillText(r,n,l)}}}finally{e.restore()}},Ty={chartType:"heatmap",buildScene:(e,t,i)=>function(e,t,i){if(e.config.heatmapAggregation)return ga(e,t,i);if(0===t.length)return[];let r=Xc(e.config.valueAccessor,"value"),o=qc(e.config.xAccessor,"x"),a=qc(e.config.yAccessor,"y"),n=new Map,l=new Map,s=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){let i=t[e],r=o(i),u=a(i);s[e]=r,c[e]=u,n.has(r)||n.set(r,n.size),l.has(u)||l.set(u,l.size)}let u=n.size,d=l.size;if(0===u||0===d)return[];let h=Array.from(n.keys()),f=Array.from(l.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e)),g=4096;if(p&&y&&u*d>g&&t.length>g){let r=new Set;for(let o=0;t.length>o;o++){let a=n.get(s[o]),d=l.get(c[o]);if(void 0!==a&&void 0!==d&&(r.add(d*u+a),r.size>g))return ga({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(p){h.sort((e,t)=>Number(e)-Number(t)),n.clear();for(let e=0;h.length>e;e++)n.set(h[e],e)}if(y){f.sort((e,t)=>Number(e)-Number(t)),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}let m=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=new Map,w=0;for(let e=0;t.length>e;e++){let i=t[e],o=n.get(s[e]),a=l.get(c[e]);if(void 0===o||void 0===a)continue;let d,h=r(i),f=a*u+o,p=v.get(f);void 0!==p?d=p:(d=w++,v.set(f,d)),m[d]=f,x[d]=h,b[d]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){let t=x[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];let S=e.config.heatmapColorScale,M=S?void 0:pa("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),_=i.width/u,P=i.height/d,L=e.config.showValues,$=e.config.heatmapValueFormat,T=[];for(let t=0;w>t;t++){let i=x[t];if(!isFinite(i))continue;let r=m[t],o=r%u,a=(r-o)/u,n=fa(i,k,A),l=S?S(i):M[n],s=b[t];T.push(ya(Do(o*_,(d-1-a)*P,_,P,l,s,L?{value:i,showValues:!0,valueFormat:$}:{value:i}),s,e))}return T}(e,t,i),canvasRenderers:[$y]},Ry=(e,t,i,r)=>{let o=t.filter(e=>"rect"===e.type);for(let t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Sa(e,t);else if(t.cornerRadii&&ba(t.cornerRadii))e.fillStyle=ka(e,t),wa(e,t),e.fill(),Aa(e,t)&&e.stroke();else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=ka(e,t);let i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();let{x:r,y:o,w:a,h:n}=t;switch(t.roundedEdge){case"right":e.moveTo(r,o),e.lineTo(r+a-i,o),e.arcTo(r+a,o,r+a,o+i,i),e.lineTo(r+a,o+n-i),e.arcTo(r+a,o+n,r+a-i,o+n,i),e.lineTo(r,o+n);break;case"left":e.moveTo(r+a,o),e.lineTo(r+i,o),e.arcTo(r,o,r,o+i,i),e.lineTo(r,o+n-i),e.arcTo(r,o+n,r+i,o+n,i),e.lineTo(r+a,o+n);break;case"bottom":e.moveTo(r,o),e.lineTo(r+a,o),e.lineTo(r+a,o+n-i),e.arcTo(r+a,o+n,r+a-i,o+n,i),e.lineTo(r+i,o+n),e.arcTo(r,o+n,r,o+n-i,i);break;default:e.moveTo(r,o+n),e.lineTo(r,o+i),e.arcTo(r,o,r+i,o,i),e.lineTo(r+a-i,o),e.arcTo(r+a,o,r+a,o+i,i),e.lineTo(r+a,o+n)}e.closePath(),e.fill(),Aa(e,t)&&e.stroke()}else e.fillStyle=ka(e,t),e.fillRect(t.x,t.y,t.w,t.h),Aa(e,t)&&e.strokeRect(t.x,t.y,t.w,t.h);ra(e,t),e.globalAlpha=1}},Cy={chartType:"bar",buildScene:(e,t)=>function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=_o(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Me(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],a=new Set(o),n=Array.from(t).filter(e=>!a.has(e)).sort(),l=o.filter(e=>t.has(e)),s=l.join("\0")+""+n.join("\0");e.barCategoryCache&&e.barCategoryCache.key===s?r=e.barCategoryCache.order:(r=[...l,...n],e.barCategoryCache={key:s,order:r})}let o=[],a=e.scales,[n,l]=a.x.domain(),s=e.config.barStyle,c=e.config.themeSemantic?.primary,u=s?.gap,d="number"!=typeof u||0>u?1:u,h={};s?.stroke&&(h.stroke=s.stroke),"number"==typeof s?.strokeWidth&&(h.strokeWidth=s.strokeWidth),"number"==typeof s?.opacity&&(h.opacity=s.opacity),s?.cursor&&(h.cursor=s.cursor);for(let t of i.values()){let i=Math.max(t.start,n),u=Math.min(t.end,l);if(i>=u)continue;let f=a.x(i),p=a.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(r&&t.categories.size>0){let i=0;for(let n of r){let r=t.categories.get(n)||0;if(0===r)continue;let l=a.y(i),u=a.y(i+r),d=Math.min(l,u),f=Math.abs(l-u),p=(e.config.barColors?X(e.config.barColors,n):void 0)??s?.fill??c??"#4e79a7",y=we({binStart:t.start,binEnd:t.end,total:t.total,category:n,categoryValue:r},t.categoryRows?.get(n)),g=e.config.areaStyle?.(y)??{};o.push(Io(m,d,x,f,{fill:p,...h,...g},y,n)),i+=r}}else{let i=a.y(0),r=a.y(t.total),n=Math.min(i,r),l=Math.abs(i-r),u=s?.fill||c||"#007bff",d=we({binStart:t.start,binEnd:t.end,total:t.total},t.rows),f=e.config.areaStyle?.(d)??{};o.push(Io(m,n,x,l,{fill:u,...h,...f},d))}}let f=new Set;for(let e of i.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(e,t),canvasRenderers:[Ry]},Iy={chartType:"swarm",buildScene:(e,t)=>function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,a=r.fill??e.config.themeSemantic?.primary??"#007bff",n=r.opacity??.7,l=r.stroke,s=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),f=a;if(e.getCategory){let t=e.getCategory(r)+"";f=(e.config.barColors?X(e.config.barColors,t):void 0)??f}let{r:p,...y}=e.config.pointStyle?.(r)??{},g={type:"point",x:d,y:h,r:p??o,style:{fill:f,opacity:n,stroke:l,strokeWidth:s,cursor:c,...y},datum:r};e.getPointId&&(g.pointId=e.getPointId(r)+""),i.push(g)}return i}(e,t),canvasRenderers:[my]},Dy=(e,t,i,r)=>{Ry(e,t);let o=t.filter(e=>"rect"===e.type);if(2>o.length)return;let a=o[0].datum,n=a?._connectorStroke;if(n){e.save(),e.strokeStyle=tu(e,n)||n,e.lineWidth=a?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){let r=o[t],a=o[t+1],n=r.datum,l=a.datum;if(null==n?.cumEnd||null==l?.baseline)continue;let s=i.y(n.cumEnd),c=r.x+r.w,u=a.x;e.beginPath(),e.moveTo(c,s),e.lineTo(u,s),e.stroke()}e.restore()}},zy={chartType:"waterfall",buildScene:(e,t,i)=>function(e,t,i){let r=[],o=e.scales,a=e.config.waterfallStyle,n=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===n.length)return r;let l=a?.positiveColor??e.config.themeSemantic?.success??"#28a745",s=a?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=a?.gap??1,u=a?.stroke,d=a?.strokeWidth,h=a?.opacity,f=0;for(let t=0;n.length>t;t++){let p=n[t],y=e.getX(p),g=e.getY(p),m=f+g,x=o.x(y),b=t>0?o.x(e.getX(n[t-1])):void 0,v=n.length-1>t?o.x(e.getX(n[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(0>=S){f=m;continue}let M=o.y(f),_=o.y(m),P=Math.min(M,_),L=Math.abs(M-_),$=0>g?s:l,T={...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:a?.connectorStroke,_connectorWidth:a?.connectorWidth},R={fill:$,stroke:u,strokeWidth:d,opacity:h,cursor:a?.cursor,...e.config.areaStyle?.(T)};r.push(Io(A,P,S,L,R,T)),f=m}return r}(e,t,i),canvasRenderers:[Dy]},Oy=(e,t,i,r)=>{for(let i of t){if("candlestick"!==i.type)continue;let t=i;e.save();let o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);let a=tu(e,t.wickColor)||t.wickColor,n=60>r.height,l=n?Math.max(t.wickWidth,2):t.wickWidth,s=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=a,e.lineWidth=l,e.stroke()};if(n||s(),t.isRange){let i=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*r.height)),o=Ir(e,ai(t.style?.fill)?t.style.fill:t.wickColor,t.wickColor);e.fillStyle=o,e.beginPath(),e.arc(t.x,t.highY,i,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,i,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){let i=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,a=Ir(e,ai(t.style?.fill)?t.style.fill:o,o),n="string"==typeof a?a:tu(e,t.wickColor)||t.wickColor;e.fillStyle=a,e.fillRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.strokeStyle=n,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1))}n&&s(),e.restore()}},Fy={chartType:"candlestick",buildScene:(e,t,i)=>function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],a=e.config.candlestickStyle||{},n=a.rangeColor||"#6366f1",l=r?n:a.upColor||"#28a745",s=r?n:a.downColor||"#dc3545",c=r?n:a.wickColor||"#333",u=a.wickWidth||(r?2:1),d=a.bodyWidth??0;if(null==a.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;i.length>o;o++){let a=e.scales.x(i[o]),n=Math.abs(a-r);n>0&&t>n&&(t=n),r=a}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let n of t){let t=e.getX(n);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(n),f=e.getLow(n);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;let p=r?h:e.getOpen(n),y=r?f:e.getClose(n);if(!r&&(null==p||Number.isNaN(p)||null==y||Number.isNaN(y)))continue;let g=y>=p,m=e.config.pointStyle?.(n)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(y),highY:e.scales.y(h),lowY:e.scales.y(f),bodyWidth:d,upColor:x&&g?x:l,downColor:x&&!g?x:s,wickColor:b??(r&&x?x:c),wickWidth:v??u,isUp:g,style:{cursor:a.cursor,...m,...void 0!==w&&{opacity:w}},datum:n};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o}(e,t,i),canvasRenderers:[Oy]},Ny={chartType:"custom",buildScene:()=>[],canvasRenderers:[py,Ry,$y,gy,my,Ay,(e,t)=>{let i=e.globalAlpha;for(let r of t)"glyph"===r.type&&Ma(e,r,r.x,r.y,i);e.globalAlpha=i},Oy,my,Dy]};import*as Ey from"react";import{area as Wy,line as jy}from"d3-shape";import*as By from"react";import{jsx as Yy,jsxs as Xy}from"react/jsx-runtime";var Gy={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};import*as Vy from"react";import{jsx as Hy}from"react/jsx-runtime";import{jsx as qy,jsxs as Uy}from"react/jsx-runtime";var Zy=new Set;import{scaleOrdinal as Ky}from"d3-scale";import{jsx as Qy,jsxs as Jy}from"react/jsx-runtime";import{jsx as eg,jsxs as tg}from"react/jsx-runtime";var ig="var(--semiotic-bg, #ffffff)";import{jsx as rg}from"react/jsx-runtime";import{jsx as og,jsxs as ag}from"react/jsx-runtime";import{jsx as ng,jsxs as lg}from"react/jsx-runtime";import{jsx as sg}from"react/jsx-runtime";var cg={secondary:0,primary:3},ug=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);import{jsx as dg}from"react/jsx-runtime";var hg={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};import{packEnclose as fg}from"d3-hierarchy";import{area as pg,curveBasis as yg,curveCardinal as gg,curveCatmullRom as mg,curveLinear as xg,curveMonotoneX as bg,curveMonotoneY as vg,curveStep as wg,curveStepAfter as kg,curveStepBefore as Ag}from"d3-shape";import*as Sg from"react";import{jsx as Mg,jsxs as _g}from"react/jsx-runtime";var Pg={linear:xg,monotoneX:bg,monotoneY:vg,step:wg,stepAfter:kg,stepBefore:Ag,basis:yg,cardinal:gg,catmullRom:mg};import{jsx as Lg,jsxs as $g}from"react/jsx-runtime";var Tg=16;import{jsx as Rg}from"react/jsx-runtime";import*as Cg from"react";import{jsx as Ig}from"react/jsx-runtime";var Dg=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];import{jsx as zg,jsxs as Og}from"react/jsx-runtime";var Fg={right:110,left:110,top:50,bottom:80};import{jsx as Ng,jsxs as Eg}from"react/jsx-runtime";var Wg={top:50,right:40,bottom:60,left:70},jg={top:20,right:80,bottom:20,left:80},Bg={top:40,right:40,bottom:40,left:40},Yg=new Set(["chord","force","circlepack","orbit"]);import{jsx as Xg,jsxs as Gg}from"react/jsx-runtime";import{Fragment as Vg,jsx as Hg,jsxs as qg}from"react/jsx-runtime";_a();import*as Ug from"react-dom/server";import{jsx as Zg,jsxs as Kg}from"react/jsx-runtime";import{jsx as Qg,jsxs as Jg}from"react/jsx-runtime";import{jsx as em,jsxs as tm}from"react/jsx-runtime";var im={top:4,bottom:4,left:4,right:4},rm={frameType:"xy",buildProps:nl,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:a,rest:n}=ll(e),[l,s]=a.size??[600,400],c=n.minimap&&"object"==typeof n.minimap?n.minimap:{},u=sl(c.height,60),d=a.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},f={top:sl(h.top,0),right:sl(h.right,sl(d?.right,20)),bottom:sl(h.bottom,20),left:sl(h.left,sl(d?.left,40))},p=u+f.top+f.bottom,y=n.frameProps&&"object"==typeof n.frameProps?n.frameProps:{},g={...n,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y"},m={...a,size:[l,s],xExtent:y.xExtent??n.brushExtent??a.xExtent,yExtent:y.yExtent??n.yExtent??a.yExtent,_idPrefix:(a._idPrefix??"minimap")+"-detail"},x=ph.buildProps(i,r,o,m,g);Object.assign(x,y);let b={...a,size:[l,p],margin:f,title:void 0,description:(a.description??a.title??"Chart")+" overview minimap",showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:n.yExtent??a.yExtent,_idPrefix:(a._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;let v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=ph.buildProps(i,r,o,b,v);w.chartType=n.fillArea?"area":"line","function"==typeof c.lineStyle&&(w.lineStyle=c.lineStyle);let k={},A={},S=Un(x,k),M=Un(w,A),_=!0===n.renderBefore,P=_?0:s,L=""+ul(S,0,_?p:0,"detail")+ul(M,0,P,"overview"),$=s+p,T=se(le(a.theme)),R="string"==typeof a.title?a.title:void 0,C="string"==typeof a.description?a.description:R||"Chart with overview minimap",I=jn(a),D=R?I+"-title":void 0,z=I+"-description",O="y"===c.brushDirection?"y":"x",F=Array.isArray(n.brushExtent)&&n.brushExtent.length>=2?[Number(n.brushExtent[0]),Number(n.brushExtent[1])]:null,N=A.evidence,E=null;if(F&&F.every(Number.isFinite)&&N){let e="x"===O?N.xDomain:N.yDomain;if(e&&e[0]!==e[1]){let t=Math.max(0,l-f.left-f.right),i=u,r=t=>(t-e[0])/(e[1]-e[0]);if("x"===O){let e=r(Math.min(...F))*t,o=r(Math.max(...F))*t;E=em("rect",{className:"selection",x:f.left+e,y:P+f.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{let e=(1-r(Math.max(...F)))*i,o=(1-r(Math.min(...F)))*i;E=em("rect",{className:"selection",x:f.left,y:P+f.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}let W=zp.renderToStaticMarkup(tm("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:l,height:$,role:"img","aria-labelledby":[D,z].filter(Boolean).join(" "),style:{fontFamily:T.fontFamily},children:[R&&em("title",{id:D,children:R}),em("desc",{id:z,children:C}),em("g",{dangerouslySetInnerHTML:{__html:L}}),E]}));if(t){let e=[k.evidence,A.evidence];t.evidence=Pa({frameType:"xy",width:l,height:$,parts:e,title:R,description:C,xDomain:dl(e,"xDomain"),yDomain:dl(e,"yDomain")})}return W}},om={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,r,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...r,showAxes:!1,margin:r.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:ch,LineChart:ph,AreaChart:gh,DifferenceChart:mh,StackedAreaChart:xh,Scatterplot:Jd,CandlestickChart:bh,BubbleChart:eh,ConnectedScatterplot:wh,QuadrantChart:vh,Heatmap:kh,WaterfallChart:fh,MultiAxisLineChart:hh,MinimapChart:rm,ScatterplotMatrix:{frameType:"xy",buildProps:nl,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:a,rest:n}=ll(e),l=Array.isArray(I=i)?I.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],s=Array.isArray(n.fields)?n.fields.filter(e=>"string"==typeof e):[],c=n.fieldLabels&&"object"==typeof n.fieldLabels?n.fieldLabels:{},u=cl(n.cellSize,150),d=Math.max(0,sl(n.cellGap,4)),h=Math.max(0,sl(n.pointRadius,2)),f=Math.max(0,Math.min(1,sl(n.pointOpacity,.5))),p=cl(n.histogramBins,20),y="string"==typeof n.diagonal?n.diagonal:"histogram",g=40+s.length*u+s.length*d,m=s.length*u+40+s.length*d,x=le(a.theme),b=se(x),v=function(e,t,i,r){if(!t)return{categories:[],color:()=>Yd};let o=Array.from(new Set(e.map(e=>hl(e,t)))),a="string"==typeof t?t:"__semioticSplomColor",n=G("function"==typeof t?e.map(e=>({...e,[a]:hl(e,t)})):e,a,i??r.colors.categorical);return{categories:o,color:e=>Y(e,t,n)}}(l,r,o,x),w="string"==typeof a.title?a.title:void 0,k="string"==typeof a.description?a.description:`Scatterplot matrix comparing ${s.length} fields`,A=w?28:0,S=n.showLegend??!!r?v.categories:[],M=0,_=0,P=S.map(e=>{let t=(e=>Math.max(72,30+7*e.length))(e);M>0&&M+t>g&&(_+=1,M=0);let i={label:e,x:M,y:24*_};return M+=t,i}),L=A+(S.length?24*(_+1)+4:0),$=L+m,T=[],R=[],C=0;var I;s.forEach((e,t)=>{s.forEach((i,o)=>{let s=40+d+o*(u+d),g=L+t*(u+d);if(t===o){let t=function(e){let{data:t,field:i,label:r,cellSize:o,bins:a,diagonal:n,colorBy:l,color:s,x:c,y:u}=e;if("label"===n)return{visibleBars:0,svg:zp.renderToStaticMarkup(em("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:em("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/a||1,p=Array.from({length:a},()=>new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(a-1,Math.floor((t-h)/f))),o=l?hl(e,l):"__all",n=p[r];n.set(o,[...n.get(o)??[],e])}let y=p.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),g=Math.max(1,...y),m=0,x=p.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];m+=1;let n=r.length/g*(o-24),c=i;return i+=n,em("rect",{x:t/a*o,y:o-c-n,width:Math.max(o/a-1,1),height:n,fill:l?s(r[0]):Yd,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:zp.renderToStaticMarkup(tm("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:[em("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),x]}))}}({data:l,field:e,label:X(c,e)??e,cellSize:u,bins:p,diagonal:y,colorBy:r,color:v.color,x:s,y:g});return C+=t.visibleBars,void R.push(t.svg)}let m={},x=Un({chartType:"scatter",data:l,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:cu(e=>({r:h,opacity:f,fill:v.color(e)}),n.styleRules,hu(i,e)),margin:im,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${X(c,i)??i} versus ${X(c,e)??e} scatterplot`,theme:a.theme,_idPrefix:`${(a._idPrefix??"splom")+""}-${t}-${o}`},m);T.push(m.evidence),R.push(ul(x,s,g,`cell-${e}-${i}`))})});let D=jn(a),z=w?D+"-title":void 0,O=D+"-description",F=zp.renderToStaticMarkup(tm("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:g,height:$,role:"img","aria-labelledby":[z,O].filter(Boolean).join(" "),style:{fontFamily:b.fontFamily},children:[w&&em("title",{id:z,children:w}),em("desc",{id:O,children:k}),em("rect",{width:g,height:$,fill:b.background}),w&&em("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:b.text,children:w}),P.map(e=>{let t=l.find(t=>r&&hl(t,r)===e.label),i=t?v.color(t):Yd;return tm("g",{transform:`translate(${e.x},${A+e.y})`,children:[em("circle",{cx:5,cy:8,r:5,fill:i}),em("text",{x:14,y:12,fontSize:11,fill:b.text,children:e.label})]},e.label)}),s.map((e,t)=>{let i=L+t*(u+d)+u/2;return em("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:X(c,e)??e},"row-"+e)}),s.map((e,t)=>em("text",{x:40+d+t*(u+d)+u/2,y:L+s.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:X(c,e)??e},"column-"+e)),em("g",{dangerouslySetInnerHTML:{__html:R.join("")}})]}));return t&&(t.evidence=Pa({frameType:"xy",width:g,height:$,parts:T,additionalMarkCountByType:C>0?{histogram:C}:void 0,title:w,description:k,categories:v.categories.length?v.categories:void 0,legendItems:S.length||void 0})),F}},TemporalHistogram:yh,XYCustomChart:Cf,BarChart:Oh,StackedBarChart:Fh,GroupedBarChart:Nh,PieChart:Eh,DonutChart:Wh,Histogram:jh,BoxPlot:Bh,ViolinPlot:Yh,SwarmPlot:Xh,DotPlot:Gh,SwimlaneChart:Hh,RidgelinePlot:qh,LikertChart:$h,FunnelChart:Uh,RadarChart:Vh,GaugeChart:zh,OrdinalCustomChart:If,ParallelCoordinatesRecipe:Df,CalendarHeatmapRecipe:zf,ForceDirectedGraph:bf,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,r,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},SankeyDiagram:Af,ProcessSankey:kf,ChordDiagram:xf,TreeDiagram:Sf,Treemap:Mf,CirclePack:vf,OrbitDiagram:wf,ChoroplethMap:Lf,ProportionalSymbolMap:$f,FlowMap:Rf,DistanceCartogram:Tf,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,r,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},GaltonBoardChart:_p,EventDropChart:Pp,UnitPileChart:Lp,CollisionSwarmChart:$p,ProcessFlowChart:Tp,GauntletChart:Rp,CrucibleChart:Cp,PacketFlowChart:Ip,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:nl,renderStatic:function(e,t){let{data:i,common:r,rest:o}=function(e){return e.__composite}(e),a=Array.isArray(y=i)?y.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],[n,l]=r.size??[920,620],s="string"==typeof r.title?r.title:"Dependency chain reaction",c=function(e){let t=[],i=new Map,r=[],o=new Set;e.data.forEach((a,n)=>{let l=(el(a,n,e.taskIDAccessor)??"")+"";if(!l)return void t.push({code:"duplicate-task-id",message:`Task row ${n} has an empty id.`,taskIDs:[]});if(i.has(l))return void t.push({code:"duplicate-task-id",message:`Task id "${l}" occurs more than once.`,taskIDs:[l]});let s=(el(a,n,e.laneAccessor)??"Unassigned")+"";o.has(s)||(o.add(s),r.push(s));let c=el(a,n,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>e+""))).sort(tl),d=el(a,n,e.blockerAccessor),h=el(a,n,e.statusAccessor)??(d?"blocked":"waiting");i.set(l,{id:l,label:(el(a,n,e.labelAccessor)??l)+"",lane:s,laneIndex:0,level:0,index:n,datum:a,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:el(a,n,e.startAccessor),end:el(a,n,e.endAccessor),progress:ol(el(a,n,e.progressAccessor)),status:h,completionTime:el(a,n,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!el(a,n,e.milestoneAccessor)})});let a=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,n=new Map(a.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=n.get(e.lane)??0;let l=new Map,s=new Map;for(let e of i.keys())l.set(e,[]),s.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let a=i.get(r);if(!a)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let n={id:il(r,e.id),sourceID:r,targetID:e.id,sourceIndex:a.index,targetIndex:e.index,socketID:rl(e.id,o),socketIndex:o};c.push(n),l.get(e.id)?.push(n),s.get(r)?.push(n),e.incomingEdgeIDs.push(n.id),e.socketIDs.push(n.socketID),a.outgoingEdgeIDs.push(n.id)});for(let e of l.values())e.sort((e,t)=>tl(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=rl(e.targetID,t)});for(let e of s.values())e.sort((e,t)=>tl(e.targetID,t.targetID));for(let e of i.values()){let t=l.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(s.get(e.id)??[]).map(e=>e.id)}let d=new Map,h=new Map;for(let e of i.keys())d.set(e,l.get(e)?.length??0),h.set(e,0);let f=[...i.keys()].filter(e=>0===d.get(e)).sort(tl),p=0;for(;f.length;){let e=f.shift();p+=1;for(let t of s.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=f.findIndex(e=>e>t.targetID);0>e?f.push(t.targetID):f.splice(e,0,t.targetID)}}}if(p!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(tl);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let y=0,g=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of g)e.level=h.get(e.id)??0,y=Math.max(y,e.level);return{nodes:g,edges:c,byID:i,incoming:l,outgoing:s,lanes:a,maxLevel:y,diagnostics:t,valid:0===t.length}}({data:a,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=le(r.theme),d=se(u),h=jn(r),f=h+"-title",p=h+"-description";var y;if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=Ug.renderToStaticMarkup(Jg("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:n,height:l,role:"img","aria-labelledby":`${f} ${p}`,style:{fontFamily:d.fontFamily},children:[Qg("title",{id:f,children:s}),Qg("desc",{id:p,children:e}),Qg("rect",{width:n,height:l,fill:d.background}),Qg("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:s}),c.diagnostics.map((e,t)=>Qg("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=Pa({frameType:"physics",width:n,height:l,parts:[],title:s,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=function(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),a=t.paddingX??48,n=t.paddingTop??48,l=t.paddingBottom??44,s=Math.max(70,(r-2*a)/Math.max(1,e.lanes.length)),c=Math.max(76,(o-n-l)/Math.max(1,e.maxLevel+1)),u=Math.min(i.taskWidth??112,Math.max(58,.78*s)),d=Math.min(i.taskHeight??58,.64*c),h=i.socketRadius??5,f=Math.max(1,Math.round(i.gutterCount??3)),p=new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=p.get(e)??[];i.push(t),p.set(e,i)}for(let e of p.values())e.sort((e,t)=>tl(e.id,t.id));let y=.86*c,g=e.nodes.map(e=>{let t=p.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=(o=t.length)>1?Math.max(22,Math.min(d,(y-4*(o-1))/o)):d;var o;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:a+s*(e.laneIndex+.5),y:n+c*(e.level+.5)+i*(r+4),width:u,height:r}}),m=new Map(g.map(e=>[e.taskID,e])),x=[],b=[];e.edges.forEach((t,i)=>{let r=m.get(t.sourceID),o=m.get(t.targetID);if(!r||!o)return;let a=e.incoming.get(t.targetID)??[],n=Math.min(.72*o.width,14*Math.max(1,a.length-1)),l=a.length>1?o.x-n/2+n*t.socketIndex/(a.length-1):o.x,s=o.y-o.height/2-h-2;x.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:l,y:s,radius:h});let c={x:r.x,y:r.y+r.height/2+3},u=Math.min(s-10,c.y+.48*Math.max(18,s-c.y)+7*(i%f-(f-1)/2));var d;b.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(d=[c,{x:c.x,y:u},{x:l,y:u},{x:l,y:s}],d.filter((e,t)=>{let i=d[t-1];return!i||i.x!==e.x||i.y!==e.y}))})});let v=new Map(x.map(e=>[e.id,e])),w=new Map(b.map(e=>[e.edgeID,e]));return{tasks:g,sockets:x,routes:b,taskByID:m,socketByID:v,routeByEdgeID:w}}(c,{width:n,height:l}),m=function(e,t,i){let r=e.nodes.map(Qn).filter(e=>null!=e),o=i,a=new Set,n=new Map;for(let t of e.nodes){let e=Qn(t);(null!=e&&o>=e||"done"===t.status&&!0)&&a.add(t.id),t.blockerReason&&!a.has(t.id)&&n.set(t.id,t.blockerReason)}let l=new Set;for(let t of e.edges)a.has(t.sourceID)&&l.add(t.id);return{currentTime:o,playing:!1,completed:a,delivered:l,inFlight:new Set,armed:Jn(e,l,n,a),blockers:n,previewTaskID:null}}(c,0,Kn(o.currentTime,1/0)),x=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],b=new Set(x),v=x[0]??null,w=v&&"none"!==o.insight?al(c,v,{completedTaskIDs:m.completed}):null,k=new Set(w?.downstreamTaskIDs??[]),A=function(e){return"number"==typeof e&&Number.isFinite(e)?e:31}(o.seed),S=function(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=al(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:r+" No explicit blockers are active."}(c,m,r.description),M=Ug.renderToStaticMarkup(Qg(Zn,{machine:c,layout:g,runtime:m,downstreamSet:k,selectedSet:b,width:n,height:l,seed:A,reduced:!0,onSelectTask:()=>{}})),_=void 0===r.theme?{}:su(u),P=Ug.renderToStaticMarkup(Jg("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:n,height:l,role:"img","aria-labelledby":`${f} ${p}`,style:{..._,fontFamily:d.fontFamily},children:[Qg("title",{id:f,children:s}),Qg("desc",{id:p,children:S}),Qg("rect",{width:n,height:l,fill:d.background}),Qg("text",{x:n/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:s}),Qg("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=Pa({frameType:"physics",width:n,height:l,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:s,description:S,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),P}},PhysicsCustomChart:Dp};import*as am from"react";import{jsx as nm}from"react/jsx-runtime";var lm=new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);import*as sm from"react-dom/server";import{scaleBand as cm,scaleLinear as um}from"d3-scale";var dm=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:X(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Xd,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};import{quantileSorted as hm}from"d3-array";import{scaleLinear as fm}from"d3-scale";var pm={bar:function(e,t){let{scales:i,columns:r,config:o,getR:a,getStack:n,resolvePieceStyle:l}=e,{r:s,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,f=o.normalize,p=[];if(n){let e=new Set;for(let t of Object.values(r))for(let i of t.pieceData){let t=n(i);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(let e of Object.values(r)){let t=new Map;for(let i of e.pieceData){let e=n?n(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let r=t.get(e);r.total+=a(i),r.pieces.push(i)}let i=0;if(f)for(let e of t.values())i+=Math.abs(e.total);let r=0,o=0;for(let a of p){let c=t.get(a);if(!c)continue;let p=c.total;f&&i>0&&(p/=i);let y=l(c.pieces[0],n?a:e.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(d){let t=s(0>p?o:r+p),i=0>p?s(o+p)-s(o):s(r)-s(r+p);u.push(Io(e.x,t,e.width,Math.abs(i),y,g,a)),0>p?o+=p:r+=p}else if(h){let t=s(0>p?o+p:r),i=0>p?s(o)-s(o+p):s(r+p)-s(r);u.push(Io(t,e.x,Math.abs(i),e.width,y,g,a)),0>p?o+=p:r+=p}}}let y="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){let t=e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=pl(o.roundedTop,t,y);i>0&&(t.roundedTop=i)}if(i.length>0){let e=i.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=pl(o.roundedTop,e,y);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:a,getGroup:n,resolvePieceStyle:l}=e,{r:s,projection:c}=i,u=[],d="vertical"===c,h=[],f=new Set;for(let e of Object.values(r))for(let t of e.pieceData){let e=n?n(t):"_default";f.has(e)||(f.add(e),h.push(e))}let p=h.length||1;for(let e of Object.values(r)){let t=e.width/p,i=.2*t,r=t-i,o=new Map;for(let t of e.pieceData){let e=n?n(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let n=0;h.length>n;n++){let c=o.get(h[n])||[];for(let o of c){let c=a(o),f=l(o,h[n]);if(d){let a=e.x+n*t+i/2,l=s(0),d=s(c);u.push(Io(a,Math.min(l,d),r,Math.abs(l-d),f,o,h[n]))}else{let a=e.x+n*t+i/2,l=s(0),d=s(c);u.push(Io(Math.min(l,d),a,Math.abs(d-l),r,f,o,h[n]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=a(e.datum),i=pl(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:a,resolvePieceStyle:n}=e,{r:l,projection:s}=i,c=[],u="vertical"===s,d="radial"===s,h=a.length>0,f=yl(e),p=2*Math.PI,y=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,s=t.__rIndex??0,g=t.__rValue??o(t),m=h&&a[s]||l,x=n(t,e.name),b=x.r||5;if(d){let t=y+(e.pctStart+e.pct/2)*p,o=m(g);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=m(g)):(i=m(g),r=e.middle);gl(c,f,t,i,r,b,x)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:a}=e,{r:n,projection:l}=i,s=[],c="vertical"===l,u=yl(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;e.pieceData.length>i;i++){let r=e.pieceData[i],l=o(r),d=a(r,e.name),h=d.r||4,f=(7919*i%100/100-.5)*t*.8;gl(s,u,r,c?e.middle+f:n(l),c?n(l):e.middle+f,h,d)}}return s},pie:ml,donut:ml,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:l,projection:s}=i,c=[],u="vertical"===s,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=bl(i),{min:o,max:s,q1:h,median:f,q3:p}=r,y=p-h,g=h-1.5*y,m=p+1.5*y,x=i.find(e=>e>=g)??o,b=s;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){b=i[e];break}r.min=x,r.max=b;let v=n(xl(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=a(e);if(g>i||i>m){let r=u?t.middle:l(i),o=u?l(i):t.middle;w.push({px:r,py:o,value:i,datum:e})}}if(c.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:l(x),q1Pos:l(h),medianPos:l(f),q3Pos:l(p),maxPos:l(b),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:l,projection:s}=i,c=[],u="vertical"===s,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],s=(o-r)/d||1,f=vl(t,r,o,s,d),p=od(f,1),y=e.width/2*.9;if(u){i=`M ${e.middle} ${l(r)}`;for(let t=0;d>t;t++){let o=l(r+(t+.5)*s);i+=` L ${e.middle+f[t]/p*y} ${o}`}i+=` L ${e.middle} ${l(o)}`;for(let t=d-1;t>=0;t--){let o=l(r+(t+.5)*s);i+=` L ${e.middle-f[t]/p*y} ${o}`}i+=" Z"}else{i=`M ${l(r)} ${e.middle}`;for(let t=0;d>t;t++)i+=` L ${l(r+(t+.5)*s)} ${e.middle-f[t]/p*y}`;i+=` L ${l(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)i+=` L ${l(r+(t+.5)*s)} ${e.middle+f[t]/p*y}`;i+=" Z"}let g,m=bl(t),x=n(xl(e.pieceData,e.name,m),e.name);h&&t.length>=4&&(g={q1Pos:l(m.q1),medianPos:l(m.median),q3Pos:l(m.q3),centerPos:e.middle,isVertical:u});let b=u?{x:e.x,y:Math.min(l(o),l(r)),width:e.width,height:Math.abs(l(o)-l(r))}:{x:Math.min(l(r),l(o)),y:e.x,width:Math.abs(l(o)-l(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,iqrLine:g,stats:m,style:x,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:l}=i,s=[],c=o.bins||25,u=o.normalize,d=l.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=nd(t),o=null!=h&&isFinite(h)?h:i,d=null!=f&&isFinite(f)?f:r,p=(d-o)/c||1,y=vl(t,o,d,p,c),g=t.length,m=od(y,1);for(let t=0;c>t;t++){if(0===y[t])continue;let i=(u?y[t]/g:y[t]/m)*e.width*.9,r=l(o+t*p),a=l(o+(t+1)*p),c=Math.min(r,a),d=Math.abs(a-r),h=e.x+e.width-i,f={...e.pieceData[0],bin:t,count:y[t],range:[o+t*p,o+(t+1)*p],category:e.name,data:e.pieceData},x=n(f,e.name);s.push(Io(c,h,d,i,x,f,e.name))}}return s},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:l,projection:s}=i,c=[],u=o.bins||20,d="horizontal"===s,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],s=(o-r)/u||1,f=vl(t,r,o,s,u),p=od(f,1),y=bl(t),g=n(xl(e.pieceData,e.name,y),e.name),m=e.width*h;if(d){let t=e.x+e.width;i=`M ${l(r)} ${t}`;for(let e=0;u>e;e++)i+=` L ${l(r+(e+.5)*s)} ${t-f[e]/p*m}`;i+=` L ${l(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${l(r)}`;for(let e=0;u>e;e++){let o=l(r+(e+.5)*s);i+=` L ${t+f[e]/p*m} ${o}`}i+=` L ${t} ${l(o)} Z`}let x=d?{x:Math.min(l(r),l(o)),y:e.x,width:Math.abs(l(o)-l(r)),height:e.width}:{x:e.x,y:Math.min(l(o),l(r)),width:e.width,height:Math.abs(l(o)-l(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,stats:y,style:{...g,fillOpacity:g.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:a}=e,{r:n,projection:l}=i,s=[],c="horizontal"===l;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,l]=i,u=a(t,e.name);if(c){let i=n(Math.min(r,l)),o=n(Math.max(r,l));s.push(Io(i,e.x,o-i,e.width,u,t,e.name))}else{let i=n(Math.max(r,l)),o=n(Math.min(r,l));s.push(Io(e.x,i,e.width,o-i,u,t,e.name))}}return s},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:a}=e,n=[],l=t.width/2,s=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return n;let u=[],d=new Set;for(let e of c)for(let t of e.pieceData){let e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}let h=u.length>1&&"_default"!==u[0],f=[],p=0;for(let e of c){let t=new Map,i=0;for(let a of e.pieceData){let e=o?o(a):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let n=t.get(e),l=r(a);n.total+=l,n.pieces.push(a),i+=l}f.push({col:e,groups:t,stepTotal:i}),h||i>p&&(p=i)}if(h)for(let e of f){let t=0,i=0;for(let r=0;u.length>r;r++){let o=e.groups.get(u[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>p&&(p=r)}if(0===p)return n;let y=new Map;for(let e of u){let t=f[0].groups.get(e);y.set(e,t?.total??0)}let g=f[0].stepTotal,m=h?.95*l:.9*t.width,x=fm().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3,v=new Map;for(let t=0;f.length>t;t++){let i=f[t],r=i.col,o=0===t,c=r.width,d=.55*c,p=r.x+(c-d)/2,m=new Map;if(h){let e=0;for(let t of u){let r=i.groups.get(t);r&&(e+=x(r.total))}let t=l,c=l;for(let h=0;u.length>h;h++){let f=u[h],g=i.groups.get(f);if(!g)continue;let b=x(g.total),v=h%2==0,w=v?t:c-b;v?t+=b:c-=b;let k=a(g.pieces[0],f),A=y.get(f)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};s&&(0===h&&(S.__funnelStepLabel=r.name,S.__funnelStepLabelX=l,S.__funnelStepLabelY=p,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=p,S.__funnelBarW=b),n.push(Io(w,p,b,d,k,S,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{let e=i.stepTotal,t=x(e),c=l-t/2,h=u[0],f="_default"!==h,y=i.groups.get(h)?.pieces[0]??r.pieceData[0],b=f?h:r.name,v=a(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:f?h:r.name};s&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=l,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=l,k.__funnelValueLabelY=p,k.__funnelBarW=t),n.push(Io(c,p,t,d,v,k,b)),m.set(h,{x:c,y:p,w:t,h:d})}if(t>0&&v.size>0){let t=h?u:[u[0]];for(let o of t){let t=v.get(o),l=m.get(o);if(!t||!l)continue;let s=(()=>{let e=i.groups.get(o);return a(e?e.pieces[0]:r.pieceData[0],"_default"===o?r.name:o)})(),c={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[l.x+l.w,l.y],[l.x,l.y]],style:{fill:s.fill||e.config.themeSemantic?.secondary||"#999",opacity:b,cursor:s.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};n.push(c)}}v=m}return n},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:a,scales:n}=e,l=[],s=n.o.domain().map(e=>i[e]).filter(Boolean);if(0===s.length)return l;let c=[],u=new Set;for(let e of s)for(let t of e.pieceData){let e=o?o(t):"_default";u.has(e)||(u.add(e),c.push(e))}let d=c.length>1&&"_default"!==c[0],h=[];for(let e of s){let t=new Map,i=0;for(let a of e.pieceData){let e=o?o(a):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let n=t.get(e),l=r(a);n.total+=l,n.pieces.push(a),i+=l}h.push({col:e,groups:t,stepTotal:i})}let f=new Map;for(let e of c){let t=h[0]?.groups.get(e);f.set(e,t?.total??0)}let p=n.r,y=d?c.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){let t=h[e],i=t.col,r=0===e,o=e>0?h[e-1]:null,n=i.width/y,s=n*g,u=n-s;for(let e=0;c.length>e;e++){let h=c[e],y=t.groups.get(h);if(!y)continue;let g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=o?.groups.get(h)?.total??g,v=r?0:Math.max(0,b-g),w=i.x+e*n+s/2,k=p(g),A=p(0)-k,S=a(y.pieces[0],d?h:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(l.push(Io(w,k,u,A,S,M,d?h:i.name)),v>0){let e=p(g+v),t=k-e,r={...S},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};l.push(Io(w,e,u,t,r,o,d?h:i.name))}}}return l},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:a,resolvePieceStyle:n}=e,{r:l,projection:s}=i,c=[],u="horizontal"===s,d=e.config.gradientFill,h=u?"left":"bottom",f=new Map,p=t=>{let i=f.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return f.set(t,o),o},y=e.config.trackFill;if(y){let e="string"==typeof y?y:y.color,t="string"==typeof y?1:y.opacity??1,[i,o]=l.range(),a=Math.min(i,o),n=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?Io(a,i.x,n,i.width,r,null,"__track__"):Io(i.x,a,i.width,n,r,null,"__track__"),l=p(i);l>0&&(o.cornerRadii={tl:l,tr:l,br:l,bl:l}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=p(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let s,f=a?a(i):e.name,p=n(i,f);if(u){let o=l(t),a=l(t+r);s=Io(o,e.x,a-o,e.width,p,i,f)}else{let o=l(t+r),a=l(t);s=Io(e.x,o,e.width,a-o,p,i,f)}d&&(s.fillGradient=d,s.roundedEdge=h),c.push(s),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}},ym=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gm=["scene-style","data-paint","accessibility","evidence"],mm=(e,t)=>({retainedData:e,invalidations:t}),xm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],vm=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wm=["scene-geometry","data-paint","accessibility","evidence"],km=["scene-style","data-paint","accessibility","evidence"],Am=[],Sm={chartType:mm("rebuild",xm),runtimeMode:mm("rebuild",xm),categoryAccessor:mm("rebuild",xm),valueAccessor:mm("rebuild",xm),oAccessor:mm("rebuild",xm),rAccessor:mm("rebuild",xm),stackBy:mm("rebuild",xm),groupBy:mm("rebuild",xm),timeAccessor:mm("rebuild",xm),accessorRevision:mm("rebuild",xm),colorAccessor:mm("rebuild",km),symbolAccessor:mm("rebuild",wm),connectorAccessor:mm("rebuild",wm),dataIdAccessor:mm("rebuild",wm),projection:mm("preserve",bm),extentPadding:mm("preserve",bm),axisExtent:mm("preserve",bm),rExtent:mm("preserve",bm),oExtent:mm("preserve",bm),multiAxis:mm("preserve",bm),normalize:mm("preserve",bm),bins:mm("preserve",bm),oSort:mm("preserve",vm),barPadding:mm("preserve",vm),roundedTop:mm("preserve",vm),baselinePadding:mm("preserve",vm),innerRadius:mm("preserve",vm),cornerRadius:mm("preserve",vm),startAngle:mm("preserve",vm),sweepAngle:mm("preserve",vm),trackFill:mm("preserve",vm),showOutliers:mm("preserve",vm),showIQR:mm("preserve",vm),amplitude:mm("preserve",vm),connectorOpacity:mm("preserve",vm),showLabels:mm("preserve",vm),dynamicColumnWidth:mm("rebuild",vm),customLayout:mm("preserve",vm),layoutConfig:mm("preserve",vm),layoutMargin:mm("preserve",vm),symbolMap:mm("preserve",wm),pieceStyle:mm("preserve",km),summaryStyle:mm("preserve",km),connectorStyle:mm("preserve",km),gradientFill:mm("preserve",km),colorScheme:mm("preserve",km),themeCategorical:mm("preserve",km),themeSemantic:mm("preserve",km),themeSequential:mm("preserve",km),themeDiverging:mm("preserve",km),barColors:mm("preserve",km),decay:mm("preserve",km),pulse:mm("preserve",km),staleness:mm("preserve",km),layoutSelection:mm("preserve",km),windowSize:mm("preserve",Am),windowMode:mm("preserve",Am),clock:mm("preserve",Am),transition:mm("preserve",Am),introAnimation:mm("preserve",Am),onLayoutError:mm("preserve",Am)},Mm=mm("preserve",vm),_m=class{constructor(){this.tracker=new gu}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},ym)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},gm):this.recordNoop("restyle")}recordConfig(e){let t=function(e){let t="preserve",i=new Set;for(let r of e){let e=Sm[r]??Mm;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as Pm}from"d3-quadtree";var Lm=class{constructor(e){this.rExtent=new Ep,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new _m,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new dm,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 Np(e.windowSize),this.getO=Uc(e.categoryAccessor||e.oAccessor,"category");let t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Xc(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Ep)):(this.getR=Xc(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Uc(e.stackBy),this.getGroup=Uc(e.groupBy),this.getColor=Uc(e.colorAccessor),this.getSymbol=Uc(e.symbolAccessor),this.getConnector=Uc(e.connectorAccessor),this.getDataId=Uc(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Np(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Eo(t,r):null)}currentTime(){return this.config.clock?.()??uo()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),No(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Wo(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=Wo(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),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){let 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){let 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){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.multiScales,a=this.columns;if(0===i.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(i,this.getR);let n,l,s=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(s),d=this.computeValueDomain(s,u),h="horizontal"===c,f="radial"===c,p=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===c?e.width:e.height):.1));if(f){n=cm().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;l=um().domain(d).range([r,i])}else h?(n=cm().domain(u).range([0,e.height]).padding(p),l=um().domain(d).range([0,e.width])):(n=cm().domain(u).range([0,e.width]).padding(p),l=um().domain(d).range([e.height,0]));this.scales={o:n,r:l,projection:c},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,o)=>{let a=this.rExtents[o];a.dirty&&a.recalculate(i,r);let[n,l]=a.extent;n===1/0&&(n=0,l=1);let s=l-n,c=s>0?s*(t.extentPadding??.05):1;return n-=c,l+=c,n>0&&(n=0),h?um().domain([n,l]).range([0,e.width]):um().domain([n,l]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,u,n,c,e),this._customLayoutFailedThisBuild=!1;let g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,this.columns=a):(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){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=new Set;for(let t of e)o.add(this.getO(t))}let a=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return a}if(!1===r)return a;if("function"==typeof r)return a.sort(r);let n=new Map;for(let t of e){let e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return a.sort("asc"===r?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return function(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:a,extentPadding:n=.05,baselinePadding:l,axisExtent:s,getO:c,getR:u,getStack:d,rawRExtent:h}=e,f=n;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&d&&o)p=0,y=1;else if("bar"===i&&d){let e=new Map,i=new Map;for(let r of t){let t=c(r),o=u(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(let t of e.values())t>y&&(y=t);for(let e of i.values())p>e&&(p=e)}else if("bar"===i){let e=new Map;for(let i of t){let t=c(i),r=u(i);e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===i){let e=new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t)}else if("clusterbar"===i||"bar-funnel"===i)for(let e of t){let t=u(e);t>y&&(y=t),p>t&&(p=t)}else{let e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}a&&(null!=a[0]&&(p=a[0]),null!=a[1]&&(y=a[1]));let g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&(null!=a?.[0]||null!=a?.[1]||(p>0&&(p=0),0>y&&(y=0))),"bar-funnel"!==i&&"exact"!==s){let e=y-p,t=e>0?e*f:1,r=g&&!l&&0===p,o=g&&!l&&0===y||"swimlane"===i;null==a?.[0]&&!r&&(p-=t),null==a?.[1]&&!o&&(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,i,r,o){return function(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:a,dynamicColumnWidth:n,getO:l,getR:s}=e,c=Object.create(null),u=new Map;for(let e of t){let t=l(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(s(e));let h=null;if(n&&"radial"!==o){h=new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof n?r.reduce((e,t)=>e+(Number(t[n])||0),0):n(r),h.set(t,i),e+=i}let t=("horizontal"===o?a.height:a.width)-r.padding()*r.step()*i.length;if(e>0)for(let[i,r]of h)h.set(i,r/e*t)}let f=0,p=0;for(let e of i){let t,i,o=u.get(e)||[],a=o.reduce((e,t)=>e+Math.abs(s(t)),0),n=d>0?a/d:0;h?(t=p,i=h.get(e)||r.bandwidth(),p+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:n,pctStart:f},f+=n}return c}({data:e,oExtent:t,oScale:i,projection:r,layout:o,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.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){let i=this.buildLayoutContext(e,t),r=Ao({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let a=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of a)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(a,this.config.layoutSelection??null)}return vo({label:"ordinal customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=pm[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...fl(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=$i(i.colorScheme,i.themeCategorical,Xd),a=this.scales;return{data:e,scales:{o:a.o,r:a.r,projection:a.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:"radial"===a.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:i.themeSemantic??{},categorical:[...o]},resolveColor:Ti(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?ho(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=fo(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=function(e,t){let i="function"==typeof t,r=i?null:t||"category",o=new Map;for(let a=0;e.length>a;a++){let n=e[a],l=i?t(n):n[r],s=o.get(l);s?s.push(a):o.set(l,[a])}return o}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=function(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(500>=t)return{quadtree:null,maxRadius:i};let r=Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:Pm().x(e=>e.x).y(e=>e.y).addAll(r)}}(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;let i=t.length;if(1>=i)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,a){let n=e.color??"rgba(255,255,255,0.6)",l=e.glowRadius??4,s=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let n of o(t)??[]){let t=i.get(n);null!=t&&(r=Math.max(r,po(e,t,a)))}s=yo(c,r,n)||s;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);s=yo(c,null==u?0:po(e,u,a),n,l)||s}return s}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&go(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;this.scene.length>o;o++){let a=this.scene[o],n=this.getNodeKey(a,t);n&&("rect"===a.type?this.prevPositionMap.set(n,r?{x:a.x,y:i,w:a.w,h:0,opacity:a.style.opacity??1}:{x:i,y:a.y,w:0,h:a.h,opacity:a.style.opacity??1}):"point"===a.type?this.prevPositionMap.set(n,{x:a.x,y:a.y,r:0,opacity:0}):"wedge"===a.type&&(void 0===e&&(e=a.startAngle),this.prevPositionMap.set(n,{x:a.cx,y:a.cy,startAngle:e,endAngle:e,innerRadius:a.innerRadius,outerRadius:a.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();let e=new Map;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=new Set,r=new Map;for(let e=0;this.scene.length>e;e++){let o=this.scene[e],a=this.getNodeKey(o,r);if(!a)continue;o._transitionKey=a;let n=this.prevPositionMap.get(a);if("point"===o.type)n?(i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.x!==o.x||n.y!==o.y||void 0!==n.r&&n.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=n.x,o.y=n.y,void 0!==n.r&&(o.r=n.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)n?(i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.x!==o.x||n.y!==o.y||n.w!==o.w||n.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=n.x,o.y=n.y,o.w=n.w??o.w,o.h=n.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(n)i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.startAngle!==o.startAngle||n.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=n.startAngle,o.endAngle=n.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(a,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;let t=so(e,this.activeTransition),i=lo(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=co(r?r.opacity??1:0,e._targetOpacity,i)}let r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=co(r.x,e._targetX,i),e.y=co(r.y,e._targetY,i)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=co(r.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=co(r?r.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;let r=this.prevPositionMap.get(t);if(!r)continue;e.x=co(r.x,e._targetX,i),e.y=co(r.y,e._targetY,i),void 0!==r.w&&(e.w=co(r.w,e._targetW,i),e.h=co(r.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style={...e.style,opacity:co(r?r.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=co(r.startAngle,e._targetStartAngle,i),e.endAngle=co(r.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(let 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){let 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,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?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):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(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):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=no(e),i=this.getDataId,r=e=>t.has(i(e));jo(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");let i=no(e),r=this.getDataId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let a=this.buffer.update(e=>i.has(r(e)),t);if(0===a.length)return this.updateResults.recordNoop("update"),a;for(let e of a)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",a.length),a}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.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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&&!Tc(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Tc(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Tc(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Tc(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Uc(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],a=Array.isArray(i)?i:[i];if(o=r.length!==a.length||r.some((e,t)=>!Tc(e,a[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Xc(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Ep)):(this.getR=Xc(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Tc(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Uc(this.config.stackBy):void 0),"groupBy"in e&&!Tc(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Uc(this.config.groupBy):void 0),"colorAccessor"in e&&!Tc(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Uc(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Tc(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Uc(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Tc(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Uc(this.config.connectorAccessor):void 0),(r||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};qo(Lm);import*as $m from"react";import*as Tm from"react";import{arc as Rm}from"d3-shape";var Cm=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});import{jsx as Im,jsxs as Dm}from"react/jsx-runtime";import{jsx as zm,jsxs as Om}from"react/jsx-runtime";import{jsx as Fm,jsxs as Nm}from"react/jsx-runtime";import{Fragment as Em,jsx as Wm,jsxs as jm}from"react/jsx-runtime";import*as Bm from"react-dom/server";var Ym=Object.create(null);import{min as Xm}from"d3-array";import{min as Gm,max as Vm,sum as Hm,mean as qm,group as Um,groups as Zm}from"d3-array";import{interpolateNumber as Km}from"d3-interpolate";import{line as Qm,curveLinearClosed as Jm}from"d3-shape";var ex=e=>{let t,i,r,o,a,n,l,s,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,a=e.source.x1,n=e.target.x0,l=Km(a,n),s=l(.5),c=l(.5),`M${t},${a}C${t},${s} ${i},${c} ${i},${n}L${r},${n}C${r},${c} ${o},${s} ${o},${a}Z`;let u=e.sankeyWidth/2,d=Km(e.source.x1,e.target.x0),{pathD:h}=Zt({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(.5),cp2X:d(.5)});return h},tx=new Set,ix=new WeakMap,rx={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(Gl))-1:0},justify:Vl},ox={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o,a="vertical"===i.orientation?"down":"right",n=i.nodeAlign||"justify",l=i.nodeWidth??15,s=i.nodePaddingRatio??.05,c=i.iterations??100,u=e.map(e=>({...e})),d=t.map(e=>({...e,source:Hc(e.source),target:Hc(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));o="down"===a?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let h=ps().extent(o).links(d).nodes(u).nodeAlign(rx[n]||Vl).nodeId(e=>e.id).nodeWidth(l).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(let r of u)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(let r of d){if(!r.circular||!r.circularPathData)continue;let a=r.circularPathData,n=(r._circularWidth??r.width??0)/2;e>a.leftFullExtent-n&&(e=a.leftFullExtent-n),a.rightFullExtent+n>t&&(t=a.rightFullExtent+n),i>a.verticalFullExtent-n&&(i=a.verticalFullExtent-n),a.verticalFullExtent+n>o&&(o=a.verticalFullExtent+n)}let a=t-e,n=o-i,l=r[0],s=r[1];if(a>0&&n>0&&(0>e||0>i||t>l||o>s)){let t=Math.min(l/a,s/n),r=-e*t+(l-a*t)/2,o=-i*t+(s-n*t)/2;for(let e of u)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(let e of d)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){let i=e.circularPathData;i.sourceX=i.sourceX*t+r,i.targetX=i.targetX*t+r,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+r,i.leftFullExtent=i.leftFullExtent*t+r,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+r,i.leftInnerExtent=i.leftInnerExtent*t+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}let f=new Map;for(let t of e)f.set(t.id,t);for(let e of u){let 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)}let p=new Map;for(let e of t)if(e._edgeKey)p.set(e._edgeKey,e);else{let t=Hc(e.source),i=Hc(e.target);p.set(`${t}\0${i}`,e)}for(let e of d){let t=Hc(e.source),i=Hc(e.target),r=p.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=a;let o=f.get(t),n=f.get(i);o&&(r.source=o),n&&(r.target=n)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",a=i.nodeStyle,n=i.edgeStyle,l=i.edgeOpacity??.5,s=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:vd,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],f=[],p=new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;let r=a?a(gs(t,"nodeStyle")):{},n={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};p.set(t.id,("string"==typeof n.fill?n.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:n,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:n,datum:t,id:t.id,label:t.id})}let y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof s?s(e)||o:"target"===s?p.get(r.id)||u.get(r.id)||o:p.get(t.id)||u.get(t.id)||o;let a,c=n?n(gs(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){let t=e.circularPathData,i=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),n=c.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+r},${t.sourceY-i}L${t.sourceX+r},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:n,fillOpacity:c.fillOpacity??l,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-a},${t.targetY-i}L${t.targetX-a},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:n,fillOpacity:c.fillOpacity??l,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}a=e.circular&&e.circularPathData?ys(e):ex(e),a&&h.push({type:"bezier",pathD:a,bezierCache:e.bezier,style:{fill:c.fill||o,fillOpacity:c.fillOpacity??l,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity,cursor:c.cursor},datum:e})}if(!1!==i.showLabels){let t=Vc(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,a=i.y1-i.y0;if(0>=e||0>=a)continue;let n,l,s,c=t?t(i):i.id;c&&("down"===o?(n=i.y0+(i.y1-i.y0)/2,l=i.x1+14,s="start"):(r[0]/2>i.x0+e/2?(n=i.x0-6,s="end"):(n=i.x1+6,s="start"),l=i.y0+a/2),f.push({x:n,y:l,text:c+"",anchor:"down"===o?"middle":s,baseline:"middle",fontSize:11}))}}return{sceneNodes:d,sceneEdges:h,labels:f}}};$l("sankey",ox);import{forceSimulation as ax,forceCenter as nx,forceX as lx,forceY as sx,forceLink as cx,forceManyBody as ux,forceCollide as dx}from"d3-force";var hx={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,a=r[0]/2,n=r[1]/2,l=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),s=Math.min(.5,.06+1.8*(1-l)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){let i=new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=ms(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=xs(e.id),a=o%360*(Math.PI/180),n=(10+o%20)*l;e.x=t/r.length+n*Math.cos(a),e.y=i/r.length+n*Math.sin(a)}else{let t=xs(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*l;e.x=a+r*Math.cos(i),e.y=n+r*Math.sin(i)}}}else{let t=2.399963229728653;for(let i=0;e.length>i;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*l,o=i*t;r.x=a+e*Math.cos(o),r.y=n+e*Math.sin(o)}}}let f=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=Zu(i.nodeSize,i.nodeSizeRange,e),y=e=>p(e);if(f>0){let c=new Map,u=new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=Hc(e.source),i=Hc(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=cx().strength(e=>{let t=e.weight,i=Hc(e.source),r=Hc(e.target),a=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*a))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?y(t):0)+(i?y(i):0)+Math.max(6,12*l);return Math.max(16,40*l,r)}).id(e=>e.id),p=ax();if((void 0!==i.random||void 0!==i.seed)&&p.randomSource(i.random??function(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}}(i.seed)),p.force("charge",ux().strength(e=>{let t=c.get(e.id)??0;return-15*l*y(e)*Math.sqrt(t+1)})).force("collide",dx(e=>y(e)+3*l).strength(.9).iterations(2)).force("center",nx(a,n).strength(.8)).force("x",lx(a).strength(s)).force("y",sx(n).strength(s)).force("bounds",function(e,t,i=2,r=.6){let o=[],a=a=>{let n=r*Math.max(a,.2);for(let r of o){let o=r.x??e[0]/2,a=r.y??e[1]/2,l=r.vx??0,s=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+l,y=a+s;u>p?r.vx=l+(u-p)*n:p>d&&(r.vx=l+(d-p)*n),h>y?r.vy=s+(h-y)*n:y>f&&(r.vy=s+(f-y)*n)}};return a.initialize=e=>{o=e},a}(r,y)),p.nodes(e),t.length>0){let e=t.map(e=>({...e,source:Hc(e.source),target:Hc(e.target)}));d.links(e),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;f>e;++e)p.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=y(t),i=f>0?2:0,o=Math.min(r[0]/2,e+i),a=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(a,Math.min(r[1]-a,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let g=new Map;for(let t of e)g.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,a=i.edgeStyle,n=Zu(i.nodeSize,i.nodeSizeRange,e),l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:vd,s=new Map;e.forEach((e,t)=>{s.set(e.id,l[t%l.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=n(gs(t,"nodeSize")),r=o?o(gs(t,"nodeStyle")):{},a={fill:r.fill||s.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}let h=new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=a?a(gs(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){let t=Vc(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=n(gs(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};$l("force",hx);import{chord as fx,ribbon as px}from"d3-chord";import{arc as yx}from"d3-shape";var gx=vd,mx={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let{padAngle:o=.01,groupWidth:a=20,sortGroups:n}=i,l=Math.min(r[0],r[1])/2,s=l-a,c=r[0]/2,u=r[1]/2,d=(f=i.valueAccessor)?"function"==typeof f?f:e=>e[f]??1:e=>e.value??1,h=new Map;var f;for(let t=0;e.length>t;t++)h.set(e[t].id,t);let p=e.length,y=Array.from({length:p},()=>Array(p).fill(0));for(let e of t){let t=Hc(e.source),i=Hc(e.target),r=h.get(t),o=h.get(i);if(void 0===r||void 0===o)continue;let a=d(e);y[r][o]=a}let g=fx().padAngle(o);n&&g.sortGroups(n);let m=g(y),x=m.groups,b=yx().innerRadius(s).outerRadius(l);for(let t of x){let i=e[t.index],r=b.centroid({innerRadius:s,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});i.x=r[0]+c,i.y=r[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}let v=new Map;for(let t of e)v.set(t.id,t);for(let e of t){let t=Hc(e.source),i=Hc(e.target),r=v.get(t),o=v.get(i);r&&(e.source=r),o&&(e.target=o)}let w=new Map;for(let e of t){let t=Hc(e.source),i=Hc(e.target);w.set(`${t}\0${i}`,e)}for(let t of m){let i=e[t.source.index].id,r=e[t.target.index].id,o=w.get(`${i}\0${r}`)||w.get(`${r}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:a=.5}=i,n=Math.min(r[0],r[1])/2,l=n-o,s=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:gx,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});let y=px().radius(l),g=[],m=[],x=[];for(let t=0;e.length>t;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(gs(i,"nodeStyle")):{},a={fill:("string"==typeof o.fill?o.fill:void 0)||p.get(i.id)||f[t%f.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};g.push({type:"arc",cx:s,cy:c,innerR:l,outerR:n,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(let e of t){let t=e.__chordData;if(!t)continue;let r=y(t);if(!r)continue;let o=bs(r,s,c),n=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",l=d?d(gs(e,"edgeStyle")):{};if(d)n=("string"==typeof l.fill?l.fill:void 0)||n;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?n=p.get(i.id)||n:t&&(n=p.get(t.id)||n)}m.push({type:"ribbon",pathD:o,style:{fill:n,fillOpacity:l.fillOpacity??a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity,cursor:l.cursor},datum:e})}if(!1!==i.showLabels){let t=Vc(i.nodeLabel),r=n+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let a=(e.startAngle+e.endAngle)/2,n=a-Math.PI/2;x.push({x:s+Math.cos(n)*r,y:c+Math.sin(n)*r,text:o+"",anchor:a>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};$l("chord",mx);import{hierarchy as xx,tree as bx,cluster as vx,treemap as wx,pack as kx,partition as Ax,treemapBinary as Sx}from"d3-hierarchy";var Mx=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],_x={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let a=i.chartType,n=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(i.childrenAccessor),l=i.hierarchySum,s="function"==typeof l?l:"string"==typeof l?e=>Number(e[l])||0:e=>Number(e.value)||0,c=xx(o,n);c.sum(s),c.sort((e,t)=>(t.value??0)-(e.value??0));let[u,d]=r;switch(a){case"tree":!function(e,t,i,r){let o=t.treeOrientation||"vertical",a=bx();a.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),a(e)}(c,i,u,d);break;case"cluster":!function(e,t,i,r){let o=t.treeOrientation||"vertical",a=vx();a.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),a(e)}(c,i,u,d);break;case"treemap":!function(e,t,i,r){let o=t.padding??4,a=t.paddingTop??0,n=wx().size([i,r]).tile(Sx).padding(o);a>0&&n.paddingTop(a),n(e)}(c,i,u,d);break;case"circlepack":!function(e,t,i,r){let o=t.padding??4;kx().size([i,r]).padding(o)(e)}(c,i,u,d);break;case"partition":!function(e,t,i,r){Ax().size([i,r]).padding(t.padding??1)(e)}(c,i,u,d)}let h=c.descendants();e.length=0,t.length=0;let f=new Map;for(let t=0;h.length>t;t++){let r=h[t],o={id:ws(r,i,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?_s(o,r,i):"treemap"===a||"partition"===a?Ps(o,r):"circlepack"===a&&Ls(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===a||"cluster"===a)for(let e of h)if(e.parent){let i=f.get(e.parent),r=f.get(e);i&&r&&t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.nodeStyle||(()=>({})),a=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(e,t,i,r,o,a){let n=[],l=[],s=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let a=o(gs(t,"nodeStyle")),l=a.fill||Ss(i);if(i.colorByDepth&&void 0!==t.depth){let e=As(i);l=e[t.depth%e.length]}n.push({type:"circle",cx:e,cy:r,r:f,style:{fill:l,stroke:a.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,cursor:a.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let y=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,n=t.y,s=r.x,f=r.y;u&&(o+=d,n+=h,s+=d,f+=h);let p=Ms(o,n,s,f,c),g=a(gs(e,"edgeStyle"));l.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:e})}if(!1!==i.showLabels){let t=ks(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,a,n=i.x,l=i.y;if(u&&(n+=d,l+=h),u){let e=n-d,t=l-h,i=Math.sqrt(e*e+t*t);i>0?(r=n+e/i*10,o=l+t/i*10,a=0>e?"end":"start"):(r=n,o=l-12,a="middle")}else"horizontal"===c?(i.data?.children&&0!==i.data.children.length?(r=n-f-6,a="end"):(r=n+f+6,a="start"),o=l):(r=n,o=l+f+14,a="middle");s.push({x:r,y:o,text:e+"",anchor:a,baseline:"middle",fontSize:11})}}return{sceneNodes:n,sceneEdges:l,labels:s}}(e,t,i,r,o,a);case"treemap":case"partition":return function(e,t,i,r){let o=[],a=[];for(let i of e){let e=i.x1-i.x0,a=i.y1-i.y0;if(0>=e||0>=a)continue;let n=r(gs(i,"nodeStyle")),l=n.fill||Ss(t);if(t.colorByDepth&&void 0!==i.depth){let e=As(t);l=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:a,style:{fill:l,stroke:n.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity,fillOpacity:n.fillOpacity,strokeOpacity:n.strokeOpacity,cursor:n.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=ks(t.nodeLabel),o=t.labelMode||"leaf",n="partition"===t.chartType;for(let l of e){let e=l.x1-l.x0,s=l.y1-l.y0;if(0>=e||0>=s)continue;let c=!(l.data?.children&&l.data.children.length>0);if(!n&&("leaf"===o&&!c||"parent"===o&&c))continue;let u=i?i(l):l.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>s)continue;let d=r(gs(l,"nodeStyle")).fill||Ss(t);if(t.colorByDepth&&void 0!==l.depth){let e=As(t);d=e[l.depth%e.length]}let h="string"==typeof d?vs(d):t.themeSemantic?.text??"#000";a.push(c?{x:l.x0+e/2,y:l.y0+s/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,s)/6)),fill:h}:{x:l.x0+4,y:l.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:a}}(e,i,0,o);case"circlepack":return function(e,t,i,r){let o=[],a=[];for(let i of e){let e=i.__radius??5;if(0>=e)continue;let a=r(gs(i,"nodeStyle")),n=a.fill||Ss(t);if(t.colorByDepth&&void 0!==i.depth){let e=As(t);n=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:n,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity??.7,cursor:a.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=ks(t.nodeLabel);for(let o of e){let e=o.__radius??5,n=i?i(o):o.id;if(!n||15>e)continue;let l=!(o.data?.children&&o.data.children.length>0),s=r(gs(o,"nodeStyle")).fill||Ss(t);if(t.colorByDepth&&void 0!==o.depth){let e=As(t);s=e[o.depth%e.length]}if(l){let i="string"==typeof s?vs(s):t.themeSemantic?.text??"#000";a.push({x:o.x,y:o.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else a.push({x:o.x,y:o.y-e+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:a}}(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};$l("tree",_x),$l("cluster",_x),$l("treemap",_x),$l("circlepack",_x),$l("partition",_x);import{pie as Px}from"d3-shape";var Lx={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&function(e,t,i,r,o){function a(e){let t=p.get(e)??0;return p.set(e,t+1),0===t?e:`${e}__${t}`}let n=function(e){if("function"==typeof e)return e;let t=e||"children";return e=>e[t]||null}(i.childrenAccessor),l=function(e){if("function"==typeof e)return e;let t=e||"name";return e=>(e[t]??"")+""}(i.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof c?()=>c:c,h="number"==typeof u?()=>u:u,f=$s(i);f.metaMap.clear(),r.length=0,o.length=0;let p=new Map,y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=a(l(e));r.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}),f.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,c,u,p,y,g){let m=n(t);if(!m?.length)return;let x=m.length,b=0,v=0,w=0;for(;x>v;)v+=s[Math.min(w,s.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){let v=s[Math.min(x,s.length-1)],w=m.slice(k,k+v);if(!w.length)break;let A=(x+1)/b,S={id:i,depth:y,data:t,parentId:i},M=g?p/d(S)*A:p*A,_=Px().value(e=>n(e)?.length?4:1).sort(null)(w),P=h(S);for(let t=0;w.length>t;t++){let n=(_[t].startAngle+_[t].endAngle)/2,s=w[t],d=a(l(s)),h=c+M*Math.sin(n),p=u+M*Math.cos(n)*P;r.push({id:d,x:h,y:p,x0:h,x1:h,y0:p,y1:p,width:0,height:0,value:0,depth:y,data:s}),f.metaMap.set(d,{ring:M,angle:n,depth:y,parentId:i,eccentricity:P}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(s,d,h,p,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,a=i.edgeStyle,n=i.nodeSize,l="number"==typeof n?()=>n:"function"==typeof n?n:()=>6,s=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=$s(i),r=new Map;for(let t of e)r.set(t.id,t);let o=new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let a=48,n={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;a>o;o++){let l=o/a*Math.PI*2,s=(o+1)/a*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(l),y1:t+i*Math.cos(l)*r,x2:e+i*Math.sin(s),y2:t+i*Math.cos(s)*r,style:n,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=l(gs(t,"nodeSize")),r=o?o(gs(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let d=new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=a?a(gs(e,"edgeStyle")):{};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor},datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=l(gs(i,"nodeSize"));if(4>=e)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(function(e,t){let i=$s(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),a=(("u">typeof performance?performance.now():Date.now())-i.startTime)/1e3,n=r*(Math.PI/6),l=new Map;for(let t of e)l.set(t.id,t);for(let t of e){let e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;let r=l.get(e.parentId);if(!r)continue;let s=e.angle+a*n*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(s),t.y=r.y+e.ring*Math.cos(s)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,i),!0)};$l("orbit",Lx);import*as $x from"react";import{arc as Tx}from"d3-shape";import{jsx as Rx,jsxs as Cx}from"react/jsx-runtime";import{Fragment as Ix,jsxs as Dx}from"react/jsx-runtime";$l("sankey",ox),$l("force",hx),$l("chord",mx),$l("tree",_x),$l("cluster",_x),$l("treemap",_x),$l("circlepack",_x),$l("partition",_x),$l("orbit",Lx);var zx=new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);import*as Ox from"react-dom/server";import{geoPath as Fx}from"d3-geo";import{quadtree as Nx}from"d3-quadtree";import{geoMercator as Ex,geoEqualEarth as Wx,geoAlbersUsa as jx,geoOrthographic as Bx,geoNaturalEarth1 as Yx,geoEquirectangular as Xx}from"d3-geo";var Gx={mercator:Ex,equalEarth:Wx,albersUsa:jx,orthographic:Bx,naturalEarth:Yx,equirectangular:Xx};import{scaleLinear as Vx}from"d3-scale";var Hx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qx=["scene-style","data-paint","accessibility","evidence"],Ux=(e,t)=>({retainedData:e,invalidations:t}),Zx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Kx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qx=["scene-geometry","data-paint","accessibility","evidence"],Jx=["scene-style","data-paint","accessibility","evidence"],eb=["overlay","accessibility","evidence"],tb=[],ib={xAccessor:Ux("rebuild",Zx),yAccessor:Ux("rebuild",Zx),lineDataAccessor:Ux("rebuild",Zx),pointIdAccessor:Ux("rebuild",Qx),lineIdAccessor:Ux("rebuild",Qx),windowSize:Ux("rebuild",Zx),projection:Ux("preserve",Kx),projectionExtent:Ux("preserve",Kx),fitPadding:Ux("preserve",Kx),lineType:Ux("preserve",Kx),flowStyle:Ux("preserve",Kx),graticule:Ux("preserve",Kx),projectionTransform:Ux("preserve",Kx),customLayout:Ux("preserve",Kx),layoutConfig:Ux("preserve",Kx),layoutMargin:Ux("preserve",Kx),areaStyle:Ux("preserve",Jx),pointStyle:Ux("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Ux("preserve",Jx),colorScheme:Ux("preserve",Jx),themeCategorical:Ux("preserve",Jx),themeDiverging:Ux("preserve",Jx),themeSemantic:Ux("preserve",Jx),themeSequential:Ux("preserve",Jx),decay:Ux("preserve",Jx),pulse:Ux("preserve",Jx),layoutSelection:Ux("preserve",Jx),annotations:Ux("preserve",eb),autoPlaceAnnotations:Ux("preserve",eb),clock:Ux("preserve",tb),transition:Ux("preserve",tb),introAnimation:Ux("preserve",tb),onLayoutError:Ux("preserve",tb)},rb=Ux("preserve",Kx),ob=class{constructor(){this.tracker=new gu}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Hx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},qx):this.recordNoop("restyle")}recordConfig(e,t={}){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=ib[r]??rb;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as ab,geoGraticule as nb,geoInterpolate as lb}from"d3-geo";var sb=class e{constructor(e){this.updateResults=new ob,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.config=function(e){return{...e,fitPadding:Ys(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??uo()}getConfiguredWindowSize(){let e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),a=this.currentTime();this.pointBuffer=new Np(e),this.timestampBuffer=new Np(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??a)})}this.retainNewestLines(e)}updateConfig(e){let t=function(e){return"fitPadding"in e?{...e,fitPadding:Ys(e.fitPadding)}:e}(e),i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);this.config={...this.config,...t};let a=this.getConfiguredWindowSize(),n=this.streaming&&a!==r;n&&(this.resizeStreamingWindow(a),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:n})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),a=r.slice(-o.length),n=this.currentTime();this.pointBuffer=new Np(t),this.timestampBuffer=new Np(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(a[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();Wo(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();for(let i of e)Wo(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!r.has(i(e)+"")||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){let{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(i(e)+"");jo(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(i(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,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++,this.updateResults.recordData("clear")}restyleScene(e){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,a=this.baseScale,n=[...this.baseTranslate],l=[...this.baseRotation],s=this.scene;this.projection=function(e){if(!e)return Wx();if("string"==typeof e){let t=Gx[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Wx())}if("object"==typeof e&&"type"in e){let t=Gx[e.type],i=t?t():Wx();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}(t.projection),this.geoPath=Fx(this.projection),this.fitProjection(e),this.geoPath=Fx(this.projection);let c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=a,this.baseTranslate=n,this.baseRotation=l):(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){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&s.length>0&&this.startTransition(s),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=Os(i.xAccessor,"lon"),a=Os(i.yAccessor,"lat"),n=this.getPoints();if(n.length>0){let e=n.map(e=>[o(e),a(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let l=Fs(i.lineDataAccessor);for(let e of this.lineData){let t=l(e);if(t&&t.length>0){let e=t.map(e=>[o(e),a(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[a,n]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,n],[a,n],[a,o],[r,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*r),t.translate([e.width/2,e.height/2])}else{let o=i.fitPadding??0,a=e.width*o,n=e.height*o;t.fitExtent([[a,n],[e.width-a,e.height-n]],{type:"FeatureCollection",features:r})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,a=i.scale(),n=[...i.translate()],l=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Fx(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(a),i.translate(n),this.currentZoom=l,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,a=i.scale(),n=[...i.translate()],l=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Fx(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(a),i.translate(n),this.currentZoom=l,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,a=[...i.rotate()];i.rotate(e),this.geoPath=Fx(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(a),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let t=this.projection;!t||!t.rotate||t.rotate(e)}hasProjection(){return null!=this.projection}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,i=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);let r=Array(i),o=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(r[o++]=e);this._quadtree=Nx().x(e=>e.x).y(e=>e.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=$i(t.colorScheme,t.themeCategorical,Xd),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Ti(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},a=Ao({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let n=a.result,l=n.nodes??[];if(this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(let e of l)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return vo({label:"geo customLayout",nodes:l,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),l}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:i,areas:r,points:o,lines:a,layout:n}){let l=Os(e.xAccessor,"lon"),s=Os(e.yAccessor,"lat"),c=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=nb();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),a=i.bounds(t),n=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:a,screenArea:n,style:Ns(e.areaStyle,t,u),datum:t,interactive:!0})}let f=Fs(e.lineDataAccessor);for(let i of a){let r=f(i);if(!r||2>r.length)continue;let o=[];if("geo"===e.lineType){let e=Array(r.length);for(let t=0;r.length>t;t++)e[t]=[l(r[t]),s(r[t])];for(let i=0;e.length-1>i;i++){let r=e[i],a=e[i+1],n=ab(r,a)||0,l=Math.max(2,Math.ceil(n/(Math.PI/180))),s=lb(r,a);for(let e=0;l>=e;e++){if(i>0&&0===e)continue;let r=t(s(e/l));null!=r&&o.push(r)}}}else for(let e=0;r.length>e;e++){let i=r[e],a=t([l(i),s(i)]);null!=a&&o.push(a)}if(2>o.length)continue;let a=Ns(e.lineStyle,i,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==r.length||2>o.length||"arc"!==e.flowStyle?2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?js(o,u):Bs(o[0],o[o.length-1],0,0,u)):o=Ws(o[0],o[o.length-1]);let h=Es(o,n.width);if(h.length>1)for(let e of h)2>e.length||c.push({type:"line",path:e,style:{...a,_edgeFade:!0},datum:i});else c.push({type:"line",path:2>o.length&&h[0]||o,style:a,datum:i})}let p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,y=t.clipAngle?t.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(let i of o){let r=l(i),o=s(i);if(null!=g&&ab([r,o],b)>g)continue;let a=t([r,o]);if(!a)continue;let n=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:a[0],y:a[1],r:n.r||4,style:n,datum:i,pointId:p?p(i)+"":void 0};c.push(u)}return c}({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=function(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(2>o.length)return null;let a=t.strength??1,n=Number.isFinite(a)?Math.max(0,Math.min(1,a)):1,l="strip"===t.layout?"strip":"radial";if("radial"===l&&0===n)return null;let s=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&s(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),h=od(d,1);r>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--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let f="strip"===l?function(e,t,i,r,o){let a=Math.max(3,Math.min(8,.35*o.height)),n=Math.max(1,o.width-2*a),l=o.height/2,s=Vx().domain([0,r]).range([0,n]);t.x=a,t.y=l;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=a,o.y=l;continue}let e=Number(i(o.datum)),n=a+(isFinite(e)&&e>=0&&r>0?s(e):0);o.x=n,o.y=l,c.push({node:o,x:n})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;c.length>d;){let e=d+1;for(;c.length>e&&3>Math.abs(c[e].x-c[d].x);)e++;let t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)c[d+e].node.y=l+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:a,cy:l,maxCost:r,availableRadius:n,layout:"strip"}}(o,u,c,h,i):function(e,t,i,r,o,a){let n=t.x,l=t.y,s=a.width/2,c=a.height/2,u=Math.min(a.width,a.height)/2,d=Vx().domain([0,r]).range([0,u]);for(let a of e){if(a===t||!a.datum)continue;let e=a.x,u=a.y,h=Math.atan2(u-l,e-n),f=Math.hypot(e-n,u-l),p=Number(i(a.datum)),y=isFinite(p)&&p>=0?r>0?d(p):0:f,g=s+Math.cos(h)*y,m=c+Math.sin(h)*y;a.x=e+(g-e)*o,a.y=u+(m-u)*o}return t.x=n+(s-n)*o,t.y=l+(c-l)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}(o,u,c,h,n,i),p=e.filter(e=>"line"===e.type);if(p.length>0){let e=new Map;for(let t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(let i of p){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let a=e.get(r+""),n=e.get(o+"");if(a&&n)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[a[0]-e[0],a[1]-e[1]],o=[n[0]-t[0],n[1]-t[1]],l=[0];for(let e=1;i.path.length>e;e++)l.push(l[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let s=l[l.length-1];i.path=i.path.map((e,t)=>{let a=s>0?l[t]/s:t/(i.path.length-1);return[e[0]+r[0]*(1-a)+o[0]*a,e[1]+r[1]*(1-a)+o[1]*a]})}else i.path=[a,n]}}}return f}(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;i.length>r;r++){let o=ho(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",a=t.glowRadius??4,n=!1;for(let l=0;i.length>l&&r.length>l;l++){let s=po(t,r[l],e);n=yo(i[l],s,o,a)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&go(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(0>=t)return;let i=new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.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)&&(o=!0))}for(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=so(e,this.activeTransition),i=lo(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.y;e.x=co(e.x,e._targetX,i),e.y=co(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let e of r)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}};sb.QUADTREE_THRESHOLD=500;var cb=sb;qo(cb);import*as ub from"react";import{jsx as db,jsxs as hb}from"react/jsx-runtime";import{jsx as fb,jsxs as pb}from"react/jsx-runtime";import{Fragment as yb,jsx as gb,jsxs as mb}from"react/jsx-runtime";import*as xb from"react-dom/server.browser";var bb={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};import{jsx as vb,jsxs as wb}from"react/jsx-runtime";var kb={top:0,right:0,bottom:0,left:0};import{jsx as Ab}from"react/jsx-runtime";import{scaleLinear as Sb}from"d3-scale";import{jsx as Mb,jsxs as _b}from"react/jsx-runtime";var Pb={top:0,right:0,bottom:0,left:0};import*as Lb from"react-dom/server";import{jsx as $b,jsxs as Tb}from"react/jsx-runtime";var Rb={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},Cb={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=Rb[i],o=lc(e.width,r.width),a=lc(e.height,r.height),n="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,l="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,s="center"===l?"middle":"end"===l?"end":"start",c="center"===l?o/2:"end"===l?o-n:n,u=le(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=function(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US";if("currency"===e){let e=t.precision??2,r=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>r.format(e)}if("percent"===e){let e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){let e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";let t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;let r=i/1e3;if(60>r)return`${t}${o=r,Math.round(100*o)/100+""}s`;var o;let a=r/60;if(60>a){let e=Math.floor(a),i=Math.round(r-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}let n=a/60;if(24>n){let e=Math.floor(n),i=Math.round(a-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}let l=Math.floor(n/24),s=Math.round(n-24*l);return 0===s?`${t}${l}d`:`${t}${l}d ${s}h`}(e);let r=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>r.format(e)}("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":(T=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${T}${("string"==typeof e.suffix?e.suffix:void 0)??""}`),p=void 0===d?void 0:function(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(t.at>e)break;r=t}return r}(d,e.thresholds),y="string"==typeof e.color?e.color:function(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}(p?.level??"neutral",p?.color,u),g="string"==typeof e.label?e.label:void 0,m="string"==typeof e.caption?e.caption:void 0,x="string"==typeof e.unit?e.unit:void 0,b=void 0===d?void 0:function(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,a=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0===a)return;let n=function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(a,i);return`${n}${r&&"string"==typeof r.label?" "+r.label:""}`}(e,d,h),v=void 0===d?void 0:function(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?" "+r.label:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}(e,d,h),w=[b,v,p?.label].filter(Boolean).join(" · "),k="string"==typeof e.description&&e.description||[g,f,x,w].filter(Boolean).join(", "),A="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,S="string"==typeof e.borderColor?e.borderColor:u.colors.border,M=n+r.labelSize,_=M+r.captionSize+4,P="presentation"===i?a/2+.32*r.valueSize:"thumbnail"===i?a/2+.34*r.valueSize:Math.min(a-n-(w?26:4),(r.showHeader&&(g||m)?m?_+10:M+14:n)+r.valueSize),L=c+("start"===s?Math.max(r.valueSize,f.length*r.valueSize*.55):0),$=Lb.renderToStaticMarkup(Tb("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:a,viewBox:`0 0 ${o} ${a}`,role:"img","aria-label":k,"data-semiotic-component":"BigNumber",children:[$b("title",{children:g??f}),"string"==typeof e.description&&$b("desc",{children:e.description}),$b("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?a-1:a,rx:r.border?8:0,fill:A,stroke:r.border?S:"none"}),r.showHeader&&g&&$b("text",{x:c,y:M,textAnchor:s,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:g}),r.showHeader&&m&&$b("text",{x:c,y:_,textAnchor:s,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:m}),$b("text",{x:c,y:P,textAnchor:s,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:y,"data-mark-type":"value",children:f}),x&&void 0!==d&&"start"===s&&$b("text",{x:L+6,y:P,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:x}),r.showDetail&&w&&$b("text",{x:c,y:Math.min(a-n,P+r.detailSize+10),textAnchor:s,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:w})]}));var T;return t&&(t.evidence=Ta({frameType:"value",width:o,height:a,marks:void 0===d?[]:[{type:"value"}],title:g,description:k})),$}};import*as Ib from"react-dom/server";import{jsx as Db,jsxs as zb}from"react/jsx-runtime";import{Fragment as Ob,jsx as Fb}from"react/jsx-runtime";var Nb=new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),Eb=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi,Wb=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],jb=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];import*as Bb from"react-dom/server";import{Fragment as Yb,jsx as Xb,jsxs as Gb}from"react/jsx-runtime";_a();export{wc as generateFrameSVGs,kc as generateFrameSequence,_c as generatePhysicsFrameSVGs,mc as renderChart,xc as renderChartWithEvidence,vc as renderDashboard,fc as renderGeoToStaticSVG,hc as renderNetworkToStaticSVG,dc as renderOrdinalToStaticSVG,cc as renderToStaticSVG,uc as renderXYToStaticSVG,le as resolveTheme,yc as serializeSvgPrecision,se as themeStyles};
|
|
1
|
+
function e(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function t(e){let t=6;for(let i=1;e.length>i;i++){let r=Math.abs(e[i]-e[i-1]);r>0&&Number.isFinite(r)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/r))+1))}let i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function i(...e){let t;for(let i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function a(e){return"string"==typeof e&&e.length>0}function n(e,t,i=!1){let r=i?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}function s(e,t){return n(e,a(t))}function l(e,t,i,r,o=8){let a=r,n="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",s=Math.max(t[a],Math.max(0,("left"===r||"right"===r?i[0]:i[1])-o)-e[n]);e[a]>s&&(e[a]=s)}function c(e){return Math.ceil(7*e.length)}function u(e,i){if(r(e)){let t=w(i),r=100;for(let i of e.legendGroups){i.label&&(r=Math.max(r,c(i.label)));for(let e of i.items)r=Math.max(r,t.swatchSize+t.labelGap+c(e.label))}return r}if(o(e)){let{gradient:i}=e,r=i.format||t(i.domain),o=Math.max(c(r(i.domain[0])),c(r(i.domain[1]))),a=i.label?c(i.label):0;return Math.max(100,19+o,a)}return 100}function d(e){return(r(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?jm:Wm:0}function f(e){return Math.max(0,e?.edgeGutter??3)}function p(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function g(t){let{bottomAxis:i,topAxis:r,leftAxis:o,rightAxis:a}=e(t.axes),n=!(r&&!i||!1===i?.visible),s=!!r&&!i&&!1!==r.visible,l=!(a&&!o||!1===o?.visible),c=!!a&&!1!==a.visible,u=!1!==t.showAxes;return{hasAxis:u&&n,hasAxisLabel:u&&n&&!!(i?.label??t.xLabel),rotatedTicks:u&&n&&(t.rotatedTicks??!!i?.autoRotate),topAxis:s?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!r?.autoRotate)}:void 0,leftAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(a?.label??t.yLabelRight??t.yLabel)}:void 0}}function y(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}function m(e,t,i){if(o(e))return e.gradient.label?46:26;if(!r(e))return 20;let a=w(i),n=Math.max(1,i?.maxWidth??t),s=a.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let r of t.items){let t=a.swatchSize+a.labelGap+c(r.label),o=0===i?t:i+a.itemGap+t;i>0&&o>n?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),s=Math.max(s,e*a.rowHeight,t.label?c(t.label):0)}return s+(e.legendGroups.length>1?16:0)}function x(e,t,i){return u(e,t)+d(e)+h(t,i)+f(t)}function b(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=m(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+p("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),a=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,a,x(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,a,x(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,a,o):e.bottom=Math.max(e.bottom,a,o)}function v(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),a=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??u(e,t.legendLayout)),n=d(e),s=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),l=f(t.legendLayout),c=m(e,o,t.legendLayout),g=p(t.axisChrome,t.legendLayout),y=p(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(l,t.margin.left-s-a-n),y:t.margin.top,width:a,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-y-n-c,width:a,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+n,Math.min(e+g+n,t.totalHeight-c)),width:a,height:c}}return{x:Math.min(t.totalWidth-a-l,t.totalWidth-t.margin.right+s+n),y:t.margin.top,width:a,height:c}}function w(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function k(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,a=i;i+=8,e&&(i+=16,o=i,i+=8);let n=i;return i+=r*t+8,{lineY:a,labelY:o,itemsY:n,endY:i}})}function A(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}function S(e){let t=0;for(;e.length>t;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(0>i)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;e.length>o;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(Bm,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function M(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function _(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function P(e,t){for(let i of e.attributes.matchAll(Bm))if(i[1]===t)return _(i[2]??i[3])}function $(e,t){let i=S(e)?.start??0;return e.slice(0,i)+e.slice(i).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,i)=>i?e.replace(Bm,(e,i,r,o)=>{let a=t(i,_(r??o));return void 0===a?e:` ${i}="${M(a)}"`}):e)}function L(e,t){let i=S(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(Bm,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${M(i)}"`)});for(let[e,t]of r)o+=` ${e}="${M(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function I(e,t){let i=S(e);if(!i)return t;let r=e=>{let r=P(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function R(e,t){let i=S(e);return i?L(e,{width:"100%",height:"100%",...void 0===P(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===P(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function T(e,t){return py({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories})}function C(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function D(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function z(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function E(e,t){let{when:i}=e,r=t.width,o=t.height,a=z(t),n=D(t);return!("number"==typeof i.minWidth&&i.minWidth>r||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof a||i.minAspectRatio>a)||"number"==typeof i.maxAspectRatio&&("number"!=typeof a||a>i.maxAspectRatio)||i.orientation&&n!==i.orientation)}function N(e,t){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])C(e[r])&&C(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}function O(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>E(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>N(e,t.rule.transform),e),matches:r}}function F(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,a=!!i||void 0!==r,n=e&&"object"==typeof e?e:void 0;if(!1===e||!1===n?.enabled||void 0===e&&!o&&!a)return Ym;let s=n??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function W(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(Xm,e)}function j(e,t,i){let r=Xm[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,a=e&&"primary"!==e||!i?.height?r.height:i.height,n=O({...t,mode:e},{width:t.width??o,height:t.height??a}).props,s=n.mode||e||"primary",l=Xm[s],c="context"===s||"sparkline"===s,u="primary"===s&&i?.width?i.width:l.width;return{mode:s,width:n.width??u,height:n.height??("primary"===s&&i?.height?i.height:l.height),showAxes:n.showAxes??l.showAxes,showGrid:n.showGrid??l.showGrid,enableHover:n.enableHover??(!!n.linkedHover||l.enableHover),showLegend:n.showLegend??l.showLegend,showLabels:n.showLabels??l.showLabels,title:c?void 0:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,xLabel:c?void 0:n.xLabel,yLabel:c?void 0:n.yLabel,categoryLabel:c?void 0:n.categoryLabel,valueLabel:c?void 0:n.valueLabel,marginDefaults:B(l.marginDefaults,n.showCategoryTicks,n.orientation),compactMode:c,mobileInteraction:F(n.mobileInteraction,{mode:s,width:n.width??u,mobileSemantics:n.mobileSemantics}),mobileSemantics:n.mobileSemantics}}function B(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Y(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function X(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[o+""]}function G(e){let t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(X(e.yAccessor,"y",i,r))))return;let o=Y(X(e.xAccessor,"x",i,r)),a=t.get(o)??/* @__PURE__ */new Set;a.add(X(e.lineBy,"series",i,r)+""),t.set(o,a)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},a=2>o.max;return a||2>o.contestedColumns||2>o.median?[{code:a?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:a?"error":"warning",message:a?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}function V(e){return Hm.has(e)}function q(e){return Hm.get(e)}function H(e){return V(e)?q(e):"BumpChart"===e?Gm:void 0}function U(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function Z(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=H(t);if(o){try{let t="function"==typeof o?o(i,e):G(i);r=Array.from(t).filter(U)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function K(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}function Q(e){let{data:t,valueAccessor:i,bins:r,ballRadius:o,seed:a,size:n,valueExtent:s}=e,{rows:l}=$y(t,"galton"),c=my(n),u=l.map((e,t)=>wy(vy(e,t,i))).filter(e=>null!=e),d=Sy(s),h=d?.[0]??(u.length?Math.min(...u):0),f=d?.[1]??(u.length?Math.max(...u):1),p=f===h?1:f-h,g=ix().domain([0,r]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:r},()=>0),m=[];l.forEach((e,t)=>{let a=wy(vy(e,t,i));if(null==a)return;let n=Math.max(0,Math.min(r-1,Math.floor((a-h)/p*r)));y[n]+=1,m.push({id:(e.id??"galton-"+t)+"",x:g(n+.5),y:c.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:a,bin:n}})});let x=c.plot.y+c.plot.height,b=[...Uy({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Zy({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:g,yTop:c.plot.y-400,yBottom:x,wallThickness:6})];return{config:by(a,b,"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:r,plot:c.plot,valueExtent:[h,f]}}}function J(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}function ee(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,a=rx().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),n=a(e.windowStart+i*e.windowSize),s=e.windowPlot.x,l=t+Math.max(18,Math.min(.3*e.windowPlot.height,n-s)),c=e=>n===s?t:l+(e-s)/(n-s)*(t-l),u=[];for(let t=0;i>t;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=a(i),n=a(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:c(o),x2:n,y2:c(n)})}return u}function te(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:a,yTop:n,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{let l=Math.min(a-1,s?.(t)??n),c=Math.max(1,a-l);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}function ie(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:a,watermarkAtArrivalAccessor:n,ballRadius:s,seed:l,size:c,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:f}=Ly({data:t,timeAccessor:i,arrivalAccessor:r,watermark:a,watermarkAtArrivalAccessor:n,windowSize:o.size}),p=my(c),g=h.map(e=>e.eventTime),y=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=wy(u?.[0]),x=wy(u?.[1]),b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):b+o.size,w=Math.min(m??b,b),k=Math.max(x??v,v),A=Math.floor(w/o.size)*o.size,S=Math.max(1,Math.ceil((k-A+o.size)/o.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(e,t)=>t).reduce((e,t)=>A+(t+1)*o.size>f?e:e+1,0))),_=J(p,s),P=A+S*o.size,$=rx().domain([A,P]).range([_.windowPlot.x,_.windowPlot.x+_.windowPlot.width]),L=Array.from({length:S},()=>({value:0,secondary:0})),I=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:a,late:n})=>{let l=Math.max(0,Math.min(S-1,Math.floor((i-A)/o.size)));L[l].value+=n?0:1,L[l].secondary+=n?1:0,I.push({id:(e.id??"event-"+t)+"",x:oe(i,l,n,{windowStart:A,windowSize:o.size,gutter:_.gutter,closedWindowCount:M,windowPlot:_.windowPlot,windowCount:S},s),y:p.plot.y+s+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:l,watermarkAtArrival:a,late:n}})});let R=p.plot.y+p.plot.height,T={closedWindowCount:M,gutter:_.gutter,plot:p.plot,windowCount:S,windowPlot:_.windowPlot,windowSize:o.size,windowStart:A},C=ee(T,p.plot.y+.28*p.plot.height);for(let e of I){let t=e.datum;e.y=re({...T,lidSegments:C},t.windowIndex,t.late,s)}let D=e=>{if(0>e||e>M)return null;let t=0===e?C[0]?.y1:C[e-1]?.y2??C[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null},z=te({idPrefix:"eventdrop-window",count:S,xScale:e=>$(A+e*o.size),yTop:_.wallTop,yTopForIndex:e=>{let t=D(e);return null==t?_.wallTop:t+1.25*s},yBottom:R,wallThickness:6}),E=[...Uy({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...z,...C.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}))];return{config:by(l,E,"EventDropChart",{friction:.08}),initialSpawns:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=M>t.windowIndex;return i&&!t.late||!i&&t.late?y:t.arrivalTime},timeScale:d},projectionRows:L.map((e,t)=>({label:`${A+t*o.size}-${A+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:_.gutter,lidSegments:C,lateCount:L.reduce((e,t)=>e+t.secondary,0),plot:p.plot,windowPlot:_.windowPlot,windowWalls:z.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:f,windowCount:S,windowSize:o.size,windowStart:A}}}function re(e,t,i,r){let{windowPlot:o,lidSegments:a}=e,n=a[t];return i&&!n?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&n?Math.min(o.y+o.height-r,Math.max(n.y1,n.y2)+2*r+4):o.y+r+2}function oe(e,t,i,r,o){let{windowPlot:a,windowCount:n,windowStart:s,windowSize:l}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=a.width/n,u=i?a.x:a.x+t*c,d=i?a.x+a.width:u+c,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,a.x+(e-s)/l*c))}function ae(e,t,i){let r=e.width/Math.max(1,t),o=Math.max(2,2*i),a=Math.min(.7*r,Math.max(3.2*o,o+8)),n=Math.max(1,Math.floor(a/o));return{laneWidth:r,tubeWidth:a,ballDiameter:o,perRow:n,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/n)*o}}function ne(e){function t(e){let t=f.get(e);return null==t&&(t=h.length,h.push(e),f.set(e,t)),t}let{data:i,categoryAccessor:r,valueAccessor:o,unitValue:a,ballRadius:n,seed:s,size:l}=e,c=Ay(a,1),{rows:u}=$y(i,"pile"),d=my(l),h=[],f=/* @__PURE__ */new Map,p=/* @__PURE__ */new Map,g=[];u.forEach((e,i)=>{t((vy(e,i,r)??"unknown")+"")});let y=Math.max(1,h.length),m=ae(d.plot,y,n),x=Math.max(0,m.tubeWidth/2-n-1),b=h.map(()=>[]);u.forEach((e,i)=>{let a=(vy(e,i,r)??"unknown")+"",s=t(a),l=o?wy(vy(e,i,o)):1,u=Math.max(0,l??0);p.set(a,(p.get(a)??0)+u);let h=Ry(u,c),f=m.centerX(s);for(let t=0;h>t;t+=1){let r=b[s].length,o=t===h-1?u-t*c:c,l=Math.min(1,o/c);b[s].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:f+(m.perRow>1?((m.perRow>1?r%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+n+2,vx:(t%3-1)*n/2,vy:0,mass:1,shape:{type:"circle",radius:n*Math.sqrt(l)},datum:{...e,category:a,unitIndex:t,unitValue:c,representedValue:o,unitFraction:l}})}});let v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(let t of b)t.length>e&&g.push(t[e]);let w=d.plot.y+d.plot.height,k=[...Uy({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;y>e;e+=1){let t=m.centerX(e);for(let i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:by(s,k,"UnitPileChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:p.get(e)??0}))}}function se(e,t,i,r){let o=(t+i)/2,a=[];for(let n of e){let s=a.filter(e=>n.radius+e.radius+.5>Math.abs(n.x-e.x)),l=[o];for(let e of s){let t=Math.sqrt((n.radius+e.radius+.5)**2-(n.x-e.x)**2);l.push(e.y-t,e.y+t)}let c=.5>r()?-1:1;l.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=l.find(e=>e-n.radius>=t&&i>=e+n.radius&&s.every(t=>(n.x-t.x)**2+(e-t.y)**2>=(n.radius+t.radius+.5)**2-1e-6));if(null==u){let r=Math.max(...e.map(e=>e.radius)),a=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*a),overlapping:!0,entryOffset:0}}a.push({...n,y:u})}return{positions:a.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...a.map(e=>e.y-e.radius-t)))}}function le(e){function t(e){let t=m.get(e);return null==t&&(t=y.length,y.push(e),m.set(e,t)),t}let{data:i,xAccessor:r,groupAccessor:o,radiusAccessor:a,pointRadius:n,seed:s,size:l,xExtent:c,collisionIterations:u,settle:d}=e,{rows:h}=$y(i,"collision-swarm"),f=my(l),p=_y(s),g=[],y=[],m=/* @__PURE__ */new Map;h.forEach((e,i)=>{let s=wy(vy(e,i,r));if(null==s)return;let l=o?(vy(e,i,o)??"All")+"":"All",c=a?wy(vy(e,i,a)):null,u=ky(null!=c&&c>0?c:n,2,18);t(l),g.push({datum:e,index:i,value:s,group:l,radius:u})});let x=g.map(e=>e.value),b=c?wy(c[0]):null,v=c?wy(c[1]):null,w=x.length?Math.min(...x):0,k=x.length?Math.max(...x):1,A=b??w,S=v??k;if(A===S&&(A-=.5,S+=.5),A>S){let e=S;S=A,A=e}let M=Math.max(n,...g.map(e=>e.radius)),_=f.plot.x+M+8,P=f.plot.x+f.plot.width-M-8,$=ox().domain([A,S]).range([_,P]),L=f.plot.height/Math.max(1,y.length),I=Math.min(6,.05*L),R=e=>f.plot.y+((m.get(e)??0)+.5)*L,T=/* @__PURE__ */new Map,C=/* @__PURE__ */new Set,D=/* @__PURE__ */new Map;for(let e of y){let t=g.filter(t=>t.group===e),i=R(e),r=t.map(e=>({x:$(e.value),radius:e.radius})),o=se(r,i-L/2+I,i+L/2-I,p);T.set(e,t.length),o.overlapping&&C.add(e),t.forEach((e,t)=>D.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let z=g.map((e,t)=>{let i=D.get(e.index),r=i.x,o=i.y,a=C.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:r,y:o-(d?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!a,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:a},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}}),E=Uy({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20});return{config:by(s,E,"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*M),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:z,projectionRows:y.map(e=>({label:e,value:T.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[A,S],xRange:[_,P],groups:y.map(e=>({label:e,y:R(e),count:T.get(e)??0,overlapping:C.has(e)})),plot:f.plot}}}function ce(e){if(Array.isArray(e)&&e.length>=2){let t=wy(e[0]),i=wy(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=wy(t.x),r=wy(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function ue(e){return Array.isArray(e)?e.map(ce).filter(e=>null!=e):[]}function de(e,t){return"normalized"===e||"pixels"===e?e:t.length>0&&t.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels"}function he(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:ky(e.x,t.plot.x,t.plot.x+t.plot.width),y:ky(e.y,t.plot.y,t.plot.y+t.plot.height)}}function fe(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function pe(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=ky(t,0,1)*fe(e),r=0;for(let t=1;e.length>t;t+=1){let o=e[t-1],a=e[t],n=Math.hypot(a.x-o.x,a.y-o.y);if(n>0){if(r+n>=i){let e=(i-r)/n;return{x:o.x+(a.x-o.x)*e,y:o.y+(a.y-o.y)*e}}r+=n}}return{...e[e.length-1]}}function ge(e,t){let i=pe(e,Math.max(0,t-.02)),r=pe(e,Math.min(1,t+.02)),o=r.x-i.x,a=r.y-i.y,n=Math.hypot(o,a)||1;return{x:o/n,y:a/n}}function ye(e){function t(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof n){let e=n(t,0);if(null!=e)return e+""}if("string"==typeof n&&null!=t[n])return t[n]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}let{coordinateMode:i,flowSpeed:r,links:o,maxParticles:a,nodeIdAccessor:n,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:f="path",reducedMotion:p,seed:g,size:y,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=e,v=my(y),w=_y(g),k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=[];c.forEach((e,t)=>{let i=(vy(e,t,n)??e.id??t)+"",r=wy(vy(e,t,s)),o=wy(vy(e,t,l));if(null!=r&&null!=o){let e={x:r,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});let M=[];o.forEach((e,i)=>{let r=t(vy(e,i,m)),o=t(vy(e,i,x)),a=Math.max(0,wy(vy(e,i,b))??0),n=ue(h?vy(e,i,h):void 0),s=n.length?n:ue(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${r}-${o}-${i}`)+"",link:e,index:i,source:r,target:o,throughput:a,rawPath:s})});let _=de(i,S),P=/* @__PURE__ */new Map;for(let[e,t]of k)P.set(e,he(t,v,_));let $=[];for(let e of M){let t=e.rawPath.map(e=>he(e,v,_));if(2>t.length){let i=P.get(e.source),r=P.get(e.target);i&&r&&(t=[i,r])}else P.has(e.source)||P.set(e.source,t[0]),P.has(e.target)||P.set(e.target,t[t.length-1]);2>t.length||0>=e.throughput||(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),$.push({...e,path:t,packetCount:0}))}let L=Ay(d,.12),I=Math.max(1,Math.round(a)),R=$.map(e=>Math.max(1,Math.round(e.throughput*L))),T=R.reduce((e,t)=>e+t,0),C=T>I?I/T:1;$.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(R[t]*C))});let D=$.reduce((e,t)=>e+t.packetCount,0);for(;D>I;){let e=$.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>$[e].packetCount)?i:e,-1);if(-1===e)break;$[e].packetCount-=1,D-=1}let z=/* @__PURE__ */new Map,E=/* @__PURE__ */new Map,N=[],O=Ay(r,90),F=Ay(u,4);$.forEach((e,t)=>{z.set(e.target,(z.get(e.target)??0)+e.throughput),E.set(e.source,(E.get(e.source)??0)+e.throughput);let i=fe(e.path);for(let r=0;e.packetCount>r;r+=1){let o=(r+.5)/e.packetCount,a=p?o:ky(.12+.84*o+.04*(w()-.5),.04,.98),n=p?a:Math.max(0,a-(.18+.12*w())),s=pe(e.path,n),l=pe(e.path,a),c=ge(e.path,n),u={x:-c.y,y:c.x},d=(w()-.5)*F*1.5;N.push({id:`${e.id}-packet-${r}`,x:s.x+u.x*d,y:s.y+u.y*d,vx:p?0:c.x*O+10*(w()-.5),vy:p?0:c.y*O+10*(w()-.5),mass:.8,spawnAt:p?0:.04*t+r/32,shape:{type:"circle",radius:F},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:a,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:O,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==f&&p?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*F,stiffness:26,damping:4.25}]:void 0})}});let W=Math.max(18,5*F),j=Array.from(P,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+My(e),point:t})),B=j.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),Y=Object.fromEntries(j.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),X=[...Uy({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...B],G=by(g,X,"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*F),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=I,G.eviction="oldest",G.observation={...G.observation,sensors:Y};let V=Array.from(P,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+My(e),incoming:z.get(e)??0,outgoing:E.get(e)??0})),q=$.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:N,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:N.length,totalThroughput:$.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:q}}}function me(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 xe(e,t){let i={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 cm({...i,kind:e.kind??"sink",force:me(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return lm({...i,kind:e.kind??"force-field",force:me(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}})}if(e.capacity){let t=Math.max(.1,e.capacity.unitsPerSecond);return sm({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:me(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return nm({...i,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:me(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?am({...i,kind:e.kind??"force-field",force:me(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):um({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function be(e){let t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=my(i),o=ky(e.ballRadius??6,2,18),a=e.seed??1,n=_y(a),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(c?"allAbsorbed":"none"),p=e.springStiffness??.28,g=e.springDamping??.72,y=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=om({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.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],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{let t=v.get(e.id)??k;return xe(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(am({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}));let M=/* @__PURE__ */new Map;for(let e of x.stages)M.set(e.id,0);let _=[];e.data.forEach((e,t)=>{let i=(s?vy(e,t,s)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(vy(e,t,l)??w)+"",a=b.has(r)?r:w;M.set(a,(M.get(a)??0)+1);let n=c?(vy(e,t,c)??"")+"":void 0,f=n&&u?(vy(e,t,u)??n)+"":n,p=d?wy(vy(e,t,d))??1:1,g=h?wy(vy(e,t,h)):null,y=ky(null!=g&&g>0?g:o,2,18);_.push({datum:e,id:i,stageId:a,groupId:n||void 0,groupLabel:f||void 0,work:p,radius:y,index:t})});let P=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map;for(let e of _){if(!e.groupId)continue;let t=P.get(e.groupId)??[];t.push(e.id),P.set(e.groupId,t),e.groupLabel&&$.set(e.groupId,e.groupLabel)}let L=ky(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*L,R=Array.from(P.keys()),T=R.map((e,i)=>{let r=P.get(e)??[],o=R.length>1?x.topY+28+i/Math.max(1,R.length-1)*(x.bottomY-x.topY-56):x.midY;return dm({id:e,label:$.get(e)??e,bodyIds:r,anchor:{x:I,y:o},x:I,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),C=_.filter(e=>A.has(e.stageId)).map(e=>e.id),D=rm(T,C),z=new Map(T.map(e=>[e.id,e])),E=_.map((e,t)=>{let i=v.get(e.stageId)??k,r=i.x+(n()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(r,"top")+e.radius+10,a=x.boundaryY(r,"bottom")-e.radius-10,s=a>o?o+n()*Math.max(1,a-o):x.midY,l=y?r:x.left+18+t%7*4,c=y?s:x.midY+(n()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:p,damping:g}];if(e.groupId){let t=z.get(e.groupId);t?.anchor&&!A.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:l,y:c,vx:y?0:40+40*n(),vy:y?0:20*(n()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:y?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}}}),N={kernel:{seed:a,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},O=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),F=t.map(e=>{let 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:N,initialSpawns:E,initialSpawnPacing:y?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:O,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:F,groups:T,groupCompletion:D,regionEffects:S}}}function ve(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function we(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function ke(e){let t=e.map(ve),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){let[e,i,r]=t[0];return we(e,i,r)}if(e>=1){let[e,r,o]=t[i];return we(e,r,o)}let r=e*i,o=Math.floor(r),a=r-o,[n,s,l]=t[o],[c,u,d]=t[o+1];return we(Math.round(n+(c-n)*a),Math.round(s+(u-s)*a),Math.round(l+(d-l)*a))}}function Ae(e){return e&&Object.prototype.hasOwnProperty.call(vx,e)?vx[e]:lx}function Se(e,t,i=Lx){if(e&&"object"==typeof e&&!Array.isArray(e)){let 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){let t=Object.prototype.hasOwnProperty.call($x,e)?$x[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Me(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Cx.has(t)}function _e(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!Me(r)?i(r):r}let r=e?.[t]+"";return i?i(r):Lx[Math.abs(Le(r))%Lx.length]}function Pe(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function $e(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>Pe(e,t)??"#999"}let r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return nx().domain(r).range(i).unknown("#999");let a=Object.prototype.hasOwnProperty.call($x,i)?$x[i]:$x.category10;if(o&&"function"==typeof a){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>a(0===e?0:Number(t)/e)}{let e=Array.isArray(a)?a:Lx;return nx().domain(r).range(e).unknown("#999")}}function Le(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}function Ie(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[a,n]=r,[s,l]=i;if(n===a)return(s+l)/2;let c=(o-a)/(n-a);return 0>c?c=0:c>1&&(c=1),s+c*(l-s)}function Re(e,t,i){return Se(e,t,i)}function Te(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Pe(i,e)||"#4e79a7":t=>{if(i){let e=Pe(i,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Ce(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}function De(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],a=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...a.length>0&&{colliders:a}}}function ze(e,t){if(!t?.length)return e;let i=/* @__PURE__ */new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}function Ee(e){let t=Ce(e.config,e.chartId,e.onObservation),i=Re(e.colorScheme,e.themeCategorical,sx),r=my(e.size),o={data:e.data,scales:{x:ax().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:ax().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Te(i,e.colorScheme),config:e.layoutConfig??{},world:new em(t)},a=e.skipLayout?{}:e.layout(o)??{},n=ze([...a.initialSpawns??a.bodies??[]],a.constraints);return{config:De(t,a),context:o,initialSpawnPacing:a.initialSpawnPacing,initialSpawns:n,result:a}}function Ne(e){let t=Be(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Oe(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function Fe(e){return`gauntlet:${e}:core`}function We(e,t){return`gauntlet:${e}:positive:${t}`}function je(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function Be(e){let t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return Dx;let i=Math.max(1,Math.min(e.width,t)),r=Math.max(2,.04*e.width);return{left:r,top:Math.max(2,.08*t),rightInset:r,thickness:Math.max(1,Math.min(4,.04*i))}}function Ye(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function Xe(e,t,i,r){let o=Be(r),a=Math.max(2,i+2),n=o.top+o.thickness/2+a,s=r.floorY-a,l=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:l(e,o.left+o.thickness/2+a,r.width-o.rightInset-o.thickness/2-a),y:l(t,n,s)}}function Ge(e,t,i){let[r,o]=e,a=220>r||160>o,n=Math.round(.48*o),s=a?o-Math.max(3,Math.min(12,.1*o)):o-36,l=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,l.length),u=.22*r,d=c>1?(.78*r-u)/(c-1):0,h=a?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:s-(a?Math.min(i,Math.max(3,.22*o)):i),floorY:s,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(a?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(a?.72:.84)),graveyardY:s-4,height:o,routeY:n,socketX:Math.round(r*(a?.82:.92)),startX:h,width:r}}function Ve(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 qe(e,t,i,r){let o=Ve(i),a=r?.(e,t,i)??{};return{...o,...a,startY:a.startY??a.routeY??o.startY,socketY:a.socketY??a.routeY??o.socketY,graveyardY:a.graveyardY??o.graveyardY}}function He(e,t,i=1){let r=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,r.indexOf(t));return{angle:.82*-Math.PI+(r.length>1?o/(r.length-1):.5)*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function Ue(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,a=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*a-1.2*e.delay-5*o))}function Ze(e,t,i,r,o){let a=Oe(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=r.map(e=>e.id),s=[...Oe(e,t,i.positiveAccessor,n)],l=[...Oe(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:a,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Oe(e,t,i.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Oe(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Oe(e,t,i.initialViability,100)}}function Ke(e,t,i,r,o,a,n){let s=Ye(i),l=Math.max(3,28*s),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*s:0),d=n?.(e,t,i,r)??{},h=d.x??c,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},g=[{...d,id:Fe(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:l},spawnAt:d.spawnAt??e.startedAt,datum:p}],y=Xe(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||l,i);g[0].x=y.x,g[0].y=y.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let a=He(e.activePositiveIds,t,s),n=r.radius??Math.max(2,10*s),l=Xe(y.x+Math.cos(a.angle)*a.radius,y.y+Math.sin(a.angle)*a.radius,n,i);g.push({id:We(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(a.angle),vy:18*Math.sin(a.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:Fe(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+a.index%2*4)*s),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=a.get(t);o&&g.push(Je(e,o,r,y.x,y.y,i,d.spawnAt??e.startedAt))}),g}function Qe(e){let t=Ge(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),a={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{let s=Ze(t,n,a,i,o);return{...s,viability:e.viability?.(s,{negativeProperties:o,positiveProperties:r})??Ue(s,r,o)}}),s=n.flatMap((i,a)=>{let n=qe(i,a,t,e.projectPlacement);return Ke(i,a,t,n,r,o,e.coreBody)});return{layout:t,states:n,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:Ne(t)}}}function Je(e,t,i,r,o,a,n){let s=Ye(a),l=t.radius??Math.max(2,7.2*s),c=Xe(r+(i%4*12-12)*s,o+(54+12*Math.floor(i/4))*s,l,a);return{id:je(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:n,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Fe(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*s),...t.spring??{}}]}}function et(e=[]){let t=/* @__PURE__ */Object.create(null);for(let[i,r]of e)t[i]=r;return t}function tt(...e){let t=et();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function it(e){return tt(e)}function rt(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function ot(e){let t=et(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:it(t.initialMetrics),metrics:it(t.metrics),productIds:[...t.productIds],history:rt(t.history)}])),i=et(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:it(t.metrics),sourceIds:[...t.sourceIds],history:rt(t.history)}])),r=et(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?it(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:it(e.input.metrics)},metrics:it(e.metrics),loss:{amount:e.loss.amount,metrics:it(e.loss.metrics)},history:rt(e.history)}}function at(e,t){return t>e?-1:e>t?1:0}function nt(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function st(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(at)}function lt(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[nt("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function ct(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function ut(e){let t=et();for(let i of e)ct(t,i.metrics);return t}function dt(e,t,i="selector"){let r=[],o=Object.values(e.components),a=new Set(o.map(e=>e.id)),n=(t.ids??[]).filter(e=>!a.has(e));if(n.length&&r.push(nt("error","unknown-component",`Selector references unknown component id${1===n.length?"":"s"}: ${n.join(", ")}.`,i+".ids",n)),void 0!==t.count&&(!Number.isInteger(t.count)||0>t.count)&&r.push(nt("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let s=t.ids?new Set(t.ids):null,l=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!s||s.has(e.id)).filter(e=>!l||l.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(at);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(nt("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function ht(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function ft(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function pt(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(nt("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function gt(e,t,i){let r=st(t);t.length||e.diagnostics.push(nt("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(nt("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(nt("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let a=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);a.length&&e.diagnostics.push(nt("error","source-already-assigned",`Source component${1===a.length?" is":"s are"} already assigned: ${a.join(", ")}.`,i,a));let n=t.filter(t=>"consumed"===e.state.components[t]?.status&&!a.includes(t));return n.length&&e.diagnostics.push(nt("error","source-unavailable",`Consumed source component${1===n.length?" is":"s are"} unavailable: ${n.join(", ")}.`,i,n)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function yt(e,t,i){let r=st(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(nt("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(nt("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(nt("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function mt(e,t,i,r,o){let a=r?.amount??0;(!Number.isFinite(a)||0>a||a>t+zx)&&e.diagnostics.push(nt("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...lt(r?.metrics,o+".metrics"));for(let[t,a]of Object.entries(r?.metrics??{}))(0>a||a>Number(i[t]??0)+zx)&&e.diagnostics.push(nt("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function xt(e,t,i,r){if(!t?.length)return[];let o=st(t),a=t.filter(t=>!e.state.relations[t]),n=t.filter(t=>"resolved"===e.state.relations[t]?.status),s=new Set(i),l=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!s.has(e)));return o.length&&e.diagnostics.push(nt("error","duplicate-relation","Basis relations must be unique.",r,o)),a.length&&e.diagnostics.push(nt("error","unknown-relation",`Unknown basis relation: ${a.join(", ")}.`,r,a)),n.length&&e.diagnostics.push(nt("error","resolved-relation",`Basis relation is already resolved: ${n.join(", ")}.`,r,n)),l.length&&e.diagnostics.push(nt("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${l.join(", ")}.`,r,l)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}function bt(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;ft(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function vt(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}function wt(e,t,i,r,o,a,n){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:a&&void 0!==e.amount?e.amount:i,metrics:a&&e.metrics?tt(r,e.metrics):it(r),status:a?"complete":"forming",sourceIds:[...t],outletId:a?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:a?o.event.id:void 0,completedAt:a?o.context.appliedAt:void 0,history:[n]}}function kt(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>zx&&e.diagnostics.push(nt("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function At(e,t,i,r,o,a){let n=e.productDefinitions.get(t.id),s=i??n?.outletId??(e.outletIds.has("product")?"product":void 0);if(!pt(e,s,a+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(nt("error","product-already-complete",`Product "${t.id}" is already complete.`,a,[t.id]));n&&(kt(e,n,t.amount,a+".productId"),void 0!==n.amount&&(t.amount=n.amount),n.metrics&&(t.metrics=tt(t.metrics,n.metrics))),t.status="complete",t.outletId=s,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let l=ht(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0});t.history.push(l),e.state.history.push(l),ft(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0})}function St(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(nt("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,r+".state")),e.diagnostics.push(...lt(t.metricsDelta,r+".metricsDelta")),pt(e,t.outletId,r+".outletId");let i=dt(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let a=i.ids.filter(e=>o.components[e].productIds.length);if(a.length&&e.diagnostics.push(nt("error","source-already-assigned",`Assigned source components cannot be retargeted: ${a.join(", ")}.`,r+".select",a)),e.diagnostics.some(e=>"error"===e.severity))return;let n=ht(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&ct(i.metrics,t.metricsDelta),i.history.push(n)}return o.history.push(n),void(i.ids.length&&ft(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(nt("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,r+".relation.id",[i.id]));let a=yt(e,i.sourceIds,r+".relation.sourceIds");if(e.diagnostics.push(...lt(i.metrics,r+".relation.metrics")),!a||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?it(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let n=ht(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(n),void ft(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=st(t.relationIds),a=t.relationIds.filter(e=>!o.relations[e]),n=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(nt("error","duplicate-relation","Relation ids must be unique.",r+".relationIds",i)),a.length&&e.diagnostics.push(nt("error","unknown-relation",`Unknown relation: ${a.join(", ")}.`,r+".relationIds",a)),n.length&&e.diagnostics.push(nt("error","resolved-relation",`Relation is already resolved: ${n.join(", ")}.`,r+".relationIds",n)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let s=ht(e,t,{relationIds:[...t.relationIds]});return o.history.push(s),void ft(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(nt("error","unknown-product",`Product "${t.productId}" has no declared mold.`,r+".productId",[t.productId]));let a=o.products[t.productId];"combine"===t.type&&a&&e.diagnostics.push(nt("error","duplicate-product",`Product "${t.productId}" has already been formed.`,r+".productId",[t.productId])),"contribute"===t.type&&(!a||"forming"!==a.status)&&e.diagnostics.push(nt("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,r+".productId",[t.productId]));let n=gt(e,t.sourceIds,r+".sourceIds"),s="contribute"===t.type&&a?[...a.sourceIds,...t.sourceIds]:t.sourceIds,l=xt(e,t.basisRelationIds,s,r+".basisRelationIds");if(!n||!l||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=n.reduce((e,t)=>e+t.amount,0),u=ut(n);if(!mt(e,c,u,t.loss,r+".loss"))return;let d=c-(t.loss?.amount??0);vt(e,u,t.loss);let h,f="combine"===t.type&&!1!==t.complete,p=ht(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(f&&kt(e,i,d,r+".productId"),h=wt(i,t.sourceIds,d,u,e,f,p),f&&!pt(e,h.outletId,r+".productId"))return;o.products[t.productId]=h}else h=a,h.sourceIds.push(...t.sourceIds),h.amount+=d,ct(h.metrics,u),h.history.push(p);for(let e of n)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),bt(e,l),ft(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(f&&ft(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void At(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(nt("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,r+".productId",[t.productId]))}if("split"===t.type){let i=gt(e,[t.sourceId],r+".sourceId");t.products.length||e.diagnostics.push(nt("error","empty-split","A split requires at least one product allocation.",r+".products"));let a=t.products.map(e=>e.productId),n=st(a);n.length&&e.diagnostics.push(nt("error","duplicate-product","Split product ids must be unique.",r+".products",n));let s=a.map(t=>e.productDefinitions.get(t)),l=a.filter((e,t)=>!s[t]),c=a.filter(e=>o.products[e]);l.length&&e.diagnostics.push(nt("error","unknown-product",`Split references undeclared product molds: ${l.join(", ")}.`,r+".products",l)),c.length&&e.diagnostics.push(nt("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,r+".products",c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||0>o.amount)&&e.diagnostics.push(nt("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...lt(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!mt(e,u.amount,u.metrics,t.loss,r+".loss"))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??s[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(nt("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",r+".products"));let p=f?h:t.products.map(()=>d/t.products.length),g=p.reduce((e,t)=>e+t,0);if(Math.abs(g-d)>zx)return void e.diagnostics.push(nt("error","split-amount-mismatch",`Split allocations total ${g}, but ${d} remains after loss.`,r+".products"));let y=it(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))y[e]=Number(y[e]??0)-i;let m=ht(e,t,{sourceIds:[u.id],productIds:a});if(t.products.forEach((i,a)=>{let n=s[a],l=d>zx?p[a]/d:1/t.products.length,c=et(Object.entries(y).map(([e,t])=>[e,t*l])),h=i.metrics??n.metrics??c,f=wt({...n,amount:p[a],metrics:h},[u.id],p[a],it(h),e,!0,m);pt(e,f.outletId,`${r}.products.${a}.productId`)&&(o.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=a,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),ft(e,{type:"split-source",sourceIds:[u.id],productIds:a});for(let t of a)ft(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){pt(e,t.outletId,r+".outletId");let i=dt(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let a=i.ids.filter(e=>o.components[e].productIds.length);if(a.length&&e.diagnostics.push(nt("error","source-already-assigned",`Assigned source components cannot be ejected: ${a.join(", ")}.`,r+".select",a)),e.diagnostics.some(e=>"error"===e.severity))return;let n=ht(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(n)}return o.history.push(n),void(i.ids.length&&ft(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...lt(t.metricsDelta,r+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,a;if("run"===t.target)ct(o.metrics,t.metricsDelta);else if("components"in t.target){let a=dt(o,t.target.components,r+".target.components");if(e.diagnostics.push(...a.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=a.ids;for(let e of a.ids)ct(o.components[e].metrics,t.metricsDelta)}else{a=[...t.target.productIds];let i=st(a),n=a.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(nt("error","duplicate-product","Metric target product ids must be unique.",r+".target.productIds",i)),n.length&&e.diagnostics.push(nt("error","unknown-product-state",`Metric target product has not formed: ${n.join(", ")}.`,r+".target.productIds",n)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of a)ct(o.products[e].metrics,t.metricsDelta)}return void o.history.push(ht(e,t,{sourceIds:i,productIds:a}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(ht(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(nt("error","invalid-outcome","Outcome must be a non-empty string.",r+".outcome"))}function Mt(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[nt("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};let r=ot(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(St(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function _t(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function Pt(e,t={}){let i=t.groupBy??"outlet",r=/* @__PURE__ */new Map,o=e=>{let t=_t({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void ct(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:it(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let a=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(a.get(e.key)??Number.MAX_SAFE_INTEGER)-(a.get(t.key)??Number.MAX_SAFE_INTEGER)||at(e.key,t.key))}function $t(e,t){return t>e?-1:e>t?1:0}function Lt(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function It(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort($t)}function Rt(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Tt(e,t,i,r,o,a){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push(Lt("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,a)),r}}function Ct(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Lt("error","invalid-metrics","Metrics must be a numeric object.",i)),et();let r=et();for(let[o,a]of Object.entries(e)){let e=Rt(a);null!=e?r[o]=e:t.push(Lt("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function Dt(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function zt(e){let t=[],i=et(),r=[],o=0,a=et();e.data.forEach((n,s)=>{let l=(n.id??"component-"+s)+"",c=((Tt(n,s,e.idAccessor,l,t,`data.${s}.id`)??l)+"").trim();if(!c)return void t.push(Lt("error","invalid-component-id","Component ids may not be empty.",`data.${s}.id`));r.push(c);let u=Rt(Tt(n,s,e.amountAccessor,1,t,`data.${s}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Lt("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${s}.amount`,[c]));let h=Ct(Tt(n,s,e.metricsAccessor,{},t,`data.${s}.metrics`),t,`data.${s}.metrics`),f=Tt(n,s,e.initialStateAccessor,"active",t,`data.${s}.status`),p=Ox.has(f)?f:"active";Ox.has(f)||t.push(Lt("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${s}.status`,[c]));let g=Tt(n,s,e.labelAccessor,(n.label??n.name??c)+"",t,`data.${s}.label`)+"",y=Tt(n,s,e.categoryAccessor,"component",t,`data.${s}.category`)+"";Object.hasOwn(i,c)||(i[c]={id:c,label:g,category:y,datum:n,status:p,initialAmount:d,amount:d,initialMetrics:tt(h),metrics:tt(h),productIds:[],history:[]},o+=d,Dt(a,h))});let n=It(r);n.length&&t.push(Lt("error","duplicate-component-id",`Component ids must be unique: ${n.join(", ")}.`,"data",n));let s=Ct(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:et(),relations:et(),input:{amount:o,metrics:a},metrics:s,loss:{amount:0,metrics:et()},history:[]},diagnostics:t}}function Et(e){let t=[];e.length||t.push(Lt("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=It(e.map(e=>e.id));i.length&&t.push(Lt("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=Rt(e.duration),a=null!=o&&o>0?o:0;e.id.trim()||t.push(Lt("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||0>=o)&&t.push(Lt("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push(Lt("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let n={...e,duration:a,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+a};return r=n.end,n}),diagnostics:t}}function Nt(e,t,i){let r=e.find(e=>Fx>=Math.abs(e.start-i));if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:Fx>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Ot(e,t,i){let r=[],o=It(e.map(e=>e.id));o.length&&r.push(Lt("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let a=[];return e.forEach((e,o)=>{let n,s,l;if(e.id.trim()||r.push(Lt("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let a=Rt(e.at.time);if(null==a||0>a||a>i+Fx)return void r.push(Lt("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));n=Math.max(0,Math.min(i,a));let c=Nt(t,i,n);s=c.phase,l=c.boundaryRank}else{if(s=t.find(t=>t.id===e.at.phaseId),!s)return void r.push(Lt("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void r.push(Lt("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));n=s.start+s.duration*i,l=0===i?1:0}s?a.push({...e,index:o,authoredAt:n,phaseId:s.id,phaseIndex:s.index,boundaryRank:l}):r.push(Lt("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),a.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:a,diagnostics:r}}function Ft(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=It(t.map(e=>e.id)),a=It(e.map(e=>e.id));return o.length&&i.push(Lt("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),a.length&&i.push(Lt("error","duplicate-product-id",`Product ids must be unique: ${a.join(", ")}.`,"products",a)),t.forEach((e,t)=>{e.id.trim()||i.push(Lt("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push(Lt("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Lt("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||0>e.amount)&&i.push(Lt("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push(Lt("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Ct(e.metrics??{},i,`products.${t}.metrics`)}),i}function Wt(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function jt(e=Ex,t=Nx){let i=Math.max(1,Rt(e[0])??900),r=Math.max(1,Rt(e[1])??520),o=360>i||260>r,a=o?Math.max(4,.035*Math.min(i,r)):20,n=o?Math.max(10,.075*r):34,s={x:a,y:a,width:Math.max(1,i-2*a),height:n},l=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:a,y:r-a-l,width:Math.max(1,i-2*a),height:l},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=s.y+s.height+(o?12:38),h=c.y-(o?10:34),f={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,o?84:180)),g={x:f.x+(f.width-p)/2,y:f.y-(o?10:24),width:p,height:o?12:28},y=Wt(t),m={left:y.filter(e=>"left"===(e.side??"bottom")),right:y.filter(e=>"right"===e.side),bottom:y.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{let r=Math.max(8,u-1.5*a),n=f.height/Math.max(1,t.length);t.forEach((t,s)=>{x.push({...t,side:e,x:"left"===e?a:i-a-r,y:f.y+s*n,width:r,height:Math.max(8,n-(o?2:8))})})};b("left",m.left),b("right",m.right);let v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-f.y-f.height-(o?4:12))})}),x.sort((e,t)=>y.findIndex(t=>t.id===e.id)-y.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:s,chamber:f,mouth:g,projection:c,outlets:x}}function Bt(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+Fx).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],a=e;for(let[e,t]of r)e>a+Fx&&o.push([a,e]),a=Math.max(a,t);return t>a+Fx&&o.push([a,t]),o}function Yt(e){let{id:t,orientation:i,fixed:r,start:o,end:a,openings:n,thickness:s,friction:l,restitution:c}=e,u=Bt(o,a,n);return u.map(([e,o],a)=>({id:1===u.length?t:`${t}:${a}`,friction:l,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:s}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:s}}))}function Xt(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),a=Math.min(t.x+t.width,i.x+i.width),n={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},s=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:a,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];s.push(...Yt({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:n.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Yt({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:n.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Yt({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:n.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)s.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return s}function Gt(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function Vt(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?Gt(e):1}function qt(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ht(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Vt(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function Ut(e){return"crucible:component:"+encodeURIComponent(e)}function Zt(e){return"crucible:product:"+encodeURIComponent(e)}function Kt(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let o=Math.min(...t,e),a=Math.max(...t,e);return a-o>Fx?r[0]+(r[1]-r[0])*Math.sqrt(Math.max(0,e-o)/(a-o)):(r[0]+r[1])/2}function Qt(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,a=Math.max(1,Math.min(r,o));return[a,Math.max(a,Math.max(r,o))]}function Jt(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>$t(e.id,t.id)),o=r.map(e=>e.amount),a=Qt(i.radiusRange,t),n=qt(Vt(i.seed)),s=t.mouth.x+t.mouth.width/2,l=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(n()-.5),h=Kt(e.amount,o,i.bodyRadius,a),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Ut(e.id),x:s+Math.cos(d)*c*(.45+.45*n()),y:l+Math.sin(d)*u*(.45+.45*n()),vx:24*(n()-.5),vy:18*(n()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}function ei(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function ti(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function ii(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function ri(e,t){let i=/* @__PURE__ */new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=/* @__PURE__ */new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||$t(e.id,t.id));let i=ei(o.length,ii(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}function oi(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>$t(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>$t(e.id,t.id)),a=[...o.map(e=>e.amount),...r.map(e=>e.amount)],n=Qt(i.radiusRange,t),s=ri(r,t),l=r.map(e=>{let r=s.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*Kt(e.amount,a,i.bodyRadius,n),l={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:Zt(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:l}}),c=/* @__PURE__ */new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=ti(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=/* @__PURE__ */new Map;for(let[e,i]of c){let r=ei(i.length,ii(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>s.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=Gt(e.id)/4294967295*Math.PI*2,a=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*a,y:r.y+Math.sin(o)*a}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=Kt(e.amount,a,i.bodyRadius,n),l={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Ut(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:l}}),...l]}function ai(e){return Array.isArray(e)?e.map(ai):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>$t(e,t)).map(([e,t])=>[e,ai(t)])):e}function ni(e){return JSON.stringify(ai(e))}function si(e,t){let i=Rt(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-Fx,a=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&e.end>r)??e.phases[0];return{elapsed:r,phaseId:a.id,phaseIndex:a.index,phaseElapsed:o?a.duration:Math.max(0,r-a.start),complete:o}}function li(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Rt(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,Rt(t.progress??0)??0));return i.start+i.duration*r}function ci(e,t=e.duration){let i=si(e,t),r=ot(e.initialState),o=[],a=[],n=[];for(let t of e.events){if(t.authoredAt>i.elapsed+Fx)break;let s=Mt(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...s.diagnostics),a.push(...s.materializations),n.push(...s.observations),s.applied&&(r=s.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:a,observations:n}}function ui(e){let t=Et(e.phases),i=t.phases.at(-1)?.end??0,r=Wt(e.outlets??Nx),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?tt(e.metrics):void 0})),a=Ot(e.events??[],t.phases,i),n=zt(e),s=jt(e.size??Ex,r),l=Xt(s),c=Ft(o,r),u=ni({seed:e.seed??1,components:Object.values(n.state.components).sort((e,t)=>$t(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:a,color:n,metrics:s})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:a,color:n,metrics:s})),products:o,outlets:r,events:a.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:a,boundaryRank:n,effects:s})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:a,boundaryRank:n,effects:s}))}),d=Jt(n.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...a.diagnostics,...n.diagnostics,...c],f={phases:t.phases,events:a.events,products:o,outlets:r,duration:i,initialState:n.state,terminalState:n.state,layout:s,colliders:l,config:Ht(e.seed,l),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},p=ci(f),g=Object.values(p.state.products).filter(e=>"forming"===e.status).map(e=>e.id),y=g.length?[Lt("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return f.terminalState=p.state,f.terminalSpawns=Wx(p.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...h,...p.diagnostics,...y],f}function di(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function hi(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function fi(e,t){let i=2166136261,r=hi(t);for(let e=0;r.length>e;e++)i^=r.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}function pi(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:a=6,angle:n=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*a));/* @__PURE__ */
|
|
2
|
+
return Yx("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */Bx("rect",{width:l,height:l,fill:i}),
|
|
3
|
+
/* @__PURE__ */Bx("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),
|
|
4
|
+
/* @__PURE__ */Bx("line",{x1:a,y1:0,x2:a,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function gi(e,t,i="#4e79a7"){if(di(e)){let i=fi(t,e);return{fill:`url(#${i})`,def:pi(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function yi(e,t,i,r){if(!e||"object"!=typeof e)return;let o=e;if(!Array.isArray(o.stops))return;let a=o.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:i,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof i&&i?i:r,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);if(!a.length)return;let n="horizontal"===o.direction?"horizontal":"vertical"===o.direction?"vertical":i,s=t+"-gradient";return{fill:`url(#${s})`,def:/* @__PURE__ */Bx("linearGradient",{id:s,x1:0,y1:0,x2:"horizontal"===n?"100%":0,y2:"vertical"===n?"100%":0,children:a.map((e,t)=>/* @__PURE__ */Bx("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},s)}}function mi(e){switch(e){case"monotoneX":return Xx;case"monotoneY":return Gx;case"cardinal":return Vx;case"catmullRom":return qx;case"step":return Hx;case"stepBefore":return Ux;case"stepAfter":return Zx;case"basis":return Kx;case"natural":return Qx;default:return null}}function xi(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function bi(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let a="circle"===e.shape.type?e.shape.radius:8,n="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",s="string"==typeof t.stroke?t.stroke:"#26323a",l="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:"crucible-body-"+i;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*a},${e.y+Math.sin(r)*a}`}).join(" "),i=u+"-glow";/* @__PURE__ */
|
|
5
|
+
return eb(jx.Fragment,{children:[
|
|
6
|
+
/* @__PURE__ */Jx("defs",{children:/* @__PURE__ */Jx("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:/* @__PURE__ */Jx("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:n,floodOpacity:"0.8"})})}),
|
|
7
|
+
/* @__PURE__ */Jx("polygon",{points:t,fill:n,stroke:s,strokeWidth:l,opacity:c,filter:`url(#${i})`}),
|
|
8
|
+
/* @__PURE__ */Jx("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*a),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:l,opacity:.72*c})]},u)}/* @__PURE__ */
|
|
9
|
+
return eb(jx.Fragment,{children:[
|
|
10
|
+
/* @__PURE__ */Jx("circle",{cx:e.x,cy:e.y,r:a,fill:n,stroke:s,strokeWidth:l,opacity:c}),
|
|
11
|
+
/* @__PURE__ */Jx("circle",{cx:e.x-.25*a,cy:e.y-.28*a,r:Math.max(1,.18*a),fill:"rgba(255,255,255,0.34)"})]},u)}function vi(e){let{x:t,y:i,width:r,height:o}=e.chamber,a=Math.min(.14*r,48),n=i+o;return[`M ${t} ${i}`,`L ${t+a} ${n-.16*o}`,`Q ${t+r/2} ${n+.1*o} ${t+r-a} ${n-.16*o}`,`L ${t+r} ${i}`].join(" ")}function wi({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));/* @__PURE__ */
|
|
12
|
+
return rb("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[
|
|
13
|
+
/* @__PURE__ */rb("defs",{children:[
|
|
14
|
+
/* @__PURE__ */rb("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[
|
|
15
|
+
/* @__PURE__ */ib("stop",{offset:"0",stopColor:nb,stopOpacity:"0.03"}),
|
|
16
|
+
/* @__PURE__ */ib("stop",{offset:"0.66",stopColor:nb,stopOpacity:"0.1"}),
|
|
17
|
+
/* @__PURE__ */ib("stop",{offset:"1",stopColor:sb,stopOpacity:"0.18"})]}),
|
|
18
|
+
/* @__PURE__ */ib("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:/* @__PURE__ */ib("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:ob,strokeOpacity:"0.08",strokeWidth:"1"})})]}),
|
|
19
|
+
/* @__PURE__ */ib("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:ob,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),
|
|
20
|
+
/* @__PURE__ */ib("path",{d:vi(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
|
|
21
|
+
/* @__PURE__ */ib("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:ob,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:/* @__PURE__ */ib("g",{"data-testid":"crucible-phase-rail",children:t.map((r,a)=>{let n=t.slice(0,a).reduce((e,t)=>e+Math.max(0,t.duration),0),s=e.phaseRail.x+n/o*e.phaseRail.width,l=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>a||i.complete;/* @__PURE__ */
|
|
22
|
+
return rb("g",{children:[
|
|
23
|
+
/* @__PURE__ */ib("rect",{x:s,y:e.phaseRail.y,width:Math.max(1,l-2),height:e.phaseRail.height,rx:2,fill:c?r.color??nb:u?lb:ob,fillOpacity:c?.68:u?.28:.09}),46>l?null:/* @__PURE__ */ib("text",{x:s+l/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?ob:ab,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()})]},r.id)})}),e.outlets.map(e=>/* @__PURE__ */rb("g",{children:[
|
|
24
|
+
/* @__PURE__ */ib("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?sb:lb),fillOpacity:"0.1",stroke:e.color??("left"===e.side?sb:lb),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:/* @__PURE__ */ib("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:ab,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function ki(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Ai({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",a=e.map(e=>Math.max(0,ki(e,o))),n=Math.max(1,...a),s=t.projection.width/Math.max(1,e.length),l=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-l-5);/* @__PURE__ */
|
|
25
|
+
return ib("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=a[i],d=Math.max(u>0?2:0,u/n*c),h=t.projection.x+i*s+.18*s;/* @__PURE__ */
|
|
26
|
+
return rb("g",{children:[
|
|
27
|
+
/* @__PURE__ */ib("rect",{x:h,y:t.projection.y+c-d,width:Math.max(3,.64*s),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?sb:"complete"===e.status?nb:lb,fillOpacity:"0.68"}),l>4&&s>=34?/* @__PURE__ */rb(tb,{children:[
|
|
28
|
+
/* @__PURE__ */ib("text",{x:h+.32*s,y:t.projection.y+c+10,fill:ab,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),
|
|
29
|
+
/* @__PURE__ */rb("text",{x:h+.32*s,y:t.projection.y+c+19,fill:ob,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[xi(u),"amount"===o&&r?" "+r:""]})]}):null]},e.key)})})}function Si(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Mi(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=/* @__PURE__ */new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let a=e.map(e=>{let i=o.get(e.id)??[],a=Math.max(0,Math.floor(e.count??i.length)),n=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??Si(e),datum:e.datum}));return{id:e.id,label:e.label,count:a,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:n,metadata:e.metadata}}),n=a.reduce((e,t)=>e+t.count,0);return a.map(e=>({...e,share:n>0?e.count/n:0}))}function _i(e){if(!e)return zy;if("string"==typeof e)return"light"===e?zy:"dark"===e?Ey:"high-contrast"===e?Ny:Wy(e)||zy;let t="dark"===e.mode?Ey:zy,i={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Fy(i)}function Pi(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,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function $i(e,t,i,r,o){let a=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==a.length)return({size:o})=>{let n=[Number(o[0])||700,Number(o[1])||420],s=my(n),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==i,[f,p]=r?.valueExtent??[0,l],g=p===f?1:p-f,y=e.map((e,t)=>{let i=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${(s.plot.x+(t+.5)*c).toFixed(1)} ${i.toFixed(1)}`}).join(" ");/* @__PURE__ */
|
|
30
|
+
return db("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?/* @__PURE__ */db(cb,{children:[Array.from({length:l+1},(e,t)=>{let i=s.plot.x+t*c;/* @__PURE__ */
|
|
31
|
+
return ub("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),
|
|
32
|
+
/* @__PURE__ */ub("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
|
|
33
|
+
/* @__PURE__ */ub("path",{d:y,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?/* @__PURE__ */ub("text",{x:s.plot.x+(t+.5)*c,y:Math.max(s.plot.y+10,u-e.value/d*s.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,a.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=s.plot.x+Math.max(0,Math.min(1,(i-f)/g))*s.plot.width,o=e.color??"var(--semiotic-warning, #f28e2b)",a="bottom"===e.labelPosition?Math.min(n[1]-8,u+16):s.plot.y+16;/* @__PURE__ */
|
|
34
|
+
return db("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[
|
|
35
|
+
/* @__PURE__ */ub("line",{x1:r,x2:r,y1:s.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:/* @__PURE__ */ub("text",{x:Math.min(s.plot.x+s.plot.width-4,r+6),y:a,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function Li(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=my(r),a=Math.max(1,t.windowCount),n=t.plot??o.plot,s=t.gutter??{x:n.x,y:n.y,width:0,height:n.height},l=t.windowPlot??n,c=l.width/a,u=n.y+n.height,d=n.y+.48*n.height,h=t.lidSegments[0]?.y1??d,f=t.windowStart,p=t.windowStart+a*t.windowSize,g=l.x+Math.max(0,Math.min(1,p===f?0:(t.watermarkValue-f)/(p-f)))*l.width;/* @__PURE__ */
|
|
36
|
+
return db("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
37
|
+
/* @__PURE__ */ub("rect",{x:n.x,y:n.y,width:n.width,height:n.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?/* @__PURE__ */db("g",{children:[
|
|
38
|
+
/* @__PURE__ */ub("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),
|
|
39
|
+
/* @__PURE__ */db("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:a},(i,o)=>{let a=e[o],n=l.x+o*c,s=t.closedWindowCount>o;/* @__PURE__ */
|
|
40
|
+
return db("g",{children:[
|
|
41
|
+
/* @__PURE__ */ub("rect",{x:n,y:d,width:c,height:u-d,fill:s?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:s?.08:.06}),s?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>/* @__PURE__ */ub("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,
|
|
42
|
+
/* @__PURE__ */ub("text",{x:n+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:a?.value??0}),
|
|
43
|
+
/* @__PURE__ */ub("text",{x:n+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:a?.label??""})]},"window-"+o)}),t.windowWalls?.map(({id:e,...t})=>/* @__PURE__ */ub("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>/* @__PURE__ */ub("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),
|
|
44
|
+
/* @__PURE__ */ub("line",{x1:n.x,x2:n.x+n.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
|
|
45
|
+
/* @__PURE__ */ub("line",{"data-testid":"event-drop-watermark",x1:g,x2:g,y1:n.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),
|
|
46
|
+
/* @__PURE__ */db("text",{x:Math.min(n.x+n.width-4,g+6),y:n.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Ii(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],a=my(o),n=ae(a.plot,e.length,t),s=a.plot.y+a.plot.height;/* @__PURE__ */
|
|
47
|
+
return db("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
48
|
+
/* @__PURE__ */ub("line",{x1:a.plot.x,x2:a.plot.x+a.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(a.plot.height,n.pileHeight(e.value/r)),l=n.tubeWidth,c=n.centerX(t),u=s-i;/* @__PURE__ */
|
|
49
|
+
return db("g",{children:[
|
|
50
|
+
/* @__PURE__ */ub("rect",{x:c-l/2,y:u,width:l,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),
|
|
51
|
+
/* @__PURE__ */ub("text",{x:c,y:Math.max(a.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),
|
|
52
|
+
/* @__PURE__ */ub("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),
|
|
53
|
+
/* @__PURE__ */ub("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function Ri(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Ti(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=my(i),o=r.plot.y+r.plot.height,[a,n]=e.xExtent,s=a+(n-a)/2,l=[{label:Ri(a),x:e.xRange[0]},{label:Ri(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Ri(n),x:e.xRange[1]}];/* @__PURE__ */
|
|
54
|
+
return db("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?/* @__PURE__ */ub("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>i[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>/* @__PURE__ */db("g",{children:[
|
|
55
|
+
/* @__PURE__ */ub("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),
|
|
56
|
+
/* @__PURE__ */ub("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),
|
|
57
|
+
/* @__PURE__ */db("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),
|
|
58
|
+
/* @__PURE__ */ub("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>/* @__PURE__ */db("g",{children:[
|
|
59
|
+
/* @__PURE__ */ub("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),
|
|
60
|
+
/* @__PURE__ */ub("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function Ci(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:a,groups:n,groupCompletion:s}=e,l=new Map(o.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,s=Number(e[1])||o.height,u=a.map(e=>{let t=l.get(e.id),r=i["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=n.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return fm({width:t,height:s,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function Di(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],a=my(o),n=Math.max(1,...e.map(e=>e.value)),s=Math.min(48,.18*a.plot.height),l=a.plot.y+6;/* @__PURE__ */
|
|
61
|
+
return hb("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let a=r.get(t.id);if(!a)return null;let c=Math.max(2,o.value/n*s),u=Math.max(8,.35*a.width);/* @__PURE__ */
|
|
62
|
+
return hb("rect",{x:a.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function zi(e){return e.toLocaleString(void 0,1e3>Math.abs(e)?{maximumFractionDigits:1}:{maximumFractionDigits:0})}function Ei(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function Ni(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let a=[Number(t[0])||760,Number(t[1])||420],n=Math.max(1,...e.links.map(e=>e.throughput)),s=new Set(e.nodes.map(e=>e.sensorId));/* @__PURE__ */
|
|
63
|
+
return pb("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/n*16,i=e.path[Math.floor(e.path.length/2)];/* @__PURE__ */
|
|
64
|
+
return pb("g",{children:[
|
|
65
|
+
/* @__PURE__ */fb("path",{d:Ei(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
|
|
66
|
+
/* @__PURE__ */fb("path",{d:Ei(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */fb("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:zi(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>/* @__PURE__ */pb("g",{children:[r&&s.has(e.sensorId)?/* @__PURE__ */fb("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?/* @__PURE__ */fb("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?/* @__PURE__ */fb("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}function Oi({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);/* @__PURE__ */
|
|
67
|
+
return yb(gb,{children:e.gates.map(a=>/* @__PURE__ */mb("g",{children:[
|
|
68
|
+
/* @__PURE__ */yb("rect",{x:a.x-a.width/2,y:r,width:a.width,height:o,rx:t?2:12,fill:a.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:a.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?/* @__PURE__ */yb("text",{x:a.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:a.label??a.id}):null]},a.id))})}function Fi({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */yb("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */yb(Oi,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */mb("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
69
|
+
/* @__PURE__ */yb("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-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),
|
|
70
|
+
/* @__PURE__ */yb("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),
|
|
71
|
+
/* @__PURE__ */yb("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),
|
|
72
|
+
/* @__PURE__ */yb(Oi,{layout:e,compact:!1,showLabels:!0}),
|
|
73
|
+
/* @__PURE__ */mb("g",{children:[
|
|
74
|
+
/* @__PURE__ */yb("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),
|
|
75
|
+
/* @__PURE__ */yb("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),
|
|
76
|
+
/* @__PURE__ */mb("g",{children:[
|
|
77
|
+
/* @__PURE__ */yb("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),
|
|
78
|
+
/* @__PURE__ */yb("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),
|
|
79
|
+
/* @__PURE__ */yb("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 Wi(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function ji({states:e,layout:t}){let i=Wi(e);if(!i.length)return null;let r=Math.max(1,...i.map(e=>e.value)),o=Math.max(40,(t.width-80)/i.length);/* @__PURE__ */
|
|
80
|
+
return mb("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:[
|
|
81
|
+
/* @__PURE__ */yb("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,a=Math.max(2,e.value/r*28),n=/kill|crash|block|grave/i.test(e.outcome);/* @__PURE__ */
|
|
82
|
+
return mb("g",{children:[
|
|
83
|
+
/* @__PURE__ */yb("rect",{x:i+.18*o,y:28-a+22,width:Math.max(10,.45*o),height:a,rx:2,fill:n?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:n?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),
|
|
84
|
+
/* @__PURE__ */yb("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function Bi(e,t){return e?"sparkline"===t?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}}function Yi(e){return e.map(e=>({...e,spawnAt:void 0}))}function Xi(e,t){return e?t?i=>tx.createElement(tx.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function Gi(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}function Vi(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return bb[(t>>>0)%bb.length]}function qi(e,t,i,r){let o=e.datum,a={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...a,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...a,fill:r.color??e?.color??Vi(e?.id??o.semanticId)}}let n,s=t.components[o.semanticId];return s?(n="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:"function"==typeof i?(i(s.datum)??"unassigned")+"":(s.datum[i+""]??"unassigned")+"",{...a,fill:r.color??Vi(n)}):{...a,fill:r.color??"#356b63"}}function Hi(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}function Ui(e){return e&&{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}}function Zi(e,t){let i=/* @__PURE__ */new Set,r=[t];for(;r.length;){let t=r.pop();if(i.has(t))continue;i.add(t);let o=e.children[t];Array.isArray(o)&&r.push(...o)}return i}function Ki(e,t){let i=[],r=e.requiredChildren[t],o=Array.isArray(r)?[...r]:[];for(;o.length;){let t=o.pop();i.push(t),o.push(...e.requiredChildren[t])}return i.sort()}function Qi(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||360>t||300>i)throw Error("Circuit geometry needs at least 360 × 300 pixels");let r=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&r.push("Unsectioned");let o=om({width:t,height:i-110,padX:22,padY:70,stages:r.map(e=>({id:e})),shape:"lane"}),a=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),n=o.stages.flatMap(t=>{let r=e.order.filter(e=>a.get(e)===t.id),o=(i-235)/Math.max(1,r.length);if(r.length&&78>o)throw Error("Increase circuit height to keep every module readable");return r.map((i,r)=>{let a=e.modules.find(e=>e.nodeId===i),n=Math.max(68,Math.min(142,t.width-56)),s=Math.min(68,o-10),l=t.x-n/2,c=95+(r+.5)*o-s/2;return{module:a,x:l,y:c,width:n,height:s,queue:{x:l+8,y:c+s-8,width:n-16,height:4},sensor:{x:l+n-5,y:c+s/2-4,width:8,height:8}}})}),s=new Map(n.map(e=>[e.module.nodeId,e])),l=new Set(e.residualEdgeIds),c=0,u=e.atlas.source.edges.map(e=>{let t,i=s.get(e.source),o=s.get(e.target),n=o.x>i.x,u=o.x===i.x,d=(t,i)=>{let r=t.module.ports.filter(e=>e.direction===i),o=r.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/r.length},h={x:i.x+(n||u?i.width:0),y:d(i,"out")},f={x:o.x+(n?0:o.width),y:d(o,"in")};if(u){let r=h.x+18+5*c++;t=e.source===e.target?[h,{x:r,y:h.y},{x:r,y:i.y-15},{x:f.x-8,y:i.y-15},{x:f.x-8,y:i.y}]:[h,{x:r,y:h.y},{x:r,y:f.y},f]}else if(!n||Math.abs(r.indexOf(a.get(e.source))-r.indexOf(a.get(e.target)))>1){let e=n?1:-1,i=62+7*c++;t=[h,{x:h.x+16*e,y:h.y},{x:h.x+16*e,y:i},{x:f.x-16*e,y:i},{x:f.x-16*e,y:f.y},f]}else{let e=(h.x+f.x)/2;t=[h,{x:e,y:h.y},{x:e,y:f.y},f]}return{edgeId:e.id,source:e.source,target:e.target,residual:l.has(e.id),points:t,pathD:Ei(t)}});return{width:t,height:i,modules:n,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}function Ji(e,t){let i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),r=i.reduce((e,t)=>e+t,0),o=Math.max(0,Math.min(1,t))*r;for(let t=0;i.length>t;t++){if(i[t]>=o){let r=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*r,y:e[t].y+(e[t+1].y-e[t].y)*r}}o-=i[t]}return e[e.length-1]}function er(e,t={}){return{observed:t.observed??e.info??e.primary??"#387e98",modeled:t.modeled??e.secondary??"#946344",residual:t.residual??e.warning??"#a56537",muted:t.muted??e.textSecondary??Db.muted,alarm:t.alarm??e.danger??Db.alarm}}function tr(e,t,i,r,o,a=Db,n){let s=Object.values(t.entry.nodes).map(e=>e.queued??0),l=Math.max(1,...s);return e.modules.map(e=>{let{module:s,x:c,y:u,width:d,height:h,queue:f}=e,p=t.entry.nodes[s.nodeId],g=o===s.nodeId?i:(p.queued??0)>0?a.alarm:a.muted,y=c+d/2,m="records"===s.semantics.unit?"rec":"attempts"===s.semantics.unit?"att":"roots",x=null!==p.capacity?`${zb(p.completions)} / ${zb(p.capacity)} ${m}/s`:null!==p.completions?`${zb(p.completions)} ${m}/s complete`:`${zb(p.arrivals)} ${m}/s offered`;return Cb("g",{key:s.id,"data-circuit-module":s.nodeId,"data-module-kind":s.kind,opacity:n?.(s.nodeId),"data-queued":p.queued??"unmeasured"},Cb("rect",{x:c,y:u,width:d,height:h,fill:"none",stroke:g,strokeWidth:o===s.nodeId?2.5:1}),Cb("path",{d:Eb[s.kind],transform:`translate(${c+10},${u+12})`,stroke:g,fill:"none",strokeWidth:1.4}),Cb("text",{x:y+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:r},s.semantics.label),Cb("text",{x:y,y:u+28,textAnchor:"middle",fontSize:8,fill:r},Nb[s.kind]),Cb("text",{x:y,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:r},x),Cb("text",{x:y,y:u+h-13,textAnchor:"middle",fontSize:8,fill:r},"Queue "+zb(p.queued)),null!==p.queued?Cb("rect",{...f,width:f.width*p.queued/l,fill:g,"data-circuit-gauge":"queue"}):null,Cb("rect",{...e.sensor,fill:i,"data-circuit-sensor":s.nodeId}),s.semantics.dependencyNodeIds?.length?Cb("text",{x:y,y:u-8,fontSize:8,textAnchor:"middle",fill:r,"data-circuit-dependency":s.nodeId},"Requires "+s.semantics.dependencyNodeIds.join(", ")):null)})}function ir(e,t,i,r,o,a){let{history:n}=e,s=e.modules.find(e=>e.module.nodeId===a)?.module,l="records"===t.unit?"queued":"attempts",c=t.entries.map(e=>s?e.nodes[s.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[l]),u=Math.max(1,...c.map(e=>e??0)),d=t.entries[0].at,h=t.entries[t.entries.length-1].at,f=e=>n.x+(e-d)/Math.max(1,h-d)*n.width,p="",g=!1;for(let[e,i]of t.entries.entries()){if(null===c[e]){g=!1;continue}let t=n.y+n.height-c[e]/u*n.height;p+=`${g?" H":"M"}${f(i.at)}${g?" V"+t:","+t}`,g=!0}return Cb("g",{"data-circuit-history":l,"data-history-module":s?.nodeId},Cb("text",{x:n.x,y:n.y-9,fill:o,fontSize:10},s?`${s.semantics.label} · ${"queued"===l?"queued "+s.semantics.unit:`offered ${s.semantics.unit}/s`} · aggregate observations`:"queued"===l?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),Cb("path",{d:p,fill:"none",stroke:r,strokeWidth:2}),Cb("line",{x1:f(i.observedAt),x2:f(i.observedAt),y1:n.y,y2:n.y+n.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>Cb("text",{key:e.id,x:f(e.at),y:n.y+n.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function rr(e,t,i,r){return{id:r.nodeId,nodeId:r.nodeId,kind:"circuit-module",moduleKind:r.kind,label:r.semantics.label,unit:r.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[r.nodeId]}}function or(e,t,i,r){return[...t.modules.map(t=>{let o=rr(e,i,r,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${r.observedAt}s. Arrivals ${Ob(o.arrivals)} ${o.unit}/s; completions ${Ob(o.completions)} ${o.unit}/s; installed capacity ${Ob(o.capacity)} ${o.unit}/s; queue ${Ob(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{let o=r.entry.flows.find(e=>e.edgeId===t.edgeId),a=t.points[Math.floor(t.points.length/2)];return{id:"pipe:"+t.edgeId,x:a.x,y:a.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${Ob(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${r.observedAt}s; transferred volume ${Ob(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:r.observedAt,...o}}})]}function ar(e,t,i,r){return{frameType:e.frameType,layout:{...e.layout,primarySize:{width:i[0],height:i[1]},...r&&{margin:r}},buildProps:(i,r,o,a,n)=>{let[s,l]=a.size,c=t({...n,...a,width:s,height:l,colorScheme:o});return e.buildProps(c.data,r,o,{...a,title:c.title,description:c.description,summary:c.summary,accessibleTable:c.accessibleTable},{...n,...c})}}}function nr(e,t,i){let r="function"==typeof t?t(e):e[(t??i)+""];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function sr({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,a=void 0!==t[0]?.[r];if(!a&&!i)return t;if(a)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],a=o+"";if(!e[a]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[a]=t}return e[a][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}function lr(e){if(!e)return Vb;let t=!1;for(let i=0;e.length>i;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function cr(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function ur(e,t){if(!cr(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function dr(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:a,fillArea:n,areaOpacity:s=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},f=!0===n||Array.isArray(n)&&null!=u&&n.includes(u);return a?d=a(e,u):i?r&&(d=_e(e,i,r)):d=o||Ix,void 0!==d&&(h.stroke=d,f&&(h.fill=d,h.fillOpacity=s)),l?.length&&Object.assign(h,Gy(e,l,c?c(e,u):{value:void 0,category:u})),h}}function hr(e,t,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),a=[],n=0,s=null,l=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${n}-${e}`,h=e=>a.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;o.length>e;e++){let a=o[e],p=t(a),g=i(a),y=r(a);if(!Number.isFinite(p)||!Number.isFinite(g)||!Number.isFinite(y))continue;let m=u(g,y);if(null!==m){if(null==s){s=m;for(let e of c)f(e,s);c=[],h({__x:p,__y:y>g?y:g,__y0:y>g?g:y,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:y,__sourceDatum:a}),l={x:p,a:g,b:y,w:m};continue}if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=g-l.a-(y-l.b);if(0!==i){let r=Math.max(0,Math.min(1,(l.b-l.a)/i));e=l.x+r*(p-l.x),t=l.a+r*(g-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),n++,s=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;c.length>e;e++)f(c[e],s)}else for(let e of c)f(e,s);c=[],h({__x:p,__y:y>g?y:g,__y0:y>g?g:y,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:y,__sourceDatum:a}),l={x:p,a:g,b:y,w:m}}else c.push({x:p,y:g,datum:a})}for(let e of c)f(e,s??"A");return a}function fr(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function pr(e,t){return Vy(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:fr(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function gr(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return pr(e=>({fill:"A"===fr(e)?t:i,stroke:"none",fillOpacity:r}),o)}function yr(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return pr(e=>({stroke:"A"===fr(e)?t:i,strokeWidth:r,fill:"none"}),o)}function mr(e,t=qb){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function xr(e){return e?mr(e):void 0}function br(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}function vr(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}function wr(e){return{stops:e.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}}function kr(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}function Ar(e,t,i){return"function"==typeof e?e(i):i[e||t]}function Sr(e){return e instanceof Date?e.getTime():Number(e)}function Mr(e,t){return px(1===t?.5:e/(t-1))}function _r(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function Pr(e,t){let i=kr(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function $r(e,t){if(!Array.isArray(e))return{data:e,orderMap:/* @__PURE__ */new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:Sr(Ar(t.orderAccessor,"order",e))-Sr(Ar(t.orderAccessor,"order",i))):e,a=/* @__PURE__ */new WeakMap,n=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=Sr(Ar(i,"x",e)),o=Sr(Ar(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n++}let s=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=Sr(Ar(i,"x",e)),o=Sr(Ar(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a.set(e,{idx:s++,total:n})}return{data:o,orderMap:a}}function Lr(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function Ir(e,t,i,r=!1){let o=g({axes:t,showAxes:i});return{...A(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function Rr(e,t,i="x",r="y"){let o="function"==typeof i?i:e=>e[i],a="function"==typeof r?r:e=>e[r],n="function"==typeof t.colorBy?t.colorBy:e=>e[t.colorBy],s=/* @__PURE__ */new Map;for(let i of e){let e=n(i)??(i.parentLine&&n(i.parentLine));if(null==e||e+""=="")continue;let r=e+"",a=s.get(r);(!a||("end"===t.position?Number(o(i))>Number(o(a)):Number(o(i))<Number(o(a))))&&s.set(r,i)}return[...s].map(([e,n])=>({type:"text",label:e,["string"==typeof i?i:"x"]:o(n),["string"==typeof r?r:"y"]:a(n),x:o(n),y:a(n),_directLabel:{id:e,position:t.position},color:t.color(e),fontSize:t.fontSize}))}function Tr(e=[]){let t=e.filter(e=>e._directLabel);return t.length?` Series endpoints: ${t.map(e=>`${e.label}: x ${e.x+""}, y ${e.y+""}`).join("; ")}.`:""}function Cr(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),a=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function Dr(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),a=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function zr(e){return Math.round(100*e)/100}function Er(e,t){let i=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;r+1>o;o++){let r=i[o][e];i[o][e]=i[o][t],i[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let a=e+1;r>a;a++)t+=i[a][e]*o[a];o[e]=(i[r][e]-t)/i[e][e]}return o}function Nr(e){let t=[0,0,0,0],i=0;for(let[r,o]of e)null!==o&&(i++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);let r=i*t[2]-t[0]*t[0],o=0===r?0:zr((i*t[3]-t[0]*t[1])/r),a=zr(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[zr(e),zr(o*e+a)]),equation:[o,a]}}function Or(e,t=2){let i=[],r=[],o=t+1;for(let t=0;o>t;t++){let a=0;for(let[i,r]of e)null!==r&&(a+=i**t*r);i.push(a);let n=[];for(let i=0;o>i;i++){let r=0;for(let[o,a]of e)null!==a&&(r+=o**(t+i));n.push(r)}r.push(n)}r.push(i);let a=Er(r,o).map(zr);return{points:e.map(([e])=>[zr(e),zr(a.reduce((t,i,r)=>t+i*e**r,0))]),equation:[...a].reverse()}}function Fr(e){let t=e.length,i=0,r=0,o=0,a=0;for(let[t,n]of e)i+=t,r+=n,o+=t*t,a+=t*n;let n=t*o-i*i;if(1e-12>Math.abs(n))return null;let s=(t*a-i*r)/n,l=(r-s*i)/t;return e=>l+s*e}function Wr(e,t){let i=e.length,r=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(i-2,1)),a=e.reduce((e,t)=>e+t[0],0)/i,n=e.reduce((e,t)=>e+(t[0]-a)**2,0);return{se:o,meanX:a,ssX:n}}function jr(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function Br(e,t,i,r){let o=t.uncertaintyOpacity,a=t.confidenceAccessor;if(!o&&!a)return;let n="object"==typeof o?o:{},s=n.min??.15,l=n.max??1;if(a){let t="function"==typeof a?a:e=>e[a];for(let i of e){let e=t(i);null!=e&&Number.isFinite(e)&&(i[Ub]=s+Math.max(0,Math.min(1,e))*(l-s))}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=Nm(u),f=h-d;e.forEach((e,t)=>{let i=c[t];Number.isFinite(i)&&(e[Ub]=l-(f>0?(i-d)/f:0)*(l-s))})}function Yr(e,t){return"function"==typeof t?t(e):!!e[t]}function Xr(e){return[{type:"anomaly-band",threshold:e.threshold??2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:e.bandOpacity??.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:e.anomalyRadius??6,label:e.label}]}function Gr(e,t,i,r,o){let{isTraining:a,isForecast:n,isAnomaly:s,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=r,g=e.map(e=>{let t="observed";return n&&Yr(e,n)?t="forecast":a&&Yr(e,a)&&(t="training"),{...e,[Hb]:t}}),y=r._groupBy,m=[];if(y){let e=/* @__PURE__ */new Map;for(let t of g){let i=t[y]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}let t=[];for(let[,i]of e)for(let e=0;i.length-1>e;e++)i[e][Hb]!==i[e+1][Hb]&&(t.push({...i[e+1],[Hb]:i[e][Hb]}),t.push({...i[e],[Hb]:i[e+1][Hb]}));m.push(...g,...t)}else for(let e=0;g.length>e;e++)m.push(g[e]),g.length-1>e&&g[e][Hb]!==g[e+1][Hb]&&(m.push({...g[e+1],[Hb]:g[e][Hb]}),m.push({...g[e],[Hb]:g[e+1][Hb]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[Hb]&&e.push({...t,[Hb]:"training-base"});m.unshift(...e)}let x=[];if(l&&c){let e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(let i of m)"function"==typeof l&&(i[e]=l(i)),"function"==typeof c&&(i[t]=c(i));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};Br(m.filter(e=>"forecast"===e[Hb]),r,e,t)}if(s){let e=r.anomalyStyle,t={type:"highlight",filter:e=>Yr(e,s)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return o&&x.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label}),{processedData:m,annotations:x}}function Vr(e,t,i,r,o){let{trainEnd:a,steps:n=10,confidence:s=.95,color:l="#6366f1",bandOpacity:c=.15,label:u}=r;if(null==a)return{processedData:e,annotations:[]};let d=[],h=[];for(let i of e)i[t]>a?h.push({...i,[Hb]:"observed"}):d.push({...i,[Hb]:"training"});let f=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),p=[],g=[];if(f.length>=3){let o=f.length,a=Fr(f);if(a){let{se:d,meanX:h,ssX:y}=Wr(f,a),m=jr(s),x=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),b=Fm(x),v=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;n>=e;e++){let r=b+e*v,n=a(r),s=d*Math.sqrt(1+1/o+(y>0?(r-h)**2/y:0))*m;g.push({[t]:r,[i]:n,[Hb]:"forecast",__forecastUpper:n+s,__forecastLower:n-s})}Br(g,r,e=>e.__forecastUpper,e=>e.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:l,fillOpacity:c,label:u})}}p.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&p.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label});let y=[];if(y.push(...d),d.length>0&&h.length>0&&y.push({...d[d.length-1],[Hb]:"observed"}),y.push(...h),g.length>0){let e=h.length>0?h[h.length-1]:d[d.length-1];e&&y.push({...e,[Hb]:"forecast"}),y.push(...g)}return{processedData:y,annotations:p}}function qr(e){return!!(e.isTraining||e.isForecast||e.isAnomaly||e.upperBounds||e.lowerBounds)}function Hr(e,t,i,r,o){return qr(r)?Gr(e,0,0,r,o):Vr(e,t,i,r,o)}function Ur(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",a=t.trainOpacity,n=t.forecastOpacity,s=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[Hb];if("training"===d){let e=u.stroke;return"darken"===s?e=Cr(u.stroke||"#666",.5):s&&(e=s),{...u,stroke:e,strokeDasharray:i,...l&&{strokeLinecap:l},...null!=a&&{strokeOpacity:a}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=Dr(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[Ub]??n;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}function Zr(e,t,i){let r="function"==typeof t,o="function"==typeof i,a=r?Zb:t,n=o?Kb:i;return r||o?{xKey:a,yKey:n,rows:e.map(e=>{let a={...e};return r&&(a[Zb]=t(e)),o&&(a[Kb]=i(e)),a})}:{rows:e,xKey:a,yKey:n}}function Kr(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function Qr(e,t,i,r,o){let a=/* @__PURE__ */new Map;for(let t of e){let e=o?(t[o]??"")+"":"__single";a.has(e)||a.set(e,[]),a.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of a)for(let o of t)Kr(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of a)for(let o of t)Kr(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let n=[],s="_gapSegment";for(let[e,t]of a){let o=0,a=[],l=()=>{if(0===a.length)return;let t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(let e of a)n.push({...e,[s]:t});a=[],o++};for(let e of t)Kr(e,i,r)?l():a.push(e);l()}return{rows:n,groupKey:s}}function Jr(e,t,i){let r=i.upperBounds,o=i.lowerBounds;if(!r&&!o)return;let a="function"==typeof r?r:"string"==typeof r?e=>e[r]:null,n="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,s=1/0,l=-1/0;for(let i of e){let e=Number(i[t]);if(Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e)),a){let e=a(i);null!=e&&Number.isFinite(e)&&(e>l&&(l=e),s>e&&(s=e))}if(n){let e=n(i);null!=e&&Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e))}}return Number.isFinite(s)&&Number.isFinite(l)?[s,l]:void 0}function eo(e,t,i,r,o,a,n,s){if(!t||!i)return{annotations:[]};let l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,d="function"==typeof i?i:e=>e[i],h=$e(e.map(e=>({__lbl:(d(e)??"")+""})),"__lbl",a??n),f=Rr(e,{position:c,fontSize:u,colorBy:i,color:e=>h?h(e):s||Ix},r,o),p=f.reduce((e,t)=>Math.max(e,Array.from(t.label+"").length*(.65*u)),0)+10;return{annotations:f,marginExtra:"end"===c?{right:p}:{left:p}}}function to(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,a=Array.isArray(e.data)?lr(e.data).filter(e=>!!e&&"object"==typeof e):[],n=Zr(a,t,i);a=n.rows;let s,l,c=n.xKey,u=n.yKey,d=Array.isArray(e.annotations)?[...e.annotations]:[],h="string"==typeof r||"function"==typeof r?r:void 0,f=e.baseLineStyle;if(e.forecast){let t=Hr(a,c,u,r&&"string"==typeof r&&"object"==typeof e.forecast?{...e.forecast,_groupBy:r}:e.forecast,e.anomaly);if(a=t.processedData,d.push(...t.annotations),s=Jr(a,u,e.forecast),r&&"string"==typeof r?(a=a.map(e=>({...e,[Qb]:`${e[r]}__${e[Hb]||"observed"}`})),h=Qb):h=Hb,e.baseLineStyle){let t=Ur(t=>e.baseLineStyle(t),e.forecast);f=e=>t(e)}}else e.anomaly&&d.push(...Xr(e.anomaly));if(e.gapStrategy){if("function"==typeof h){let e=h;a=a.map(t=>({...t,__semiotic_gapGroup:e(t)})),h="__semiotic_gapGroup"}let t=Qr(a,e.gapStrategy,c,u,"string"==typeof h?h:void 0);a=t.rows,t.groupKey&&(h=t.groupKey)}if(e.directLabel){let t=eo(a,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,c,u,e.colorScheme,e.themeCategorical,e.color);d.push(...t.annotations),l=t.marginExtra}return{data:a,xAccessor:"function"==typeof t?c:t,yAccessor:"function"==typeof i?u:i,groupAccessor:h,colorAccessor:o,annotations:d,lineStyle:f,yExtent:s,marginExtra:l}}function io(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=_i(r.theme).colors.categorical,s=i??r.colorScheme??n,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrScatterColorBy:t(e)})):a,u=t?$e(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],f=d?a.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Nm(f):void 0,g=Yy(o.xAccessor,o.yAccessor),y=o.styleRules;return e=>{let i={fill:t&&u?_e(e,t,u):"string"==typeof o.color?o.color:Ix,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Ie(e,d,h,p):"number"==typeof o.pointRadius?o.pointRadius:5};return y?.length&&Object.assign(i,Gy(e,y,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function ro(e,t){if(!t)return[];let i=/* @__PURE__ */new Set,r=[];for(let o of e){if(!o||"object"!=typeof o)continue;let e=("function"==typeof t?t(o):o[t])+"";i.has(e)||(i.add(e),r.push(e))}return r}function oo(e,t,i,r){if(!i.categoryAccessor)return;let o=ro(e,i.categoryAccessor),a=i.colors,n="explicit-then-alpha"===r?[...Object.keys(a??{}).filter(e=>o.includes(e)),...o.filter(e=>!Object.hasOwn(a??{},e)).sort()]:o,s=_i(t.theme).colors.categorical,l=s?.length?s:Rx;return Object.fromEntries(n.map((e,t)=>[e,a&&Pe(a,e)||i.fill||l[t%l.length]]))}function ao(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=_i(r.theme).colors.categorical,s=i??r.colorScheme??n,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrBubbleColorBy:t(e)})):a,u=t?$e(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],f=d?a.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Nm(f):void 0,g=Yy(o.xAccessor,o.yAccessor),y=o.styleRules;return e=>{let i={fill:t&&u?_e(e,t,u):"string"==typeof o.color?o.color:Ix,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Ie(e,d,h,p):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return y?.length&&Object.assign(i,Gy(e,y,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function no(e,t){return t?.length&&Object.defineProperty(e,sv,{configurable:!0,enumerable:!1,value:t}),e}function so(e){return e?.[sv]}function lo(e){return e.parentLine?no({...e.parentLine,...e},so(e)):e}function co(e){return no({...e[0]},e.map(lo))}function uo(e){return!!e&&so(e)?.[0]===e}function ho(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=Pe(i,r);if(e)return e}let a;if(Array.isArray(i))a=i;else if(t&&t.length>0)a=t;else if("string"==typeof i){let e=$x[i];Array.isArray(e)&&(a=e)}return a&&0!==a.length?null!=r?(o.has(r)||o.set(r,o.size),a[o.get(r)%a.length]):a[0]:Ix}function fo(e,t,i){return"function"==typeof e?e(t,i):t[e]}function po(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[Y(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(Y(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function go(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:a,neutralColor:n,themeCategorical:s,themeNeutral:l}=e;if(null==r&&null==o)return a;let c=new Set(i.slice(0,null==r?i.length:Math.max(0,Math.floor(r)))),u=/* @__PURE__ */new Map,d={};for(let e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(c.has(e)?ho(void 0,s,a,e,u):n??l??"#b8bec8")});return d}function yo(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",a=t.rankDirection??"descending",n=[],s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,c=[],u=/* @__PURE__ */new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let a=fo(i,e,t),f=Y(a),p=s.get(f);null==p&&(p=n.length,s.set(f,p),n.push(a),l.set(p,[]));let g=fo(o,e,t)+"";u.has(g)||(u.set(g,c.length),c.push(g));let y=Number(fo(r,e,t));Number.isFinite(y)&&(d=Math.min(d,y),h=Math.max(h,y),l.get(p)?.push({datum:e,inputIndex:t,series:g,value:y}))});let f=[],p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(let e=0;n.length>e;e++){let t=l.get(e)??[];t.sort((e,t)=>("descending"===a?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;f.push({datum:t.datum,xIndex:e,xValue:n[e],series:t.series,value:t.value,rank:r}),p.set(t.series,(p.get(t.series)??0)+r),g.set(t.series,(g.get(t.series)??0)+1)})}let y=c.length+1,m=[...c].sort((e,t)=>{let i=g.get(e)??0,r=g.get(t)??0;return((p.get(e)??0)+(n.length-i)*y)/Math.max(1,n.length)-((p.get(t)??0)+(n.length-r)*y)/Math.max(1,n.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:f.map(e=>{let t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:n,seriesOrder:c,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}function mo(e,t,i,r,o){let a=1-o;return a*a*a*e+3*a*a*o*t+3*a*o*o*i+o*o*o*r}function xo(e,t,i,r,o){let a=1-o;return 3*a*a*(t-e)+6*a*o*(i-t)+3*o*o*(r-i)}function bo(e,t,i,r,o){let a=[],n=(e.x+t.x)/2;for(let s=0;o>=s;s++){let l,c,u,d,h=s/o;"linear"===r?(l=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(l=mo(e.x,n,n,t.x,h),c=mo(e.y,e.y,t.y,t.y,h),u=xo(e.x,n,n,t.x,h),d=xo(e.y,e.y,t.y,t.y,h)),a.push({x:l,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:.5>h?i:i+1})}return a}function vo(e,t={}){let i=[],r=[],o=[];if(2>e.length)return{topPath:i,bottomPath:r,datumIndices:o};let a=t.curve??"smooth",n=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){let s=bo(e[t],e[t+1],t,a,n);for(let e=0===t?0:1;s.length>e;e++){let t=s[e],a=Math.hypot(t.dx,t.dy)||1,n=-t.dy/a,l=t.dx/a,c=Math.max(0,t.radius);i.push([t.x+n*c,t.y+l*c]),r.push([t.x-n*c,t.y-l*c]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:r,datumIndices:o}}function wo(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),a="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,n=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),s=[];for(let{candidate:e}of n){if(s.length>=a)break;s.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||s.push(e)}return new Set(s.map(e=>e.id))}function ko({datum:e,x:t,y:i,side:r,color:o,highlighted:a,labelStyle:n}){let s=ym(),l=s.isActive&&!s.predicate(e),c="function"==typeof n?n(e.__bumpRaw):n;/* @__PURE__ */
|
|
85
|
+
return lv("text",{className:"semiotic-bump-label",x:t+("end"===r?8:-8),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:l?.16:1,fontWeight:a?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...c},children:e.__bumpSeries})}function Ao(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function So(e,t,i){let[r,o]=t,[a,n]=i;return o===r?(a+n)/2:a+(n-a)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function Mo(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function _o(e){let t=e.config,i=/* @__PURE__ */new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],a=[],n=[];for(let a of r){let r=(i.get(a)??[]).sort((e,t)=>e.x-t.x);if(2>r.length)continue;let s=r[0].__bumpHighlighted,l=(t.colorMap&&Pe(t.colorMap,a))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(s?l:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??l),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?So(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=vo(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:s?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,Gy(r[0].__bumpRaw,t.styleRules,Mo(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:a+" ranking trajectory",tableFields:r.map(e=>e.__bumpRaw)},group:a,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:s?1:.75};t.styleRules?.length&&Object.assign(r,Gy(e.__bumpRaw,t.styleRules,Mo(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${a}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${a}:${e.x}`})});let f=!0===t.showLabels?"end":t.showLabels,p=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);n.push({id:`${a}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:s,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===f||"both"===f)&&p(r[0],0,"start"),("end"===f||"both"===f||"auto"===f)&&p(r.at(-1),r.length-1,"end")}let s=wo(n,e.dimensions.plot.height,"auto"!==(!0===t.showLabels?"end":t.showLabels)||"auto",t.maxLabels);for(let e of n)s.has(e.id)&&a.push(
|
|
86
|
+
/* @__PURE__ */lv(ko,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:a.length?/* @__PURE__ */lv("g",{className:"semiotic-bump-labels",children:a}):void 0,restyle:(e,t)=>{let i=Ao(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function Po(e,t,i){let r=Se(t,i,Lx),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||"Series "+(t+1),a=o?.[i];return"string"==typeof a&&a.length>0?a:r[t%r.length]})}function $o(e,t){let i=By(e),r=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:By(e.yAccessor)}));return(e,t)=>{let o=(e[dv]??t??"")+"",a=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:a,x:i(e),y:a,category:o||void 0}}}function Lo(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(r>e&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}function Io(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=_i(r.theme).colors.categorical,s=i??r.colorScheme??n,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrLineColorBy:t(e)})):a,u=t?$e(c,l,s):void 0,d=Yy(o.xAccessor,o.yAccessor);return ur(dr({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:d}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}function Ro(e,t,i,r,o){let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=_i(r.theme).colors.categorical,s=i??r.colorScheme??n,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrAreaColorBy:t(e)})):a,u=t?$e(c,l,s):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=By(o.yAccessor),g=o.styleRules;return(e,i)=>{let r=t&&u?_e(e,t,u):"string"==typeof o.color?o.color:Ix,a={fill:r,fillOpacity:f,stroke:d?r:"none",...d&&{strokeWidth:h}};return g?.length&&Object.assign(a,Gy(e,g,{value:p(e),category:i})),void 0!==o.stroke&&(a.stroke=o.stroke),void 0!==o.strokeWidth&&(a.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(a.opacity=o.opacity),a}}function To(e,t,i,r,o){if(!o.showPoints)return;let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=_i(r.theme).colors.categorical,s=i??r.colorScheme??n,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrPointColorBy:t(e)})):a,u=t?$e(c,l,s):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?_e(e,t,u):"string"==typeof o.color?o.color:Ix;return{r:d,fill:i,stroke:"none"}}}function Co(e){let t=2166136261;for(let i=0;e.length>i;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2146121005),t^=t>>>15,t=Math.imul(t,2221713035),t^=t>>>16,t>>>0}function Do(e){return"p"+(Math.round(1e3*e)/10+"").replace(".","_")}function zo(e,t,i){let r=e.length;for(e.push(t);r>0;){let o=r-1>>>1;if(0>=i(e[o],t))break;e[r]=e[o],r=o}e[r]=t}function Eo(e,t){let i=e[0],r=e.pop();if(e.length>0){let i=0;for(;e.length>2*i+1;){let o=2*i+1;if(e.length>o+1&&0>t(e[o+1],e[o])&&o++,0>=t(r,e[o]))break;e[i]=e[o],i=o}e[i]=r}return i}function No(e,t){switch(t){case"distinct":return e.distinct??0;case"p50":case"p95":case"p99":return e.percentiles?.[t]??NaN;default:return e[t]??e.mean}}function Oo(e,t,i,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];let o=No(e,i),a=e.stddev*r;return[o-a,o+a]}function Fo(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;let t=e.trim();if(""===t)return null;Lv.lastIndex=0;let i,r=0,o=0;for(;null!==(i=Lv.exec(t));){let e=parseFloat(i[1]),t=$v[i[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=i[0].length}return o!==t.length?null:r>0?r:null}function Wo(e){let t=e.window??"tumbling",i=Fo("session"===t?e.gap??e.size:e.size);if(null==i)return null;let r=null!=e.hop?Fo(e.hop):void 0,o=null!=e.gap?Fo(e.gap):void 0;return new Pv({window:t,size:i,hop:r??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function jo(e,t){let i=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{let t={[Iv]:(e.start+e.end)/2,[Rv]:No(e,i),[zv]:e.count,[Dv]:e.partial,[Ev]:e.start,[Nv]:e.end},a=Oo(e,r,i,o);return a&&(t[Tv]=a[0],t[Cv]=a[1]),t})}function Bo(e){return"none"!==(e.band??"none")}function Yo(e,t,i){return e??i??Math.max(t?.length??0,200)}function Xo(e,t,i){let r=By(e),o=By(t),a=By(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?Go(e.value):a(e),x:t?Go(e.xCenter):r(e),y:t?Go(e.yCenter):o(e)}}}function Go(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Vo(e,t){let i=Array.isArray(e)?lr(e):[],r=t.aggregate;if(!r)return i;let o=new Fv(r,t.seriesAccessor);for(let e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(r)}function qo(e){let t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>nr(e,t,"time")??NaN,valueAccessor:e=>nr(e,i,"value")??NaN}}function Ho(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:Yo(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...qo(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}function Uo(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function Zo(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(Uv,t)){let i=Uv[t];if(1===e)return[i(.5)];let r=[];for(let t=0;e>t;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let a=e%2!=0,n=Math.floor(e/2),s=[];for(let e=0;n>e;e++)s.push(i[Math.min(Math.floor(e*i.length/n),i.length-1)]);a&&s.push(o);for(let e=0;n>e;e++)s.push(r[Math.min(Math.floor(e*r.length/n),r.length-1)]);return s}function Ko(e,t,i,r,o,a,n={}){let s=/* @__PURE__ */new Map,l=new Set(t);for(let n of e){let e=i(n);s.has(e)||s.set(e,/* @__PURE__ */new Map);let c=s.get(e);if(r){let e=r(n);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}let i=e-1;if(0>i||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&a){let e=o(n),t=a(n);if(!l.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of s){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;t.length>o;o++){let a=t[o],s=i.get(a)||0,l={};n.category&&(l[n.category]=e),n.level&&(l[n.level]=a),n.count&&(l[n.count]=s),n.score&&(l[n.score]=o+1),c.push({...l,__likertCategory:e,__likertLevel:a,__likertLevelLabel:a,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return c}function Qo(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),a=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;a.push({...t,__likertLevel:Zv,__likertPct:-e}),a.push({...t,__likertLevel:Kv,__likertPct:e})}else a.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return a}function Jo(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),a=/* @__PURE__ */new Map;for(let t of e){let e=a.get(t.__likertCategory)||[];e.push(t),a.set(t.__likertCategory,e)}let n=[];for(let[,e]of a){let t,a,s=/* @__PURE__ */new Map;for(let i of e)i.__likertLevel===Zv?t=i:i.__likertLevel===Kv?a=i:s.set(i.__likertLevelIndex,i);r&&t&&n.push(t);for(let e=o-1;e>=0;e--){let t=s.get(e);t&&n.push(t)}r&&a&&n.push(a);for(let e=r?o+1:o;i>e;e++){let t=s.get(e);t&&n.push(t)}}return n}function ea({value:e,min:t,max:i,radius:r,showScaleLabels:o}){let a=Math.max(16,.3*r);/* @__PURE__ */
|
|
87
|
+
return ew("g",{textAnchor:"middle",children:[
|
|
88
|
+
/* @__PURE__ */Jv("text",{y:0,dominantBaseline:"central",fontSize:a,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&/* @__PURE__ */ew("text",{y:.7*a+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}function ta(e){return Math.max(0,Math.min(1,e))}function ia(e){let 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)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function ra(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function oa(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:ta(e.offset),color:e.color??i,opacity:null==e.opacity?1:ta(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=ia(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let a=ta(t);if(r[0].offset>=a)return o(r[0]);if(a>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;r.length-1>e;e++){let t=r[e],i=r[e+1];if(t.offset>a||a>i.offset)continue;let n=i.offset-t.offset,s=n>0?(a-t.offset)/n:0,l=ia(t.color),c=ia(i.color);if(!l||!c)return o(.5>s?t:i);let[u,d,h]=l,[f,p,g]=c,y=u+(f-u)*s,m=d+(p-d)*s,x=h+(g-h)*s,b=t.opacity+(i.opacity-t.opacity)*s;return 1===b?ra(y,m,x):`rgba(${Math.round(y)},${Math.round(m)},${Math.round(x)},${b})`}return o(r[r.length-1])}function aa(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function na(e){let{min:t,max:i,value:r,thresholds:o,fillColor:a,backgroundColor:n,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,r))-t)/d,f=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:a||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});let p=!!c&&c.stops.length>=2,g=[],y=/* @__PURE__ */new Map,m=[];if(p){let e=s?h:1,t=aa("bg",0);if(g.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:n,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;i>t;t++)r.push(oa(c.stops,e*(t+.5)/i,a||f[0]?.color||"#007bff"));let o=aa("fill",0);g.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),y.set(o,{fill:r[0]||n})}}else{let e=t;for(let i=0;f.length>i;i++){let r=f[i],o=(r.value-e)/d,a=(e-t)/d,l=(r.value-t)/d,c=Math.max(0,(s?Math.min(h,l):l)-a),u=s?Math.max(0,o-c):0;if(c>0){let e=aa("fill",i);g.push({category:e,value:c,_zone:r.label||"Zone "+(i+1),_isFill:!0}),y.set(e,{fill:r.color})}if(u>0){let e=aa("bg",i);g.push({category:e,value:u,_zone:r.label||"Zone "+(i+1),_isFill:!1}),y.set(e,{fill:n,opacity:.4})}e=r.value}}if(l&&o&&o.length>0)for(let e of o)e.value>t&&i>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:g,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:n},gaugeAnnotations:m}}function sa(e=240){let t=360-e,i=180+t/2,r=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:r,offsetRad:-Math.PI/2+r}}function la(e=240){let{sweepRad:t,offsetRad:i}=sa(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)t+.001>=((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),a=r.map(e=>e[1]),[n,s]=Nm(o),[l,c]=Nm(a);return{minX:n,maxX:s,minY:l,maxY:c,width:s-n,height:c-l,cx:(n+s)/2,cy:(l+c)/2}}function ca(e){return mr(e)}function ua(e,t,i,r,o,a){let n=_i(r.theme).colors.categorical,s=i??r.colorScheme,l=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?l.map(e=>({...e,__ssrColorBy:t(e)})):l,d=t?$e(u,c,s??n):void 0,h=ho("string"==typeof o.color?o.color:void 0,n,s,void 0,
|
|
89
|
+
/* @__PURE__ */new Map),f=a??By(o.valueAccessor??"value"),p=o.styleRules,g=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?_e(e,t,d):h};return p?.length&&Object.assign(r,Gy(e,p,{value:f(e,i),category:i})),"function"==typeof g?Object.assign(r,g(e,i)||{}):g&&"object"==typeof g&&Object.assign(r,g),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function da(e,t,i,r,o,a="median",n=.8){let s=By(o.valueAccessor??"value"),l=ua(e,t,i,r,o,e=>"number"==typeof e[a]?e[a]:s(e));return(e,t)=>{let i=l(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=n),void 0===i.stroke&&(i.stroke=i.fill),i}}function ha(e,t,i,r,o){return da(e,t,i,r,o,"median",.6)}function fa(e,t,i,r,o){let a=ua(e,t,i,r,o),n="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:n,fillOpacity:.8,...a(e,t)})}function pa(e,t,i,r,o){let a=ua(e,t,i,r,o),n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=s?n.map(e=>"function"==typeof s?s(e):Number(e[s])).filter(Number.isFinite):[],u=c.length?Nm(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:s?Ie(e,s,l,u):d,fillOpacity:h,...a(e,t)})}function ga(e="static"){return vw[e]??vw.static}function ya(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:ww.has(e.kind)?"fatal":"warn"}function ma(e){let t=[],i=[];for(let r of e)"fatal"===ya(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}function xa(e,t,i,r={}){let o=ga(r.usageMode??"static"),a=[],n=/* @__PURE__ */new Set;for(let t of e)n.has(t.id)&&a.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),n.add(t.id);let s=/* @__PURE__ */new Set,l=Array.isArray(i)&&2===i.length,c=l&&Number.isFinite(i[0])&&Number.isFinite(i[1]);(!l||!c||!c||i[0]>i[1])&&a.push({kind:"invalid-domain"});for(let 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]||a.push({kind:"invalid-node-time",id:t.id}));for(let e of t)s.has(e.id)&&a.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),n.has(e.source)||a.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),n.has(e.target)||a.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&a.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||0>=e.value)&&a.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&a.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):a.push({kind:"invalid-edge-time",id:e.id});return a}function ba(e,t,i="static"){if("strip"!==ga(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}function va(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`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function wa(){/* @__PURE__ */
|
|
90
|
+
return Object.create(null)}function ka(e,t){return t>e?-1:e>t?1:0}function Aa(e){return e.occupants.map(e=>e.id).sort(ka).join("\0")}function Sa(e,t,i=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?i:t)}function Ma(e,t){return e.map(e=>{let i=/* @__PURE__ */new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function _a(e,t,i){return xm(Ma([e,t],i)).adjacentClearance[0]??0}function Pa(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:a}=i,n=i.stackValueScale??a,s=Sa(e,r,i.groupPadding??0),l=[r+e[0].peak.topPeak*n];for(let i=1;e.length>i;i++)l.push(l[i-1]+t[i-1]*n+s[i-1]);let c=l[l.length-1]+e[e.length-1].peak.botPeak*n+r;if(c>o&&c>0){let e=o/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function $a(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function La(e,t,i,r,o,a,n){let s=e.length;if(0===s)return[];let{padding:l,plotH:c,valueScale:u}=n,d=Sa(e,l,n.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,p=c-l-e[s-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=p-f)return Pa(e,o,n);let g=1===s?[(f+p)/2]:[...a];for(let e=0;12>e;e++){let e=Array(s).fill(0),o=Array(s).fill(0);for(let a of i){let i=t[a.source],n=t[a.target];if(null==i||null==n||i===n)continue;let s=r[a.source]?.localAttachments.get(a.id),l=r[a.target]?.localAttachments.get(a.id);if(!s||!l)continue;let c=a.value>0&&Number.isFinite(a.value)?a.value:1,d=$a(s,u),h=$a(l,u);e[i]+=(g[n]+h-d)*c,o[i]+=c,e[n]+=(g[i]+d-h)*c,o[n]+=c}let a=g.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),n=mm({desired:a,minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:p}),l=0;for(let e=0;s>e;e++)l=Math.max(l,Math.abs(n[e]-g[e]));if(g=n,.01>l)break}return g}function Ia(e,t,i,r,o,a){let n=a.adjacentClearance?[...a.adjacentClearance]:xm(Ma(r,i)).adjacentClearance,s=Pa(r,n,a),l="hug"===a.lanePlacement?La(r,o,t,i,n,s,a):[...s];if("hug"===a.lanePlacement){let i=t=>{let i=wa();for(let r of e)i[r.id]=t[o[r.id]];return i};Ra(i(l),t)>Ra(i(s),t)+1e-6&&(l=[...s])}let c=wa();for(let t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*a.valueScale),d=Math.max(d,e+r.botPeak*a.valueScale))}return{adjacentClearance:n,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&a.plotH>0?Math.max(0,Math.min(1,(d-u)/a.plotH)):0}}function Ra(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function Ta(e,t){let i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let r=0,o=i.length-1,a=0;for(;o>=r;){let e=r+o>>>1;i[e].t>t?o=e-1:(a=e,r=e+1)}let n=i[a].boundaryOffset??0;return{top:i[a].topMass-n,bot:i[a].botMass+n}}function Ca(e,t,i,r,o){let a=1-o;return a*a*a*e+3*a*a*o*t+3*a*o*o*i+o*o*o*r}function Da(e,t){let i=0,r=1;for(let o=0;28>o;o++){let o=(i+r)/2;Ca(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function za(e,t,i){let r=t+$a(e,i),o=e.value*i/2;return[r-o,r+o]}function Ea(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function Na(e,t,i,r,o,a,n){let{valueScale:s,domain:l,mode:c="quality"}=n,u="source"===n.ribbonLane?.85:"target"===n.ribbonLane?.15:.5,d=0;for(let n of e){let e=r[n.source],h=r[n.target];if(null==e||null==h||2>Math.abs(e-h))continue;let f=t[n.source]?.localAttachments.get(n.id),p=t[n.target]?.localAttachments.get(n.id);if(!f||!p)continue;let g=Math.max(n.startTime,l?.[0]??-1/0),y=Math.min(n.endTime,l?.[1]??1/0);if(g>=y)continue;let[m,x]=za(f,o[n.source],s),[b,v]=za(p,o[n.target],s),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){let r=i[e];if(!r)continue;let l=[g,y];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>g&&y>i.t&&l.push(i.t);let h=e=>{let i=Da((e-g)/(y-g),u),l=Ca(m,m,b,b,i),c=Ca(x,x,v,v,i),d=0;for(let i of r.occupants){if(i.id===n.source||i.id===n.target)continue;let r=a[i.id];if(null!=r?.start&&r.start>e||null!=r?.end&&e>r.end)continue;let u=Ta(t[i.id],e),h=o[i.id];d=Math.max(d,Ea(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t),p=0;for(let e=0;f.length-1>e;e++){let t=f[e],i=f[e+1]-t;p+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=p/(y-g)*(n.value>0?n.value:1)}}return d}function Oa(e,t,i,r,o,a,n,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:Ra(n,i),transitOcclusion:Na(i,r,o,a,n,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function Fa(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Wa(e,t){return e.map(e=>({t:Fa(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function ja(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let a=r+t;return[a-o,a]}let a=e.sideMassAfter*i;if("top"===e.side){let e=r-a;return[e,e+o]}let n=r+a;return[n-o,n]}function Ba(e,t,i,r,o){if(0===e.length)return null;let a=Wa(e,o),n=e=>t+(a[e].boundaryOffset??0)*i,s=e=>n(e)-a[e].topMass*i,l=e=>n(e)+a[e].botMass*i,c=`M${r(a[0].t)},${s(0)}`;for(let e=1;a.length>e;e++)c+=` L${r(a[e].t)},${s(e)}`;c+=` L${r(a[a.length-1].t)},${l(a.length-1)}`;for(let e=a.length-2;e>=0;e--)c+=` L${r(a[e].t)},${l(e)}`;return c+" Z"}function Ya(e,t,i,r,o,a){let n=i.nodeData[e];if(!n||0===n.samples.length)return[];let s=i.valueScale,l=i.centerlines[e],c=Wa(n.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),p=e=>r(Fa(e,o)),g=[],y=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=n.localAttachments.get(i.id),t=a?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){let r=p(i.systemInTime),a=p(t),n=null!=o&&o[0]>i.systemInTime,c=n?r:r-20,u=n?Math.min(a,r+20):r,d=Math.max(h,c);if(a>d){let[t,i]=ja(e,l,s);g.push({pathD:y(d,t,a,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=n.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=p(i.systemOutTime),r=p(i.endTime),o=t+20,a=Math.min(f,o);if(a>r){let[i,n]=ja(e,l,s);g.push({pathD:y(r,i,a,n),x0:t,x1:o,from:1,to:0})}}}}return g}function Xa(e,t){let i=wa(),r=wa();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}function Ga(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||ka(e.id,t.id):(e,t)=>t.value-e.value||ka(e.id,t.id),a="temporal"===r?(e,t)=>e.startTime-t.startTime||ka(e.id,t.id):(e,t)=>t.value-e.value||ka(e.id,t.id),n=/* @__PURE__ */new Map;for(let e of t)n.set(e.id,{});let s=(e,t)=>{let i=/* @__PURE__ */new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}let n=[...i.values()];n.sort("temporal"===r?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||ka(e.partner,i.partner):e.latestEnd-i.latestEnd||ka(e.partner,i.partner):(e,t)=>t.total-e.total||ka(e.partner,t.partner));for(let e of n)e.edges.sort("target"===t?a:o);return n};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)n.get(t.id).sourceSide=i});else if(0===e.length)s(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)n.get(t.id).targetSide=i});else{let t=s(r,"source"),i=s(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)n.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)n.get(t.id).sourceSide=r}}}return n}function Va(e,t,i,r,o="temporal"){let a=t.incoming[e.id],n=t.outgoing[e.id],s=[];for(let e of a)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of n)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=(e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0},u=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||c(e,t)||ka(e.edge?.id??"",t.edge?.id??"")||ka(e.side,t.side)||e.delta-t.delta)},d=s.length?Om(s.map(e=>e.time)):null,h=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,f=null!=h?h-1:null!=d&&Number.isFinite(d)?d-1:null;u();let p=null,g=0;for(let e of s)e.time!==p&&(p=e.time,g=0),e.sequence=g++;let y=e=>({time:e.time,phase:0,sequence:e.sequence??0}),m=[],x=0,b=0;for(let e of s)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?x:b);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?x:b);if(r>0){let o=y(e);m.push({...o,delta:-r,kind:"transfer-out",side:t}),m.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?x-=r:b-=r,"top"===e.side?x+=r:b+=r,i-=r}i>0&&null!==f&&(m.push({time:f,delta:+i,kind:"create",side:e.side}),"top"===e.side?x+=i:b+=i)}"top"===e.side?x-=t:b-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?x+=t:b+=t}s.push(...m),u();let v=0,w=0,k=0,A=0,S=0,M=0,_=[],P=/* @__PURE__ */new Map,$=e=>{_.push({t:e,topMass:v,botMass:w,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},L=()=>{A=Math.max(A,v+w),S=Math.max(S,v-k),M=Math.max(M,w+k)};for(let e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&$(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?v:w;P.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:w+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,L(),$(e.time)):"transfer-out"!==e.kind&&(L(),"out"===e.kind&&1e-12>=v+w&&(k=0),$(e.time))}let I=[],R=0;for(;_.length>R;){let e=R;for(;_.length>e+1&&_[e+1].t===_[R].t;)e++;I.push(_[R]);for(let t=R+1;e>=t;t++){let e=I[I.length-1];(_[t].topMass!==e.topMass||_[t].botMass!==e.botMass||(_[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&I.push(_[t])}R=e+1}let T=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,C=null;for(let e of n)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let D=null;for(let e of a)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===D||e.systemOutTime>D)&&(D=e.systemOutTime);if(I.length>0){let e=I[I.length-1],t=Math.max(T??-1/0,D??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=I[0],o=I.find(e=>e.topMass+e.botMass>0),a=1/0;null!=h&&Number.isFinite(h)&&r.t>h&&r.topMass+r.botMass>0&&(a=h,i=r),o&&null!=C&&Number.isFinite(C)&&o.t>C&&a>C&&(a=C,i=o),i&&Number.isFinite(a)&&I.unshift({t:a,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let z=I;if("max"===o&&null!=h&&null!=T&&T>h){let e,t=0;for(let i of I){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};z=[...I.filter(e=>h>e.t),{t:h,...t},{t:T,...t},...I.filter(e=>e.t>T)]}}return{samples:z,peak:A,topPeak:S,botPeak:M,localAttachments:P}}function qa(e,t,i,r){let o=/* @__PURE__ */new Map;for(let a of e){let e=t[a.source]?.localAttachments.get(a.id),n=t[a.target]?.localAttachments.get(a.id),s=i[a.source],l=i[a.target];if(!(e&&n&&Number.isFinite(s)&&Number.isFinite(l)))continue;let c=ja(e,s,r),u=ja(n,l,r);o.set(a.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}function Ha(e,t){let i=(e,i)=>{for(let r of e){let e=/* @__PURE__ */new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,a="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,n=e.get(r);if(null!=n&&n!==a)return!0;e.set(r,a)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}function Ua(e,t,i){let r=/* @__PURE__ */new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||ka(e.edge.id,t.edge.id));let a=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},n=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let a=i-o;a>0&&(e[r]=Math.max(0,e[r]-a))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";a(r.target)[e]+=r.value;continue}let o=a(r.source),s=t.get(r.id),l=s.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}n(o,l,r.value)}}function Za(e,t,i,r){for(let o of e){let e=t.incoming[o.id],a=t.outgoing[o.id];if(0===e.length||0===a.length)continue;let n=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of a)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{let o=n(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=s||0>=l)return!1;let c=Math.min(s,l),u=a.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||ka(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},l=a.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}function Ka(e){let t=wa();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function Qa(e,t,i){e.splice(0,e.length,...i);let r=Ka(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function Ja(e){let t=/* @__PURE__ */new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:Aa(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(Aa).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||ka(e.stableId,t.stableId))}function en(e){return e.some(e=>e.group)?Ja(e).flatMap(e=>e.slots):[...e]}function tn(e){let t=/* @__PURE__ */new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}function rn(e){return e.flatMap(e=>e.slots)}function on(e,t){let i=/* @__PURE__ */new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=/* @__PURE__ */new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,n=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(n);s?s.weight=(s.weight??0)+a:r.set(n,{source:t,target:o,weight:a})}return[...r.values()]}function an(e,t,i){let r=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;let a=/* @__PURE__ */new Map;for(let t of e.slots)a.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;a.set(e.source,(a.get(e.source)??0)+n*t)}else if(i===o&&t!==o){let i=t>o?1:-1;a.set(e.target,(a.get(e.target)??0)+n*i)}}let n=[...e.slots].sort((e,t)=>(a.get(e)??0)-(a.get(t)??0)||i(e,t));return{...e,slots:n}})}function nn(e,t){e.some(e=>e.group)&&Qa(e,t,en(e))}function sn(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost}function ln({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:a,slotForNode:n,averageGap:s,evaluate:l}){let c=(i,o)=>{let a=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),n=e.indexOf(i),c=a[0],u=a[a.length-1];if(3>a.length||!a.includes(n)||u-c+1!==a.length||1>=Math.abs(2*n-c-u))return;let d=[...e];d.splice(n,1),d.splice(c+u>>1,0,i);let h=en(d),f=l(h),p=new Set(i.occupants.map(e=>e.id)),g=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),y=r.reduce((e,t)=>p.has(t.source)&&g.has(t.target)||p.has(t.target)&&g.has(t.source)?e+(t.value>0?t.value:1):e,0);sn(f,t,Math.abs(2*n-c-u)*s*Math.max(1,y))&&(e=h,t=f)};for(let[e,t]of o)!a.has(e)&&t.size>=3&&c(n.get(e),[...t].map(e=>n.get(e)));for(let e of i){let t=n.get(e.id);!e.group&&t.group&&(a.get(e.id)?.size??0)>=3&&c(t,[...a.get(e.id)??[]].map(e=>n.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}function cn(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function un(e,t){return km(t,t=>[e[t.source],e[t.target]],cn)}function dn(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function hn(e,t,i){let[r,o]=i.get(e.first),[a,n]=i.get(e.second);return 0>(t.get(r)-t.get(a))*(t.get(o)-t.get(n))?1:0}function fn(e,t,i,r,o,a,n){let s=[...o],l=new Map(o.map(e=>[e,Aa(e)])),c=/* @__PURE__ */new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=/* @__PURE__ */new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!cn(t[e],t[i]))continue;let r=/* @__PURE__ */new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:r})}let f=/* @__PURE__ */new Map;for(let e of o)f.set(e,[]);for(let e of h)for(let t of e.involvedSlots)f.get(t)?.push(e);let p=new Uint32Array(h.length),g=0,y=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=n.plotH/Math.max(1,o.length),x=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),b=Math.max(1,y)*(Math.max(1,n.plotH)+m*Math.max(x,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=/* @__PURE__ */new Map,A=(e,t)=>{let r=k.get(e);r||(r=/* @__PURE__ */new Map,k.set(e,r));let o=r.get(t);if(null!=o)return o;let a=_a(e,t,i);return r.set(t,a),a},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{let t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),_=/* @__PURE__ */new Map;for(let e of t){let t=u.get(e);t&&_.set(e,{source:S.get(t[0]),target:S.get(t[1])})}let P=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,L=/* @__PURE__ */new Map,I=(e,t,i)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(i)};for(let e of t)I(P,e.source,e.target),I($,e.target,e.source),I(L,e.source,e.target),I(L,e.target,e.source);let R=e=>1===P.get(e.source)?.size&&P.get(e.source).has(e.target)||1===L.get(e.source)?.size||1===L.get(e.target)?.size,T=t.flatMap(e=>{if(!R(e))return[];let t=_.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(let i of T)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},D=e=>{let t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return C(t)},z=h.map(e=>{let t=_.get(e.first),i=_.get(e.second);return[t.source,t.target,i.source,i.target]}),E=new Int16Array(o.length),N=new Float64Array(o.length),O=new Float64Array(o.length+1),F=e=>{for(let t=0;e.length>t;t++)E[S.get(e[t])]=t;let t=0;for(let[e,i,r,o]of z)0>(E[e]-E[r])*(E[i]-E[o])&&t++;if(e.length>0){let t=S.get(e[0]);N[t]=n.padding+e[0].peak.topPeak*n.valueScale;for(let t=1;e.length>t;t++){let i=S.get(e[t-1]),r=S.get(e[t]);N[r]=N[i]+A(e[t-1],e[t])*n.valueScale+n.padding}let i=S.get(e[e.length-1]),r=N[i]+e[e.length-1].peak.botPeak*n.valueScale+n.padding;if(r>n.plotH&&r>0){let e=n.plotH/r;for(let t=0;N.length>t;t++)N[t]*=e}}O[0]=0;for(let t=0;e.length>t;t++)O[t+1]=O[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of M){let t=E[e.source],a=E[e.target];if(i+=Math.abs(t-a)*e.weight,r+=Math.abs(N[e.source]-N[e.target])*e.weight,Math.abs(t-a)>=2){let i=Math.min(t,a)+1;o+=(O[Math.max(t,a)]-O[i])*e.weight}}return t*b+r+o*m+C(E)+1e-6*i},W=(e,i)=>{let r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],a=i[e.target];if(null==t||null==a||2>Math.abs(t-a))continue;let n=Math.min(t,a)+1;o+=(r[Math.max(t,a)]-r[n])*(e.value>0?e.value:1)}return o},j=r=>{let o=Ka(r),a=r.slice(0,-1).map((e,t)=>A(e,r[t+1])),s=Ia(e,t,i,r,o,{plotH:n.plotH,padding:n.padding,valueScale:n.valueScale,lanePlacement:n.lanePlacement??"stack",groupPadding:n.groupPadding,adjacentClearance:a});return{map:o,geometry:s,weightedLength:dn(o,t),pixelLength:Ra(s.centerlines,t),transitOcclusion:W(r,o)}},B=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*b+t.pixelLength+t.transitOcclusion*m+D(i)+1e-6*t.weightedLength}),Y=(e,t)=>{let i=t;if(null==i){let t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+hn(i,t,u),0),w.fullCrossing++}return B(i,j(e),e)},X=(e,o,a="quality")=>{let s=o;if(null==s){let t=new Map(e.map((e,t)=>[e,t]));s=h.reduce((e,i)=>e+hn(i,t,u),0),w.fullCrossing++}let l=j(e);return B(s,{...l,transitOcclusion:Na(t,i,e,l.map,l.geometry.centerlines,r,{valueScale:n.valueScale,ribbonLane:n.ribbonLane,domain:n.domain,mode:a})},e)},G=[...s],V=(e,t)=>ka(l.get(e),l.get(t)),q=tn(G),H=e=>{let t=bm(e,d,e=>Y(e).cost,{passes:6,compare:V,maxEvaluations:Sw}),i=Y(t),r=Sw;for(let e=0;6>e&&r>0;e++){let o=!1,a=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&a.reverse();for(let e of a){if(0>=r--)break;let a=t[e],n=t[e+1],s=new Map(t.map((e,t)=>[e,t])),l=0,c=[];g++;for(let e of[...f.get(a)??[],...f.get(n)??[]])p[e.index]!==g&&(p[e.index]=g,c.push(e),l+=hn(e,s,u));[t[e],t[e+1]]=[n,a];let d=new Map(s);d.set(a,e+1),d.set(n,e);let h=0;for(let e of c)h+=hn(e,d,u);w.localCrossing+=c.length;let y=Y(t,i.crossings-l+h);i.cost>y.cost?(i=y,o=!0):[t[e],t[e+1]]=[a,n]}if(!o)break}return t},U=e=>{let t=H(e);if((e.length>8?1/0:kw(e.length)*(e.length+M.length+z.length))>Aw)return t;let i=wm(e,F,{maxItems:8,maxEvaluations:5e4}),r=X(i),o=X(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?i:t},Z="geometry-refine"===n.mode;if(Z||"crossing-min"!==n.laneOrder&&"crossing-min+inside-out"!==n.laneOrder){if(!Z&&"inside-out"===n.laneOrder)if(q){let e=Ja(G),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||ka(e.stableId,i.stableId)),r=Array(i.length),o=Math.floor((i.length-1)/2)-1,a=Math.floor((i.length-1)/2)+1;i.length>0&&(r[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>a||0>o?r[a++]=i[e]:r[o--]=i[e];G=rn(r)}else{let e=[...G].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||V(e,t)),t=Array(e.length),i=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>i?t[r++]=e[o]:t[i--]=e[o];G=t}}else G=q?(e=>{let t=Ja(e);if(1>=t.length)return rn(t);let i=e=>Y(rn(e)).cost;t=Ja(U(e)),t=an(t,d,V);let r=on(t,d);if(t=bm(t,r,i,{passes:6,compare:(e,t)=>ka(e.stableId,t.stableId),maxEvaluations:Sw}),t=vm(t,i,{passes:8,maxEvaluations:Sw}),(t.length>8?1/0:kw(t.length)*(t.length+M.length+z.length))<=Aw){let e=wm(t,e=>F(rn(e)),{maxItems:8,maxEvaluations:5e4}),i=rn(e),r=rn(t),o=X(i),a=X(r);o.crossings!==a.crossings?t=a.crossings>o.crossings?e:t:a.cost>o.cost&&(t=e)}return t=an(t,d,V),rn(t)})(G):U(G);if(!Z&&"crossing-min+inside-out"===n.laneOrder&&G.length>1)if(q){let e=Ja(G),t=Y(rn(e)),i=rn(e),r=t,o=Math.floor((e.length-1)/2),a=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,t)=>a(t)-a(e)||ka(e.stableId,t.stableId));for(let a of n){let n=e.indexOf(a);if(n===o)continue;e.splice(n,1),e.splice(o,0,a);let s=rn(e),l=Y(s);l.cost>t.cost?(e.splice(o,1),e.splice(n,0,a)):(t=l,r.cost>l.cost&&(i=s,r=l))}G=i}else{let e=Y(G),t=[...G],i=e,r=Math.floor((G.length-1)/2),o=[...G].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||V(e,t));for(let a of o){let o=G.indexOf(a);if(o===r)continue;G.splice(o,1),G.splice(r,0,a);let n=Y(G);n.cost>e.cost?(G.splice(r,1),G.splice(o,0,a)):(e=n,i.cost>n.cost&&(t=[...G],i=n))}G=t}if((Z||"crossing-min"===n.laneOrder||"crossing-min+inside-out"===n.laneOrder)&&G.length>1)if(q){let e=Ja(G),t=X(rn(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];let o=rn(e),a=X(o,void 0,"score");t.cost>a.cost?(G=o,t=a,i=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!i)break}e=an(Ja(G),d,V),G=rn(e)}else{let e=X(G,void 0,"score");for(let t=0;G.length-1>t;t++){let i=G[t],r=G[t+1],o=new Map(G.map((e,t)=>[e,t])),a=0,n=[];g++;for(let e of[...f.get(i)??[],...f.get(r)??[]])p[e.index]!==g&&(p[e.index]=g,n.push(e),a+=hn(e,o,u));[G[t],G[t+1]]=[r,i];let s=new Map(o);s.set(i,t+1),s.set(r,t);let l=0;for(let e of n)l+=hn(e,s,u);w.localCrossing+=n.length;let c=X(G,e.crossings-a+l,"score");e.cost>c.cost?e=c:[G[t],G[t+1]]=[i,r]}}let K=en(s);G=en(G);let Q=X(G),J=X(K);if(Z){let e=D(K),t=D(G);(Q.crossings>J.crossings||Q.crossings===J.crossings&&t>e+1e-9||Q.cost>J.cost)&&(G=K,Q=J)}else Q.cost>J.cost&&(G=K,Q=J);let ee=ln({order:G,after:Q,nodes:e,edges:t,outgoingPartners:P,incomingPartners:$,slotForNode:c,averageGap:m,evaluate:X});return G=ee.order,Q=ee.after,Qa(o,a,G),{before:J,after:Q,initialOrder:s.map(e=>l.get(e)),evaluations:w}}function pn(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));Qa(e,t,[...e].sort((e,t)=>(r.get(Aa(e))??1/0)-(r.get(Aa(t))??1/0)||ka(Aa(e),Aa(t))))}function gn(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,a=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),a=Math.max(a,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:a},...null!=e.group?{group:e.group}:{}}}),o=wa();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function yn(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}function mn(e){return Mw.get(e)}function xn(e,t){for(Mw.has(e)&&Mw.delete(e),Mw.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(wa(),t.slotByNode)});Mw.size>12;){let e=Mw.keys().next().value;if(null==e)break;Mw.delete(e)}}function bn(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function vn(e,t){return ka(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function wn(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let r of e)i.has(r.source)||i.set(r.source,/* @__PURE__ */new Set),t.has(r.target)||t.set(r.target,/* @__PURE__ */new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function kn(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=/* @__PURE__ */new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=/* @__PURE__ */new Map,a=e=>{if(o.has(e))return;let r=t.get(e),a=i.get(e),n=/* @__PURE__ */new Map;for(let[e,t]of r??[])n.set(e,(n.get(e)??0)+t);for(let[e,t]of a??[])n.set(e,(n.get(e)??0)+t);if(1===n.size){let[t,i]=[...n][0];o.set(e,{partner:t,weight:i})}};for(let t of e)a(t.source),a(t.target);return o}function An(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function Sn(e,t,i){return!!i.has(e)&&t.some(t=>!An(e,t,i))}function Mn(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function _n(e,t,i,r,o,a){let n=/* @__PURE__ */new Set,s=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),l=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(let e of r)n.add(vn(e.source,e.target)),s.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let r=i+1;e.length>r;r++){let o=vn(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of l.values())d([...e],c);for(let e of s.values())d([...e],u);let h=/* @__PURE__ */new Set;for(let[e,[r,o]]of c)u.has(e)&&(bn(t[r],t[o])||bn(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),s=o.get(i);return!((null==r||null==s||r===s)&&(null!=r==(null!=s)||n.has(vn(e,i))||a.has(e)&&a.has(i)&&An(e,i,a))&&!bn(t[e],t[i])&&(!h.has(e)&&!h.has(i)||n.has(vn(e,i))))}}}function Pn(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||ka(e.id,i.id)).map(e=>e.id)}function $n(e,t,i=/* @__PURE__ */new Map){let r=[],o=[];for(let a of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(a,e))&&!Sn(a,e,i));-1===e&&!i.has(a)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(a,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(a),o.push(e)}return{assignment:o,slotCount:r.length}}function Ln(e,t,i,r){if(12>=e.length||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),a=Array.from({length:e.length},()=>/* @__PURE__ */new Map),n=wn(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Mn(e,n);a[t].set(i,(a[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let s=kn(i),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>/* @__PURE__ */new Map),u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(s.has(e[i]))for(let r=i+1;e.length>r;r++){if(!s.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(l[i],l[r])||Math.max(l[i],l[r]),a=An(e[i],e[r],s)?o:-o;if(Math.abs(a)>Pw&&(c[i].set(r,a),c[r].set(i,a),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let f=(e,t,i)=>{let r=d[t],o=d[i],a=0,n=/* @__PURE__ */new Set;for(let s of[t,i])for(let[l,c]of e[s]){let e=l>s?`${s}:${l}`:`${l}:${s}`;if(n.has(e))continue;n.add(e);let u=(s===t?o:r)===(l===t?o:l===i?r:d[l]);d[s]===d[l]!==u&&(a+=u?c:-c)}return a},p=(e,t,i)=>{let r=0;for(let[o,a]of e[t]){let e=i===d[o];d[t]===d[o]!==e&&(r+=e?a:-a)}return r},g=(e,t)=>e>Pw||Pw>=Math.abs(e)&&t>Pw,y=(e,t,i,r)=>e>i+Pw||Pw>=Math.abs(e-i)&&t>r+Pw,m=0;for(let i=0;32>i&&_w>m;i++){let i=null,r=-1,o=-1,n=-1,s=-1/0,l=-1/0;for(let u=0;e.length>u;u++){for(let f=0;h.length>f&&m++<_w;f++){if(f===d[u]||!h[f].every(i=>!t.conflicts(e[u],e[i])))continue;let m=p(a,u,f),x=p(c,u,f);g(m,x)&&y(m,x,s,l)&&(i="move",r=u,o=-1,n=f,s=m,l=x)}if(m>=_w)break}for(let u=0;e.length-1>u;u++){for(let p=u+1;e.length>p&&m++<_w;p++){let m=d[u],x=d[p];if(m===x||!h[x].every(i=>i===p||!t.conflicts(e[u],e[i]))||!h[m].every(i=>i===u||!t.conflicts(e[p],e[i])))continue;let b=f(a,u,p),v=f(c,u,p);g(b,v)&&y(b,v,s,l)&&(i="swap",r=u,o=p,n=-1,s=b,l=v)}if(m>=_w)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[n].push(r),d[r]=n;continue}let u=d[r],x=d[o];h[u].splice(h[u].indexOf(r),1,o),h[x].splice(h[x].indexOf(o),1,r),d[r]=x,d[o]=u}return d}function In(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}function Rn(e,t,i,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),a=Array.from({length:e.length},()=>new Float64Array(e.length)),n=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=Array.from({length:e.length},()=>/* @__PURE__ */new Map),l=wn(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Mn(e,l);a[t][i]+=r,a[i][t]+=r,s[t].set(i,(s[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let c=kn(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(let[e,r]of n[t])d[t][i]+=Math.min(r,n[i].get(e)??0);for(let[e,r]of s[t])d[t][i]+=Math.min(r,s[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=An(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],f=(t=>{let i=0,r=0;for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++)t[o]===t[n]&&(i+=a[o][n],r+=d[o][n]);return{flow:i,affinity:r}})(h),p=0,g=Array(e.length).fill(-1),y=Array.from({length:r.slotCount},()=>[]),m=(i,o,n,s)=>{if(p>=75e3)return;if(i===e.length)return p++,void((n>f.flow||n===f.flow&&s>f.affinity||n===f.flow&&s===f.affinity&&In(g,h))&&(h=[...g],f={flow:n,affinity:s}));let l=Math.min(o+1,r.slotCount-1);for(let r=0;l>=r;r++){if(y[r].some(r=>t.conflicts(e[i],e[r])))continue;let l=0,c=0;for(let e of y[r])l+=a[i][e],c+=d[i][e];if(g[i]=r,y[r].push(i),m(i+1,Math.max(o,r),n+l,s+c),y[r].pop(),g[i]=-1,p>=75e3)return}};return g[0]=0,y[0].push(0),m(1,0,0,0),h}function Tn(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])1e-9>=t.topMass+t.botMass||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),i>r?{start:null,end:null}:{start:i,end:r}):{start:null,end:null}}function Cn(e,t,i,r){let o=yn(e,t,i,r),a=mn(o);if(a)return gn(a.slots,i,r);let n=wa();for(let t of e)n[t.id]=Tn(i[t.id],r[t.id]);let s=Pn(e,n),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=kn(t),d=_n(s,n,r,t,c,u),h=$n(s,d,u),f=Rn(s,d,t,{...h,assignment:Ln(s,d,t,h)}),p=/* @__PURE__ */new Map,g=f.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),y=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=wa();s.forEach((e,t)=>{let i=g[t],r=y[i];r.occupants.push({id:e,end:n[e].end??-1/0});let o=l.get(e)?.group;o&&(r.group=o),m[e]=i});for(let t of[...e].sort((e,t)=>ka(e.id,t.id)))null==m[t.id]&&(y[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(let e of y){e.occupants.sort((e,t)=>(n[e.id].start??1/0)-(n[t.id].start??1/0)||ka(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let x={slots:y,slotByNode:m};return xn(o,x),x}function Dn(e){return e.topMass+e.botMass}function zn(e){let t=/* @__PURE__ */new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let a=t.get(o);if(a){let e=a.reduce((e,t)=>Dn(t)<Dn(e)?e:t,a[0]);return{exact:a,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:a,sample:e.samples[i-1]??null}}}function En(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]))}function Nn(e,t,i,r,o,a,n=0){let s=/* @__PURE__ */new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=s.get(i.group)??[];e.push(i),s.set(i.group,e)}if(0===s.size||0>=a)return t;let l=En(t);for(let[e,c]of s){let s=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;let u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;let p=(h-u.peak.topPeak*a+(f+d.peak.botPeak*a))/2,g=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),y=/* @__PURE__ */new Map;for(let e of c)y.set(e.id,/* @__PURE__ */new Map);let m=new Map(c.map(e=>[e.id,zn(t[e.id])]));for(let e of g){let t=/* @__PURE__ */new Map;for(let i of c){let{sample:o}=m.get(i.id)(e);if(!o||1e-9>=Dn(o))continue;let a=r[i.id];if(null==a)continue;let n=t.get(a)??[];n.push({node:i,sample:o}),t.set(a,n)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Dn(e)))}));if(0===i.length)continue;let s=p-(i.reduce((e,t)=>e+t.mass,0)*a+Math.max(0,n)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(s-o[i.id])/a+r.topMass-(r.boundaryOffset??0);y.get(i.id).set(e,t)}s+=t.mass*a+Math.max(0,n)}}for(let e of c){let i=t[e.id],r=l[e.id],o=y.get(e.id),a=m.get(e.id),n=[];for(let e of g){let t=o.get(e),{exact:i,sample:r}=a(e);i?n.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||1e-9>=Dn(r)||n.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=n,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return l}function On(e,t,i,r,o){let{plotH:a,padding:n,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=o,g=wa(),y=wa();for(let t of e)g[t.id]=i[t.id].topPeak||0,y[t.id]=i[t.id].botPeak||0;let m="half"===u,x=wa();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,a=null!=i&&Number.isFinite(i)?i:-1/0;for(let e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);let t=m?(e.startTime+e.endTime)/2:e.endTime;t>a&&(a=t)}for(let e of r.incoming[t.id]){let t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>a&&(a=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>a&&(a=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(a)?a:null}}let b=wa(),v=[],w=[];if(o.frozenSlots){let e=gn(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(Aa)}else if("reuse"===l){let r=Cn(e,t,i,x);v=r.slots,b=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:g[e.id],botPeak:y[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});nn(v,b),0===w.length&&(w=v.map(Aa));let k=null;o.frozenSlots||(o.fixedSlotOrder?pn(v,b,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=fn(e,t,i,x,v,b,{plotH:a,padding:n,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:p}))),nn(v,b);let A=Ia(e,t,i,v,b,{plotH:a,padding:n,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,P=k?.before.weightedLength??null,$=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(Aa),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:$}}function Fn(e,t,i){let{plotH:r,pairing:o="temporal",packing:a="reuse",laneOrder:n="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=i,p=Number.isFinite(d)?Math.max(0,d):0,g=Xa(e,t),y=Ga(e,t,g,o),m=wa();for(let t of e)m[t.id]=Va(t,g,y,void 0,u);let x=On(e,t,m,g,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:n,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=/* @__PURE__ */new Set;for(let e of t){let t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=y.get(e.id);t!==i?t>i?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=g.outgoing[t.id],i=g.incoming[t.id],r=new Set(e.map(e=>y.get(e.id).sourceSide)),o=new Set(i.map(e=>y.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(y.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(y.get(i.id).sourceSide=t)}}Ua(t,y,x.slotByNode),Za(e,g,y,v),m=wa();for(let t of e)m[t.id]=Va(t,g,y,void 0,u);let w=On(e,t,m,g,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:n,lifetimeMode:s,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*p)/S),_=2*M+Sa(w.slots,M,p).reduce((e,t)=>e+t,0),P=k>0?Math.max(0,(r-_)/k):1,$=Number.isFinite(l)&&l>0?Math.min(P,l):P,L=On(e,t,m,g,{plotH:r,padding:M,valueScale:$,packing:a,laneOrder:n,lifetimeMode:s,frozenSlots:b,lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P}),I=Number.isFinite(l)&&l>0&&P>l+1e-12;if("insertion"!==n&&("hug"===c||I)&&L.slots.length>1&&(fn(e,t,m,L.laneLifetime,L.slots,L.slotByNode,{plotH:r,padding:M,valueScale:$,groupPadding:p,laneOrder:n,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),L=On(e,t,m,g,{plotH:r,padding:M,valueScale:$,packing:a,laneOrder:n,lifetimeMode:s,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(Aa),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})),Ha(g,y)){let i=qa(t,m,L.centerlines,$);m=wa();for(let t of e)m[t.id]=Va(t,g,y,i,u);L=On(e,t,m,g,{plotH:r,padding:M,valueScale:$,packing:a,laneOrder:n,lifetimeMode:s,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(Aa),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})}let R=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),T=[...L.slots].sort((e,t)=>(R.get(Aa(e))??1/0)-(R.get(Aa(t))??1/0)||ka(Aa(e),Aa(t))),C=wa();T.forEach((e,t)=>{for(let i of e.occupants)C[i.id]=t});let D=Ia(e,t,m,T,C,{plotH:r,padding:M,valueScale:$,stackValueScale:P,lanePlacement:"stack",groupPadding:p}),z=Nn(e,m,T,C,D.centerlines,$,p),E=Oa(un(C,t),dn(C,t),t,z,T,C,D.centerlines,L.laneLifetime,$,D.verticalUtilization,h,f);m=Nn(e,m,L.slots,L.slotByNode,L.centerlines,$,p);let N=Oa(un(L.slotByNode,t),dn(L.slotByNode,t),t,m,L.slots,L.slotByNode,L.centerlines,L.laneLifetime,$,L.verticalUtilization,h,f);return{nodeData:m,sides:y,valueScale:$,padding:M,compressedPadding:12>M,centerlines:L.centerlines,laneLifetime:L.laneLifetime,slots:L.slots,slotByNode:L.slotByNode,crossingsBefore:"insertion"===n?null:E.crossings,crossingsAfter:"insertion"===n?null:N.crossings,lengthBefore:"insertion"===n?null:E.weightedLength,lengthAfter:"insertion"===n?null:N.weightedLength,layoutQualityBefore:E,layoutQuality:N}}function Wn(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:a,tBot:n,cp1X:s,cp2X:l}=e,c=(i+r)/2,u=(a+n)/2;return{pathD:[`M${t},${i}`,`C${s},${i} ${l},${a} ${o},${a}`,`L${o},${n}`,`C${l},${n} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}function jn(e,t,i,r,o,a,n,s,l={}){let c,u,d,h,f=o,p=e=>s?Math.max(s[0],Math.min(s[1],e)):e,g=a(p(e.time)),y=a(p(i.time)),m=e.value*f,x=i.value*f,b=t+(e.boundaryOffset??0)*f,v=r+(i.boundaryOffset??0)*f,w=e.sideMassBefore*f,k=i.sideMassAfter*f;"top"===e.side?(c=b-w,u=c+m):(u=b+w,c=u-m),"top"===i.side?(d=v-k,h=d+x):(h=v+k,d=h-x);let A=l.sourceRunwayStart,S=l.minRun,M=Math.abs((d+h)/2-(c+u)/2),_=y-g,P="number"==typeof A&&Number.isFinite(A),$="number"==typeof S&&Number.isFinite(S)&&S>0;if(P&&M>1e-9&&_>0&&("auto"===S||$)){let t="source"===n?.85:"target"===n?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>_){let t=a(p(Math.min(A,e.time)));Number.isFinite(t)&&(g=Math.min(g,Math.max(Math.min(g,t),y-i)))}}let L="source"===n?g+.85*(y-g):"target"===n?g+.15*(y-g):(g+y)/2;return{sx:g,sTop:c,sBot:u,tx:y,tTop:d,tBot:h,cp1X:L,cp2X:L}}function Bn(e,t,i,r,o,a){let n=new Map(t),s=/* @__PURE__ */new Map;for(let t of e){let e=a?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,r=s.get(i)??/* @__PURE__ */new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(i,r)}for(let e of s.values())for(let[a,s]of e){if(!s.some(e=>i.has(e.id)))continue;let e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let l=r(a),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;let u=Math.max(...s.map(e=>{let t=i.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(let e of s){let i=t.get(e.id),r=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);n.set(e.id,{...i,sx:d,cp1X:r,cp2X:r})}}return n}function Yn(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),a=/* @__PURE__ */new Map;for(let e of t){if(r.has(e.source))continue;let t=a.get(e.source)??[];t.push(e),a.set(e.source,t)}let n=/* @__PURE__ */new Map;for(let t of e){if(!t.group)continue;let e=n.get(t.group)??[];e.push(t),n.set(t.group,e)}let s=/* @__PURE__ */new Set;for(let[e,t]of n){let i=t.flatMap(e=>a.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(a.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&s.add(e)}let l=/* @__PURE__ */new Map;for(let[e,t]of a){let r=o.get(e);if(r?.group&&!s.has(r.group))continue;let a=r?.xExtent?.[0],n=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=n[0]?.startTime-1,u=null;for(let e=0;n.length>e;){let t=n[e].startTime,r=e+1;for(;n.length>r&&n[r].startTime===t;)r++;for(let t=e;r>t;t++){let e=n[t],r=Number.isFinite(a)&&e.startTime>a,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let s=i[0];r&&(s=Math.max(s,a)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&l.set(e.id,s)}u=t,e=r}}for(let[e,t]of n){if(!s.has(e))continue;let i=t.flatMap(e=>a.get(e.id)??[]);if(!i.every(e=>l.has(e.id))){for(let e of i)l.delete(e.id);continue}let r=Math.max(...i.map(e=>l.get(e.id)));for(let e of i)l.set(e.id,r)}return l}function Xn(e,t,i,r,o){let a=/* @__PURE__ */new Map;for(let n of e){if(!i.has(n.id))continue;let e=t.get(n.id);if(!e||e.sx>=r(n.startTime)-1e-9)continue;let s=o(e.sx);Number.isFinite(s)&&n.startTime>s&&a.set(n.id,s)}return a}function Gn(e,t,i){let r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let a of e){let e=t.get(a.id);if(null==e||!Number.isFinite(e)||e>=a.startTime)continue;let n=i?.get(a.source),s=null==n?[a.source]:o.get(n)??[a.source];for(let t of s){let i=r.get(t)??/* @__PURE__ */new Map,o=i.get(a.startTime);i.set(a.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}function Vn(e,t){return t&&0!==t.size?e.map(e=>{let i=t.get(e.t);return null==i?e:{...e,t:i}}):e}function qn(e){return Math.max(18,11*e.length*.58)}function Hn(e){let t=1.22*qn(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Un(e,t){let i=e.labelX-qn(e.labelText),r=t.labelX-qn(t.labelText);return t.labelX+3>=i&&e.labelX+3>=r}function Zn(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)Un(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;i.length>t;t+=1)Un(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}function Kn(e,t,i){let r=e.map(e=>({...e})),o=/* @__PURE__ */new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let a=e=>{if(2>e.length)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-qn(r.labelText);t.length>0&&e>i+3&&(a(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}a(t)}return Zn(r,i),r}function Qn(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*qn(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}let o=[],a=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of a){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=/* @__PURE__ */new Map;for(let i of e){let[e,o]=Hn(i),a=t.findIndex(t=>e>t+8);-1===a&&(a=t.length),t[a]=o,r.set(i,a)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,a=14*t.length+8>o;for(let t of e){let e=r.get(t)??0;t.labelY=a?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}function Jn(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let a=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(a=Math.min(a,Math.floor(o.maxLabels)));let n=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+qn(e.labelText):qn(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(n.slice(0,a).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}function es(e){return e.replace($w,(e,t,i)=>`${i},${t}`)}function ts(e){if(!e)return;let t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function is(e){return{...e,pathD:es(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function rs(e,t){return"horizontal"===t?e:{...e,pathD:es(e.pathD),gradientStubs:e.gradientStubs?.map(is),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function os(e,t){return"horizontal"===t?e:{...e,pathD:es(e.pathD),bezier:ts(e.bezier)}}function as(e){let{nodes:t,edges:i,domain:r,plotW:o,plotH:a,ribbonLane:n,ribbonMinRun:s=0,edgeOpacity:l,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:g="raw",styleRules:y,colorBy:m,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?a:o,w="vertical"===d?o:a,k=xa(t,i,r,{usageMode:b}),{fatal:A,warnings:S}=ma(k),M=ba(i,k,b),_=bw().domain(r).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};let P=Fn(t,M,{plotH:w,...u,ribbonLane:n,domain:r}),{centerlines:$,nodeData:L,valueScale:I}=P,R=Xy(m,x),T=[],C=[],D=0===s?/* @__PURE__ */new Map:Yn(t,M,r),z=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),E=/* @__PURE__ */new Map;for(let e of M){let t=L[e.source]?.localAttachments.get(e.id),i=L[e.target]?.localAttachments.get(e.id);!t||!i||E.set(e.id,jn(t,$[e.source],i,$[e.target],I,_,n,r,{minRun:s,sourceRunwayStart:D.get(e.id)}))}let N=Bn(M,E,D,_,n,z),O=Xn(M,N,D,_,e=>r[0]+e/v*(r[1]-r[0])),F=Gn(M,O,z);t.forEach((e,t)=>{let i=L[e.id];if(!i||0===i.samples.length)return;let o=Vn(i.samples,F.get(e.id)),a=Ba(o,$[e.id],I,_,r);if(!a)return;let n,s,l=Wa(o,r),u=l.find(e=>e.topMass+e.botMass>0)||l[0],h=$[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*I/2,f=c(e.id,t),p=f,g=.5,m=e.__raw??e;if(y&&y.length>0){let e=Gy(m,y,R(m));"string"==typeof e.fill?f=e.fill:null!=e.fill&&di(e.fill)&&(s=e.fill,f=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:f),"string"==typeof e.stroke&&(p=e.stroke),"number"==typeof e.strokeWidth&&(g=e.strokeWidth),"number"==typeof e.fillOpacity&&(n=e.fillOpacity),"number"==typeof e.opacity&&null==n&&(n=e.opacity)}let x=Ya(e.id,M,P,_,r,O);T.push({id:e.id,pathD:a,fill:f,stroke:p,strokeWidth:g,...null!=n&&{fillOpacity:n},...s&&{hatchFill:s},...x.length>0&&{gradientStubs:x},rawDatum:m,labelX:_("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});let W=/* @__PURE__ */new Map;t.forEach((e,t)=>W.set(e.id,t)),M.forEach(e=>{let t=N.get(e.id);if(!t)return;let i=W.get(e.source)??0,r=c(e.source,i),{pathD:o,bezier:a}=Wn(t),n=e.__raw??e,s="function"==typeof l?Number(l(n)):l,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;C.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:n,bezier:a})});let j=Kn(T,P.slotByNode,w).map(e=>rs(e,d)),B="vertical"===d?Qn(j,o,a):j,Y=/* @__PURE__ */new Map;if(null!=f)for(let e of t){let t=e.__raw??e,i="function"==typeof f?f(t):Number(t[f]);Number.isFinite(i)&&Y.set(e.id,i)}let X=Jn(B,o,a,h,{...Y.size>0&&{priorityById:Y},...null!=p&&{maxLabels:p}});return{layout:P,layoutConfig:{bands:X,ribbons:C.map(e=>os(e,d)),showLabels:!1!==h,selectionDatum:g},issues:[],warnings:S,xScale:_}}function ns(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function ss(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,a=e.plotH,n=e.timelineExtent,s=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,f=e.toTime,p=e.xScale,{centerlines:g,laneLifetime:y,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null;for(let e of i){let t=y[e.id];if(!t||null===t.start||null===t.end)continue;let i=p(t.start),r=p(t.end);(null===S||S>i)&&(S=i),(null===M||r>M)&&(M=r)}let _=e=>Math.max(0,Math.min(n,e)),P=_(S??0),$=Math.max(P,_(M??n)),L=s.map((e,t)=>({tick:e,index:t,coordinate:p(f(e.date))})).filter(({coordinate:e})=>e>=P-.5&&$+.5>=e),I=null!==(w??null)&&null!=k&&null!=A,R=l&&(I||u.length>0)?/* @__PURE__ */Rw("g",{fill:Dw,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */Rw(Lw,{children:[
|
|
91
|
+
/* @__PURE__ */Rw("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),
|
|
92
|
+
/* @__PURE__ */Rw("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),u.map((e,t)=>/* @__PURE__ */Rw("text",{x:o,y:I?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,T=b?/* @__PURE__ */Iw("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:Dw,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,C=(e,t)=>h?h(e,t):Tw;/* @__PURE__ */
|
|
93
|
+
return Rw("g","vertical"===r?{children:[R,T,L.map(({index:e,coordinate:t})=>/* @__PURE__ */Iw("line",{x1:0,y1:t,x2:o,y2:t,stroke:Tw,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=y[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},a=g[e.id]+(o.botPeak-o.topPeak)*x/2,n=p(i.start),s=p(i.end),l=C(e.id,t);/* @__PURE__ */
|
|
94
|
+
return Rw("g",{children:[
|
|
95
|
+
/* @__PURE__ */Iw("line",{x1:a,y1:n,x2:a,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
|
|
96
|
+
/* @__PURE__ */Iw("line",{x1:a-4,y1:n,x2:a+4,y2:n,stroke:l,strokeOpacity:.5}),
|
|
97
|
+
/* @__PURE__ */Iw("line",{x1:a-4,y1:s,x2:a+4,y2:s,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),
|
|
98
|
+
/* @__PURE__ */Iw("line",{x1:-4,y1:P,x2:-4,y2:$,stroke:Tw}),L.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";/* @__PURE__ */
|
|
99
|
+
return Rw("g",{transform:`translate(-4,${i})`,children:[
|
|
100
|
+
/* @__PURE__ */Iw("line",{x2:-6,stroke:Tw}),
|
|
101
|
+
/* @__PURE__ */Iw("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Cw,children:o})]},t)})]}:{children:[R,T,L.map(({index:e,coordinate:t})=>/* @__PURE__ */Iw("line",{x1:t,y1:0,x2:t,y2:a,stroke:Tw,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=y[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},a=g[e.id]+(o.botPeak-o.topPeak)*x/2,n=p(i.start),s=p(i.end),l=C(e.id,t);/* @__PURE__ */
|
|
102
|
+
return Rw("g",{children:[
|
|
103
|
+
/* @__PURE__ */Iw("line",{x1:n,y1:a,x2:s,y2:a,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
|
|
104
|
+
/* @__PURE__ */Iw("line",{x1:n,y1:a-4,x2:n,y2:a+4,stroke:l,strokeOpacity:.5}),
|
|
105
|
+
/* @__PURE__ */Iw("line",{x1:s,y1:a-4,x2:s,y2:a+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),
|
|
106
|
+
/* @__PURE__ */Iw("line",{x1:P,y1:a+4,x2:$,y2:a+4,stroke:Tw}),L.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";/* @__PURE__ */
|
|
107
|
+
return Rw("g",{transform:`translate(${i},${a+4})`,children:[
|
|
108
|
+
/* @__PURE__ */Iw("line",{y2:6,stroke:Tw}),
|
|
109
|
+
/* @__PURE__ */Iw("text",{y:20,textAnchor:"middle",fontSize:11,fill:Cw,children:o})]},t)})]})}function ls(e,t){return"scene"===t?e:e.data}function cs(e,t,i){return!t?.isActive||t.predicate(ls(e,i))}function us(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function ds(e,t,i,r){if(e&&e.length>0)return e;let o=/* @__PURE__ */new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],a="function"==typeof r?r(e):e[r];o.add(t),o.add(a)}),Array.from(o).map(e=>({id:e}))}function hs({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:a={}}){return n=>{let s={fillOpacity:o,...a};if("function"==typeof e)s.fill=e(n);else if("source"===e){let e="object"==typeof n.source?n.source:null;t&&e?s.fill=_e(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof n.target?n.target:null;t&&e?s.fill=_e(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function fs(e,t,i={}){return ur(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function ps(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?a=>{let n=a?.data||a,s=o;if("number"==typeof t)s=t;else if("function"==typeof t)s=t(n);else if("string"==typeof t){let e=n?.[t],i="number"==typeof e?e:Number(e);s=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:s,opacity:r??e.opacity??.6}}:void 0}function gs(e,t,i){let[r,o]=i;if(!t)return r;let[a,n]=t,s=n>a?n-a:0,l=Number(e),c=Number.isFinite(l)?l:a;return r+Math.max(0,Math.min(1,s>0?(c-a)/s:0))*(o-r)}function ys(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:a,edgeLinecap:n,styleRules:s}=e,l=By(t);return Vy(e=>({stroke:o(e),strokeWidth:gs(e[t],i,r),strokeLinecap:n,opacity:a,fillOpacity:0}),s,e=>({value:l(e)}))}function ms(e,t,i,r){let o,a,n=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?n:n.map(e=>({...e,__geoColorBy:t(e)}));o=$e(r,e,i)}if(r.sizeBy){let e=n.map("function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(a=Nm(e))}return e=>({fill:t&&o?_e(e,t,o):Ix,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?Ie(e,r.sizeBy,r.sizeRange,a):r.pointRadius??6})}function xs(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function bs(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,a=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(o>e&&(o=e),e>a&&(a=e))}let n=[Number.isFinite(o)?o:0,Number.isFinite(a)?a:1],s=Gw(Ae(i)).domain(n);return{domain:n,colorScale:e=>s(e),valueAccessor:r}}function vs(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}function ws(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let i=tk.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;let r=Date.parse(i);return Number.isFinite(r)?r:NaN}function ks(e){return e instanceof Date?e.getTime():"string"==typeof e?ws(e):+e}function As(e){return new Set(Array.isArray(e)?e:[e])}function Ss(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Ms(e,t){return Math.min((e-t.startTime)/t.duration,1)}function _s(e,t,i){return e+(t-e)*i}function Ps(){return"u">typeof performance?performance.now():Date.now()}function $s(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Ls(e){let 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;let i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}function Is(e,t,i){if(1>=i)return 1;let r=i-1;return Ls({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function Rs(e){let t=/* @__PURE__ */new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function Ts(e,t,i,r=Rs(i)){let o=i.length;if(o>1)for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;let a=Array(t.length),n=!1;for(let i=0;t.length>i;i++){let s=r.get(t[i]);null!=s?(a[i]=Is(e,s,o),1>a[i]&&(n=!0)):a[i]=1}n&&(i._decayOpacities=a);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],a=i.topPath?i.topPath.length:t.length;if(2>a)continue;if(t.length===a){let n=Array(a),s=!1;for(let i=0;t.length>i;i++){let a=r.get(t[i]);null!=a?(n[i]=Is(e,a,o),1>n[i]&&(s=!0)):n[i]=1}s&&(i._decayOpacities=n)}else{let n=1;for(let i of t){let t=r.get(i);if(null!=t){let i=Is(e,t,o);n>i&&(n=i)}}if(1>n){let e=Array(a);e.fill(n),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let a=Is(e,t,o);"candlestick"===i.type?i._decayOpacity=a:i.style={...i.style,opacity:(i.style?.opacity??1)*a}}}function Cs(e,t,i){let r=e.duration??500,o=i-t;return r>o?1-o/r:0}function Ds(e,t,i,r,o,a=("u">typeof performance?performance.now():Date.now())){let n=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1,c=o??(()=>{let e=/* @__PURE__ */new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,s=!1;for(let i of t){let t=c.get(i);if(null==t)continue;s=!0;let n=r.get(t);if(null==n)continue;let l=Cs(e,n,a);l>o&&(o=l)}s&&(l=zs(i,o,n)||l);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);l=zs(i,null==o?0:Cs(e,o,a),n,s)||l}return l}function zs(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Es(e,t,i=("u">typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&r>i-o}function Ns(e){return[e[0],e[1]]}function Os(e,t,i,r){let o,a=/* @__PURE__ */new Map;for(let i=0;t.length>i;i++)a.set(t[i],e[i]);for(let e of r){let t=a.get(e);if(t){o=t;break}}let n,s=Array(i.length),l=Array(i.length);for(let e=0;i.length>e;e++){l[e]=Ns(i[e]);let t=a.get(r[e]);t?(s[e]=Ns(t),n=t):s[e]=Ns(n??o??i[e])}return{prev:s,target:l}}function Fs(e,t,i){if(Array.isArray(t)&&t.length===i&&0!==i){if(e.getPointId){let i=t.map(t=>e.getPointId(t)+"");if(i.every(e=>e.length>0))return i}if("streaming"===e.runtimeMode){let i=t.map(t=>"x:"+e.getX(t));if(new Set(i).size===i.length)return i}}}function Ws(e,t,i){return t.pathIds&&t.pathIds.length===i?t.pathIds:Fs(e,t.datum,i)}function js(e,t){if(e.length!==t.length)return!0;for(let i=0;e.length>i;i++)if(e[i][0]!==t[i][0]||e[i][1]!==t[i][1])return!0;return!1}function Bs(e,t,i,r){r.set(i,"line"!==t.type?{topPath:t.topPath.map(Ns),bottomPath:t.bottomPath.map(Ns),pathIds:Ws(e,t,t.topPath.length),opacity:t.style?.opacity}:{path:t.path.map(Ns),pathIds:Ws(e,t,t.path.length),opacity:t.style?.opacity})}function Ys(e,t,i){if(!i.path)return!1;let r=Ws(e,t,t.path.length),o=i.pathIds;if(o&&r&&o.length===i.path.length&&r.length===t.path.length){let e=Os(i.path,o,t.path,r);return!(!js(e.prev,e.target)&&void 0===t._introClipFraction||(t._targetPath=e.target,t._prevPath=e.prev,t.path=e.prev.map(Ns),0))}if(i.path.length===t.path.length){t._targetPath=t.path.map(Ns),t._prevPath=i.path;for(let e=0;t.path.length>e;e++)t.path[e]=Ns(i.path[e]);return!0}return!1}function Xs(e,t,i){if(!i.topPath||!i.bottomPath)return!1;let r=Ws(e,t,t.topPath.length),o=i.pathIds;if(o&&r&&o.length===i.topPath.length&&r.length===t.topPath.length&&i.bottomPath.length===i.topPath.length&&t.bottomPath.length===t.topPath.length){let e=Os(i.topPath,o,t.topPath,r),a=Os(i.bottomPath,o,t.bottomPath,r);return!(!js(e.prev,e.target)&&!js(a.prev,a.target)&&void 0===t._introClipFraction||(t._targetTopPath=e.target,t._targetBottomPath=a.target,t._prevTopPath=e.prev,t._prevBottomPath=a.prev,t.topPath=e.prev.map(Ns),t.bottomPath=a.prev.map(Ns),0))}if(i.topPath.length===t.topPath.length&&i.bottomPath.length===t.bottomPath.length){t._targetTopPath=t.topPath.map(Ns),t._targetBottomPath=t.bottomPath.map(Ns),t._prevTopPath=i.topPath,t._prevBottomPath=i.bottomPath;for(let e=0;t.topPath.length>e;e++)t.topPath[e]=Ns(i.topPath[e]);for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=Ns(i.bottomPath[e]);return!0}return!1}function Gs(e,t,i,r,o){if(!i)return t._targetOpacity=t.style.opacity??1,t._startOpacity=0,t.style={...t.style,opacity:0},!0;r.add(o);let a="line"===t.type?Ys(e,t,i):Xs(e,t,i);return t._targetOpacity=t.style.opacity??1,t._startOpacity=i.opacity??t.style.opacity??1,a}function Vs(e,t){let i=[];for(let[r,o]of e)if(!t.has(r))if(r.startsWith("l:")&&o.path){let e={type:"line",path:o.path.map(Ns),group:r.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:o.opacity??1},_targetOpacity:0,_transitionKey:r,datum:null};i.push(e)}else if(r.startsWith("a:")&&o.topPath&&o.bottomPath){let e={type:"area",topPath:o.topPath.map(Ns),bottomPath:o.bottomPath.map(Ns),group:r.slice(2),style:{fill:"#999",opacity:o.opacity??1},_targetOpacity:0,_transitionKey:r,datum:null};i.push(e)}return i}function qs(e,t){if(void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_s(e._startOpacity??0,e._targetOpacity,t)}),void 0!==e._introClipFraction&&(e._introClipFraction=t),"line"===e.type){let i=e._prevPath,r=e._targetPath;if(i&&r&&i.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=_s(i[o][0],r[o][0],t),e.path[o][1]=_s(i[o][1],r[o][1],t);return}let i=e._prevTopPath,r=e._prevBottomPath,o=e._targetTopPath,a=e._targetBottomPath;if(i&&o&&i.length===e.topPath.length)for(let r=0;e.topPath.length>r;r++)e.topPath[r][0]=_s(i[r][0],o[r][0],t),e.topPath[r][1]=_s(i[r][1],o[r][1],t);if(r&&a&&r.length===e.bottomPath.length)for(let i=0;e.bottomPath.length>i;i++)e.bottomPath[i][0]=_s(r[i][0],a[i][0],t),e.bottomPath[i][1]=_s(r[i][1],a[i][1],t)}function Hs(e){if("line"===e.type){let t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];return e._prevPath=void 0,e._targetPath=void 0,void(e._introClipFraction=void 0)}let t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}function Us(e,t,i){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){let i=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Zs(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Ks(e,t,i,r){i.clear(),r.clear();for(let o=0;t.length>o;o++){let a=t[o],n=Us(e,a,o);n&&("point"===a.type?i.set(n,{x:a.x,y:a.y,r:a.r,opacity:Zs(a.style)}):"glyph"===a.type?i.set(n,{x:a.x,y:a.y,r:a.size,opacity:Zs(a.style),glyph:a.glyph}):"rect"===a.type||"heatcell"===a.type?i.set(n,{x:a.x,y:a.y,w:a.w,h:a.h,opacity:Zs(a.style)}):"candlestick"===a.type?i.set(n,{x:a.x,y:a.openY,w:a.bodyWidth,openY:a.openY,closeY:a.closeY,highY:a.highY,lowY:a.lowY,opacity:Zs(a.style)}):("line"===a.type||"area"===a.type)&&Bs(e,a,n,r))}}function Qs(e,t,i,r,o,a=Ps()){if(0===r.size&&0===o.size)return i;let n=t.duration??300;if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let s=!1,l=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;for(let t=0;i.scene.length>t;t++){let a=i.scene[t],n=Us(e,a,t);if(!n)continue;if(a._transitionKey=n,"line"===a.type||"area"===a.type){Gs(e,a,o.get(n),c,n)&&(s=!0);continue}let u=r.get(n);if("point"===a.type)if(u){l.add(n);let e={x:a.x,y:a.y,r:a.r};a._targetOpacity=Zs(a.style),(u.x!==e.x||u.y!==e.y||u.r!==e.r)&&(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=u.x,a.y=u.y,a.r=u.r??a.r,s=!0)}else a._targetOpacity=Zs(a.style),a.style={...a.style,opacity:0},s=!0;else if("glyph"===a.type)if(u){l.add(n);let e={x:a.x,y:a.y,size:a.size};a._targetOpacity=Zs(a.style),(u.x!==e.x||u.y!==e.y||u.r!==e.size)&&(a._targetX=e.x,a._targetY=e.y,a._targetR=e.size,a.x=u.x,a.y=u.y,a.size=u.r??a.size,s=!0)}else a._targetOpacity=Zs(a.style),a.style={...a.style,opacity:0},s=!0;else if("rect"===a.type)if(u){l.add(n);let e={x:a.x,y:a.y,w:a.w,h:a.h};a._targetOpacity=Zs(a.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=u.x,a.y=u.y,a.w=u.w??a.w,a.h=u.h??a.h,s=!0)}else a._targetOpacity=Zs(a.style),a.style={...a.style,opacity:0},s=!0;else if("heatcell"===a.type)if(u){l.add(n);let e={x:a.x,y:a.y,w:a.w,h:a.h};a._targetOpacity=Zs(a.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=u.x,a.y=u.y,a.w=u.w??a.w,a.h=u.h??a.h,s=!0)}else a._targetOpacity=Zs(a.style),a.style={...a.style||{},opacity:0},s=!0;else if("candlestick"===a.type)if(u&&null!=u.openY){l.add(n);let e={x:a.x,openY:a.openY,closeY:a.closeY,highY:a.highY,lowY:a.lowY};a._targetOpacity=Zs(a.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(a._targetX=e.x,a._targetOpenY=e.openY,a._targetCloseY=e.closeY,a._targetHighY=e.highY,a._targetLowY=e.lowY,a.x=u.x,a.openY=u.openY,a.closeY=u.closeY??a.closeY,a.highY=u.highY??a.highY,a.lowY=u.lowY??a.lowY,s=!0)}else a._targetOpacity=Zs(a.style),a.style={...a.style||{},opacity:0},s=!0}let u=Vs(o,c);u.length&&(i.exitNodes.push(...u),s=!0);for(let[e,t]of r)if(!l.has(e)){if(e.startsWith("p:"))i.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)i.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:"))i.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:"))i.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:")){let r=t.openY??t.y;i.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}s=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),s&&(i.activeTransition={startTime:a,duration:n}),i}function Js(e,t,i,r,o){if(!i.activeTransition)return!1;let a=Ms(e,i.activeTransition),n=Ss(a,"linear"===t.easing?"linear":"ease-out-cubic");for(let e of i.scene){let t=e._transitionKey;if("line"!==e.type&&"area"!==e.type){if("point"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=_s(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=_s(i.x,e._targetX,n),e.y=_s(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.r=_s(i.r,e._targetR,n))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=_s(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=_s(i.x,e._targetX,n),e.y=_s(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.size=_s(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=_s(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=_s(i.x,e._targetX,n),e.y=_s(i.y,e._targetY,n),void 0!==i.w&&(e.w=_s(i.w,e._targetW,n)),void 0!==i.h&&(e.h=_s(i.h,e._targetH,n))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:_s(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=_s(i.x,e._targetX,n),e.y=_s(i.y,e._targetY,n),void 0!==i.w&&(e.w=_s(i.w,e._targetW,n)),void 0!==i.h&&(e.h=_s(i.h,e._targetH,n))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:_s(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=_s(i.x,e._targetX,n),void 0!==i.openY&&(e.openY=_s(i.openY,e._targetOpenY,n)),void 0!==i.closeY&&(e.closeY=_s(i.closeY,e._targetCloseY,n)),void 0!==i.highY&&(e.highY=_s(i.highY,e._targetHighY,n)),void 0!==i.lowY&&(e.lowY=_s(i.lowY,e._targetLowY,n))}}else qs(e,n)}if(a>=1){for(let e of i.scene){if(void 0!==e._targetOpacity){let t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("line"!==e.type&&"area"!==e.type){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 Hs(e)}if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}function el(e){ik[e.chartType]=e}function tl(e){return ik[e]}function il(e){return Array.isArray(e)?{nodes:e,binBoundaries:[]}:{nodes:e.nodes,binBoundaries:e.binBoundaries}}function rl(e){tl(e)||rk&&(ok.has(e)||(ok.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}function ol(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;al(r)&&0===i.length&&nl(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&nl(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function al(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(al))}function nl(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function sl(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."}}}function ll(e,t,i,r){let o=sl(t),a="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:a,message:`Semiotic ${e} ${a} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}function cl(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=ll(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function ul(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?NaN:+t}}function dl(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=ul(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=Cy(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:ul(e.y1Accessor,"y1"),getBottom:ul(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function hl(e,t,i,r,o,a=!1){let n=/* @__PURE__ */new Map;for(let s of e){let e=t(s),l=i(s);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;let c=Math.floor(e/r)*r,u=n.get(c);if(u||(u={start:c,end:c+r,total:0,categories:/* @__PURE__ */new Map,...a?{rows:[],categoryRows:/* @__PURE__ */new Map}:{}},n.set(c,u)),u.total+=l,u.rows?.push(s),o){let e=o(s);if(u.categories.set(e,(u.categories.get(e)||0)+l),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(s)}}}return n}function fl(e,t,i,r,o){let a=hl(e,t,i,r,o);if(0===a.size)return[0,0];let n=0;for(let e of a.values())e.total>n&&(n=e.total);return[0,n]}function pl(e,t){let i=0,r=0,o=0;for(let a of e){let e=t(a);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>r&&(r=o))}return[i,r]}function gl(e,t,i,r,o,a){let n=[];for(let a of e){let e=i(a),s=r(a),l=o?o(a):0;if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(l))continue;let c=t.x(e),u=t.y(s),d=o?t.y(l):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||n.push({x:c,y:u,bottom:d,raw:s,datum:a})}n.sort((e,t)=>e.x-t.x);let s=Array(n.length),l=o?Array(n.length):[],c=Array(n.length),u=Array(n.length),d=a?Array(n.length):void 0;for(let e=0;n.length>e;e++){let t=n[e];s[e]=[t.x,t.y],o&&(l[e]=[t.x,t.bottom]),c[e]=t.raw,u[e]=t.datum,d&&a&&(d[e]=a(t.datum)+"")}return d?{topPath:s,bottomPath:l,rawValues:c,datum:u,pathIds:d}:{topPath:s,bottomPath:l,rawValues:c,datum:u}}function yl(e,t,i,r,o,a,n){let{topPath:s,rawValues:l,datum:c,pathIds:u}=gl(e,t,i,r,void 0,n),d={type:"line",path:s,rawValues:l,style:o,datum:c,group:a};return u&&(d.pathIds=u),d}function ml(e,t,i,r,o,a,n,s,l){return{type:"area",...gl(e,t,i,r,s??(()=>o),l),style:a,group:n}}function xl(e,t,i,r){let o=/* @__PURE__ */new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){let a=e[r-1],n=e[r],s=0,l=0,c=0;for(let e of t){let t=i(e,n)||0;s+=(2*c+t)*(t-(i(e,a)||0)),l+=t,c+=t}let u=o.get(a)??0;o.set(n,u-(l>0?s/(2*l):0))}if(e.length>0){let r=0;for(let a of e){let e=0;for(let r of t)e+=i(r,a)||0;r+=(o.get(a)??0)+e/2}let a=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-a)}}else for(let t of e)o.set(t,0);return o}function bl(e,t,i){let r=0,o=0;for(let a of e){let e=0,n=0;for(let r of t){let t=i(r,a)||0;0>t?n+=t:e+=t}r>n&&(r=n),e>o&&(o=e)}return[r,o]}function vl(e,t,i,r,o,a,n,s="zero",l){let c=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(let t of e){let e=/* @__PURE__ */new Map;for(let o of t.data){let t=i(o),a=r(o);if(!Number.isFinite(t)||(c.add(t),!Number.isFinite(a)))continue;let n=e.get(t);n?(n.value+=a,n.sources?n.sources.push(o):n.sources=[n.datum,o]):e.set(t,{value:a,datum:o})}u.set(t.key,e)}let d,h=Array.from(c).sort((e,t)=>e-t);if(a){d=/* @__PURE__ */new Map;for(let t of h){let i=0;for(let r of e)i+=u.get(r.key)?.get(t)?.value||0;d.set(t,i||1)}}let f=xl(h,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)?.value||0,s),p="diverging"===s&&!a,g=[],y=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(let e of h)m.set(e,f.get(e)??0),x.set(e,0),b.set(e,0);for(let i of e){let e=u.get(i.key),r=/* @__PURE__ */new Map,s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1,S=()=>{if(0!==s.length){if(s.length>=2){let e=A?s.map((e,t)=>t).sort((e,t)=>s[e][0]-s[t][0]):void 0,t=e?e.map(e=>v[e]):v,r={type:"area",topPath:e?e.map(e=>s[e]):s,bottomPath:e?e.map(e=>c[e]):c,rawValues:e?e.map(e=>f[e]):f,style:o(i.key,co(i.data)),datum:t,accessibleDatum:e?e.map(e=>w[e]):w,group:i.key};k&&(r.pathIds=e?e.map(e=>k[e]):k),n&&(r.curve=n),g.push(r)}s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1}};for(let o of h){let n,l,u=e.get(o),h=void 0!==u,g=u?.value??0;if(a&&h&&(g/=d.get(o)),!h||!Number.isFinite(g)||0===g){S();continue}p?g>0?(n=x.get(o),l=n+g,x.set(o,l)):(n=b.get(o),l=n+g,b.set(o,l)):(n=m.get(o),l=n+g,m.set(o,l));let y=t.x(o),M=t.y(n),_=t.y(l);if(!Number.isFinite(y)||!Number.isFinite(M)||!Number.isFinite(_)){S();continue}let P=u.sources,$=u.value,L=P?{...P[0],__aggregateValue:$,__aggregateCount:P.length,__aggregateRows:P}:u.datum;s.length>0&&s[s.length-1][0]>y&&(A=!0),s.push([y,_]),c.push([y,M]),v.push(L),f.push($),k&&k.push("x:"+o),w.push(P?{x:o,value:$,group:i.key,observations:P.length}:L),r.set(o,l)}S(),y.set(i.key,r)}return{nodes:g,stackedTops:y}}function wl(e,t,i,r,o,a,n){let s=i(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c={type:"point",x:t.x(s),y:t.y(l),r:o,style:a,datum:e};return void 0!==n&&(c.pointId=n),c}function kl(e,t,i,r,o,a,n,s){let l=i(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:a,style:n,datum:e};return void 0!==s&&(u.pointId=s),u}function Al(e,t,i,r,o,a,n){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:a,group:n}}function Sl(e,t,i,r,o,a,n){let s={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:a};return void 0!==n?.value&&(s.value=n.value),n?.showValues&&(s.showValues=!0,n.valueFormat&&(s.valueFormat=n.valueFormat)),s}function Ml(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function _l(e){let{config:t,groups:i,getX:r,getY:o}=e,a="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,a?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let n=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===n)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set,c=0,u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(let e of i){let t=/* @__PURE__ */new Map,i=0;for(let a of e.data){let e=r(a),n=o(a);if(!Number.isFinite(e)||!Number.isFinite(n))continue;t.set(e,(t.get(e)||0)+n),l.add(e),i+=n;let s=(u.get(e)||0)+n;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,i)}let h,f,p=t.stackOrder??"key",g=(e,t)=>t>e?-1:e>t?1:0;if("input"===p)h=i.map(e=>e.key);else if("insideOut"===p){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}),t=[],r=[],o=0,a=0;for(let i of e)a>o?(t.push(i),o+=d.get(i)??0):(r.push(i),a+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:g(e,t)}):"desc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}):i.map(e=>e.key).sort(g);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),i=xl(e,h,(e,t)=>s.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,a=u.get(t)??0;r>e&&(r=e),e+a>o&&(o=e+a)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let n=o-r,c=a?0:n>0?n*t.extentPadding:1;f=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),[i,r]=bl(e,h,(e,t)=>s.get(e)?.get(t)||0),o=r-i,n=a?0:o>0?o*t.extentPadding:1;f=[i-n,r+n]}else f=[0,c+(a?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:n,yDomain:f}}}function Pl(e,t,i,r,o,a,n){let[,s]=fl(e,t,i,r,o);return[0,n?s:s+s*a]}function $l(e,t,i,r){let[o,a]=pl(e,t),n=a-o,s=r?0:n>0?n*i:1;return[Math.min(0,o-Math.abs(s)),Math.max(0,a+Math.abs(s))]}function Ll(e,t,i,r,o){let a=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>a.length)return Ml(i,r);let n=a[0],s=a[1],l=a[a.length-1],c=a[a.length-2];return Ml("log"===o&&n>0?[n/Math.sqrt(s/n),l*Math.sqrt(l/c)]:[n-(s-n)/2,l+(l-c)/2],r)}function Il(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),a=t.getBottom(e);Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i)),Number.isFinite(a)&&(r>a&&(r=a),a>o&&(o=a))}return[r,o]}function Rl(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}function Tl(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}function Cl(e,t,i){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===i){let e=Date.now();r=[e-864e5,e]}else r=[0,1];return(o[0]===1/0||o[1]===-1/0)&&(o=[0,1]),{xDomain:r,yDomain:o}}function Dl(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return nk().domain(e).range(i).clamp(!0)}return"symlog"===e?sk().domain(t).range(i):"time"===e?lk().domain([new Date(t[0]),new Date(t[1])]).range(i):ak().domain(t).range(i)}function zl(e){let{config:t,layout:i,xDomain:r}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,a="streaming"===t.runtimeMode,n=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(a){let e="left"===t.arrowOfTime?[i.width-n,n]:[n,i.width-n];return{x:ak().domain(r).range(e),y:Dl(t.yScaleType,o,[i.height-n,n])}}return{x:Dl(t.xScaleType,r,[n,i.width-n]),y:Dl(t.yScaleType,o,[i.height-n,n])}}function El(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Pe(e,t):void 0}function Nl(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=/* @__PURE__ */new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}function Ol(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let a=/* @__PURE__ */new Set;if(t)for(let i of e){let e=t(i);e&&a.add(e)}let n=Array.from(a).sort(),s=n.join("\0");if(o&&o.key===s){let e={...o,version:r};return{map:e.map,cache:e}}let l=Se(i.colorScheme,i.themeCategorical,Rx),c=/* @__PURE__ */new Map;for(let e=0;n.length>e;e++)c.set(n[e],El(i.colorScheme,n[e])??l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}function Fl(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:a}=e,{groupColorCounter:n}=e,s=El(a.colorScheme,t);if(s)return{color:s,groupColorCounter:n};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:n}}let l=r.get(t);if(l)return{color:l,groupColorCounter:n};let c=Se(a.colorScheme,a.themeCategorical,Rx);if(0===c.length)return{color:null,groupColorCounter:n};let u=c[n%c.length];if(n++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:n}}function Wl(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let a=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||a||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||a||"#007bff",strokeWidth:2}}function jl(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let a=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||a||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||a||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let n=r(t)||a||"#4e79a7";return{fill:n,fillOpacity:.7,stroke:n,strokeWidth:2}}function Bl(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let a=r(t,i);return{fill:a.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=a.opacity&&{opacity:a.opacity},stroke:"none",cursor:a.cursor}}function Yl(e,t,i){e.capacity>=t||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Xl(e,t){let i=new Jw(e.capacity);return e.forEach(()=>i.push(t)),i}function Gl(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function Vl(e,t,i){if(!t||0===t.size)return;let r=/* @__PURE__ */new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}function ql(){return this.updateResults.last}function Hl(){return this.updateResults.last}function Ul(e){return this.updateResults.subscribe(e)}function Zl(e){this.config.layoutSelection=e}function Kl(){ck.set(this,!0)}function Ql(){let e=!0===ck.get(this);return ck.delete(this),e}function Jl(e){Object.assign(e.prototype,{getLastUpdateResult:ql,getUpdateSnapshot:Hl,subscribeUpdateResult:Ul,setLayoutSelection:Zl,markStylePaintPending:Kl,consumeStylePaintPending:Ql})}function ec(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=vk[r]??wk;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function tc(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)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("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(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)void 0!==t._targetX&&(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||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}function ic(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?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):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(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):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}function rc(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function oc(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:a,datum:n,pathIds:s}=gl(t,e.scales,e.getX,r.getTop,r.getBottom,e.getPointId);return 2>o.length?null:{type:"area",topPath:o,bottomPath:a,...s&&{pathIds:s},...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:rc(e,r,i,co(t)),datum:n,group:i,interactive:r.interactive}}function ac(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function nc(e,t,i){let r=[];for(let o of i){let i=oc(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function sc(e,t,i,r){let o=[];for(let a of r){let r=oc(e,t,i,a);r&&o.push(r)}return o}function lc(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let a of r.data){let r=e.config.pointStyle(a);!r.fill&&t&&(r={...r,fill:t});let n=r.r??3,s=e.getPointId?e.getPointId(a)+"":void 0,l=wl(a,e.scales,e.getX,o,n,r,s);l&&i.push(l)}}}function cc(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function uc(e){return mr(e)}function dc(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],a=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)e>r&&(e=r),r>t&&(t=r);a=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let n=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=l?Mm(l,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:s,opacity:.8},l=t.r||r;if(a&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(l=a(t))}if(n&&e.getColor&&!t.fill){let i=e.getColor(o);i&&n.has(i)&&(t={...t,fill:n.get(i)})}let u=e.getPointId?e.getPointId(o)+"":void 0;if(c){let r=c(o),a=kl(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);a&&i.push(a)}else{let r=wl(o,e.scales,e.getX,e.getY,l,t,u);r&&i.push(r)}}return i}function hc(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function fc(e){let t=Object.prototype.hasOwnProperty.call(vx,e)?e:"blues",i=$k.get(t);if(i)return i;i=Array(Pk);let r=Ae(t);for(let e=0;Pk>e;e++)i[e]=r(e/255);return $k.set(t,i),i}function pc(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function gc(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),a=e.config.heatmapAggregation??"count",n=Cy(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/o,f=r*o;if(f>1e6)return[];let p=new Int32Array(f),g=new Float64Array(f),y=e.config.trackHoverRows||uo(e.config.areaStyle)?/* @__PURE__ */new Map:void 0;for(let i=0;t.length>i;i++){let a=t[i],l=e.getX(a),u=e.getY(a);if(!isFinite(l)||!isFinite(u))continue;let f=Math.min(Math.floor((l-s)/d),r-1),m=Math.min(Math.floor((u-c)/h),o-1);if(0>f||0>m)continue;let x=m*r+f;p[x]++;let b=n(a);if(g[x]+=isFinite(b)?b:0,y){let e=y.get(x);e||(e=[],y.set(x,e)),e.push(a)}}let m=1/0,x=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(a){case"sum":t=g[e];break;case"mean":t=g[e]/p[e];break;default:t=p[e]}m>t&&(m=t),t>x&&(x=t)}if(!isFinite(m))return[];let b=e.config.heatmapColorScale,v=b?void 0:fc("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/r,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){let i=t*r;for(let n=0;r>n;n++){let r,l=i+n;if(0===p[l])continue;switch(a){case"sum":r=g[l];break;case"mean":r=g[l]/p[l];break;default:r=p[l]}let u=hc(r,m,x),f=b?b(r):v[u],_=A?{value:r,showValues:!0,valueFormat:S}:{value:r},P=no({xi:n,yi:t,value:r,count:p[l],sum:g[l],xCenter:s+(n+.5)*d,yCenter:c+(t+.5)*h,agg:a},y?.get(l));M.push(pc(Sl(n*w,(o-1-t)*k,w,k,f,P,_),P,e))}}return M}function yc(){for(let e of Object.keys(Lk))tl(e)||el({chartType:e,buildScene:Lk[e],canvasRenderers:[]})}function mc(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,a=Array.from(
|
|
110
|
+
/* @__PURE__ */new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),n="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,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:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:n,warnings:a,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function xc(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}function bc(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function vc(e){if(!e||2>e.length)return;let t=bc(e[0]),i=bc(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function wc(e){let{count:t,byType:i}=xc(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let a=Array.isArray(e.annotations)?e.annotations.length:0,n="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,s=e.margin,l=s?{x:s.left,y:s.top,width:e.width-s.left-s.right,height:e.height-s.top-s.bottom}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,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:e.annotationRender?.renderedCount??a,...e.annotationRender?.layout?{layout:e.annotationRender.layout}:{},...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:n,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...s?{margin:s}:{},...l?{plot:l}:{}}}function kc(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?i.value>e&&(r=i.color):e>i.value&&(r=i.color);return r}function Ac(e,t,i,r){if(2>e.length||t.length!==e.length||0===i.length)return[];let o=[],a=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){let[n,s]=e[o-1],[l,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){let t=h[e-1],o=h[e];a(kc(u+d*((t+o)/2),i,r),[n+(l-n)*t,s+(c-s)*t],[n+(l-n)*o,s+(c-s)*o])}}return o}function Sc(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Mc(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}function _c(e,t="#4e79a7"){return di(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Pc(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function $c(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;let a=_m(o,e.size);if(0>=a.scale)return null;let n=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${a.offsetX},${a.offsetY}) scale(${a.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=$m(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?Pc(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:Pm(i.fill,s,e.accent),a=t?i.stroke&&"none"!==i.stroke?t:void 0:Pm(i.stroke??"none",s,e.accent);return o||a?/* @__PURE__ */Dk("path",{d:i.d,fill:o??"none",stroke:a,strokeWidth:a?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});/* @__PURE__ */
|
|
111
|
+
return zk("g",{transform:n,opacity:1===u?void 0:u,children:[l&&c&&/* @__PURE__ */Dk("clipPath",{id:c,children:/* @__PURE__ */Dk("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?/* @__PURE__ */Dk("g",{children:d(e.ghostColor)}):null,l&&c?/* @__PURE__ */Dk("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function Lc(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>i.length?null:i.map((e,t)=>/* @__PURE__ */Dk("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function Ic(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,a=e.x,n=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,n=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,a=e.x,n=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,a=e.x+e.w,n=e.y);let s=Lc(i.stops,_c(e.style.fill));return s?/* @__PURE__ */Dk("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:a,y2:n,children:s}):null}function Rc(e){let{x:t,y:i,w:r,h:o}=e,{tl:a,tr:n,br:s,bl:l}=Mc(e),c=`M${t+a},${i}`;return c+=` L${t+r-n},${i}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+r},${i+n}`),c+=` L${t+r},${i+o-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${i+o}`),c+=` L${t+l},${i+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${i+o-l}`),c+=` L${t},${i+a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+a},${i}`),c+=" Z",c}function Tc(e,t,i){let r=Am(e.symbolType,e.size,e.path);/* @__PURE__ */
|
|
112
|
+
return Dk("path",{d:r,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?_c(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function Cc(e,t,i){let r="point"===e.type,o=r?"circle":"rect",a=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},n=`${i?i+"-":""}${r?"point":"xyrect"}-${t}-hatch`,s=di(e.style.fill)?pi(e.style.fill,n):void 0;/* @__PURE__ */
|
|
113
|
+
return zk(Ck.Fragment,{children:[s&&/* @__PURE__ */Dk("defs",{children:s}),Ck.createElement(o,{...a,fill:s?`url(#${n})`:_c(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function Dc(e){if(!1!==e?.interactive)return e?.style?.cursor}function zc(e,t,i){let r=Dc(t);return r&&null!=e&&!1!==e?/* @__PURE__ */Ok("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}function Ec(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)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function Nc(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0;for(let[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(let[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;let a=Lc(i.stops,_c(e.style.fill));return a?/* @__PURE__ */Fk("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:a}):null}function Oc(e,t,i,r){if(!e||2>t.length)return null;let o=Lc(e.stops,r);return o?/* @__PURE__ */Fk("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Fc(e,t,i,r=30){let o=Wc(e,t,i,r);return"area"===e.type?o:zc(o,e,"xy-cursor-"+t)}function Wc(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=mi(r.curve),a=o?Tk().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),n=Pc(`${i?i+"-":""}line-${t}-stroke-gradient`),s=Oc(r.strokeGradient,r.path,n,r.style.stroke||"#4e79a7");/* @__PURE__ */
|
|
114
|
+
return Wk(Ik.Fragment,{children:[s&&/* @__PURE__ */Fk("defs",{children:s}),
|
|
115
|
+
/* @__PURE__ */Fk("path",{d:a,fill:"none",stroke:s?`url(#${n})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{let o=e;if(0===o.topPath.length)return null;let a=mi(o.curve),n=!a||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:Rk().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(a)(o.topPath)??"",s=`${i?i+"-":""}area-${t}-hatch`,l=di(o.style.fill)?pi(o.style.fill,s):void 0,c=Pc(`${i?i+"-":""}area-${t}-gradient`),u=Nc(o,c),d=u?`url(#${c})`:l?`url(#${s})`:_c(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,f=a?Tk().x(([e])=>e).y(([,e])=>e).curve(a)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=Dc(o),g=p&&r>=0?/* @__PURE__ */Fk("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,y=Pc(`${i?i+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=m||x?null:Oc(o.strokeGradient,o.topPath,y,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)w>e&&(w=e),e>k&&(k=e);let A=x?o.strokeColorBands.map((e,r)=>Pc(`${i?i+"-":""}area-${t}-stroke-band-${r}`)):[],S=x?o.strokeColorBands.map((e,t)=>/* @__PURE__ */Fk("clipPath",{id:A[t],children:/* @__PURE__ */Fk("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>/* @__PURE__ */Fk("path",{d:f,fill:"none",stroke:e.color??_c(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?Ac(o.topPath,o.rawValues,o.colorThresholds,_c(o.style.stroke)).map((e,i)=>/* @__PURE__ */Fk("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):/* @__PURE__ */Fk("path",{d:f,fill:"none",stroke:b?`url(#${y})`:_c(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?i+"-":""}area-clip-${t}`;/* @__PURE__ */
|
|
116
|
+
return Wk("g",{children:[
|
|
117
|
+
/* @__PURE__ */Wk("defs",{children:[u,!u&&l,b,S,
|
|
118
|
+
/* @__PURE__ */Fk("clipPath",{id:e,children:/* @__PURE__ */Fk("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),
|
|
119
|
+
/* @__PURE__ */Wk("g",{clipPath:`url(#${e})`,children:[
|
|
120
|
+
/* @__PURE__ */Fk("path",{d:n,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,g]})]},"area-"+t)}/* @__PURE__ */
|
|
121
|
+
return Wk(Ik.Fragment,{children:[(u||l||b||S)&&/* @__PURE__ */Wk("defs",{children:[u,!u&&l,b,S]}),
|
|
122
|
+
/* @__PURE__ */Fk("path",{d:n,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,g]},"area-"+t)}case"point":case"rect":return Cc(e,t,i);case"symbol":return Tc(e,t);case"glyph":return $c(e,e.x,e.y,`${i??""}glyph-${e.pointId??t}`);case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,a,n]=Ec(i.fill),s=.299*o+.587*a+.114*n>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));/* @__PURE__ */
|
|
123
|
+
return Wk("g",{children:[
|
|
124
|
+
/* @__PURE__ */Fk("rect",{...r}),
|
|
125
|
+
/* @__PURE__ */Fk("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:l+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},"heatcell-"+t)}/* @__PURE__ */
|
|
126
|
+
return Fk("rect",{...r},"heatcell-"+t)}case"candlestick":{let r=e,o=`${i?i+"-":""}candle-${t}-hatch`,a=di(r.style?.fill)?pi(r.style.fill,o):void 0,n=a?`url(#${o})`:void 0,{fill:s,...l}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=n??r.wickColor;/* @__PURE__ */
|
|
127
|
+
return Wk(Ik.Fragment,{children:[a&&/* @__PURE__ */Fk("defs",{children:a}),
|
|
128
|
+
/* @__PURE__ */Wk("g",{style:l,children:[
|
|
129
|
+
/* @__PURE__ */Fk("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
|
|
130
|
+
/* @__PURE__ */Fk("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),
|
|
131
|
+
/* @__PURE__ */Fk("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},"candle-"+t)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=n??d;/* @__PURE__ */
|
|
132
|
+
return Wk(Ik.Fragment,{children:[a&&/* @__PURE__ */Fk("defs",{children:a}),
|
|
133
|
+
/* @__PURE__ */Wk("g",{style:l,children:[
|
|
134
|
+
/* @__PURE__ */Fk("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
|
|
135
|
+
/* @__PURE__ */Fk("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:n?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},"candle-"+t)}default:return null}}function jc(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.id&&"function"==typeof e.cacheKey&&"function"==typeof e.drawCanvas&&"function"==typeof e.renderStaticSVG}function Bc(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return jc(i)?i:void 0}function Yc(e,t){if("u">typeof process&&"production"===process.env?.NODE_ENV)return;let i=`${e}:${t}`;jk.has(i)||(jk.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Xc(e){let{node:t,index:i,renderMode:r,fallback:o}=e,a=Bc(r,t);if(!a)return{element:o(),renderedByBackend:!1};let n=a.renderStaticSVG({node:t,style:t.style??{},key:`${a.id}-${i}`});return null!=n?{element:zc(n,t,`${a.id}-${i}-cursor`),renderedByBackend:!0}:(Yc(a.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Gc(e){return Xc(e).element}function Vc(e){let t=[];return e.nodes.forEach((i,r)=>{let o=Xc({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!=o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}function qc(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>Pe(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:sx;return Bk().domain(e).range(r)}function Hc(e,t,i){if(0===e.length)return;let r=qc(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function Uc(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Zc(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Kc(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Qc(e){return e.typography.legendFontWeight}function Jc(e,t,i,r){let o=Zc(r);return t+i+Math.ceil(e.length*o*.58)}function eu(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:a,legendLayout:n}=e,{swatchSize:s,labelGap:l,itemGap:c,rowHeight:u}=w(n),d=s+l,h="top"===r||"bottom"===r,f=Math.max(s,o-a.left-a.right),p=t.map(e=>Jc(e,s,l,i));if(h){let e=Math.max(s,n?.maxWidth??f),i=[],r=0,o=0;p.forEach((t,a)=>{let n=0===o?t:o+c+t;o>0&&n>e?(i.push({start:r,end:a,width:o}),r=a,o=t):o=n}),t.length>0&&i.push({start:r,end:t.length,width:o});let a=Uc(n?.align),l=[];return i.forEach((i,r)=>{let o="center"===a?Math.max(0,(e-i.width)/2):"end"===a?Math.max(0,e-i.width):0;for(let e=i.start;i.end>e;e++)l.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:l,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}let g=p.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:g,height:t.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}function tu(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:a,legendLayout:n}=e,{swatchSize:s,labelGap:l,rowHeight:c}=w(n),u=s+l,d=Math.max(12,Zc(i)),h="top"===r||"bottom"===r,f=Math.max(s,o-a.left-a.right);if(h){let r=Math.max(s,n?.maxWidth??f),o=Uc(n?.align),a=0,l=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=eu({...e,categories:t,legendLayout:{...n,maxWidth:Math.max(s,r-d-8),align:"start"}}),h=o.label?d:0,f=o.label?Jc(o.label,0,0,i):0,p=h>0?h+8:0,g=p+u.width,y=Math.max(u.height,f);c.push({group:o,x:a,y:0,itemOffsetX:p,itemOffsetY:0,width:g,height:y,items:u.items}),a+=g+12,l=Math.max(l,y)}let h=c.length>0?a-12:0,p=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:h,height:l,swatchSize:s,labelOffset:u,swatchRadius:0}}let p=k(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c),g=0;return{groups:t.map((e,t)=>{let r=e.items.map(e=>Jc(e.label,s,l,i)),o=Math.max(0,...r,e.label?Jc(e.label,0,0,i):0);return g=Math.max(g,o),{group:e,x:0,y:p[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:o,height:e.items.length*c,items:e.items.map((e,t)=>({category:e.label,width:r[t],x:0,y:t*c}))}}),width:g,height:p.at(-1)?.endY??0,swatchSize:s,labelOffset:u,swatchRadius:0}}function iu(e){return e.flatMap(e=>e.items.map((t,i)=>({group:e,item:t,itemIndex:i,label:t.label})))}function ru(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}function ou(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:a,totalHeight:n,margin:s}=e;if(!t||0===t.length)return null;let l=qc(t,i,r),c="top"===o||"bottom"===o,d=eu(e),h={...Hc(t,i,r),legendDistance:e.legendDistance},f=e.reservedWidth??u(h,e.legendLayout),{x:p,y:g}=v(h,{totalWidth:a,totalHeight:n,margin:s,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:f});if(c){let e=d.items.map((e,t)=>/* @__PURE__ */Xk("g",{transform:`translate(${e.x},${e.y})`,children:[
|
|
136
|
+
/* @__PURE__ */Yk("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),
|
|
137
|
+
/* @__PURE__ */Yk("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Zc(r),fill:r.colors.text,fontFamily:Kc(r),children:e.category})]},"legend-"+t));/* @__PURE__ */
|
|
138
|
+
return Yk("g",{className:"semiotic-legend",transform:`translate(${p},${g})`,fontWeight:Qc(r),children:e})}let y=k([{hasLabel:!1,itemCount:t.length}],Math.max(d.swatchSize,e.legendLayout?.rowHeight??22))[0],m=d.items.map((e,t)=>/* @__PURE__ */Xk("g",{transform:`translate(${e.x},${e.y+y.itemsY})`,children:[
|
|
139
|
+
/* @__PURE__ */Yk("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),
|
|
140
|
+
/* @__PURE__ */Yk("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Zc(r),fill:r.colors.text,fontFamily:Kc(r),children:e.category})]},"legend-"+t));/* @__PURE__ */
|
|
141
|
+
return Xk("g",{className:"semiotic-legend",transform:`translate(${p},${g})`,fontWeight:Qc(r),children:[
|
|
142
|
+
/* @__PURE__ */Yk("line",{x1:0,y1:y.lineY,x2:f,y2:y.lineY,stroke:"gray"}),m]})}function au(e){if(0===iu(e.legendGroups).length)return null;let t=tu(e),i="top"===e.position||"bottom"===e.position,r={legendGroups:e.legendGroups,legendDistance:e.legendDistance},o=e.reservedWidth??u(r,e.legendLayout),a=e.theme.colors.grid||e.theme.colors.textSecondary,{x:n,y:s}=v(r,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:o});if(!i){let i=k(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,a)=>{let n=i[a],s=r.type??"fill",l=[
|
|
143
|
+
/* @__PURE__ */Yk("line",{x1:0,y1:n.lineY,x2:o,y2:n.lineY,stroke:"gray"},"legend-group-neatline-"+a)];return r.label&&null!=n.labelY&&l.push(
|
|
144
|
+
/* @__PURE__ */Yk("text",{y:n.labelY,fontSize:Zc(e.theme),fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:r.label},"legend-group-label-"+a)),l.push(
|
|
145
|
+
/* @__PURE__ */Yk("g",{transform:`translate(0,${n.itemsY})`,children:r.items.map((i,o)=>{let n=r.styleFn(i,o),l="function"==typeof s?s(i):"line"===s?/* @__PURE__ */Yk("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:n}):/* @__PURE__ */Yk("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:n});/* @__PURE__ */
|
|
146
|
+
return Xk("g",{transform:`translate(0,${o*Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[l,
|
|
147
|
+
/* @__PURE__ */Yk("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Zc(e.theme),fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:i.label})]},`legend-${a}-${o}`)})},"legend-group-"+a)),l});/* @__PURE__ */
|
|
148
|
+
return Yk("g",{className:"semiotic-legend",transform:`translate(${n},${s})`,"data-orientation":"vertical",fontWeight:Qc(e.theme),children:r})}let l=t.groups.flatMap((r,o)=>{let{group:n}=r,s=n.type??"fill",l=[];if(n.label&&l.push(/* @__PURE__ */Yk("text",i?{transform:`translate(${r.x},${r.y}) rotate(90)`,textAnchor:"start",fontSize:Zc(e.theme),fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:n.label}:{x:r.x,y:r.y+Zc(e.theme),fontSize:Zc(e.theme),fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:n.label},"legend-group-label-"+o)),l.push(...r.items.map((i,a)=>{let l=n.items[a],c=n.styleFn(l,a),u="function"==typeof s?s(l):"line"===s?/* @__PURE__ */Yk("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:c}):/* @__PURE__ */Yk("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:c});/* @__PURE__ */
|
|
149
|
+
return Xk("g",{transform:`translate(${r.x+r.itemOffsetX+i.x},${r.y+r.itemOffsetY+i.y})`,children:[u,
|
|
150
|
+
/* @__PURE__ */Yk("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Zc(e.theme),fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:i.category})]},`legend-${o}-${a}`)})),i&&t.groups.length-1>o){let e=r.x+r.width+6;l.push(
|
|
151
|
+
/* @__PURE__ */Yk("line",{x1:e,y1:0,x2:e,y2:t.height,stroke:a},"legend-group-separator-"+o))}return l});/* @__PURE__ */
|
|
152
|
+
return Yk("g",{className:"semiotic-legend",transform:`translate(${n},${s})`,"data-orientation":i?"horizontal":"vertical",fontWeight:Qc(e.theme),children:l})}function nu(e){let i=ru(e),r="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},a=u(o),n=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||t(e.gradient.domain),{x:l,y:c}=v(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:a}),d=Array.from({length:17},(t,i)=>{let o=i/16;/* @__PURE__ */
|
|
153
|
+
return Yk("stop",{offset:o,stopColor:e.gradient.colorFn(r?e.gradient.domain[0]+o*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-o*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(r){let t=e.gradient.label?12:void 0,r=e.gradient.label?18:0;/* @__PURE__ */
|
|
154
|
+
return Xk("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Qc(e.theme),children:[
|
|
155
|
+
/* @__PURE__ */Yk("defs",{children:/* @__PURE__ */Yk("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),e.gradient.label&&/* @__PURE__ */Yk("text",{x:i.width/2,y:t,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:e.gradient.label}),
|
|
156
|
+
/* @__PURE__ */Yk("rect",{x:0,y:r,width:i.width,height:12,fill:`url(#${n})`,rx:2}),
|
|
157
|
+
/* @__PURE__ */Yk("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Kc(e.theme),children:s(e.gradient.domain[0])}),
|
|
158
|
+
/* @__PURE__ */Yk("text",{x:i.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Kc(e.theme),children:s(e.gradient.domain[1])})]})}let h=e.gradient.label?12:void 0,f=e.gradient.label?18:0;/* @__PURE__ */
|
|
159
|
+
return Xk("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Qc(e.theme),children:[
|
|
160
|
+
/* @__PURE__ */Yk("defs",{children:/* @__PURE__ */Yk("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.gradient.label&&/* @__PURE__ */Yk("text",{x:0,y:h,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Kc(e.theme),children:e.gradient.label}),
|
|
161
|
+
/* @__PURE__ */Yk("rect",{x:0,y:f,width:14,height:100,fill:`url(#${n})`,rx:2}),
|
|
162
|
+
/* @__PURE__ */Yk("text",{x:19,y:f+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Kc(e.theme),children:s(e.gradient.domain[1])}),
|
|
163
|
+
/* @__PURE__ */Yk("text",{x:19,y:f+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Kc(e.theme),children:s(e.gradient.domain[0])})]})}function su(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=/* @__PURE__ */new Set;for(let t of e){let e=i(t);null!=e&&r.add(e+"")}return Array.from(r)}function lu(e,t,i="end",r=2){let o,a=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,s=(e,t)=>{let i=n.get(e)??{count:0,labelIds:[]};i.count++,20>i.labelIds.length&&i.labelIds.push(t),n.set(e,i)},l=(e,t)=>{a.set(e,{id:e,status:"omitted",reason:t}),s(t,e),s("LABEL_OMITTED",e)},c=[...e].sort((e,t)=>(Number.isFinite(e.anchor.y)?e.anchor.y:1/0)-(Number.isFinite(t.anchor.y)?t.anchor.y:1/0)||(t.id>e.id?-1:e.id>t.id?1:0)),u=[],d=0;for(let e of c){let{id:i,anchor:a,measurement:n}=e;if("estimated"===n.source&&s("ESTIMATED_METRICS",i),![a.x,a.y,n.width,n.height,n.ascent].every(Number.isFinite)||0>n.width||0>=n.height){l(i,"INVALID_PROJECTION");continue}o===a.y&&s("TIED_ENDPOINTS",i),o=a.y;let c=n.height+(u.length?r:0);![t.x,t.y,t.width,t.height,r].every(Number.isFinite)||0>r||n.width>t.width||d+c>t.height?l(i,"INSUFFICIENT_SPACE"):(u.push(e),d+=c)}let h=mm({desired:u.map(e=>e.anchor.y-e.measurement.height/2),minGaps:u.slice(0,-1).map(e=>e.measurement.height+r),min:t.y,max:t.y+t.height-(u.at(-1)?.measurement.height??0)});u.forEach((e,r)=>{let o={x:"end"===i?t.x:t.x+t.width-e.measurement.width,y:h[r],width:e.measurement.width,height:e.measurement.height},n="end"===i?o.x:o.x+o.width,s=o.y+o.height/2,l={x:n-e.anchor.x,y:s-e.anchor.y};a.set(e.id,{id:e.id,status:"placed",box:o,offset:l,...Math.abs(l.y)>.01||Math.abs(l.x)>6.01?{connector:{x1:e.anchor.x,y1:e.anchor.y,x2:n,y2:s}}:{}})});let f=e.map(e=>a.get(e.id)),p=f.filter(e=>"placed"===e.status&&Math.abs(e.offset.y)>.01),g=f.filter(e=>"omitted"===e.status),y=e.filter(e=>"estimated"===e.measurement.source).length;return{dispositions:f,evidence:{status:y||g.length?"incomplete":"complete",requested:e.length,rendered:u.length,displaced:p.length,omitted:g.length,omittedIds:g.slice(0,20).map(e=>e.id),displacedIds:p.slice(0,20).map(e=>e.id),measurement:{measured:e.length-y,estimated:y},collisions:0,overflows:0,fallback:"accessible-series-list",findings:[...n].map(([e,t])=>({code:e,...t,remedy:qk[e]})),coverage:{directLabels:"assessed",axisLabels:"not-assessed"}}}}function cu(e,t){let i=e.filter(e=>e._directLabel);if(!i.length)return{node:null};let r=i[0]._directLabel.position,o=t.measure??Vk,a=i.map(e=>({family:t.fontFamily||"sans-serif",version:t.fontVersion??0,weight:400,size:e.fontSize||11})),n=i.map((e,i)=>{let r=(e,t)=>{if(null==e||!t)return NaN;try{return t(Number(e))}catch{return NaN}};return{id:e._directLabel.id+"",anchor:{x:r(e.x,t.scales?.x),y:r(e.y,t.scales?.y)},measurement:o(e.label+"",a[i])}}),s=Math.max(0,(t.margin?.["end"===r?"right":"left"]??0)-10),l=lu(n,{x:"end"===r?t.width+6:-s-6,y:0,width:s,height:t.height},r),c=l.dispositions.map((e,r)=>{if("omitted"===e.status)return null;let o=e.box,s=e.connector,c=i[r],u=/* @__PURE__ */Uk("g",{"data-direct-label-id":e.id,children:[s&&/* @__PURE__ */Hk("line",{...s,stroke:c.color,strokeWidth:.75}),
|
|
164
|
+
/* @__PURE__ */Hk("text",{x:o.x+(n[r].measurement.left??0),y:o.y+n[r].measurement.ascent,fontFamily:a[r].family,fontWeight:a[r].weight,fontSize:a[r].size,fill:c.color,textAnchor:"start",children:c.label})]},e.id),d=t.renderLabel?t.renderLabel({...c,dx:o.x+(n[r].measurement.left??0)-n[r].anchor.x,dy:o.y+n[r].measurement.ascent-n[r].anchor.y,fontFamily:a[r].family},r,u):u;if(!d){let t=l.evidence;t.rendered--,t.omitted++,20>t.omittedIds.length&&t.omittedIds.push(e.id),Math.abs(e.offset.y)>.01&&t.displaced--,t.displacedIds=t.displacedIds.filter(t=>t!==e.id);for(let i of["RENDER_FAILURE","LABEL_OMITTED"]){let r=t.findings.find(e=>e.code===i);r||(r={code:i,count:0,labelIds:[],remedy:qk[i]},t.findings.push(r)),r.count++,20>r.labelIds.length&&r.labelIds.push(e.id)}}if(d!==u&&(l.evidence.status="incomplete",d)){let t=l.evidence.findings.find(e=>"UNSUPPORTED_GEOMETRY"===e.code);t||(t={code:"UNSUPPORTED_GEOMETRY",count:0,labelIds:[],remedy:qk.UNSUPPORTED_GEOMETRY},l.evidence.findings.push(t)),t.count++,20>t.labelIds.length&&t.labelIds.push(e.id)}return d?/* @__PURE__ */Hk(Gk.Fragment,{children:d},e.id):null}),u=/* @__PURE__ */Hk("g",{role:"list","aria-label":"Series endpoints","data-direct-label-fallback":"accessible-series-list",children:i.map((e,t)=>/* @__PURE__ */Hk("g",{role:"listitem","aria-label":`${e.label}: x ${e.x+""}, y ${e.y+""}`,children:/* @__PURE__ */Hk("title",{children:`${e.label}: x ${e.x+""}, y ${e.y+""}`})},n[t].id))});return{evidence:l.evidence,node:/* @__PURE__ */Uk("g",{className:"semiotic-direct-labels","data-label-layout":JSON.stringify(l.evidence),children:[c,u]},"direct-labels")}}function uu(e,t){return(e+"").length*t*.6}function du(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}function hu(e){let{x:t,y:i,text:r,fill:o,fontSize:a=12,fontWeight:n,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=du(u),f=e=>/* @__PURE__ */Zk("text",{x:t,y:i,textAnchor:l,dominantBaseline:c,fill:o,fontSize:a,fontWeight:n,fontFamily:s,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Qk,strokeWidth:h.haloWidth??3});let p,g,y=h.padding??{x:6,y:3},m="number"==typeof y?y:y.x,x="number"==typeof y?y:y.y,b=uu(r,a),v=a+2*x;return p="middle"===l?t-b/2-m:"end"===l?t-b-m:t-m,g="middle"===c||"central"===c?i-v/2:"hanging"===c||"text-before-edge"===c?i-x:i-.8*a-x,/* @__PURE__ */Kk("g",{className:d,children:[
|
|
165
|
+
/* @__PURE__ */Zk("rect",{x:p,y:g,width:b+2*m,height:v,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Qk,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function fu(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};/* @__PURE__ */
|
|
166
|
+
return Jk("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}function pu({ann:e,position:t,vertical:i,width:r,height:o,color:a,fontSize:n=12,fontFamily:s,bold:l,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,f=t>.6*r,p=i?t+(f?-4:4):"left"===h?4:"center"===h?r/2:r-4,g=i?"bottom"===h?o-4:"center"===h?o/2:16:20>t?Math.min(o-4,t+16):t-d,y=i?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",m=i?[t,0]:[0,t],x=i?[t,o]:[r,t];/* @__PURE__ */
|
|
167
|
+
return tA("g",{opacity:e.opacity,children:[
|
|
168
|
+
/* @__PURE__ */eA("line",{x1:m[0],y1:m[1],x2:x[0],y2:x[1],stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),fu(e.endCap,m,a),e.label&&/* @__PURE__ */eA(hu,{x:p,y:g,text:e.label,textAnchor:y,fill:a,fontSize:n,fontFamily:s,fontWeight:l?"bold":void 0,background:c??e.labelBackground??"halo"})]})}function gu(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function yu(e,t,i,r){if(!e)/* @__PURE__ */return iA("g",{className:"annotation-note"});let{label:o,title:a,orientation:n,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!a)/* @__PURE__ */return iA("g",{className:"annotation-note"});let u=n;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,f=s;(!f||"dynamic"===f)&&(f=d?0>t?"right":"left":0>i?"bottom":"top");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=0>t?"end":"start";let g=e.useHTML||e.html,y=g?void 0:Rm(e),m=y?.lineHeight??16,x=y?.titleLines??(a?c?[a]:Tm(a,l,8):[]),b=y?.labelLines??(o?c?[o]:Tm(o,l,8):[]),v=x.length+b.length,w=h?"end"===p?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(g)k.push(
|
|
169
|
+
/* @__PURE__ */iA("foreignObject",{className:"annotation-note-html",x:"end"===p?w-l:"middle"===p?w-l/2:w,y:-m,width:l,height:Math.max(m,v*m+(a&&o?2:0))+m,style:{overflow:"visible"},children:/* @__PURE__ */rA("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:m+"px",overflow:"visible",textAlign:"end"===p?"right":"middle"===p?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[a&&/* @__PURE__ */iA("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:a}),o&&/* @__PURE__ */iA("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"));else for(let e of[!0,!1]){let t=e?x:b;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(
|
|
170
|
+
/* @__PURE__ */iA("text",{className:i,fill:A,textAnchor:p,fontWeight:e?y?.titleFontWeight??"bold":void 0,y:e?void 0:x.length*m,children:t.map((e,t)=>/* @__PURE__ */iA("tspan",{x:w,dy:0===t?0:m,children:e},t))},i))}let S=null;if((a||o)&&(0!==t||0!==i)){let e=d?y?y.width:Math.min(l,120):(x.length+b.length+(b.length>0?1:0))*m,t=d?p:f,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=/* @__PURE__ */iA("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*m,_=0;(d||h)&&(_=h&&"middle"===f?-(M+m+(b.length>0&&x.length>0?2:0))/2+m/2:0>i||h&&"bottom"===f?-(M+2):2+m);let P=0!==_?`translate(0,${_})`:void 0;/* @__PURE__ */
|
|
171
|
+
return rA("g",{className:"annotation-note",transform:`translate(${t},${i})`,...y?.textProps,children:[
|
|
172
|
+
/* @__PURE__ */iA("g",{className:"annotation-note-content",transform:P,children:k}),S]})}function mu(e,t,i,r,o){let a=null,n=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(a=/* @__PURE__ */iA("circle",{r:e,fill:"none",stroke:n},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(a=/* @__PURE__ */iA("rect",{width:e,height:i,fill:"none",stroke:n},"subject-rect"));break}case"callout-custom":a=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,s=0,l=0,c=0,u=0;if(void 0!==t?.x)s=l=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,s=(t.x1||0)-e,l=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)s=(t.x1||0)-e,l=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}a=/* @__PURE__ */iA("line",{x1:s,y1:c,x2:l,y2:u,stroke:n,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(a=/* @__PURE__ */iA("path",{d:gu(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:n},"bracket-path"));break}}/* @__PURE__ */
|
|
173
|
+
return iA("g",{className:"annotation-subject",children:a})}function xu(e,t,i,r,o,a){let n,s,l=0,c=0;if("callout-circle"!==o&&"label"!==o||!a?.radius){if("callout-rect"===o&&a){let i=a.width||0,r=a.height||0;if(i>0||r>0){let o=i/2,a=r/2,n=e-o,s=t-a;if(0!==n||0!==s){let e=Math.abs(n),t=Math.abs(s),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;l=o+n*h,c=a+s*h}}}else if("bracket"===o&&a){let e=a.width,t=a.height,i=a.depth||30;void 0!==e?(l=e/2,c=i):void 0!==t&&(l=i,c=t/2)}}else{let i=(a.radius||0)+(a.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);l=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-l,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",a="curve"===i?.type,f=Math.atan2(d,u);if(a){let r=(l+e)/2,a=(c+t)/2,s=-d/h,p=u/h,g=(i?.curve??.25)*h,y=r+s*g,m=a+p*g;n=/* @__PURE__ */iA("path",{className:"connector-curve",d:`M${l},${c}Q${y},${m} ${e},${t}`,fill:"none",stroke:o},"connector-line"),f=Math.atan2(m-c,y-l)}else n=/* @__PURE__ */iA("line",{x1:l,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.2792526803190927;s=/* @__PURE__ */iA("path",{d:`M${l},${c}L${l+10*Math.cos(f+e)},${c+10*Math.sin(f+e)}L${l+10*Math.cos(f-e)},${c+10*Math.sin(f-e)}Z`,fill:o,stroke:"none"},"connector-arrow")}}/* @__PURE__ */
|
|
174
|
+
return rA("g",{className:"annotation-connector",children:[n,s]})}function bu(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:a,ny:n,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:g,events:y={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(i)?i[0]??0:i,v=Array.isArray(f)?f:[],w=r||0,k=o||0;null!=a&&(w=a-x),null!=n&&(k=n-b);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}/* @__PURE__ */
|
|
175
|
+
return rA("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...g&&{strokeDasharray:g},...y,children:[!v.includes("connector")&&xu(w,k,l,d,A,c),!v.includes("subject")&&mu(A,c,d,x,b),!v.includes("note")&&yu(s,w,k,d)]})}function vu(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),a=i.map((i,a)=>{let n=Object.assign({},t,{note:0===a?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});/* @__PURE__ */
|
|
176
|
+
return iA(bu,{"data-testid":"semiotic-annotation",...n,type:r},"multi-annotation-"+a)});/* @__PURE__ */
|
|
177
|
+
return iA("g",{children:a})}let a=t.note||{title:"none",label:t.label},n=`${a.label}-${a.title}-${t.i}`;/* @__PURE__ */
|
|
178
|
+
return iA(bu,{"data-testid":"semiotic-annotation",events:o,...t,type:r},n)}function wu(e){return!0===e?._annotationDeferred}function ku(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Au(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis?e.emphasis:null}function Su(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Mu(e){return Math.max(.72,.95-.06*e)}function _u(e){let t=e.map((e,t)=>({p:e,i:t,emphasis:Au(e.annotation),confidence:Su(e.annotation),readingOrder:null,rank:1})),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>wu(e.annotation)),o=e.some(e=>null!=ku(e.annotation)),a=e.some(e=>"layer"===ku(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let n=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);n.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,n.length)});for(let e of t)e.emphasis&&(e.rank=aA[e.emphasis]);let s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,a=wu(t.annotation),n=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;n=/* @__PURE__ */oA("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Mu(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+i)}let s=ku(t.annotation);return s&&(n=/* @__PURE__ */oA("g",{className:"annotation-cohesion--"+s,children:n},"annotation-cohesion-"+i)),a&&(n=/* @__PURE__ */oA("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:n},"annotation-deferred-"+i)),n});return r&&s.unshift(
|
|
179
|
+
/* @__PURE__ */oA("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")),a&&s.unshift(
|
|
180
|
+
/* @__PURE__ */oA("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")),s}function Pu(e,t,i,r){let o=[];return e.forEach((e,a)=>{let n;n=i?i(e,a,r)??t(e,a,r):t(e,a,r),n&&o.push({node:n,annotation:e})}),{nodes:_u(o),renderedAnnotations:o.map(e=>e.annotation)}}function $u(e,t,i,r){let o=gi(e.fill??e.color,t,r);return yi(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r)??o}function Lu(e,t,i){let r=e.position,o="string"==typeof r&&nA.has(r)?r:"bottom-left",a=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",n=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",s="top"===n?0:"bottom"===n?i:i/2;return{x:("left"===a?0:"right"===a?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:s+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===a?"start":"right"===a?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===n?"hanging":"bottom"===n?"auto":"middle"}}function Iu(e,t,i,r){return{...Lu(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function Ru({annotation:e,width:t,height:i,defaults:r=lA}){let o=e.label??e.text;return null==o?null:/* @__PURE__ */sA("text",{...Iu(e,t,i,r),children:o})}function Tu(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}function Cu(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function Du(e,t={}){let i=Tu(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=Cu(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function zu(e,t=.3){let i=e.length;if(2>i)return e.slice();let r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),a=r.map(e=>e[1]),n=Math.min(i,Math.max(2,Math.ceil(t*i))),s=Number.isFinite(n)&&o.every(Number.isFinite),l=0,c=n-1,u=[];for(let e=0;i>e;e++){let t,r=o[e],d=0,h=i-1;if(s){for(;i-1>c&&Math.abs(o[l]-r)>=Math.abs(o[c+1]-r);)l++,c++;let e=Math.max(Math.abs(o[l]-r),Math.abs(o[c]-r));t=e||1,e>0&&(d=l,h=c)}else t=o.map(e=>Math.abs(e-r)).sort((e,t)=>e-t)[n-1]||1;let f=0,p=0,g=0,y=0,m=0;for(let e=d;h>=e;e++){let i=Math.abs(o[e]-r)/t,n=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==n&&(f+=n,p+=n*o[e],g+=n*a[e],y+=n*o[e]*o[e],m+=n*o[e]*a[e])}if(0===f){u.push([r,a[e]]);continue}let x=f*y-p*p;if(1e-12>Math.abs(x))u.push([r,g/f]);else{let e=(f*m-p*g)/x;u.push([r,(g-e*p)/f+e*r])}}return u}function Eu(e,t,i){switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:Cm({...e,type:"point"},i),y:Dm({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=cA(r),a=e.padding||10;/* @__PURE__ */
|
|
181
|
+
return kA("g",{children:[
|
|
182
|
+
/* @__PURE__ */wA("circle",{cx:o.x,cy:o.y,r:o.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */wA(hu,{x:o.x,y:o.y-o.r-a-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:Cm({...e,type:"point"},i),y:Dm({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=e.padding||10,[a,n]=Nm(r.map(e=>e.x)),[s,l]=Nm(r.map(e=>e.y)),c=a-o,u=n+o,d=s-o;/* @__PURE__ */
|
|
183
|
+
return kA("g",{children:[
|
|
184
|
+
/* @__PURE__ */wA("rect",{x:c,y:d,width:u-c,height:l+o-d,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */wA(hu,{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],a={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};/* @__PURE__ */
|
|
185
|
+
return wA("g",{children:o.map((t,r)=>{let o=Cm(t,i),n=Dm(t,i);if(null==o||null==n)return null;let s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||a;/* @__PURE__ */
|
|
186
|
+
return wA("circle",{cx:o,cy:n,r:s,...l},"hl-"+r)})},"ann-"+t)}case"bracket":{let r=Cm(e,i),o=Dm(e,i);/* @__PURE__ */
|
|
187
|
+
return wA(vu,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:Im(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{let r=i.data||[];if(2>r.length)return null;let o,a=i.xAccessor||"x",n=i.yAccessor||"y",s="ordinal"===i.frameType,l="horizontal"===i.projection,c=s?a:null,u=s?n:null,d=[],h=/* @__PURE__ */new Map;if(s&&c&&u){for(let e of r){let t=e[c];if(null==t)continue;let i=t+"";h.has(i)||(h.set(i,d.length),d.push(i))}o=r.map(e=>{let t=e[c],i=e[u];if(null==t||null==i)return null;let r=h.get(t+"");return null!=r?[r,+i]:null}).filter(e=>null!==e)}else o=r.map(e=>[e[a],e[n]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>o.length)return null;let f=i.scales?.x??i.scales?.time,p=i.scales?.y??i.scales?.value;if(!f||!p)return null;let g,y=e=>t=>{let i=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,i+1),o=t-i,a=e(d[i]);return a+(e(d[r])-a)*o},m=f,x=p;if(s)if(l){let e=y(x);g=(t,i)=>[m(i),e(t)]}else{let e=y(m);g=(t,i)=>[e(t),x(i)]}else g=(e,t)=>[m(e),x(t)];let b=e.method||"linear",v="loess"===b?zu(o,e.bandwidth??.3):("polynomial"===b?Or(o,e.order||2):Nr(o)).points,w=v.map(([e,t])=>{let[i,r]=g(e,t);return`${i},${r}`}).join(" "),k=e.color||"#6366f1",A=v[v.length-1],[S,M]=g(A[0],A[1]);/* @__PURE__ */
|
|
188
|
+
return kA("g",{children:[
|
|
189
|
+
/* @__PURE__ */wA("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&/* @__PURE__ */wA("text",{x:S+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"envelope":{let r=i.data||[];if(2>r.length)return null;let o=i.xAccessor||"x",a=i.scales?.x??i.scales?.time,n=i.scales?.y??i.scales?.value;if(!a||!n)return null;let s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;let d=AA[i.curve||"linear"]||pA,h=uA().x(e=>a(e[o])).y0(e=>n(e[l])).y1(e=>n(e[s])).curve(d)(u);if(!h)return null;let f=e.fill||"#6366f1",p=u[u.length-1];/* @__PURE__ */
|
|
190
|
+
return kA("g",{children:[
|
|
191
|
+
/* @__PURE__ */wA("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&/* @__PURE__ */wA("text",{x:a(p[o])+4,y:n(p[s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{let r=i.data||[];if(2>r.length)return null;let o=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,n=i.scales?.y??i.scales?.value;if(!a||!n)return null;let s=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;let l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=n(l+d*u),p=n(h),g=e.fill||"#6366f1",y=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=r.filter(e=>{let t=e[o];return null!=t&&Math.abs(t-l)>d*u});/* @__PURE__ */
|
|
192
|
+
return kA("g",{children:[!1!==e.showBand&&/* @__PURE__ */wA("rect",{x:0,y:Math.min(f,p),width:i.width||0,height:Math.abs(p-f),fill:g,fillOpacity:e.fillOpacity??.1}),x.map((e,t)=>{let r=Cm(e,i),o=Dm(e,i);return null==r||null==o?null:/* @__PURE__ */wA("circle",{cx:r,cy:o,r:m,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5},"anomaly-"+t)}),e.label&&/* @__PURE__ */wA("text",{x:(i.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{let r=i.data||[];if(3>r.length)return null;let o=i.xAccessor||"x",a=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!n||!s)return null;let l,c=r.map(e=>[e[o],e[a]]).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;if("polynomial"===e.method){let t=Or(c,e.order||2).equation;l=e=>t.reduce((t,i,r)=>t+i*Math.pow(e,r),0)}else{let e=Fr(c);if(!e)return null;l=e}let{se:u,meanX:d,ssX:h}=Wr(c,l),f=c.length,p=jr(e.confidence??.95),g=c[f-1][0],y=(g-c[0][0])/Math.max(f-1,1),m=Array.from({length:e.steps??5},(e,t)=>{let i=g+(t+1)*y,r=l(i),o=u*Math.sqrt(1+1/f+(h>0?(i-d)**2/h:0))*p;return{x:i,center:r,upper:r+o,lower:r-o}}),x=m.map(e=>`${n(e.x)},${s(e.upper)}`).join(" L"),b=m.slice().reverse().map(e=>`${n(e.x)},${s(e.lower)}`).join(" L"),v=m.map(e=>`${n(e.x)},${s(e.center)}`).join(" "),w=e.strokeColor||"#6366f1",k=m[m.length-1];/* @__PURE__ */
|
|
193
|
+
return kA("g",{children:[
|
|
194
|
+
/* @__PURE__ */wA("path",{d:`M${x} L${b} Z`,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),
|
|
195
|
+
/* @__PURE__ */wA("polyline",{points:`${n(g)},${s(l(g))} ${v}`,fill:"none",stroke:w,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k&&/* @__PURE__ */wA("text",{x:n(k.x)+4,y:s(k.center)-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let a=Em(e,t,i);if(!a)return null;r=a.x,o=a.y}if(!Hy(r,o,i))return null;let a=e.width??32,n=e.height??32,s=e.content??/* @__PURE__ */wA("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});/* @__PURE__ */
|
|
196
|
+
return wA("foreignObject",{x:r+(e.dx??0)-a/2,y:o+(e.dy??0)-n/2,width:a,height:n,style:{overflow:"visible",pointerEvents:"auto"},children:/* @__PURE__ */wA("div",{...Du(e),style:{width:a,height:n,display:"flex",alignItems:"center",justifyContent:"center"},children:s})},"ann-"+t)}default:return null}}function Nu(e,t){return e.color||t.colors.annotation||t.colors.text}function Ou(e,t,i){let r=e.labelBackground,o=t.colors.background,a=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:a}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:a}:"box"===r?{type:"box",fill:a}:{fill:a,...r}}function Fu(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Wu(e,t,i),y:ju(e,t,r)}}function Wu(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function ju(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function Bu(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=fy(t).filter(e=>!e._directLabel),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,a=!!r&&!e.scales.x&&!e.scales.y,n=e=>Number(e),s=e.scales.x??(a?n:void 0),l=e.scales.y??(a?n:void 0),c=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===e.projection?{x:e.scales.o??s,y:e.scales.r??l,time:e.scales.o??s,value:e.scales.r??l,o:e.scales.o}:"horizontal"===e.projection?{x:e.scales.r??s,y:e.scales.o??l,time:e.scales.r??s,value:e.scales.o??l,o:e.scales.o}:{x:s,y:l,time:s,value:l,o:e.scales.o},...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),...c?{projection:c}:{}},d=cu(t,{...e.layout,scales:e.scales,margin:e.margin,fontFamily:e.theme.typography.fontFamily,measure:e.labelMeasurer,...e.svgAnnotationRules?{renderLabel:(t,i,r)=>e.svgAnnotationRules(t,i,u)??r}:{}}),h=e.autoPlaceAnnotations?Ky({annotations:o,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,f=Pu(h,(t,i,r)=>Yu(t,i,e,r)??Eu(t,i,r),e.svgAnnotationRules,u),p=d.node?[...f.nodes,d.node]:f.nodes,g=/* @__PURE__ */new Map;for(let e of f.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";g.set(t,(g.get(t)??0)+1)}d.evidence&&g.set("text",(g.get("text")??0)+d.evidence.rendered);let y=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=g.get(t)??0;i>0?g.set(t,i-1):y.push(t)}return e.onRender?.({inputCount:t.length,eligibleCount:h.length,renderedCount:f.renderedAnnotations.length+(d.evidence?.rendered??0),...d.evidence?{layout:d.evidence}:{},unrenderedCount:y.length,unrenderedTypes:y}),p.length>0?/* @__PURE__ */SA("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:p}):null}function Yu(e,t,i,r){let{scales:o,layout:a,theme:n,xAccessor:s,yAccessor:l}=i;switch(e.type){case"frame-text":/* @__PURE__ */
|
|
197
|
+
return SA(Ru,{annotation:e,width:a.width,height:a.height,defaults:{fill:n.colors.text,fontSize:11,fontFamily:n.typography.fontFamily}},"ann-frame-text-"+t);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let s=Nu(e,n),l=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:/* @__PURE__ */MA("g",{opacity:e.opacity,children:[
|
|
198
|
+
/* @__PURE__ */SA("line",{x1:i,y1:0,x2:i,y2:a.height,stroke:s,strokeWidth:u,strokeDasharray:c}),fu(e.endCap,[i,0],s),l&&/* @__PURE__ */SA(hu,{x:i+4,y:16,textAnchor:"start",fontSize:n.typography.tickSize,fill:s,fontFamily:n.typography.fontFamily,text:l,background:Ou(e,n,"halo")})]},"ann-ythresh-"+t)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:/* @__PURE__ */SA(pu,{ann:e,position:d,vertical:!1,width:a.width,height:a.height,color:s,fontSize:n.typography.tickSize,fontFamily:n.typography.fontFamily,background:Ou(e,n,"halo"),dash:"6,4",labelGap:6},"ann-ythresh-"+t)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let s="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==s)return null;let l=Nu(e,n);/* @__PURE__ */
|
|
199
|
+
return SA(pu,{ann:e,position:s,vertical:!0,width:a.width,height:a.height,color:l,fontSize:n.typography.tickSize,fontFamily:n.typography.fontFamily,background:Ou(e,n,"halo"),dash:"6,4"},"ann-xthresh-"+t)}case"band":{let i=o.y?.domain?.(),r=e.y0??i?.[0],s=e.y1??i?.[1],l=null!=r&&o.y?o.y(r):null,c=null!=s&&o.y?o.y(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=$u(e,"ssr-band-"+t,"vertical",Nu(e,n)),f=e.fillOpacity??.1;/* @__PURE__ */
|
|
200
|
+
return MA("g",{opacity:e.opacity,children:[h.def&&/* @__PURE__ */SA("defs",{children:h.def}),
|
|
201
|
+
/* @__PURE__ */SA("rect",{x:0,y:u,width:a.width,height:d,fill:h.fill,fillOpacity:f}),e.label&&/* @__PURE__ */SA(hu,{x:a.width-4,y:Math.max(u,0)+16,textAnchor:"end",fontSize:n.typography.tickSize,fill:e.color||Nu(e,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ou(e,n,"halo")})]},"ann-band-"+t)}case"x-band":{let i=o.x?.domain?.(),r=e.x0??i?.[0],s=e.x1??i?.[1],l=null!=r&&o.x?o.x(r):null,c=null!=s&&o.x?o.x(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=$u(e,"ssr-xband-"+t,"horizontal",Nu(e,n)),f=e.fillOpacity??.1;/* @__PURE__ */
|
|
202
|
+
return MA("g",{opacity:e.opacity,children:[h.def&&/* @__PURE__ */SA("defs",{children:h.def}),
|
|
203
|
+
/* @__PURE__ */SA("rect",{x:u,y:0,width:d,height:a.height,fill:h.fill,fillOpacity:f}),e.label&&/* @__PURE__ */SA(hu,{x:u+4,y:16,textAnchor:"start",fontSize:n.typography.tickSize,fill:e.color||n.colors.primary||Nu(e,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ou(e,n,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(e.category+"");if(null==r)return null;let s=o.o.bandwidth?o.o.bandwidth():40,l=Nu(e,n),c=e.opacity??.1,u=e.label;/* @__PURE__ */
|
|
204
|
+
return MA("g","horizontal"===i.projection?{children:[
|
|
205
|
+
/* @__PURE__ */SA("rect",{x:0,y:r,width:a.width,height:s,fill:l,opacity:c}),u&&/* @__PURE__ */SA(hu,{x:12,y:r+s/2,dominantBaseline:"middle",fill:l,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:Ou(e,n,"none")})]}:{children:[
|
|
206
|
+
/* @__PURE__ */SA("rect",{x:r,y:0,width:s,height:a.height,fill:l,opacity:c}),u&&/* @__PURE__ */SA(hu,{x:r+s/2,y:16,textAnchor:"middle",fill:l,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:Ou(e,n,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=Fu(e,o,s,l),a=null==i.x||null==i.y?Em(e,t,r):null,c=i.x??a?.x??null,u=i.y??a?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),f=e.dy??(d?0:-30),p=e.color||n.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;/* @__PURE__ */
|
|
207
|
+
return SA(vu,{noteData:{x:c,y:u,dx:h,dy:f,note:Im(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:p,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}/* @__PURE__ */
|
|
208
|
+
return SA("g",{children:/* @__PURE__ */SA("text",{x:c+h,y:u+f,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||n.typography.labelSize,fill:p,fontFamily:n.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}function Xu(e,t,i,r="right",o,a){if(null==e||!1===e)return null;let{x:n,y:s}=v(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:a});/* @__PURE__ */
|
|
209
|
+
return _A("g",{transform:`translate(${n}, ${s})`,children:e})}function Gu(e){let t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:"c"+t,r=i+"-semiotic-title",o=i+"-semiotic-desc";return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function Vu(e,t){if(0===t.categories.length)return;let i=t.position||"right";b(e,{legend:Hc(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function qu(e,t){b(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function Hu(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Uu(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function Zu(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)t>r.pixel&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function Ku(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Qu(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Ku(e)}}}function Ju(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,a=Math.ceil(t/8),n="M0,"+r;for(let e=0;a>e;e++){let i=8*(e+1);n+=`L${Math.min(8*e+4,t)},${r+4*o}`,n+=`L${Math.min(i,t)},${r}`}return n}let r="bottom"===e?0:t,o="bottom"===e?1:-1,a=Math.ceil(i/8),n=`M${r},0`;for(let e=0;a>e;e++){let t=8*(e+1);n+=`L${r+4*o},${Math.min(8*e+4,i)}`,n+=`L${r},${Math.min(t,i)}`}return n}function ed(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],a=r instanceof Date,n=r instanceof Date?r.getTime():r,s=o instanceof Date?o.getTime():o;if(2>t||n===s)return a?[new Date(n),new Date(s)]:[n,s];let l=(s-n)/(t-1),c=Array(t);for(let e=0;t>e;e++){let i=e===t-1?s:n+e*l;c[e]=a?new Date(i):i}return c}function td(e,t,i){return"exact"===i?ed(e,t):e.ticks(t)}function id(e){return"string"==typeof e||"number"==typeof e}function rd(e){let{label:t,x:i,y:r,textAlign:o,fontSize:a,fontFamily:n,color:s}=e;/* @__PURE__ */
|
|
210
|
+
return $A("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */$A("div",{style:{color:s,fontFamily:n,fontSize:a,textAlign:o,userSelect:"none"},children:t})})}function od(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ad(e,t){let i=od(e);if(!i)return!1;let r=od(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}function nd(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):ad(t.value,i>0?r[i-1].value:void 0))}function sd(e,t){return e?.ticks??e?.tickCount??t}function ld(e,t){return!("string"!=typeof e&&"number"!=typeof e||"string"!=typeof t&&"number"!=typeof t||e+""!=t+"")}function cd(e,t){if(2>=e.length)return e;let i=[e[0]];for(let r=1;e.length-1>r;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return t>Math.abs(r.pixel-i[i.length-1].pixel)?i[i.length-1]=r:i.push(r),i}function ud(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${LA[t.getUTCMonth()]} ${t.getUTCDate()}`}function dd(e){let t=Math.abs(e[1]-e[0]);return 864e5>t?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(r+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(r+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),r}:3156e7>t?ud:1578e8>t?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${LA[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function hd(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function fd(e){for(let t=1;e.length>t;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(hd(i.label)+hd(r.label))/2+8)return!0}return!1}function pd(e){let{scale:i,axis:r,size:o,horizontal:a=!1,axisExtent:n}=e,s=r?.extent??n,l=i.domain(),c=sd(r,5),u=Math.max(2,Math.floor(o/(a?70:30))),d="exact"===s?Math.max(2,c):Math.min(c,u),h=r?.tickValues??td(i,d,s),f=h.map(e=>e.valueOf()),p=r?.tickFormat||e.format||(l[0]instanceof Date||h[0]instanceof Date?dd([l[0].valueOf(),l[l.length-1].valueOf()]):t(f)),g=(e,t)=>a?p(e,t,f):p(e),y=h.map((e,t)=>({value:e,pixel:i(e),label:g(e,t)})),m=22;if(a){let e=y.reduce((e,t)=>Math.max(e,hd(t.label)),0);m=r?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=cd(y,m);if(x.length>1&&(x=x.filter((e,t)=>0===t||!ld(e.label,x[t-1].label))),r?.includeMax&&x.length>0&&"exact"!==s&&!r.tickValues){let e=l[l.length-1];if(null!=e){let t=i(e),r=Math.abs(t-x[x.length-1].pixel);if(r>1){let i=g(e,x.length);m>r&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:t,label:i}]}}}return x}function gd(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.id;return null==t?null:t+""}return null}function yd(e){let t=e._idPrefix||e.chartId;if(t){let e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;i.length>e;e++)r=31*r+i.charCodeAt(e)|0;return"c"+(r>>>0).toString(36)}function md(e,t,r){return i(e.showLegend&&!e.__legendIncludesAutomatic?Hc(t,e.colorScheme,r):void 0,e.legend)}function xd(e,t){if(e.__autoLegendMargin)return TA[t]}function bd(e,t){let i={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,reservedWidth:t.reservedWidth,axisChrome:t.axisChrome,legendDistance:r(e)||o(e)?e.legendDistance:void 0};return r(e)?au({...i,legendGroups:e.legendGroups}):o(e)?nu({...i,gradient:e.gradient}):null}function vd(e,t){let{props:i,categories:r,theme:o,size:a,hasTitle:n}=t,s=i.legendPosition||"right",c={...e},u={theme:o,position:s,size:a,hasTitle:n,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:xd(i,s)};if(null!=i.legend){let t=md(i,r,o);null!=t&&!1!==t&&qu(e,{...u,legend:t})}else i.showLegend&&r.length>0&&Vu(e,{...u,categories:r,colorScheme:i.colorScheme});return l(e,c,a,s),s}function wd(e){let{props:t,categories:i,theme:a,size:n,margin:s,hasTitle:l}=e,c=t.legendPosition||"right",u={theme:a,position:c,size:n,margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){let e=md(t,i,a);return PA.isValidElement(e)?Xu(e,n,s,c,t.legendLayout,t.axisChrome):bd(e,u)||(r(e)||o(e)?null:Xu(e??null,n,s,c,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?ou({categories:i,colorScheme:t.colorScheme,theme:a,position:c,totalWidth:n[0],totalHeight:n[1],margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function kd(e,t,i,r,o,a){let n=e.scales;if(!n||"radial"===n.projection)return null;let{grid:s}=Pi(i),l=r?r+"-":"",c="vertical"===n.projection,u=a??td(n.r,5,o);/* @__PURE__ */
|
|
211
|
+
return IA("g",c?{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=n.r(e);/* @__PURE__ */
|
|
212
|
+
return IA("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=n.r(e);/* @__PURE__ */
|
|
213
|
+
return IA("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}function Ad(e,t){let i=Pi(t.theme),r=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",a="string"==typeof t.title?t.title:void 0,n=t.idPrefix?Gu(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},s=a?n.titleId:void 0,l=t.description?n.descId:void 0,c=[s,l].filter(Boolean).join(" ")||void 0;/* @__PURE__ */
|
|
214
|
+
return RA("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[a&&/* @__PURE__ */IA("title",{id:s,children:a}),t.description&&/* @__PURE__ */IA("desc",{id:l,children:t.description}),t.defs&&/* @__PURE__ */IA("defs",{children:t.defs}),r&&"transparent"!==r&&/* @__PURE__ */IA("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),
|
|
215
|
+
/* @__PURE__ */IA("g",{id:o+"data-area",transform:t.innerTransform,children:e}),a&&/* @__PURE__ */IA("text",{id:o+"chart-title",x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:a}),t.legend&&/* @__PURE__ */IA("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function Sd(t,i,r,o,a,n,s,l=!1){let c=Pi(o),u=r.legendPosition??"right",d=h(r.legendLayout,s?.leftAxis),f=h(r.legendLayout,s?.rightAxis),p=l&&"left"===u&&d>0?d:n?.left??r.margin?.left??40,g=l&&"right"===u&&f>0?f:n?.right??r.margin?.right??40,{xAxis:y,yAxis:m,xOrient:x,yOrient:b}=e(r.axes),v="top"===x?0:i.height,w="right"===b?i.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=pd({scale:t.x,axis:y,size:i.width,horizontal:!0,format:r.xFormat||r.tickFormatTime,axisExtent:r.axisExtent}),M=pd({scale:t.y,axis:m,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),_=!(!y?.autoRotate||!fd(S)),P=Zu(S),$=Zu(M),L=y?.label??r.xLabel,I=m?.label??("right"===b?r.yLabelRight??r.yLabel:r.yLabel),R=Qu(y?.axisStyle,{stroke:c.border,strokeWidth:1}),T=Qu(m?.axisStyle,{stroke:c.border,strokeWidth:1}),C="right"===b?i.width+g-15:15-p;/* @__PURE__ */
|
|
216
|
+
return RA("g",{id:(a?a+"-":"")+"axes",className:"stream-axes",children:[!1!==y?.visible&&/* @__PURE__ */RA("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==y?.baseline&&!y?.jaggedBase&&/* @__PURE__ */IA("line",{x1:0,y1:v,x2:i.width,y2:v,...R}),y?.jaggedBase&&/* @__PURE__ */IA("path",{d:Ju(x,i.width,i.height),fill:"none",...R}),S.map((e,t)=>{let i=nd(y?.landmarkTicks,e,t,S);/* @__PURE__ */
|
|
217
|
+
return RA("g",{transform:`translate(${e.pixel},${v})`,children:[
|
|
218
|
+
/* @__PURE__ */IA("line",{y2:5*k,...R}),id(e.label)?/* @__PURE__ */IA("text",{y:k*(_?12:18),textAnchor:_?"end":Hu(y?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,transform:_?"top"===x?"rotate(45)":"rotate(-45)":void 0,children:e.label}):rd({label:e.label,x:-30,y:"top"===x?-30:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"xtick-"+t)}),L&&/* @__PURE__ */IA("text",{x:i.width/2,y:"top"===x?-(_?58:40):i.height+(_?58:40),textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:L})]}),!1!==m?.visible&&/* @__PURE__ */RA("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&/* @__PURE__ */IA("line",{x1:w,y1:0,x2:w,y2:i.height,...T}),m?.jaggedBase&&/* @__PURE__ */IA("path",{d:Ju(b,i.width,i.height),fill:"none",...T}),M.map((e,t)=>{let i=nd(m?.landmarkTicks,e,t,M);/* @__PURE__ */
|
|
219
|
+
return RA("g",{transform:`translate(${w},${e.pixel})`,children:[
|
|
220
|
+
/* @__PURE__ */IA("line",{x2:5*A,...T}),id(e.label)?/* @__PURE__ */IA("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:Uu(m?.tickAnchor,e.pixel===$.min,e.pixel===$.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):rd({label:e.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"ytick-"+t)}),I&&/* @__PURE__ */IA("text",{x:C,y:i.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${C}, ${i.height/2})`,children:I})]})]})}function Md(e,t,i,r,o,a,n){let{grid:s}=Pi(i),l=r?r+"-":"",c=a?.find(e=>"bottom"===e.orient),u=a?.find(e=>"top"===e.orient),d=a?.find(e=>"left"===e.orient),h=a?.find(e=>"right"===e.orient),f=c??u,p=d??h,g=pd({scale:e.x,axis:f,size:t.width,horizontal:!0,format:n?.xFormat||n?.tickFormatTime,axisExtent:o}),y=pd({scale:e.y,axis:p,size:t.height,format:n?.yFormat||n?.tickFormatValue,axisExtent:o}),m=!1!==f?.grid,x=!1!==p?.grid,b=Ku(f?.gridStyle),v=Ku(p?.gridStyle),w=Qu(f?.gridStyle,{stroke:s,strokeWidth:.5}),k=Qu(p?.gridStyle,{stroke:s,strokeWidth:.5});/* @__PURE__ */
|
|
221
|
+
return DA("g",{id:l+"grid",className:"semiotic-grid",opacity:.8,children:[m&&g.map((e,i)=>/* @__PURE__ */CA("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+i)),x&&y.map((e,i)=>/* @__PURE__ */CA("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}function _d(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}function Pd(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}function $d(e){return OA.has(e)?NA:EA}function Ld(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:a,rightAxis:n,margin:s,axisChrome:l,hasRenderedLegend:c}=e;if(!a||!n||!1===n.visible)return null;let u=Pi(o),d=pd({scale:t.y,axis:n,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),f=Zu(d),p=n.label??r.yLabelRight,g=Qu(n.axisStyle,{stroke:u.border,strokeWidth:1}),y=r.legendPosition??"right",m=h(r.legendLayout,l?.rightAxis),x=i.width+(c&&"right"===y&&m>0?m:s.right)-15;/* @__PURE__ */
|
|
222
|
+
return WA("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==n.baseline&&!n.jaggedBase&&/* @__PURE__ */FA("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...g}),n.jaggedBase&&/* @__PURE__ */FA("path",{d:Ju("right",i.width,i.height),fill:"none",...g}),d.map((e,t)=>{let r=nd(n.landmarkTicks,e,t,d);/* @__PURE__ */
|
|
223
|
+
return WA("g",{transform:`translate(${i.width},${e.pixel})`,children:[
|
|
224
|
+
/* @__PURE__ */FA("line",{x2:5,...g}),id(e.label)?/* @__PURE__ */FA("text",{x:8,textAnchor:"start",dominantBaseline:Uu(n.tickAnchor,e.pixel===f.min,e.pixel===f.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):rd({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),p&&/* @__PURE__ */FA("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:p})]})}function Id(e,t){let i=_i(e.theme),r=e.size||[500,300],o=s({...zA,...e.margin},e.title),n=a(e.title),l=_d(lr(e.data),e.lineDataAccessor),c=e.showLegend?su(l,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],u=g({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});vd(o,{props:{...e,axisChrome:u},categories:c,theme:i,size:r,hasTitle:n});let d=wd({props:{...e,axisChrome:u},categories:c,theme:i,size:r,margin:o,hasTitle:n}),h=r[0]-o.left-o.right,f=r[1]-o.top-o.bottom,p="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),y=e.colorScheme||i.colors.categorical,m=(e.axes?.find(e=>"left"===e.orient)??e.axes?.find(e=>"right"===e.orient))?.extent??e.axisExtent,x={chartType:e.chartType,runtimeMode:p?"streaming":"bounded",windowSize:e.windowSize??e.capacity??200,windowMode:e.windowMode??e.capacityMode??"sliding",arrowOfTime:p?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:e.xAccessor,yAccessor:e.yAccessor,timeAccessor:p?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor||(e.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,invertY:e.invertY,axisExtent:e.axisExtent,yAxisExtent:m,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:mr(e.gradientFill),lineGradient:xr(e.lineGradient),semanticLineStops:e.semanticLineStops,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:y,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Oy(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat,heatmapColorScale:e.heatmapColorScale,heatmapAggregation:e.heatmapAggregation,heatmapXBins:e.heatmapXBins,heatmapYBins:e.heatmapYBins,pointIdAccessor:e.pointIdAccessor,onLayoutError:e.onLayoutError},b=new _k(x);e.data&&b.ingest({inserts:l,bounded:!0}),b.computeScene({width:h,height:f});let v=Pd(e.backgroundGraphics,r,o,b.scales),w=Pd(e.foregroundGraphics,r,o,b.scales),k=Tr(e.annotations),A=k?`${e.description||e.title||"Line chart."}${k}`:e.description;if(!b.scales){let a,n=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{},layout:{width:h,height:f},theme:i,idPrefix:e._idPrefix,onRender:e=>{a=e}}):null;return t&&(t.evidence=wc({frameType:"xy",width:r[0],height:r[1],marks:[],title:e.title,description:A,annotations:e.annotations,annotationRender:a,extraWarnings:b.scales?[]:["NO_SCALES"],margin:o})),Qw.renderToStaticMarkup(Ad(v||w||e.annotations?/* @__PURE__ */YA(jA,{children:[v,n,w]}):null,{width:r[0],height:r[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:A,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}let S,M=e._idPrefix,_=Vc({nodes:b.scene,renderMode:e.renderMode,fallback:(t,i)=>Fc(t,i,M,e.hoverRadius??30)}),P=!b.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:dd(b.scales.x.domain().map(e=>e.valueOf()))},$=e.showGrid?Md(b.scales,{width:h,height:f},i,M,e.axisExtent,e.axes,P):null,L=_.map(e=>e.element),I=yd(e)+"-plot-clip",R=!1!==e.showAxes,T=R?Sd(b.scales,{width:h,height:f},P,i,M,o,u,!!d):null,C=R?Ld({scales:b.scales,layout:{width:h,height:f},props:e,theme:i,leftAxis:e.axes?.find(e=>"left"===e.orient),rightAxis:e.axes?.find(e=>"right"===e.orient),margin:o,axisChrome:u,hasRenderedLegend:!!d}):null,D=e.annotations?Bu({annotations:e.annotations,margin:o,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{x:b.scales.x,y:b.scales.y},layout:{width:h,height:f},theme:i,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:M,onRender:e=>{S=e}}):null;t&&(t.evidence=wc({frameType:"xy",width:r[0],height:r[1],marks:_.map(e=>e.node),title:e.title,description:A,annotations:e.annotations,annotationRender:S,xDomain:vc(b.scales.x?.domain?.()),yDomain:vc(b.scales.y?.domain?.()),legendItems:c.length>0?c.length:void 0,margin:o}));let z=e.svgPreRenderers&&b.scales?e.svgPreRenderers.map((e,t)=>{try{/* @__PURE__ */
|
|
225
|
+
return BA(Kw.Fragment,{children:e(b.scene,b.scales,{width:h,height:f})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return Qw.renderToStaticMarkup(Ad(/* @__PURE__ */YA(jA,{children:[v,z,$,
|
|
226
|
+
/* @__PURE__ */BA("defs",{children:/* @__PURE__ */BA("clipPath",{id:I,children:/* @__PURE__ */BA("rect",{x:0,y:0,width:h,height:f})})}),
|
|
227
|
+
/* @__PURE__ */BA("g",{clipPath:`url(#${I})`,children:L}),T,C,D,w,b.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:A,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}function Rd(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}function Td({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:a,height:n,seed:s,reduced:l,onSelectTask:c}){let u=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);/* @__PURE__ */
|
|
228
|
+
return VA("svg",{"aria-hidden":"true",width:a,height:n,viewBox:`0 0 ${a} ${n}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[
|
|
229
|
+
/* @__PURE__ */GA("defs",{children:/* @__PURE__ */GA("filter",{id:"chain-shadow-"+s,x:"-20%",y:"-20%",width:"140%",height:"150%",children:/* @__PURE__ */GA("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;/* @__PURE__ */
|
|
230
|
+
return VA("g",{children:[
|
|
231
|
+
/* @__PURE__ */GA("line",{x1:r,x2:r,y1:h,y2:n-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),
|
|
232
|
+
/* @__PURE__ */GA("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),a=r.has(e.targetID)||r.has(e.sourceID),n=e.points.map(e=>`${e.x},${e.y}`).join(" ");/* @__PURE__ */
|
|
233
|
+
return GA("polyline",{points:n,fill:"none",stroke:a?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:a?4:o?3:2,strokeOpacity:t||o||a?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);/* @__PURE__ */
|
|
234
|
+
return VA("g",{children:[
|
|
235
|
+
/* @__PURE__ */GA("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&/* @__PURE__ */GA("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let a=t.taskByID.get(e.id);if(!a)return null;let n=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,f=r.has(e.id),p=Rd(e,i),g=a.x-a.width/2,y=a.y-a.height/2,m=Math.max(2,a.height*e.progress);/* @__PURE__ */
|
|
236
|
+
return VA("g",{children:[
|
|
237
|
+
/* @__PURE__ */VA("g",{style:{transform:`rotate(${n?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:l?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+s+")"},children:[
|
|
238
|
+
/* @__PURE__ */GA("rect",{x:g,y:y,width:a.width,height:a.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),
|
|
239
|
+
/* @__PURE__ */GA("rect",{x:g+3,y:y+a.height-m+1,width:a.width-6,height:Math.max(0,m-4),rx:2,fill:p,opacity:n?.86:.46})]}),u&&/* @__PURE__ */VA("g",{opacity:d?.28:1,children:[
|
|
240
|
+
/* @__PURE__ */GA("line",{x1:g-8,x2:g+14,y1:a.y+9,y2:a.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),
|
|
241
|
+
/* @__PURE__ */GA("circle",{cx:g-8,cy:a.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),
|
|
242
|
+
/* @__PURE__ */VA("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[
|
|
243
|
+
/* @__PURE__ */GA("rect",{x:g,y:y,width:a.width,height:a.height,fill:"transparent"}),
|
|
244
|
+
/* @__PURE__ */GA("text",{x:a.x,y:a.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),
|
|
245
|
+
/* @__PURE__ */VA("text",{x:a.x,y:a.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",n?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function Cd(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function Dd(e){if(null==e.completionTime)return null;let t=Cd(e.completionTime,NaN);return Number.isFinite(t)?t:null}function zd(e,t,i,r){let o=/* @__PURE__ */new Set;for(let a of e.nodes){let n=e.incoming.get(a.id)??[];(r.has(a.id)||!i.has(a.id)&&n.every(e=>t.has(e.id)))&&o.add(a.id)}return o}function Ed(e,t,i,r){let o=e.nodes.map(Dd).filter(e=>null!=e),a=o.length?Math.min(...o)-1:0,n="replay"!==t||r?i:a,s=/* @__PURE__ */new Set,l=/* @__PURE__ */new Map;for(let i of e.nodes){let e=Dd(i);(null!=e&&n>=e||"done"===i.status&&"replay"!==t)&&s.add(i.id),i.blockerReason&&!s.has(i.id)&&l.set(i.id,i.blockerReason)}let c=/* @__PURE__ */new Set;if("replay"!==t||r)for(let t of e.edges)s.has(t.sourceID)&&c.add(t.id);return{currentTime:n,playing:!1,completed:s,delivered:c,inFlight:/* @__PURE__ */new Set,armed:zd(e,c,l,s),blockers:l,previewTaskID:null}}function Nd(e,t,i){return $s(i,e,t)}function Od(e,t){return t>e?-1:e>t?1:0}function Fd(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Wd(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function jd(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function Bd(e){let t=[],i=/* @__PURE__ */new Map,r=[],o=/* @__PURE__ */new Set;e.data.forEach((a,n)=>{let s=(Nd(a,n,e.taskIDAccessor)??"")+"";if(!s)return void t.push({code:"duplicate-task-id",message:`Task row ${n} has an empty id.`,taskIDs:[]});if(i.has(s))return void t.push({code:"duplicate-task-id",message:`Task id "${s}" occurs more than once.`,taskIDs:[s]});let l=(Nd(a,n,e.laneAccessor)??"Unassigned")+"";o.has(l)||(o.add(l),r.push(l));let c=Nd(a,n,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>e+""))).sort(Od),d=Nd(a,n,e.blockerAccessor),h=Nd(a,n,e.statusAccessor)??(d?"blocked":"waiting");i.set(s,{id:s,label:(Nd(a,n,e.labelAccessor)??s)+"",lane:l,laneIndex:0,level:0,index:n,datum:a,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:Nd(a,n,e.startAccessor),end:Nd(a,n,e.endAccessor),progress:jd(Nd(a,n,e.progressAccessor)),status:h,completionTime:Nd(a,n,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!Nd(a,n,e.milestoneAccessor)})});let a=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,n=new Map(a.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=n.get(e.lane)??0;let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(let e of i.keys())s.set(e,[]),l.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let a=i.get(r);if(!a)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let n={id:Fd(r,e.id),sourceID:r,targetID:e.id,sourceIndex:a.index,targetIndex:e.index,socketID:Wd(e.id,o),socketIndex:o};c.push(n),s.get(e.id)?.push(n),l.get(r)?.push(n),e.incomingEdgeIDs.push(n.id),e.socketIDs.push(n.socketID),a.outgoingEdgeIDs.push(n.id)});for(let e of s.values())e.sort((e,t)=>Od(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=Wd(e.targetID,t)});for(let e of l.values())e.sort((e,t)=>Od(e.targetID,t.targetID));for(let e of i.values()){let t=s.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(l.get(e.id)??[]).map(e=>e.id)}let d=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(let e of i.keys())d.set(e,s.get(e)?.length??0),h.set(e,0);let f=[...i.keys()].filter(e=>0===d.get(e)).sort(Od),p=0;for(;f.length;){let e=f.shift();p+=1;for(let t of l.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=f.findIndex(e=>e>t.targetID);0>e?f.push(t.targetID):f.splice(e,0,t.targetID)}}}if(p!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(Od);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let g=0,y=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of y)e.level=h.get(e.id)??0,g=Math.max(g,e.level);return{nodes:y,edges:c,byID:i,incoming:s,outgoing:l,lanes:a,maxLevel:g,diagnostics:t,valid:0===t.length}}function Yd(e){return e.filter((t,i)=>{let r=e[i-1];return!r||r.x!==t.x||r.y!==t.y})}function Xd(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),a=t.paddingX??48,n=t.paddingTop??48,s=t.paddingBottom??44,l=Math.max(70,(r-2*a)/Math.max(1,e.lanes.length)),c=Math.max(76,(o-n-s)/Math.max(1,e.maxLevel+1)),u=Math.min(i.taskWidth??112,Math.max(58,.78*l)),d=Math.min(i.taskHeight??58,.64*c),h=i.socketRadius??5,f=Math.max(1,Math.round(i.gutterCount??3)),p=/* @__PURE__ */new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=p.get(e)??[];i.push(t),p.set(e,i)}for(let e of p.values())e.sort((e,t)=>Od(e.id,t.id));let g=.86*c,y=e=>e>1?Math.max(22,Math.min(d,(g-4*(e-1))/e)):d,m=e.nodes.map(e=>{let t=p.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=y(t.length);return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:a+l*(e.laneIndex+.5),y:n+c*(e.level+.5)+i*(r+4),width:u,height:r}}),x=new Map(m.map(e=>[e.taskID,e])),b=[],v=[];e.edges.forEach((t,i)=>{let r=x.get(t.sourceID),o=x.get(t.targetID);if(!r||!o)return;let a=e.incoming.get(t.targetID)??[],n=Math.min(.72*o.width,14*Math.max(1,a.length-1)),s=a.length>1?o.x-n/2+n*t.socketIndex/(a.length-1):o.x,l=o.y-o.height/2-h-2;b.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:s,y:l,radius:h});let c={x:r.x,y:r.y+r.height/2+3},u=Math.min(l-10,c.y+.48*Math.max(18,l-c.y)+7*(i%f-(f-1)/2));v.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:Yd([c,{x:c.x,y:u},{x:s,y:u},{x:s,y:l}])})});let w=new Map(b.map(e=>[e.id,e])),k=new Map(v.map(e=>[e.edgeID,e]));return{tasks:m,sockets:b,routes:v,taskByID:x,socketByID:w,routeByEdgeID:k}}function Gd(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=Jy(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),a=[...tm(o,t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),n=Array.from(new Set(a.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:a.length,affectedLaneCount:n.length,downstreamTaskIDs:a.map(e=>e.id),affectedLanes:n}}function Vd(e){return e.__composite}function qd(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function Hd(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function Ud(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=Gd(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:r+" No explicit blockers are active."}function Zd(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function Kd(e){return e.__composite}function Qd(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function Jd(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function eh(e,t){return Math.max(1,Math.floor(Jd(e,t)))}function th(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function ih(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}function rh(e,t){return("function"==typeof t?t(e):e[t])+""}function oh(e,t,i,r){if(!t)return{categories:[],color:()=>Ix};let o=Array.from(new Set(e.map(e=>rh(e,t)))),a="string"==typeof t?t:"__semioticSplomColor",n=$e("function"==typeof t?e.map(e=>({...e,[a]:rh(e,t)})):e,a,i??r.colors.categorical);return{categories:o,color:e=>_e(e,t,n)}}function ah(e){let{data:t,field:i,label:r,cellSize:o,bins:a,diagonal:n,colorBy:s,color:l,x:c,y:u}=e;if("label"===n)return{visibleBars:0,svg:Zw.renderToStaticMarkup(
|
|
246
|
+
/* @__PURE__ */UA("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:/* @__PURE__ */UA("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/a||1,p=Array.from({length:a},()=>/* @__PURE__ */new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(a-1,Math.floor((t-h)/f))),o=s?rh(e,s):"__all",n=p[r];n.set(o,[...n.get(o)??[],e])}let g=p.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),y=Math.max(1,...g),m=0,x=p.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];m+=1;let n=r.length/y*(o-24),c=i;return i+=n,/* @__PURE__ */UA("rect",{x:t/a*o,y:o-c-n,width:Math.max(o/a-1,1),height:n,fill:s?l(r[0]):Ix,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:Zw.renderToStaticMarkup(
|
|
247
|
+
/* @__PURE__ */ZA("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:[
|
|
248
|
+
/* @__PURE__ */UA("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),x]}))}}function nh(e,t,i){if(!eS.isValidElement(e)||!iS.has(e.type))return null;let r=e,o="text"===r.type?eS.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;/* @__PURE__ */
|
|
249
|
+
return tS("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}function sh(e,t,i,r,o,a){let n=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let n of o(t)??[]){let t=i.get(n);null!=t&&(r=Math.max(r,Cs(e,t,a)))}l=zs(c,r,n)||l;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);l=zs(c,null==u?0:Cs(e,u,a),n,s)||l}return l}function lh(e,t,i){let{scales:r,config:o,getConnector:a,getO:n}=e;if(!a||!r)return[];let s=[],{projection:l}=r,c=/* @__PURE__ */new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=a(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===l?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:n(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},f=e=>"function"==typeof d?d(e):d||h,p=(e,t,i)=>{s.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:f(e.datum),datum:e.datum,group:i})};for(let[e,t]of c)if(t.length>=2){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;t.length-1>i;i++)p(t[i],t[i+1],e);"radial"===l&&t.length>=3&&p(t[t.length-1],t[0],e)}return s}function ch(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function uh(e){let t=e.getSymbol;return t?Mm(t,e.config.symbolMap):null}function dh(e,t,i,r,o,a,n){e.push(t?{type:"symbol",x:r,y:o,size:Math.PI*a*a,symbolType:t(i),style:n,datum:i}:{type:"point",x:r,y:o,r:a,style:n,datum:i})}function hh(e,t){let{columns:i,config:r,resolvePieceStyle:o}=e,a=[],n=Math.min(t.width,t.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,l=-Math.PI/2+(r.startAngle||0)*Math.PI/180,c=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI,u=null!=r.sweepAngle&&360>r.sweepAngle,d=Object.values(i),h=d.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(r.cornerRadius??0)>0;for(let e=0;d.length>e;e++){let t=d[e],i=t.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h=l+u*c,p=l+(u+("number"==typeof i?._pct?i._pct:t.pct))*c,g=o(t.pieceData[0],t.name),y=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:n,startAngle:h,endAngle:p,...r.cornerRadius&&{cornerRadius:r.cornerRadius},style:g,datum:i?._nonInteractive?null:t.pieceData,category:t.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:y,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),a.push(x)}return a}function fh(e,t,i){return{...e[0],...i,category:t,data:e}}function ph(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:sS(e,.25)??i,median:sS(e,.5)??(i+r)/2,q3:sS(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function gh(e,t,i,r,o){let a=Array(o).fill(0);for(let n of e)t>n||n>i||a[Math.min(Math.floor((n-t)/r),o-1)]++;return a}function yh(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:a,extentPadding:n=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,f=n;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let p=0,g=0;if("bar"===i&&d&&o)p=0,g=1;else if("bar"===i&&d){let e=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let r of t){let t=c(r),o=u(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(let t of e.values())t>g&&(g=t);for(let e of i.values())p>e&&(p=e)}else if("bar"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i),r=u(i);e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>g&&(g=t),p>t&&(p=t)}else if("swimlane"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>g&&(g=t)}else if("clusterbar"===i||"bar-funnel"===i)for(let e of t){let t=u(e);t>g&&(g=t),p>t&&(p=t)}else{let e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(g=t)}a&&(null!=a[0]&&(p=a[0]),null!=a[1]&&(g=a[1]));let y="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(y&&(null!=a?.[0]||null!=a?.[1]||(p>0&&(p=0),0>g&&(g=0))),"bar-funnel"!==i&&"exact"!==l){let e=g-p,t=e>0?e*f:1,r=y&&!s&&0===p,o=y&&!s&&0===g||"swimlane"===i;null==a?.[0]&&!r&&(p-=t),null==a?.[1]&&!o&&(g+=t)}return[p,g]}function mh(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:a,dynamicColumnWidth:n,getO:s,getR:l}=e,c=/* @__PURE__ */Object.create(null),u=/* @__PURE__ */new Map;for(let e of t){let t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(l(e));let h=null;if(n&&"radial"!==o){h=/* @__PURE__ */new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof n?r.reduce((e,t)=>e+(Number(t[n])||0),0):n(r),h.set(t,i),e+=i}let t=("horizontal"===o?a.height:a.width)-r.padding()*r.step()*i.length;if(e>0)for(let[i,r]of h)h.set(i,r/e*t)}let f=0,p=0;for(let e of i){let t,i,o=u.get(e)||[],a=o.reduce((e,t)=>e+Math.abs(l(t)),0),n=d>0?a/d:0;h?(t=p,i=h.get(e)||r.bandwidth(),p+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:n,pctStart:f},f+=n}return c}function xh(e,t){let i="function"==typeof t,r=i?null:t||"category",o=/* @__PURE__ */new Map;for(let a=0;e.length>a;a++){let n=e[a],s=i?t(n):n[r],l=o.get(s);l?l.push(a):o.set(s,[a])}return o}function bh(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=bS[r]??vS;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function vh(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(500>=t)return{quadtree:null,maxRadius:i};let r=Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:kS().x(e=>e.x).y(e=>e.y).addAll(r)}}function wh(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,a=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(a){let e=PS(i,r),t=PS(i,o);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}let e=PS(i,r),n=PS(i,o),s=PS(t,o),l=PS(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${n.x},${n.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}let n=Math.max(0,Math.min(e.cornerRadius??0,(i-t)/2));if(0===n)return wh({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let s=Math.asin(Math.min(1,n/Math.max(1e-9,i-n))),l=a?0:Math.asin(Math.min(1,n/Math.max(1e-9,t+n))),c=o-r,u=e.roundStart&&e.roundEnd?c/2:c,d=!!e.roundStart&&u>s,h=!!e.roundEnd&&u>s;if(!d&&!h)return wh({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let f=r+(d?s:0),p=o-(h?s:0),g=r+(d?l:0),y=o-(h?l:0),m=PS(i,f),x=PS(i,p),b=(i-n)*Math.cos(s),v=PS(b,r),w=PS(b,o),k=a?null:PS(t,y),A=a?null:PS(t,g),S=a?0:(t+n)*Math.cos(l),M=a?null:PS(S,r),_=a?null:PS(S,o),P=p-f>Math.PI?1:0,$=a?0:y-g>Math.PI?1:0,L="";if(d)L+=`M${v.x},${v.y}`,L+=` A${n},${n} 0 0 1 ${m.x},${m.y}`;else{let e=PS(i,r);L+=`M${e.x},${e.y}`}if(h)L+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,L+=` A${n},${n} 0 0 1 ${w.x},${w.y}`;else{let e=PS(i,o);L+=` A${i},${i} 0 ${P} 1 ${e.x},${e.y}`}if(a)L+=" L0,0";else{if(h)L+=` L${_.x},${_.y}`,L+=` A${n},${n} 0 0 1 ${k.x},${k.y}`;else{let e=PS(t,o);L+=` L${e.x},${e.y}`}if(d)L+=` A${t},${t} 0 ${$} 0 ${A.x},${A.y}`,L+=` A${n},${n} 0 0 1 ${M.x},${M.y}`;else{let e=PS(t,r);L+=` A${t},${t} 0 ${$} 0 ${e.x},${e.y}`}}return L+=" Z",L}function kh(e){let t=wh({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)i.push({d:wh({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,slices:i}}function Ah(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Sh(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,a=Number(i.__funnelStepLabelX),n=Number(i.__funnelStepLabelY),s=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(a)&&Number.isFinite(n)&&(!Number.isFinite(s)||s>=8.4*o.length+16)&&r.push(
|
|
250
|
+
/* @__PURE__ */$S("text",{x:a,y:n+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));let l=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${Ah(l)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:Ah(l);7.8*o.length+16>d&&(o=Ah(l)),d>=7.8*o.length+16&&r.push(
|
|
251
|
+
/* @__PURE__ */$S("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return r.length?/* @__PURE__ */$S("g",{children:r},t+"-funnel-labels"):null}function Mh(e,t,i){return zc(_h(e,t,i),e,"ordinal-cursor-"+t)}function _h(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,a=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=Pc(a)+"-grad",n=Ic(r,o);if(n)i=`url(#${o})`;else if(di(r.style.fill)){let e=Pc(a)+"-hatch";t=pi(r.style.fill,e),i=`url(#${e})`}else i=_c(r.style.fill);let s=n||t?/* @__PURE__ */LS("defs",{children:[n,t]}):null;if(r.cornerRadii&&Sc(r.cornerRadii)){let e=Rc(r);/* @__PURE__ */
|
|
252
|
+
return LS(MS.Fragment,{children:[s,
|
|
253
|
+
/* @__PURE__ */$S("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:n,w:l,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${n} L${o+l-t},${n} A${t},${t} 0 0 1 ${o+l},${n+t} L${o+l},${n+c-t} A${t},${t} 0 0 1 ${o+l-t},${n+c} L${o},${n+c} Z`;break;case"left":e=`M${o+l},${n} L${o+t},${n} A${t},${t} 0 0 0 ${o},${n+t} L${o},${n+c-t} A${t},${t} 0 0 0 ${o+t},${n+c} L${o+l},${n+c} Z`;break;case"bottom":e=`M${o},${n} L${o+l},${n} L${o+l},${n+c-t} A${t},${t} 0 0 1 ${o+l-t},${n+c} L${o+t},${n+c} A${t},${t} 0 0 1 ${o},${n+c-t} Z`;break;default:e=`M${o},${n+c} L${o},${n+t} A${t},${t} 0 0 1 ${o+t},${n} L${o+l-t},${n} A${t},${t} 0 0 1 ${o+l},${n+t} L${o+l},${n+c} Z`}/* @__PURE__ */
|
|
254
|
+
return LS(MS.Fragment,{children:[s,
|
|
255
|
+
/* @__PURE__ */$S("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}/* @__PURE__ */
|
|
256
|
+
return LS(MS.Fragment,{children:[s,
|
|
257
|
+
/* @__PURE__ */$S("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),Sh(r,a)]},a)}case"point":{let t=e;/* @__PURE__ */
|
|
258
|
+
return $S("circle",{cx:t.x,cy:t.y,r:t.r,fill:_c(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}case"symbol":return Tc(e,t,i);case"glyph":return $c(e,e.x,e.y,`${i??""}ord-glyph-${e.pointId??t}`);case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=Pc(`${i?i+"-":""}gauge-grad-${o.category||a}-${t}`),{clipPath:r,slices:n}=kh({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});/* @__PURE__ */
|
|
259
|
+
return LS("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[
|
|
260
|
+
/* @__PURE__ */$S("defs",{children:/* @__PURE__ */$S("clipPath",{id:e,children:/* @__PURE__ */$S("path",{d:r})})}),
|
|
261
|
+
/* @__PURE__ */$S("g",{clipPath:`url(#${e})`,children:n.map((e,t)=>/* @__PURE__ */$S("path",{d:e.d,fill:_c(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&
|
|
262
|
+
/* @__PURE__ */$S("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},a)}if(o.roundedEnds)r=wh({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=_S().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(Ek)||""}/* @__PURE__ */
|
|
263
|
+
return $S("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:_c(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},a)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;/* @__PURE__ */
|
|
264
|
+
return LS("g","vertical"===t.projection?{children:[
|
|
265
|
+
/* @__PURE__ */$S("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
266
|
+
/* @__PURE__ */$S("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:_c(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
267
|
+
/* @__PURE__ */$S("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
|
|
268
|
+
/* @__PURE__ */$S("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
269
|
+
/* @__PURE__ */$S("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]}:{children:[
|
|
270
|
+
/* @__PURE__ */$S("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
271
|
+
/* @__PURE__ */$S("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:_c(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
272
|
+
/* @__PURE__ */$S("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
|
|
273
|
+
/* @__PURE__ */$S("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),
|
|
274
|
+
/* @__PURE__ */$S("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},a)}case"violin":{let t=e,i=[
|
|
275
|
+
/* @__PURE__ */$S("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:_c(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth??1},o("path"))];if(t.iqrLine&&t.bounds){let e=t.bounds,r=e.x+e.width/2,a=e.y+e.height/2;t.iqrLine.isVertical?i.push(
|
|
276
|
+
/* @__PURE__ */$S("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
|
|
277
|
+
/* @__PURE__ */$S("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(
|
|
278
|
+
/* @__PURE__ */$S("line",{x1:t.iqrLine.q1Pos,y1:a,x2:t.iqrLine.q3Pos,y2:a,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
|
|
279
|
+
/* @__PURE__ */$S("circle",{cx:t.iqrLine.medianPos,cy:a,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}/* @__PURE__ */
|
|
280
|
+
return $S("g",{children:i},a)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?_c(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";/* @__PURE__ */
|
|
281
|
+
return $S("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},a)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");/* @__PURE__ */
|
|
282
|
+
return $S("polygon",{points:i,fill:_c(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}default:return null}}function Ph(e){return"connector"===e.node.type}function $h(e,t,i,r){if(2>e.length)return null;let o=e[0].node,a=o.style.fill;if(!a||"none"===a)return null;let n=Pc(`${t?t+"-":""}connector-${i}-${r}-hatch`),s=di(a)?pi(a,n):null,l=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return zc(/* @__PURE__ */RS(SS.Fragment,{children:[s&&/* @__PURE__ */IS("defs",{children:s}),
|
|
283
|
+
/* @__PURE__ */IS("polygon",{points:l,fill:s?`url(#${n})`:_c(a,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function Lh(e,t,i){let r=/* @__PURE__ */new Map;for(let t of e){if(!Ph(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>/* @__PURE__ */RS("g",{children:[$h(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),a=e[0],n=Ph(a)?null:a.element;for(let e of r.values())for(let t of e)t.element=null;a.element=/* @__PURE__ */RS(SS.Fragment,{children:[o,n]},"ordinal-connector-run-"+i)}function Ih(e){let t=Vc({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>Mh(t,i,e.idPrefix)}),i=0;for(let r=0;t.length>r;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;t.length>o&&!t[o].renderedByBackend;)o++;Lh(t.slice(r,o),e.idPrefix,i++),r=o}return t}function Rh(e){let{id:t,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:a=6,angle:n=45}=e,s=Math.max(8,Math.ceil(2*a));/* @__PURE__ */
|
|
284
|
+
return CS("pattern",{id:t,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */TS("rect",{width:s,height:s,fill:i}),
|
|
285
|
+
/* @__PURE__ */TS("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o}),
|
|
286
|
+
/* @__PURE__ */TS("line",{x1:a,y1:0,x2:a,y2:s,stroke:r,strokeWidth:o})]},t)}function Th(e,i,r,o,a,n,s,l=!1){let c=e.scales;if(!c||"radial"===c.projection)return null;let u=Pi(o),d="vertical"===c.projection,f=e.columns,p=r.categoryFormat||r.oFormat,g=r.valueFormat||r.rFormat,y=r.categoryLabel||r.oLabel,m=r.valueLabel||r.rLabel,x=r.legendPosition??"right",b=h(r.legendLayout,s?.leftAxis),v=l&&"left"===x&&b>0?b:n?.left??r.margin?.left??40,w=Object.values(f).map((e,t)=>({pixel:e.middle,label:p?p(e.name,t):e.name})),k=r.rTickValues??td(c.r,5,r.axisExtent),A=g||t(k),S=k.map(e=>({pixel:c.r(e),label:A(e)}));/* @__PURE__ */
|
|
287
|
+
return ES("g",d?{id:(a?a+"-":"")+"axes",className:"ordinal-axes",children:[
|
|
288
|
+
/* @__PURE__ */zS("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>/* @__PURE__ */ES("g",{transform:`translate(${e.pixel},${i.height})`,children:[
|
|
289
|
+
/* @__PURE__ */zS("line",{y2:5,stroke:u.border,strokeWidth:1}),id(e.label)?/* @__PURE__ */zS("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):rd({label:e.label,x:-30,y:6,textAlign:"center",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oxtick-"+t)),y&&/* @__PURE__ */zS("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:y}),
|
|
290
|
+
/* @__PURE__ */zS("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>/* @__PURE__ */ES("g",{transform:`translate(0,${e.pixel})`,children:[
|
|
291
|
+
/* @__PURE__ */zS("line",{x2:-5,stroke:u.border,strokeWidth:1}),
|
|
292
|
+
/* @__PURE__ */zS("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oytick-"+t)),m&&/* @__PURE__ */zS("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:m})]}:{id:(a?a+"-":"")+"axes",className:"ordinal-axes",children:[
|
|
293
|
+
/* @__PURE__ */zS("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>/* @__PURE__ */ES("g",{transform:`translate(${e.pixel},${i.height})`,children:[
|
|
294
|
+
/* @__PURE__ */zS("line",{y2:5,stroke:u.border,strokeWidth:1}),
|
|
295
|
+
/* @__PURE__ */zS("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oxtick-"+t)),m&&/* @__PURE__ */zS("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:m}),
|
|
296
|
+
/* @__PURE__ */zS("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>/* @__PURE__ */ES("g",{transform:`translate(0,${e.pixel})`,children:[
|
|
297
|
+
/* @__PURE__ */zS("line",{x2:-5,stroke:u.border,strokeWidth:1}),id(e.label)?/* @__PURE__ */zS("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):rd({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),y&&/* @__PURE__ */zS("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:y})]})}function Ch(e,t){let i=_i(e.theme),r=e.size||[500,400],o=s({...zA,...e.margin},e.title),n=a(e.title),l=lr(e.data),c=e.showLegend?su(l,e.colorAccessor||e.stackBy||e.groupBy):[],u=y({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});vd(o,{props:{...e,axisChrome:u},categories:c,theme:i,size:r,hasTitle:n});let d=wd({props:{...e,axisChrome:u},categories:c,theme:i,size:r,margin:o,hasTitle:n}),h=r[0]-o.left-o.right,f=r[1]-o.top-o.bottom,p=e.projection||"vertical",g="radial"===p,m=e.colorScheme||i.colors.categorical,x={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:p,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,axisExtent:e.axisExtent,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,gradientFill:mr(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:m,themeCategorical:i.colors.categorical,themeSemantic:Oy(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},b=new AS(x);e.data&&b.ingest({inserts:l,bounded:!0}),b.computeScene({width:h,height:f});let v=Pd(e.backgroundGraphics,r,o,b.scales),w=Pd(e.foregroundGraphics,r,o,b.scales);if(!b.scales){let a,n=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{},layout:{width:h,height:f},theme:i,projection:p,idPrefix:e._idPrefix,onRender:e=>{a=e}}):null;return t&&(t.evidence=wc({frameType:"ordinal",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:a,extraWarnings:b.scales?[]:["NO_SCALES"],margin:o})),rS.renderToStaticMarkup(Ad(v||w||e.annotations?/* @__PURE__ */ES(DS,{children:[v,n,w,b.customLayoutOverlays]}):null,{width:r[0],height:r[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}let k=e._idPrefix,A=e.showGrid?kd(b,{width:h,height:f},i,k,e.axisExtent,e.rTickValues):null,S=null;if(b.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=yd(e),r=/* @__PURE__ */new Set;for(let e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&r.add("string"==typeof e.style.fill?e.style.fill:"#666");S=Array.from(r).map((e,r)=>Rh({id:`funnel-hatch-${t}-${r}`,background:e,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));let o=/* @__PURE__ */new Map;Array.from(r).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(let e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}let M,_=Ih({nodes:b.scene,renderMode:e.renderMode,idPrefix:k}),P=_.map(e=>e.element),$=!1!==e.showAxes?Th(b,{width:h,height:f},e,i,k,o,u,!!d):null,L=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{o:b.scales.o,r:b.scales.r,y:"vertical"===b.scales.projection?b.scales.r:void 0},layout:{width:h,height:f},theme:i,projection:p,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:k,onRender:e=>{M=e}}):null;if(t){let i=b.scales.o?.domain?.();t.evidence=wc({frameType:"ordinal",width:r[0],height:r[1],marks:_.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:M,yDomain:vc(b.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:o})}let I=g&&e.centerContent?nh(e.centerContent,o.left+h/2,o.top+f/2):null,R=g&&e.centerContent?I??/* @__PURE__ */zS("foreignObject",{x:o.left,y:o.top,width:h,height:f,pointerEvents:"none",children:/* @__PURE__ */zS("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,T=/* @__PURE__ */ES(DS,{children:[A,P,$,L,w,b.customLayoutOverlays]});return rS.renderToStaticMarkup(Ad(/* @__PURE__ */ES(DS,g?{children:[v?/* @__PURE__ */zS("g",{transform:`translate(${-h/2},${-f/2})`,children:v}):null,T]}:{children:[v,T]}),{width:r[0],height:r[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:g?`translate(${o.left+h/2},${o.top+f/2})`:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:f,legend:d,defs:S,outerElements:R,idPrefix:e._idPrefix}))}function Dh({nodes:e,edges:t,restyle:i,restyleEdge:r,baseStyles:o,selection:a}){let n=!(!i&&!r);if(i)for(let t of e){let e=o.get(t)??t.style,r=i(t,a);t.style=r?{...e,...r}:e}if(r)for(let e of t){let t=o.get(e)??e.style,i=r(e,a);e.style=i?{...t,...i}:t}return n}function zh(e,t){OS[e]=t}function Eh(e){return OS[e]}function Nh(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function Oh(e){function t(t){var i=[t],c=[t];for(r[t]=o[t]=d,a[t]=!0,d+=1;c.length>0;){var u=e[t=c[c.length-1]];if(u.length>n[t]){for(var p=n[t];u.length>p;++p){var g=u[p];if(0>r[g]){r[g]=o[g]=d,a[g]=!0,d+=1,i.push(g),c.push(g);break}a[g]&&(o[t]=0|Math.min(o[t],o[g])),s[g]>=0&&l[t].push(s[g])}n[t]=p}else{if(o[t]===r[t]){var y=[],m=[],x=0;for(p=i.length-1;p>=0;--p){var b=i[p];if(a[b]=!1,y.push(b),m.push(l[b]),x+=l[b].length,s[b]=h.length,b===t){i.length=p;break}}h.push(y);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];f.push(v)}c.pop()}}}for(var i=e.length,r=Array(i),o=Array(i),a=Array(i),n=Array(i),s=Array(i),l=Array(i),c=0;i>c;++c)r[c]=-1,o[c]=0,a[c]=!1,n[c]=0,s[c]=-1,l[c]=[];var u,d=0,h=[],f=[];for(c=0;i>c;++c)0>r[c]&&t(c);for(c=0;f.length>c;c++){var p=f[c];if(0!==p.length){p.sort(function(e,t){return e-t}),u=[p[0]];for(var g=1;p.length>g;g++)p[g]!==p[g-1]&&u.push(p[g]);f[c]=u}}return{components:h,adjacencyList:f}}function Fh(e,t){function i(e){u[e]=!1,d.hasOwnProperty(e)&&Object.keys(d[e]).forEach(function(t){delete d[e][t],u[t]&&i(t)})}function r(e){var t,a,n=!1;for(c.push(e),u[e]=!0,t=0;h[e].length>t;t++)(a=h[e][t])===s?(o(s,c),n=!0):u[a]||(n=r(a));if(n)i(e);else for(t=0;h[e].length>t;t++){var l=d[a=h[e][t]];l||(d[a]=l={}),l[a]=!0}return c.pop(),n}function o(e,i){var r=[].concat(i).concat(e);t?t(r):l.push(r)}function a(t){for(var i=0;e.length>i;i++)(t>i||!e[i])&&(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}function n(t){a(t);for(var i,r=Oh(e).components.filter(function(e){return e.length>1}),o=1/0,n=0;r.length>n;n++)for(var s=0;r[n].length>s;s++)o>r[n][s]&&(o=r[n][s],i=n);var l=r[i];return!!l&&{leastVertex:o,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}var s,l=[],c=[],u=[],d={},h=[];s=0;for(var f=e.length;f>s;){var p=n(s);if(s=p.leastVertex,h=p.adjList){for(var g=0;h.length>g;g++)for(var y=0;h[g].length>y;y++){var m=h[g][y];u[+m]=!1,d[m]={}}r(s),s+=1}else s=f}if(!t)return l}function Wh(e){return e.y0-e.y1>0?"up":"down"}function jh(e,t){return t(e.source)==t(e.target)}function Bh(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),!(t>1||i>1)}function Yh(e){return e.target.x0-e.source.x1}function Xh(e,t){var i=Vh(e),r=Yh(t)/Math.tan(i);return"up"==Wh(e)?e.y1-r:e.y1+r}function Gh(e,t){var i=Vh(e),r=Yh(t)/Math.tan(i);return"up"==Wh(e)?e.y1+r:e.y1-r}function Vh(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function qh(e,t){return t(e)}function Hh(e){return Zh(e.source)}function Uh(e){return Zh(e.target)}function Zh(e){return(e.y0+e.y1)/2}function Kh(e){return e.virtual?0:e.value}function Qh(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!jh(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!jh(e,t)?r+1:r}),i+r}function Jh(e){return e.target.depth}function ef(e,t){return e.sourceLinks.length?e.depth:t-1}function tf(e,t){return e.y0-t.y0}function rf(e,t){return t.y0-e.y0}function of(e,t){return e.y1-t.y1}function af(e,t){return t.y1-e.y1}function nf(e,t){return lf(e.source,t.source)||e.index-t.index}function sf(e,t){return lf(e.target,t.target)||e.index-t.index}function lf(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function cf(e,t){return uf(e)==uf(t)?"bottom"==e.circularLinkType?rf(e,t):tf(e,t):uf(t)-uf(e)}function uf(e){return e.target.column-e.source.column}function df(e,t){let i=e;return i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var r=i.links.filter(function(i){return qh(i.source,t)==qh(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!ff(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=Xh(t,e);return e.y1-i}if(t.target.column>e.target.column)return Xh(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 a=e.y0;r.forEach(function(e){e.y0=a+e.width/2,a+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var a=i+1,n=0;o>a;a++)n+=r[a].width;t.y0=e.y1-n-t.width/2}})}),i}function hf(e,t){let i=e;return i.nodes.forEach(function(e){var r=i.links.filter(function(i){return qh(i.target,t)==qh(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!ff(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=Gh(t,e);return e.y0-i}if(t.source.column>e.source.column)return Gh(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 a=e.y0;r.forEach(function(e){e.y1=a+e.width/2,a+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var a=i+1,n=0;o>a;a++)n+=r[a].width;t.y1=e.y1-n-t.width/2}})}),i}function ff(e,t){return pf(e)==pf(t)}function pf(e){return e.y0-e.y1>0?"up":"down"}function gf(e){var t=e.source.x1,i=e.y0,r=e.target.x0,o=e.y1,a=(t+r)/2;return"M"+t+","+i+"C"+a+","+i+" "+a+","+o+" "+r+","+o}function yf(e,t,i,r,o){let a=e;var n=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,n))});var s=FS(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=a.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),mf(a.links.filter(function(e){return"top"==e.circularLinkType}),t,i),mf(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,jh(e,t)&&Bh(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var n=e.source.column,l=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==n&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?rf:tf);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),n=e.target.column,(c=a.links.filter(function(e){return e.target.column==n&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?af:of),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?bf(e):gf(e)}),a}function mf(e,t,i){e.sort(cf);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var a=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(jh(e,t)&&Bh(e))e.circularPathData.verticalBuffer=a+e._circularWidth/2;else{for(var n=0;r.length>n;n++){var s=r[n];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&xf(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;a=l>a?l:a}}e.circularPathData.verticalBuffer=a+e._circularWidth/2}}),e}function xf(e,t){return!(t.target.column>e.source.column||e.target.column>t.source.column)}function bf(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}function vf(e){return function(){return e}}function wf(e){return e.index}function kf(e){return e.nodes}function Af(e){return e.links}function Sf(e,t){var i=/* @__PURE__ */new Map;return XS(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function Mf(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=Sf(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=Nh(i,r)),"object"!=typeof o&&(o=e.target=Nh(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}function _f(e,t){var i=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var a=e.links[o],n=a.source.index,s=a.target.index;r[n]||(r[n]=[]),r[s]||(r[s]=[]),-1===r[n].indexOf(s)&&r[n].push(s)}var l=Fh(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}function Pf(e,t){var i=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>i?"top":"bottom","top"==o.circularLinkType?i++:r++,e.nodes.forEach(function(e){(qh(e,t)==qh(o.source,t)||qh(e,t)==qh(o.target,t))&&(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),jh(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function $f(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(BS(e.sourceLinks,Kh),BS(e.targetLinks,Kh)),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)})})}function Lf(e,t,i){var r,o,a;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var n=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){n=t(e)==s?n:n+1,s=t(e)==s?s:t(e),e.column=n})}for(r=e.nodes,o=[],a=0;r.length;++a,r=o,o=[])r.forEach(function(e){e.depth=a,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],a=0;r.length;++a,r=o,o=[])r.forEach(function(e){e.height=a,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?i(e,a):e.column})}function If(e,t,i){var r=GS(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=WS(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/BS(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var a=jS(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/a),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})}function Rf(e){var t=0,i=0;return e.targetLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=Zh(e.source)*r,t+=r}}),e.sourceLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=Zh(e.target)*r,t+=r}}),t>0?i/t:NaN}function Tf(e,t,i){var r=GS(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,a){var n=o.length;if(t)o.sort(t);else if(a>0){var s=/* @__PURE__ */new Map;o.forEach(function(e,t){var i=Rf(e);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var i=s.get(e),r=s.get(t),o=i.bc,a=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?i.idx-r.idx:1:-1:o-a})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Qh(t,i)-Qh(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==n||0==t.depth&&1==n?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Qh(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/n*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-n/2+o,t.y1=t.y0+t.value*e.ky)})})}function Cf(e,t,i,r,o,a){function n(t,i){var r=l.length;l.forEach(function(o){var a=o.length,n=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Qh(o,i)>0){var l=YS(o.sourceLinks,Uh),c=YS(o.targetLinks,Hh),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Zh(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==n&&1==a)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(n==r-1&&1==a)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=YS(o.sourceLinks,Uh),f=YS(o.targetLinks,Hh),p=((h&&f?(h+f)/2:h||f)-Zh(o))*t;o.y0+=p,o.y1+=p}})})}function s(){l.forEach(function(i){var a,n,s,l=e.y0,c=i.length;for(i.sort(t||lf),s=0;c>s;++s)(n=l-(a=i[s]).y0)>0&&(a.y0+=n,a.y1+=n),l=a.y1+r;if((n=l-r-e.y1)>0)for(l=a.y0-=n,a.y1-=n,s=c-2;s>=0;--s)(n=(a=i[s]).y1+o-l)>0&&(a.y0-=n,a.y1-=n),l=a.y0})}var l=GS(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});s();for(var c=1,u=a;u>0;--u)n(c*=.99,i),s()}function Df(e){e.nodes.forEach(function(e){e.sourceLinks.sort(sf),e.targetLinks.sort(nf)}),e.nodes.forEach(function(e){var t=e.y0,i=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function zf(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-a)/(n-a)*(e.y1-e.y0)+e.y0};var a=WS(t,function(e){return e.y0}),n=jS(t,function(e){return e.y1}),s=(e.y1-e.y0)/(n-a);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}function Ef(){function e(){var e={nodes:p.apply(null,arguments),links:g.apply(null,arguments)};return t(e),e}function t(e){e.x0=i,e.y0=r,e.x1=o,e.y1=a,e.py=0,Mf(e,c),_f(e,d),Pf(e,c),$f(e),Lf(e,d,u);var t=s;if(null!==l){var p=GS(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=jS(p,function(e){return e.length});g>1&&(t=Math.max(1,(a-r)*l/(g-1)))}If(e,t,n),Tf(e,d,c),Cf(e,d,c,t,t,h),Df(e),yf(e,c,f,10,8),Tf(e,d,c),Cf(e,d,c,t,t,h),Df(e),yf(e,c,f,10,8),df(e,c),hf(e,c),zf(e),yf(e,c,f,10,8)}var i=0,r=0,o=1,a=1,n=24,s=8,l=null,c=wf,u=ef,d=void 0,h=32,f=2,p=kf,g=Af;return e.update=function(e){return Df(e),yf(e,c,f,10,8),e},e.nodeWidth=function(t){return arguments.length?(n=+t,e):n},e.nodePadding=function(t){return arguments.length?(s=+t,e):s},e.nodePaddingRatio=function(t){return arguments.length?(l=+t,e):l},e.nodes=function(t){return arguments.length?(p="function"==typeof t?t:vf(t),e):p},e.links=function(t){return arguments.length?(g="function"==typeof t?t:vf(t),e):g},e.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:vf(t),e):c},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:vf(t),e):u},e.nodeSort=function(t){return arguments.length?(d=t,e):d},e.iterations=function(t){return arguments.length?(h=+t,e):h},e.circularLinkGap=function(t){return arguments.length?(f=+t,e):f},e.extent=function(t){return arguments.length?(i=+t[0][0],r=+t[0][1],o=+t[1][0],a=+t[1][1],e):[[i,r],[o,a]]},e.size=function(t){return arguments.length?(i=r=0,o=+t[0],a=+t[1],e):[o-i,a-r]},e}function Nf(e){let t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r||"down"===e.direction)return null;if(e._circularStub){let i=r.sourceX,o=r.sourceY,a=r.targetX,n=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;let s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-i))),l=Math.max(15,Math.min(40,.33*(a-r.leftFullExtent)));return`M${i},${o-t}L${i+s},${o-t}L${i+s},${o+t}L${i},${o+t}ZM${a},${n-t}L${a-l},${n-t}L${a-l},${n+t}L${a},${n+t}Z`}let o=r.sourceX,a=r.sourceY,n=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${a-d*t}L${l},${a-d*t}L${l+i},${a-d*t+d*h}L${l+i},${u+d*i-d*h}L${l+i-h},${u+d*i}L${c-i+h},${u+d*i}L${c-i},${u+d*i-d*h}L${c-i},${s-d*t+d*h}L${c-i+h},${s-d*t}L${n},${s-d*t}L${n},${s+d*t}L${c+i},${s+d*t}L${c+i},${u-d*i}L${l-i},${u-d*i}L${l-i},${a+d*t}L${o},${a+d*t}Z`}function Of(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=KS.get(e);if(i){let e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,KS.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;ZS.has(e)||(ZS.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,r)}});return i.set(t,r),r}function Ff(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Wf(e,t,i){let r=[];for(let o of t){let t=hy(o.source),a=hy(o.target),n=null;if(t===e?n=a:a===e&&(n=t),n){let e=i.get(n);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function jf(e,t,i=2,r=.6){let o=[],a=a=>{let n=r*Math.max(a,.2);for(let r of o){let o=r.x??e[0]/2,a=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+s,g=a+l;u>p?r.vx=s+(u-p)*n:p>d&&(r.vx=s+(d-p)*n),h>g?r.vy=l+(h-g)*n:g>f&&(r.vy=l+(f-g)*n)}};return a.initialize=e=>{o=e},a}function Bf(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function Yf(e){return e?"function"==typeof e?e:t=>t[e]??1:e=>e.value??1}function Xf(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],a=0;for(;r.length>a;){let e=r[a];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),a++;r.length>a&&!isNaN(Number(r[a]));)o.push(Number(r[a])+t+""),a++,r.length>a&&!isNaN(Number(r[a]))&&(o.push(Number(r[a])+i+""),a++);else if("A"===e)for(o.push(e),a++;r.length>a&&!isNaN(Number(r[a]));)o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&o.push(r[a++]),r.length>a&&(o.push(Number(r[a])+t+""),a++),r.length>a&&(o.push(Number(r[a])+i+""),a++);else"Z"===e||"z"===e?(o.push(e),a++):(o.push(r[a]),a++)}return o.join(" ")}function Gf(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)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function Vf(e){let[t,i,r]=Gf(e);return.299*t+.587*i+.114*r>150?"#222":"#fff"}function qf(e){if(e)return"function"==typeof e?e:t=>t[e]}function Hf(e,t,i){let r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+i}function Uf(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Zf(e){return"number"==typeof e?e:5}function Kf(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:vM}function Qf(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 Jf(e,t,i,r,o,a){let n=[],s=[],l=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f=Zf(i.nodeSize);for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let a=o(Of(t,"nodeStyle")),s=a.fill||Qf(i);if(i.colorByDepth&&void 0!==t.depth){let e=Kf(i);s=e[t.depth%e.length]}n.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:a.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,cursor:a.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let p=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,n=t.y,l=r.x,f=r.y;u&&(o+=d,n+=h,l+=d,f+=h);let g=ip(o,n,l,f,c),y=a(Of(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:y.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:y.strokeWidth??1.5,opacity:y.opacity??p,cursor:y.cursor},datum:e})}if(!1!==i.showLabels){let t=Uf(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,a,n=i.x,s=i.y;if(u&&(n+=d,s+=h),u){let e=n-d,t=s-h,i=Math.sqrt(e*e+t*t);i>0?(r=n+e/i*10,o=s+t/i*10,a=0>e?"end":"start"):(r=n,o=s-12,a="middle")}else"horizontal"===c?(i.data?.children&&0!==i.data.children.length?(r=n-f-6,a="end"):(r=n+f+6,a="start"),o=s):(r=n,o=s+f+14,a="middle");l.push({x:r,y:o,text:e+"",anchor:a,baseline:"middle",fontSize:11})}}return{sceneNodes:n,sceneEdges:s,labels:l}}function ep(e,t,i,r){let o=[],a=[];for(let i of e){let e=i.x1-i.x0,a=i.y1-i.y0;if(0>=e||0>=a)continue;let n=r(Of(i,"nodeStyle")),s=n.fill||Qf(t);if(t.colorByDepth&&void 0!==i.depth){let e=Kf(t);s=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:a,style:{fill:s,stroke:n.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity,fillOpacity:n.fillOpacity,strokeOpacity:n.strokeOpacity,cursor:n.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Uf(t.nodeLabel),o=t.labelMode||"leaf",n="partition"===t.chartType;for(let s of e){let e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;let c=!(s.data?.children&&s.data.children.length>0);if(!n&&("leaf"===o&&!c||"parent"===o&&c))continue;let u=i?i(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Of(s,"nodeStyle")).fill||Qf(t);if(t.colorByDepth&&void 0!==s.depth){let e=Kf(t);d=e[s.depth%e.length]}let h="string"==typeof d?Vf(d):t.themeSemantic?.text??"#000";a.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:a}}function tp(e,t,i,r){let o=[],a=[];for(let i of e){let e=i.__radius??5;if(0>=e)continue;let a=r(Of(i,"nodeStyle")),n=a.fill||Qf(t);if(t.colorByDepth&&void 0!==i.depth){let e=Kf(t);n=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:n,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity??.7,cursor:a.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Uf(t.nodeLabel);for(let o of e){let e=o.__radius??5,n=i?i(o):o.id;if(!n||15>e)continue;let s=!(o.data?.children&&o.data.children.length>0),l=r(Of(o,"nodeStyle")).fill||Qf(t);if(t.colorByDepth&&void 0!==o.depth){let e=Kf(t);l=e[o.depth%e.length]}if(s){let i="string"==typeof l?Vf(l):t.themeSemantic?.text??"#000";a.push({x:o.x,y:o.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else a.push({x:o.x,y:o.y-e+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:a}}function ip(e,t,i,r,o){if("horizontal"===o){let o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${i},${r}`}if("radial"===o){let o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${i},${r}`}{let o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${r}`}}function rp(e,t,i,r){let o=t.treeOrientation||"vertical",a=pM();a.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),a(e)}function op(e,t,i,r){let o=t.treeOrientation||"vertical",a=gM();a.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),a(e)}function ap(e,t,i,r){let o=t.padding??4,a=t.paddingTop??0,n=yM().size([i,r]).tile(bM).padding(o);a>0&&n.paddingTop(a),n(e)}function np(e,t,i,r){let o=t.padding??4;mM().size([i,r]).padding(o)(e)}function sp(e,t,i,r){xM().size([i,r]).padding(t.padding??1)(e)}function lp(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function cp(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 up(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function dp(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:"u">typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function hp(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function fp(e){if("function"==typeof e)return e;let t=e||"children";return e=>e[t]||null}function pp(e){if("function"==typeof e)return e;let t=e||"name";return e=>(e[t]??"")+""}function gp(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function yp(e,t,i,r,o){function a(e){let t=p.get(e)??0;return p.set(e,t+1),0===t?e:`${e}__${t}`}let n=fp(i.childrenAccessor),s=pp(i.nodeIDAccessor),l=hp(i.orbitMode),c=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof c?()=>c:c,h="number"==typeof u?()=>u:u,f=dp(i);f.metaMap.clear(),r.length=0,o.length=0;let p=/* @__PURE__ */new Map,g=t[0]/2,y=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=a(s(e));r.push({id:x,x:g,y:y,x0:g,x1:g,y0:y,y1:y,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,c,u,p,g,y){let m=n(t);if(!m?.length)return;let x=m.length,b=0,v=0,w=0;for(;x>v;)v+=l[Math.min(w,l.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){let v=l[Math.min(x,l.length-1)],w=m.slice(k,k+v);if(!w.length)break;let A=(x+1)/b,S={id:i,depth:g,data:t,parentId:i},M=y?p/d(S)*A:p*A,_=kM().value(e=>n(e)?.length?4:1).sort(null)(w),P=h(S);for(let t=0;w.length>t;t++){let n=(_[t].startAngle+_[t].endAngle)/2,l=w[t],d=a(s(l)),h=c+M*Math.sin(n),p=u+M*Math.cos(n)*P;r.push({id:d,x:h,y:p,x0:h,x1:h,y0:p,y1:p,width:0,height:0,value:0,depth:g,data:l}),f.metaMap.set(d,{ring:M,angle:n,depth:g,parentId:i,eccentricity:P}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(l,d,h,p,M,g+1,!0)}k+=v}}(e,x,g,y,m,1,!1)}function mp(e,t,i,r){let o=dp(t),a=t.orbitSpeed??.25,n=t.orbitRevolution??gp(t.orbitRevolutionStyle),s=(("u">typeof performance?performance.now():Date.now())-o.startTime)/1e3,l=a*(Math.PI/6),c=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,t);for(let t of e){let e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;let i=c.get(e.parentId);if(!i)continue;let r=e.angle+s*l*n({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(r),t.y=i.y+e.ring*Math.cos(r)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}function xp(e,t){return zc(bp(e,t),e,"network-node-cursor-"+t)}function bp(e,t){switch(e.type){case"circle":{let i=e,r=di(i.style.fill)?pi(i.style.fill,`net-circle-${t}-hatch`):void 0;/* @__PURE__ */
|
|
298
|
+
return PM(SM.Fragment,{children:[r&&/* @__PURE__ */_M("defs",{children:r}),
|
|
299
|
+
/* @__PURE__ */_M("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:r?`url(#net-circle-${t}-hatch)`:_c(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{let i=e,r=di(i.style.fill)?pi(i.style.fill,`net-rect-${t}-hatch`):void 0;/* @__PURE__ */
|
|
300
|
+
return PM(SM.Fragment,{children:[r&&/* @__PURE__ */_M("defs",{children:r}),
|
|
301
|
+
/* @__PURE__ */_M("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:r?`url(#net-rect-${t}-hatch)`:_c(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{let i=e,r=MM().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Ek)||"",o=di(i.style.fill)?pi(i.style.fill,`net-arc-${t}-hatch`):void 0;/* @__PURE__ */
|
|
302
|
+
return PM(SM.Fragment,{children:[o&&/* @__PURE__ */_M("defs",{children:o}),
|
|
303
|
+
/* @__PURE__ */_M("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:_c(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-arc-"+t)}case"symbol":{let i=e,r=Am(i.symbolType,i.size,i.path);/* @__PURE__ */
|
|
304
|
+
return _M("path",{d:r,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?_c(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},"net-symbol-"+t)}case"glyph":return $c(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}function vp(e,t){return zc(wp(e,t),e,"network-edge-cursor-"+t)}function wp(e,t){switch(e.type){case"line":/* @__PURE__ */
|
|
305
|
+
return _M("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":{let i=e,r=`net-bezier-${t}-hatch`,o=di(i.style.fill)?pi(i.style.fill,r):void 0;/* @__PURE__ */
|
|
306
|
+
return PM(SM.Fragment,{children:[o&&/* @__PURE__ */_M("defs",{children:o}),
|
|
307
|
+
/* @__PURE__ */_M("path",{d:i.pathD,fill:o?`url(#${r})`:_c(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=di(i.style.fill)?pi(i.style.fill,r):void 0;/* @__PURE__ */
|
|
308
|
+
return PM(SM.Fragment,{children:[o&&/* @__PURE__ */_M("defs",{children:o}),
|
|
309
|
+
/* @__PURE__ */_M("path",{d:i.pathD,fill:o?`url(#${r})`:_c(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"curved":{let i=e;/* @__PURE__ */
|
|
310
|
+
return _M("path",{d:i.pathD,fill:_c(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth??1,opacity:i.style.opacity},"net-edge-"+t)}default:return null}}function kp(e,t){/* @__PURE__ */
|
|
311
|
+
return _M("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)}function Ap(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Sp(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=Lm(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Sm(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Mp(e){if(!e)return;let t=[];for(let i of e){let e=Sp(i);e&&t.push({pointId:Ap(i),...e})}return t}function _p(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Pp(e,t){let i=_p(t.nodeIDAccessor,"id");return e.map(e=>({id:i(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}))}function $p(e,t){let i=_p(t.sourceAccessor,"source"),r=_p(t.targetAccessor,"target"),o=_p(t.valueAccessor,"value");return e.map((e,t)=>{let a=Number(o(e)),n=i(e)+"",s=r(e)+"";return{source:n,target:s,value:Number.isFinite(a)?a:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${n}\0${s}\0${t}`}})}function Lp(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function Ip(e,t){let i=_i(e.theme),r=e.chartType||"force",o=t=>wc({frameType:"network",width:n[0],height:n[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:l}),n=e.size||[500,500],l=s({...$d(r),...e.margin},e.title),c=a(e.title),u=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=lr(e.nodes||[]);if(o.length>0)return su(o,t);if(IM.has(r)&&e.data)return su(us(e.data,e.childrenAccessor||"children"),t);let a=Array.isArray(e.edges)?lr(e.edges):[];if(0===a.length)return[];let n=_p(e.sourceAccessor,"source"),s=_p(e.targetAccessor,"target"),l=Array.from(new Set(a.flatMap(e=>[n(e),s(e)]).filter(e=>null!=e).map(String)));return su(l.map(e=>({id:e})),t)})():[];vd(l,{props:e,categories:u,theme:i,size:n,hasTitle:c});let d=wd({props:e,categories:u,theme:i,size:n,margin:l,hasTitle:c}),h=n[0]-l.left-l.right,f=n[1]-l.top-l.bottom,p=Pd(e.backgroundGraphics,n,l,null),g=Pd(e.foregroundGraphics,n,l,null),y=()=>{let r,a=e=>Number(e),s=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:a,y:a},layout:{width:h,height:f},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=o(r)),NS.renderToStaticMarkup(Ad(p||g||e.annotations?/* @__PURE__ */LM($M,{children:[p,s,g]}):null,{width:n[0],height:n[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))},m=Eh(r);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let x,b,v={chartType:r,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,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};if(IM.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return y();v.__hierarchyRoot=t,x=[],b=[]}else{let t=lr(e.nodes||[]),i=Array.isArray(e.edges)?lr(e.edges):[];if(0===t.length&&0===i.length)return y();if(b=$p(i,v),0===t.length&&b.length>0){let e=/* @__PURE__ */new Set;for(let t of b){let i=gd(t.source),r=gd(t.target);i&&e.add(i),r&&e.add(r)}x=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 x=Pp(t,v)}let w=[],k=[],A=[],S=null,M=null;if(v.customNetworkLayout){let t=v.colorScheme,r=Re(t,i.colors.categorical,sx),o=Te(r,t),a={nodes:x,edges:b,dimensions:{width:h,height:f,plot:{x:0,y:0,width:h,height:f}},theme:{semantic:i.colors,categorical:[...r]},resolveColor:o,config:v.layoutConfig??{},selection:e.layoutSelection??null},n=v.customNetworkLayout(a);w=n.sceneNodes??[],k=n.sceneEdges??[],Dh({nodes:w,edges:k,restyle:n.restyle,restyleEdge:n.restyleEdge,selection:e.layoutSelection??null,baseStyles:/* @__PURE__ */new WeakMap}),A=n.labels??[],S=n.backgrounds??null,M=n.overlays??null}else if(m){m.computeLayout(x,b,v,[h,f]);let e=m.buildScene(x,b,v,[h,f]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}let _=Pi(i);for(let e of A)e.fill||(e.fill=_.text);let P,$=Vc({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>vp(e,t)}),L=Vc({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>xp(e,t)}),I=$.map(e=>e.element),R=L.map(e=>e.element),T=A.map((e,t)=>kp(e,t)).filter(Boolean),C=e=>Number(e),D=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:f},theme:i,frameType:"network",annotationData:Lp(w),pointNodes:Mp(w),idPrefix:e._idPrefix,onRender:e=>{P=e}}):null;return t&&(t.evidence=wc({frameType:"network",width:n[0],height:n[1],marks:[...L.map(({node:e})=>({type:"node:"+(e.type??"node")})),...$.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:P,nodeCount:L.length,edgeCount:$.length,margin:l})),NS.renderToStaticMarkup(Ad(/* @__PURE__ */LM($M,{children:[p,S,I,R,T,D,g,M]}),{width:n[0],height:n[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}function Rp(e){if(!e)return zM();if("string"==typeof e){let t=WM[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),zM())}if("object"==typeof e&&"type"in e){let t=WM[e.type],i=t?t():zM();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function Tp(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Cp(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Dp(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function zp(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function Ep(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function Np(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function Op(e,t){if(2>e.length)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;e.length>t;t++){let a=e[t];Math.abs(a[0]-e[t-1][0])>i?(o.length>=2&&r.push(o),o=[a]):o.push(a)}return o.length>=2&&r.push(o),r}function Fp(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],a=Math.sqrt(r*r+o*o);if(0===a)return[e,t];let n=-o/a,s=r/a,l=Math.min(.3*a,80),c=(e[0]+t[0])/2+n*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;i>=r;r++){let o=r/i,a=1-o;d.push([a*a*e[0]+2*a*o*c+o*o*t[0],a*a*e[1]+2*a*o*u+o*o*t[1]])}return d}function Wp(e,t){if(2>e.length)return e;let i=t/2+1,r=[];for(let t=0;e.length>t;t++){let o,a,n=e[t];0===t?(o=e[1][0]-n[0],a=e[1][1]-n[1]):t===e.length-1?(o=n[0]-e[t-1][0],a=n[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],a=e[t+1][1]-e[t-1][1]);let s=Math.sqrt(o*o+a*a)||1;r.push([n[0]+a/s*i,n[1]+-o/s*i])}return r}function jp(e,t,i,r,o){let a=t[0]-e[0],n=t[1]-e[1],s=Math.sqrt(a*a+n*n);if(0===s)return[e,t];let l=n/s,c=-a/s,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}function Bp(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(2>o.length)return null;let a=t.strength??1,n=Number.isFinite(a)?Math.max(0,Math.min(1,a)):1,s="strip"===t.layout?"strip":"radial";if("radial"===s&&0===n)return null;let l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),h=Fm(d,1);r>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--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let f="strip"===s?Xp(o,u,c,h,i):Yp(o,u,c,h,n,i),p=e.filter(e=>"line"===e.type);if(p.length>0){let e=/* @__PURE__ */new Map;for(let t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(let i of p){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let a=e.get(r+""),n=e.get(o+"");if(a&&n)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[a[0]-e[0],a[1]-e[1]],o=[n[0]-t[0],n[1]-t[1]],s=[0];for(let e=1;i.path.length>e;e++)s.push(s[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let l=s[s.length-1];i.path=i.path.map((e,t)=>{let a=l>0?s[t]/l:t/(i.path.length-1);return[e[0]+r[0]*(1-a)+o[0]*a,e[1]+r[1]*(1-a)+o[1]*a]})}else i.path=[a,n]}}}return f}function Yp(e,t,i,r,o,a){let n=t.x,s=t.y,l=a.width/2,c=a.height/2,u=Math.min(a.width,a.height)/2,d=jM().domain([0,r]).range([0,u]);for(let a of e){if(a===t||!a.datum)continue;let e=a.x,u=a.y,h=Math.atan2(u-s,e-n),f=Math.hypot(e-n,u-s),p=Number(i(a.datum)),g=isFinite(p)&&p>=0?r>0?d(p):0:f,y=l+Math.cos(h)*g,m=c+Math.sin(h)*g;a.x=e+(y-e)*o,a.y=u+(m-u)*o}return t.x=n+(l-n)*o,t.y=s+(c-s)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}function Xp(e,t,i,r,o){let a=Math.max(3,Math.min(8,.35*o.height)),n=Math.max(1,o.width-2*a),s=o.height/2,l=jM().domain([0,r]).range([0,n]);t.x=a,t.y=s;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=a,o.y=s;continue}let e=Number(i(o.datum)),n=a+(isFinite(e)&&e>=0&&r>0?l(e):0);o.x=n,o.y=s,c.push({node:o,x:n})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;c.length>d;){let e=d+1;for(;c.length>e&&3>Math.abs(c[e].x-c[d].x);)e++;let t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)c[d+e].node.y=s+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:a,cy:s,maxCost:r,availableRadius:n,layout:"strip"}}function Gp(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=KM[r]??QM;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Vp({config:e,projection:t,path:i,areas:r,points:o,lines:a,layout:n}){let s=Tp(e.xAccessor,"lon"),l=Tp(e.yAccessor,"lat"),c=[],u=zp(e),d=Np(e),h=Ep(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=t_();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),a=i.bounds(t),n=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:a,screenArea:n,style:Dp(e.areaStyle,t,u),datum:t,interactive:!0})}let f=Cp(e.lineDataAccessor);for(let i of a){let r=f(i);if(!r||2>r.length)continue;let o=[];if("geo"===e.lineType){let e=Array(r.length);for(let t=0;r.length>t;t++)e[t]=[s(r[t]),l(r[t])];for(let i=0;e.length-1>i;i++){let r=e[i],a=e[i+1],n=e_(r,a)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),l=i_(r,a);for(let e=0;s>=e;e++){if(i>0&&0===e)continue;let r=t(l(e/s));null!=r&&o.push(r)}}}else for(let e=0;r.length>e;e++){let i=r[e],a=t([s(i),l(i)]);null!=a&&o.push(a)}if(2>o.length)continue;let a=Dp(e.lineStyle,i,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==r.length||2>o.length||"arc"!==e.flowStyle?2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?Wp(o,u):jp(o[0],o[o.length-1],0,0,u)):o=Fp(o[0],o[o.length-1]);let h=Op(o,n.width);if(h.length>1)for(let e of h)2>e.length||c.push({type:"line",path:e,style:{...a,_edgeFade:!0},datum:i});else c.push({type:"line",path:2>o.length&&h[0]||o,style:a,datum:i})}let p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,g=t.clipAngle?t.clipAngle()??0:0,y=g>0?g*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(let i of o){let r=s(i),o=l(i);if(null!=y&&e_([r,o],b)>y)continue;let a=t([r,o]);if(!a)continue;let n=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:a[0],y:a[1],r:n.r||4,style:n,datum:i,pointId:p?p(i)+"":void 0};c.push(u)}return c}function qp(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}function Hp(e,t){return zc(Up(e,t),e,"geo-cursor-"+t)}function Up(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=di(i.style.fill)?pi(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */
|
|
312
|
+
return s_(a_.Fragment,{children:[r&&/* @__PURE__ */n_("defs",{children:r}),
|
|
313
|
+
/* @__PURE__ */n_("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:_c(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:(i.style.opacity??1)*(i._decayOpacity??1)})]},"geoarea-"+t)}case"point":{let i=e,r=di(i.style.fill)?pi(i.style.fill,`geopoint-${t}-hatch`):void 0;/* @__PURE__ */
|
|
314
|
+
return s_(a_.Fragment,{children:[r&&/* @__PURE__ */n_("defs",{children:r}),
|
|
315
|
+
/* @__PURE__ */n_("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:_c(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+t)}case"line":{let i=e;if(2>i.path.length)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");/* @__PURE__ */
|
|
316
|
+
return n_("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+t)}case"glyph":return $c(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}function Zp(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=Lm(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}function Kp({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:a,layout:n},ringStyle:s,ringValues:l,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===n,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...s};/* @__PURE__ */
|
|
317
|
+
return c_("g",h?{children:[
|
|
318
|
+
/* @__PURE__ */l_("line",{x1:i,y1:r,x2:i+a,y2:r,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),
|
|
319
|
+
/* @__PURE__ */l_("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&l.map(n=>{let s=i+(o>0?n/o*a:0);/* @__PURE__ */
|
|
320
|
+
return c_("g",{children:[
|
|
321
|
+
/* @__PURE__ */l_("line",{x1:s,y1:r-2.5,x2:s,y2:r+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&/* @__PURE__ */c_("text",{x:s,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[n,t?" "+t:""]})]},n)})]}:{children:[l.map(e=>{let n=e/o*a;/* @__PURE__ */
|
|
322
|
+
return c_("g",{children:[
|
|
323
|
+
/* @__PURE__ */l_("circle",{cx:i,cy:r,r:n,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&/* @__PURE__ */c_("text",{x:i+n+3,y:r-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?" "+t:""]})]},e)}),c&&/* @__PURE__ */c_("g",{transform:"translate(24, 24)",children:[
|
|
324
|
+
/* @__PURE__ */l_("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),
|
|
325
|
+
/* @__PURE__ */l_("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),
|
|
326
|
+
/* @__PURE__ */l_("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),
|
|
327
|
+
/* @__PURE__ */l_("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),
|
|
328
|
+
/* @__PURE__ */l_("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),
|
|
329
|
+
/* @__PURE__ */l_("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Qp(e,t){let i=_i(e.theme),r=e.size||[e.width||600,e.height||400],o=s({top:10,right:10,bottom:10,left:10,...e.margin},e.title),n=a(e.title),l=Array.isArray(e.areas)?lr(e.areas):e.areas,c=lr(e.points),u=lr(e.lines),d=e.showLegend?(()=>{let t="string"==typeof(r=e.colorBy)||"function"==typeof r?e.colorBy:void 0,i=c.length>0?c:Array.isArray(l)&&l.length>0?"string"==typeof t?l.map(e=>({...e.properties||{},...e})):l:[];var r;return su(i,t)})():[];vd(o,{props:e,categories:d,theme:i,size:r,hasTitle:n});let h=wd({props:e,categories:d,theme:i,size:r,margin:o,hasTitle:n}),f=r[0]-(o.left??0)-(o.right??0),p=r[1]-(o.top??0)-(o.bottom??0),g={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutSelection:e.layoutSelection,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:Oy(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},y=new o_(g);if(l){if("string"==typeof l)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${l}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${l}')\` before calling renderGeoToStaticSVG.`);y.setAreas(l)}e.points&&y.setPoints(c),e.lines&&y.setLines(u),y.computeScene({width:f,height:p});let m=Pd(e.backgroundGraphics,r,o,y.scales),x=Pd(e.foregroundGraphics,r,o,y.scales),b=Vc({nodes:y.scene,renderMode:e.renderMode,fallback:(e,t)=>Hp(e,t)});if(0===b.length){let a,n=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:y.scales?.projectedPoint?([e,t])=>y.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:Zp(y.scene),idPrefix:e._idPrefix,onRender:e=>{a=e}}):null;return t&&(t.evidence=wc({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:a,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),RM.renderToStaticMarkup(Ad(m||x||e.annotations||y.customLayoutOverlays?/* @__PURE__ */h_(u_,{children:[m,n,x,y.customLayoutOverlays]}):null,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}let v,w=b.map(e=>e.element),k=e.cartogramChrome,A=y.cartogramLayout&&k?/* @__PURE__ */d_(Kp,{layout:{...y.cartogramLayout,layout:y.cartogramLayout.layout??"radial"},ringValues:Jp(y.cartogramLayout.maxCost,k.showRings),showRings:k.showRings??!0,showNorth:k.showNorth??!0,showRingLabels:k.showRingLabels??!0,costLabel:"string"==typeof k.costLabel?k.costLabel:void 0}):null,S=e.annotations?Bu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:y.scales?.projectedPoint?([e,t])=>y.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:Zp(y.scene),idPrefix:e._idPrefix,onRender:e=>{v=e}}):null;return t&&(t.evidence=wc({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:v,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),RM.renderToStaticMarkup(Ad(/* @__PURE__ */h_(u_,{children:[m,w,S,A,x,y.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}function Jp(e,t){if(!1===t||0>=e)return[];if(Array.isArray(t))return t.filter(t=>t>0&&e>=t);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;i>=e;e++)o.push(Math.round(r*e*10)/10);return o}function eg(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}))}function tg(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}:{}}))}function ig(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}function rg(e,t={}){let i=t.bodies??eg(e),r=i.filter(e=>e.sleeping).length,o=e.queue.length,a=e.sediment.reduce((e,t)=>e+t.count,0),n="settled"===e.simulationState&&0===o&&r===i.length,s=[];n||s.push("PHYSICS_NOT_SETTLED"),o>0&&s.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?ig(t.charge,i.length,o,a):void 0;return l&&!l.balanced&&s.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:n,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:tg(t.projectionRows),queuedCount:o,sedimentedCount:a,...l?{ledger:l}:{},warnings:s}}function og(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function ag(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function ng(e,t,i){let r="function"==typeof t?t(e,i):t;return{...p_,...r??{}}}function sg(e,t={},i={index:0,simulationState:"settled"}){let r=og(e),o={label:t.getBodyLabel?.(e)??ag(e)},a={style:ng(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_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,...a}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...a}}function lg(e,t={},i="settled"){return e.map((e,r)=>sg(e,t,{index:r,simulationState:i}))}function cg(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:r,sceneNodes:lg(r,t,o.simulationState),evidence:rg(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}function ug(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}function dg(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function hg(e,t={}){let{width:i=640,height:r=360,title:o,description:a,background:n,backgroundGraphics:s,backgroundGraphicsBackdrop:l,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:g,...y}=t,m=cg(e,y),x={...m_,...h},b=[i,r],v=dg(s,b,x),w=dg(u,b,x),k=ug(d),A=o?k+"-title":void 0,S=a?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,_=x.left||x.top?`translate(${x.left},${x.top})`:void 0,P=Math.max(1,i-x.left-x.right),$=Math.max(1,r-x.top-x.bottom),L=k+"-plot-clip",I=_&&null!=v?/* @__PURE__ */g_("g",{transform:_,children:v}):v;return{element:/* @__PURE__ */y_("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:f,children:[o&&/* @__PURE__ */g_("title",{id:A,children:o}),a&&/* @__PURE__ */g_("desc",{id:S,children:a}),
|
|
330
|
+
/* @__PURE__ */g_("defs",{children:/* @__PURE__ */g_("clipPath",{id:L,children:/* @__PURE__ */g_("rect",{width:P,height:$})})}),l&&"transparent"!==l?/* @__PURE__ */g_("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:l}):null,!s&&n&&"transparent"!==n?/* @__PURE__ */g_("rect",{x:0,y:0,width:i,height:r,fill:n}):null,I,
|
|
331
|
+
/* @__PURE__ */g_("g",{id:k+"-data-area",transform:_,clipPath:`url(#${L})`,children:m.sceneNodes.map((e,t)=>{let i=m.bodies[t],r=i&&p?p(i,e.style??{},t,k):void 0;return null!=r?zc(r,e,t):zc("point"===e.type||"rect"===e.type?Cc(e,t,k):null,e,"xy-cursor-"+t)})}),w,g?.(m)]}),scene:m,evidence:m.evidence}}function fg(e,t={}){let{element:i,scene:r,evidence:o}=hg(e,t);return{svg:f_.renderToStaticMarkup(i),scene:r,evidence:o}}function pg(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function gg(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,pg(e.thickness)??pg(i)??pg(t.thickness)??4)}function yg(e=[],t={}){let i=t.idPrefix?t.idPrefix+"-":"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,a=o.axis??t.defaultAxis??"x",n=gg(o,t),s=o.colliderId??`${i}${o.id}`;if("x"===a){let i=pg(o.x),r=pg(o.y1)??pg(t.plotBounds?.y)??pg(o.y),a=pg(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??pg(o.y);if(null==i||null==r||null==a)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:a,thickness:n}}else{let i=pg(o.y),r=pg(o.x1)??pg(t.plotBounds?.x)??pg(o.x),a=pg(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??pg(o.x);if(null==i||null==r||null==a)continue;e={type:"segment",x1:r,y1:i,x2:a,y2:i,thickness:n}}r.push({id:s,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:pg(o.restitution)??pg(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:pg(o.friction)??pg(t.barrierFriction)}})}return r}function mg(e){return e.sensorId??"stream-region-"+e.id}function xg(e){let t=mg(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,a=e.shape.x+e.shape.width/2,n=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...i,id:t+"-top",shape:{type:"segment",x1:o,y1:n,x2:a,y2:n,thickness:r}},{...i,id:t+"-right",shape:{type:"segment",x1:a,y1:n,x2:a,y2:s,thickness:r}},{...i,id:t+"-bottom",shape:{type:"segment",x1:a,y1:s,x2:o,y2:s,thickness:r}},{...i,id:t+"-left",shape:{type:"segment",x1:o,y1:s,x2:o,y2:n,thickness:r}}]}return e.collider?[{...i,id:t+"-collider",shape:e.shape}]:[]}function bg({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:a,seed:n,size:s}){let l=yg((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?t+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:s[0],height:s[1]}}),c=void 0===n||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:n}},u=a.flatMap(e=>[{id:mg(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...xg(e)]),d=Object.fromEntries(a.map(e=>[mg(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,f=a.length>0;return f||u.length>0||l.length>0||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...l],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{f&&o(e),h?.onObservation?.(e)}}}:c}function vg({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?/* @__PURE__ */x_("foreignObject",{x:0,y:0,width:t,height:i,children:e}):/* @__PURE__ */x_("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}function wg(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function kg(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,wg(e))}))}function Ag(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:b_().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:b_().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}function Sg(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}function Mg(e,t,i,r,o){let a=Math.max(1,i[0]-r.left-r.right),n=Math.max(1,i[1]-r.top-r.bottom),s=Sg(t.annotations),l=Ag({width:a,height:n,pointNodes:kg(e.bodies)}),c=l.scales?.x,u=l.scales?.y;if(!c||!u)throw Error("Physics annotation context requires pixel scales");let d,h=Bu({annotations:s,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:a,height:n},theme:o,frameType:"network",xAccessor:l.xAccessor,yAccessor:l.yAccessor,pointNodes:l.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{d=e}}),f=t.legend?bd(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??Xu(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:d,node:/* @__PURE__ */w_("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[
|
|
332
|
+
/* @__PURE__ */v_("g",{transform:`translate(${r.left},${r.top})`,children:h}),
|
|
333
|
+
/* @__PURE__ */v_(vg,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),f]})}}function _g(e,t){let i=e.size??[e.width??600,e.height??400],r=_i(e.theme),o=void 0===e.theme?{}:jy(r),a=e.bodyStyle,s=!1,c=e.legendPosition??"right",u=n({...k_,...e.margin},s,!!e.legend&&"top"===c);if(e.legend){let t={...u};b(u,{legend:e.legend,position:c,size:i,hasTitle:s,legendLayout:e.legendLayout}),l(u,t,i,c)}let d,h=bg({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),f=new em(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&f.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));let p=fg(f,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof a?a(e,t):a}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:u,renderChrome:t=>{let o=Mg(t,e,i,u,r);return d=o.annotationRender,o.node}});return t&&(t.evidence=wc({frameType:"physics",width:i[0],height:i[1],marks:p.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:d,extraWarnings:[...0===p.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...p.scene.evidence.warnings]})),p.svg}function Pg(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US";if("currency"===e){let e=t.precision??2,r=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>r.format(e)}if("percent"===e){let e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){let e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>$g(e);let r=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>r.format(e)}function $g(e){if(!Number.isFinite(e))return e+"";let t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;let r=i/1e3;if(60>r)return`${t}${Lg(r)}s`;let o=r/60;if(60>o){let e=Math.floor(o),i=Math.round(r-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}let a=o/60;if(24>a){let e=Math.floor(a),i=Math.round(o-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}let n=Math.floor(a/24),s=Math.round(a-24*n);return 0===s?`${t}${n}d`:`${t}${n}d ${s}h`}function Lg(e){return Math.round(100*e)/100+""}function Ig(e,t,i){return`${t??""}${e}${i??""}`}function Rg(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function Tg(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(t.at>e)break;r=t}return r}function Cg(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function Dg(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}function zg(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,a=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0!==a)return`${Rg(a,i)}${r&&"string"==typeof r.label?" "+r.label:""}`}function Eg(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?" "+r.label:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}function Ng(e,t,i){return P_[e](t,i)}function Og(e,t,i){let{title:r,subtitle:o,theme:a,width:n=1200,height:s,layout:l={},background:c}=t,u=Pi(_i(a)),d=l.columns||2,h=l.gap??16,f=0;r&&(f+=30),o&&(f+=20),f>0&&(f+=10);let p=Math.floor((n-h-h*(d-1))/d),g=[],y=0,m=f+h,x=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=p*e+h*(e-1),o=t.props.height||300;y+e>d&&(m+=x+h,y=0,x=0);let n=h/2+y*(p+h),s={...t.props,width:r,height:o,theme:a,_idPrefix:"chart-"+g.length},l=t.component?i.chart(t.component,s):t.frameType?i.frame(t.frameType,s):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=I(l,{width:r,height:o}),u=Math.max(o,c.height);g.push({x:n,y:m,width:r,height:u,svg:l,svgDimensions:c}),x=Math.max(x,u),y+=e}let b=s||m+x+h,v=g.map((e,t)=>/* @__PURE__ */L_("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */L_("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */L_("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:R(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return $_.renderToStaticMarkup(
|
|
334
|
+
/* @__PURE__ */I_("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&/* @__PURE__ */L_("title",{children:r}),c&&/* @__PURE__ */L_("rect",{x:0,y:0,width:n,height:b,fill:c}),r&&/* @__PURE__ */L_("text",{x:n/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&/* @__PURE__ */L_("text",{x:n/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}function Fg(e,t){switch(e){case"xy":return Id(t);case"ordinal":return Ch(t);case"network":return Ip(t);case"geo":return Qp(t);case"physics":return _g(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Wg(e){return Id(e)}function jg(e){return Ch(e)}function Bg(e){return Ip(e)}function Yg(e){return Qp(e)}function Xg(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function Gg(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":o+""}function Vg(e,t){let i,r=RegExp(D_.source,D_.flags),o="",a=0,n=!1;for(;i=r.exec(e);){let r=e.slice(a,i.index);o+=n&&0===r.length?" ":r,o+=Gg(i[0],t),a=i.index+i[0].length,n=!0}return o+e.slice(a)}function qg(e,t){let i=Xg(t);return void 0===i?e:$(e,(e,t)=>{if(C_.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return Vg(t,i)})}function Hg(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function Ug(e,t,i){return Kg(e,t,i).svg}function Zg(e,t,i){let r={},{svg:o,frameType:a}=Kg(e,t,i,r),n=r.evidence??wc({frameType:a,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"]});if(n.component=e,n.sceneHashVersion=2,n.sceneHash=T(o,n),Z(n,e,t),i?.artifactContract){let r=gy(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(n.artifactContract=r.contract),n.artifactTransfer=r.transfer,n.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?yy(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:n}}function Kg(e,t,i,r){if(Object.prototype.hasOwnProperty.call(P_,e))return{svg:qg(Ng(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(JA,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,a=JA[e],n=j(a.layout?.mode??(W(t.mode)?t.mode:void 0),{...a.layout?.modeDefaults,...Hg(t,E_)},a.layout?.primarySize),{data:s,theme:l,background:c,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:g,...y}=t,{width:m,height:x}=n,b=[m,x],v=y.frameProps||{},w=a.layout?.margin,k="function"==typeof w?w(t,n):w??n.marginDefaults,S="xy"===a.frameType?A(k,y.axes??v.axes,!!n.title):k,M=void 0!==h?h:v.margin,_=K(M),P="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},$=Hg(y,z_),L=e=>v[e]??n[e],I={...v,...$,theme:l,title:n.title,description:n.description,showAxes:L("showAxes"),showLegend:L("showLegend"),showLabels:L("showLabels"),showGrid:L("showGrid"),xLabel:L("xLabel"),yLabel:L("yLabel"),categoryLabel:L("categoryLabel"),valueLabel:L("valueLabel"),background:c,className:u,annotations:d,size:b,margin:P,__compactMode:n.compactMode,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==g&&{legendPosition:g},_idPrefix:y._idPrefix},R=a.buildProps(s,p,f,I,y);if(a.renderStatic)o=a.renderStatic(R,r);else switch(a.frameType){case"xy":o=Id(R,r);break;case"ordinal":o=Ch(R,r);break;case"network":o=Ip(R,r);break;case"geo":o=Qp(R,r);break;case"physics":o=_g(R,r)}let T=a.renderOverlay?.(R,{theme:_i(l)});if(null!=T){let e=Um.renderToStaticMarkup(/* @__PURE__ */T_(R_,{children:T})),t=o.lastIndexOf("</svg>");o=0>t?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:qg(o,i?.precision),frameType:a.frameType}}function Qg(e,t={}){return Og(e,t,{chart:Ug,frame:Fg})}function Jg(e,t,i,r={}){let{stepSize:o,windowSize:a,frameCount:n,xExtent:l,yExtent:c,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:f}=r,p=i.width||600,g=i.height||400,y=_i(i.theme),m={...i,...l&&{xExtent:l},...c&&{yExtent:c}};if(!t||0===t.length)return[];let x=o||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=x;t.length>=e;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);let v=/* @__PURE__ */new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=s({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=p-w.left-w.right,A=g-w.top-w.bottom,S=[];if(v)for(let r=0;b.length>r;r++){let o=b[r],n=t.slice(a?Math.max(0,o-a):0,o),s={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical,...f&&{decay:f}},l=new AS(s);l.ingest({inserts:n,bounded:!0}),l.computeScene({width:k,height:A}),l.scene.length>0&&S.push(ly(l.scene,p,g,y,m,S.length))}else for(let r=0;b.length>r;r++){let o=b[r],n=t.slice(a?Math.max(0,o-a):0,o),s={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:l,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...f&&{decay:f},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},x=new _k(s);if(x.ingest({inserts:n,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;let v=x.scales?{y:x.scales.y}:void 0;if(S.push(sy(x.scene,p,g,y,m,v,S.length)),u>0&&r>0&&x.activeTransition){let e=u*(1e3/d);for(let t=1;u>=t;t++)x.advanceTransition(x.activeTransition.startTime+t/u*e),S.push(sy(x.scene,p,g,y,m,v,S.length))}}return S}function ey(e,t,i={}){return t.map(t=>{try{return Ug(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function ty(e,t,i,r){let o=Gu(`${e}-${t}`),a="string"==typeof i&&i.length>0?i:void 0,n="string"==typeof r&&r.length>0?r:void 0,s=a?o.titleId:void 0,l=n?o.descId:void 0;return{titleText:a,descText:n,titleId:s,descId:l,labelledBy:[s,l].filter(Boolean).join(" ")||void 0}}function iy(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:yd(e)||t}function ry(e,t,i){let r=t.size??[t.width??600,t.height??400],o=_i(t.theme),a=Pi(o),n=t.background||o.colors.background,s=t.idPrefix??"physics-gif",l=ty(s,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=l,h=lg(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),f=/* @__PURE__ */W_("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:a.fontFamily},children:[t.title&&/* @__PURE__ */F_("title",{id:c,children:t.title}),t.description&&/* @__PURE__ */F_("desc",{id:u,children:t.description}),n&&"transparent"!==n?/* @__PURE__ */F_("rect",{x:0,y:0,width:r[0],height:r[1],fill:n}):null,
|
|
335
|
+
/* @__PURE__ */F_("g",{id:`${s}-frame-${i}`,children:h.map((e,t)=>Fc(e,t,`${s}-${i}`))})]});return N_.renderToStaticMarkup(f)}function oy(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:a=!0,stepDt:n,stepsPerFrame:s,background:l}=t,c=Math.max(.001,n??e.config?.fixedDt??1/120),u=s??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=l?{...e,background:l}:e,f=new em(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);let p=[];for(a&&(f.tick(0),p.push(ry(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(c);p.push(ry(f,h,p.length))}return p}function ay(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function ny(e,t,i,r,o,a){if(!e||0===e.length)return null;let n=Pi(r),s=[];for(let r=0;e.length>r;r++){let l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(a)e=a(l.value);else if(o){let[t,r]=o,a=r-t;if(0===a)continue;e=i-(l.value-t)/a*i}if(null==e)continue;let c=l.color||n.primary,u=l.labelPosition||"right";s.push(
|
|
336
|
+
/* @__PURE__ */W_("g",{children:[
|
|
337
|
+
/* @__PURE__ */F_("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:l.strokeWidth??1.5,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&/* @__PURE__ */F_("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:n.tickSize,fill:c,fontFamily:n.fontFamily,children:l.label})]},"ann-"+r))}}return s.length>0?/* @__PURE__ */F_(O_,{children:s}):null}function sy(e,t,i,r,o,a,n=0){let l=Pi(r),c=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-c.left-c.right,d=i-c.top-c.bottom,h=ay(o,r),f=o.renderMode,p=e.map((e,t)=>Gc({node:e,index:t,renderMode:f,fallback:()=>Fc(e,t)})).filter(Boolean),g=ny(o.annotations,u,d,r,o.yExtent,a?.y),{titleText:y,descText:m,titleId:x,descId:b,labelledBy:v}=ty(iy(o,"xy-gif"),n,o.title,o.description);return N_.renderToStaticMarkup(/* @__PURE__ */W_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:l.fontFamily},children:[y&&/* @__PURE__ */F_("title",{id:x,children:y}),m&&/* @__PURE__ */F_("desc",{id:b,children:m}),h&&/* @__PURE__ */F_("rect",{x:0,y:0,width:t,height:i,fill:h}),
|
|
338
|
+
/* @__PURE__ */W_("g",{transform:`translate(${c.left},${c.top})`,children:[g,p]}),y&&/* @__PURE__ */F_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:l.titleFontSize,fontWeight:l.titleFontWeight,fill:l.text,fontFamily:l.titleFontFamily,children:y})]}))}function ly(e,t,i,r,o,a=0){let n=Pi(r),l=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c="radial"===o.projection,u=c?l.left+(t-l.left-l.right)/2:l.left,d=c?l.top+(i-l.top-l.bottom)/2:l.top,h=ay(o,r),f=Ih({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:p,descText:g,titleId:y,descId:m,labelledBy:x}=ty(iy(o,"ordinal-gif"),a,o.title,o.description);return N_.renderToStaticMarkup(/* @__PURE__ */W_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":x,style:{fontFamily:n.fontFamily},children:[p&&/* @__PURE__ */F_("title",{id:y,children:p}),g&&/* @__PURE__ */F_("desc",{id:m,children:g}),h&&/* @__PURE__ */F_("rect",{x:0,y:0,width:t,height:i,fill:h}),
|
|
339
|
+
/* @__PURE__ */F_("g",{transform:`translate(${u},${d})`,children:f}),p&&/* @__PURE__ */F_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:n.titleFontSize,fontWeight:n.titleFontWeight,fill:n.text,fontFamily:n.titleFontFamily,children:p})]}))}import{A as cy,B as uy,C as dy,D as hy,E as fy,a as py,d as gy,i as yy,j as my,k as xy,l as by,m as vy,n as wy,o as ky,p as Ay,q as Sy,r as My,s as _y,t as Py,u as $y,v as Ly,w as Iy,x as Ry,y as Ty,z as Cy}from"./c-4XLHPQTP.min.js";import{a as Dy}from"./c-OVQB75PE.min.js";import"./c-4V3CD337.min.js";import"./c-3NA6I656.min.js";import"./c-3FOUMWLR.min.js";import{b as zy,c as Ey,d as Ny,e as Oy,f as Fy,x as Wy,y as jy}from"./c-O53GOO7H.min.js";import{a as By,b as Yy,c as Xy,e as Gy,f as Vy,g as qy}from"./c-FOTTQHOO.min.js";import{Aa as Hy,E as Uy,F as Zy,Fa as Ky,G as Qy,Ga as Jy,H as em,Ha as tm,Ia as im,K as rm,L as om,P as am,Q as nm,R as sm,S as lm,T as cm,U as um,V as dm,W as hm,X as fm,a as pm,aa as gm,ba as ym,ca as mm,da as xm,ea as bm,fa as vm,ga as wm,ha as km,ja as Am,ka as Sm,ma as Mm,pa as _m,ra as Pm,sa as $m,ta as Lm,ua as Im,va as Rm,wa as Tm,xa as Cm,ya as Dm,z as zm,za as Em}from"./c-IHWZ2C6D.min.js";import{a as Nm,b as Om,c as Fm}from"./c-3PFVJFBK.min.js";var Wm=34,jm=70,Bm=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Ym={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},Xm={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}}},Gm={kind:"rank-competition"},Vm=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),qm=globalThis,Hm=qm[Vm]??(qm[Vm]=/* @__PURE__ */new Map);import*as Um from"react-dom/server";var Zm={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},Km={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},Qm={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,r,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},Jm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...Km.buildProps(e,t,i,r,o),customLayout:zm,showAxes:!1})},ex={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Zm.buildProps(e,t,i,r,o),customLayout:pm,showAxes:!1})};import*as tx from"react";import{scaleLinear as ix}from"d3-scale";import{scaleLinear as rx}from"d3-scale";import{scaleLinear as ox}from"d3-scale";import{scaleLinear as ax}from"d3-scale";import{scaleOrdinal as nx}from"d3-scale";var sx=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],lx=ke(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),cx=ke(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ux=ke(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),dx=ke(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),hx=ke(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),fx=ke(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),px=ke(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),gx=ke(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),yx=ke(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),mx=ke(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),xx=ke(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),bx=ke(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),vx={blues:lx,reds:cx,greens:ux,viridis:px,oranges:dx,purples:hx,greys:fx,plasma:gx,inferno:yx,magma:mx,cividis:xx,turbo:bx},wx=ke(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),kx=ke(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Ax=ke(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Sx=ke(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Mx=ke(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),_x=ke(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Px=ke(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),$x={category10:sx,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...vx},Lx=sx,Ix="#007bff",Rx=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Tx=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Cx=/* @__PURE__ */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"]),Dx={left:28,top:76,rightInset:30,thickness:8},zx=1e-9,Ex=[900,520],Nx=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Ox=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Fx=1e-9,Wx=oi;import*as jx from"react";import{jsx as Bx,jsxs as Yx}from"react/jsx-runtime";import{curveMonotoneX as Xx,curveMonotoneY as Gx,curveCardinal as Vx,curveCatmullRom as qx,curveStep as Hx,curveStepBefore as Ux,curveStepAfter as Zx,curveBasis as Kx,curveNatural as Qx}from"d3-shape";import{jsx as Jx,jsxs as eb}from"react/jsx-runtime";import{Fragment as tb,jsx as ib,jsxs as rb}from"react/jsx-runtime";var ob="var(--semiotic-text, #26323a)",ab="var(--semiotic-text-secondary, #6c7377)",nb="var(--semiotic-primary, #b8792d)",sb="var(--semiotic-danger, #9f3d35)",lb="var(--semiotic-success, #356b63)";import{Fragment as cb,jsx as ub,jsxs as db}from"react/jsx-runtime";import{jsx as hb}from"react/jsx-runtime";import{jsx as fb,jsxs as pb}from"react/jsx-runtime";import{Fragment as gb,jsx as yb,jsxs as mb}from"react/jsx-runtime";var xb={margin:(e,t)=>Bi(t.compactMode,e.mode)},bb=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],vb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n=o.bins??21,s=o.seed??1,l=Math.max(1,Math.round(o.pegRows??n-1)),c="mechanical"===(o.simulationMode??o.mode),u=Q({data:c?Py({bins:n,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:l,seed:s}):Array.isArray(e)?e:[],valueAccessor:o.valueAccessor||"value",bins:n,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:s,size:a,valueExtent:c?[0,l]:o.valueExtent});return{...r,config:u.config,initialSpawns:Yi(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:Xi($i(u.projectionRows,n,Gi(r,o,"showProjection"),u.metadata,o.referenceLines),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},wb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n=ie({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:a,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:n.config,initialSpawns:Yi(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:Xi(Li(n.projectionRows,n.metadata,Gi(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},kb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,400],n="mechanical"===(o.simulationMode??o.mode),s=ne({data:n?Iy({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(n?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:a});return{...r,config:s.config,initialSpawns:Yi(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:Xi(Ii(s.projectionRows,o.ballRadius??8,Gi(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy||(n?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},Ab={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[600,360],n=le({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:a,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:n.config,initialSpawns:Yi(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:Xi(Ti(n.metadata,Gi(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},Sb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,420],n=Array.isArray(o.stages)?o.stages:[],s=be({data:Array.isArray(e)?e:[],stages:n,size:a,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),l=s.metadata;return{...r,config:s.config,initialSpawns:Yi(s.initialSpawns),projectionRows:s.projectionRows,regionEffects:l?.regionEffects,backgroundGraphics:Xi(Ci(s.metadata,Gi(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:Xi(Di(s.projectionRows,s.metadata,Gi(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},Mb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,520],n=Qe({data:Array.isArray(e)?e:[],size:a,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...r,config:n.config,initialSpawns:Yi(n.initialSpawns),projectionRows:[],backgroundGraphics:Xi(Gi(r,o,"showChrome")?tx.createElement(Fi,{layout:n.layout,states:n.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:Xi(Gi(r,o,"showProjection")?tx.createElement(ji,{layout:n.layout,states:n.states}):void 0,r.foregroundGraphics),bodyStyle:xy(t||o.colorBy)}}},_b={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[900,520],n=ui({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:a,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),s=ci(n,"snapshot"===o.playback?li(n,o.snapshotAt):n.duration).state,l=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},c=Pt(s,l),u=l.measure??"count",d=Mi(c.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===u||"amount"===u?e.amount:Number(e.metrics[u]??0),secondaryLabel:"count"===u||"amount"===u?o.amountLabel??"amount":u,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),h={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},f=t??o.colorBy??"category",p=!1===o.showChrome?null:tx.createElement(wi,{layout:n.layout,phases:n.phases,state:s,compact:520>a[0]||360>a[1]}),g=!1===o.showProjection?null:tx.createElement(Ai,{rows:c,layout:n.layout,projection:l,amountLabel:o.amountLabel});return{...r,config:n.config,initialSpawns:Yi(oi(s,n.layout,h)),projectionRows:d,bodyStyle:e=>qi(e,s,f,o),getBodyLabel:e=>Hi(e,s),renderBodySVG:bi,backgroundGraphics:Xi(p,r.backgroundGraphics),foregroundGraphics:Xi(g,r.foregroundGraphics)}}},Pb={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[760,420],n=ye({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:a});return{...r,config:n.config,initialSpawns:Yi(n.initialSpawns),projectionRows:n.projectionRows,foregroundGraphics:Xi(Ni(n.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:xy(t||o.colorBy||"source")}}},$b={frameType:"physics",layout:xb,buildProps:(e,t,i,r,o)=>{let a=r.size??[700,380],n=_i(r.theme),s=Ee({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Oy(n)??{},size:a,themeCategorical:n.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:Yi(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??xy(t||o.colorBy),backgroundGraphics:Xi(r.backgroundGraphics,s.result.backgroundOverlays),foregroundGraphics:Xi(r.foregroundGraphics,s.result.overlays)}}};import*as Lb from"react";var Ib=e=>{let{forest:t,selection:i,reading:r="organize"}=e.config,{atlas:o}=t,a=e.dimensions.plot,n=e.theme.semantic.text??"#273442",s=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",l=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",c=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=/* @__PURE__ */new Map;for(let i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(let e of Zi(t,i))e!==i&&d.set(e,i);let h=t.order.filter(e=>!d.has(e)),f=new Map(o.source.nodes.map(e=>[e.id,e])),p=/* @__PURE__ */new Map;for(let e of d.values())p.set(e,(p.get(e)??0)+1);let g=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){let i=g.get(t);i?i.push(e.id):g.set(t,[e.id])}}let y=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&y.push("Unsectioned");let m=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=y.map(e=>h.filter(t=>m.get(t)===e)),b=/* @__PURE__ */new Map,v=[],w=[],k=[],A=[],S=(e,t,i,r=11)=>v.push({x:e,y:t,text:i,fill:n,anchor:"middle",fontSize:r}),M=Math.max(16,Math.min(94,a.width/Math.max(1,y.length)-20));x.forEach((e,t)=>{let i=a.x+a.width*(t+.5)/y.length;S(i,a.y+18,y[t],12),e.forEach((t,r)=>{b.set(t,{x:i,y:a.y+58+(r+.5)*Math.max(40,a.height-110)/Math.max(1,e.length)})})});for(let t of h){let i=b.get(t),r=f.get(t),a=p.get(t)??0,n=g.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=r.completeness&&"known"!==r.completeness,y=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?c:h?l:s,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...r,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:a,internalEdgeIds:n},accessibleDatum:{node:t,section:m.get(t),status:y??"Admitted",hiddenCount:a,internalEdges:n.join(", ")}}),S(i.x,i.y+4,a?`${t} +${a}`:t,12),y?S(i.x,i.y+30,y,9):a&&S(i.x,i.y+30,n.length+" internal links",9)}let _=new Set(t.forest.backboneEdgeIds),P=new Set(e.config.highlightedEdgeIds),$=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;let r=b.get(t),n=b.get(i),u=JSON.stringify([t,i]),h=12*($.get(u)??0);$.set(u,($.get(u)??0)+1);let f,p,g=_.has(e.id),m=P.has(e.id)?c:g?s:l,x=n.x>r.x,v=r.x+(x?M/2:-M/2),w=n.x+(x?-M/2:M/2),S=[...b.values()].filter(e=>e.x>Math.min(r.x,n.x)&&Math.max(r.x,n.x)>e.x);if(t===i)f=`M${r.x-14},${r.y-17} C${r.x-35-h},${r.y-64-h} ${r.x+35+h},${r.y-64-h} ${r.x+14},${r.y-17}`,p=1;else if(r.x===n.x){let e=n.y>r.y?1:-1,t=r.x+e*M/2,i=t+e*(32+h);f=`M${t},${r.y} C${i},${r.y} ${i},${n.y} ${t},${n.y}`,p=1===e?2:0}else if(S.length){let e=Math.min(r.y,n.y,...S.map(e=>e.y))-17-26-h,t=(a.width/y.length-M)/2*(x?1:-1);f=`M${v},${r.y} C${v+t},${r.y} ${v},${e} ${v+t},${e} H${w-t} C${w},${e} ${w-t},${n.y} ${w},${n.y}`,p=x?0:2}else if(x){let e=(v+w)/2;f=`M${v},${r.y} C${e},${r.y-h} ${e},${n.y-h} ${w},${n.y}`,p=0}else{let e=Math.min(r.y,n.y)-48-h;f=`M${v},${r.y} C${v-25},${e} ${w+25},${e} ${w},${n.y}`,p=2}k.push({type:"curved",id:e.id,pathD:f,style:{stroke:m,strokeWidth:P.has(e.id)?3:g?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:g?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:g?"backbone":"residual cross-link"}}),A.push(Lb.createElement("path",{key:"arrow:"+e.id,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:m,transform:`translate(${t===i?r.x+14:r.x===n.x?r.x+(n.y>r.y?M/2:-M/2):w},${t===i?r.y-17:n.y}) rotate(${90*p})`}))}if("required-paths"===r&&u){let e=Ki(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){let e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,r=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;A.push(Lb.createElement("path",{key:"required-bracket",d:`M${t-7},${r} H${t} V${o} H${t-7}`,fill:"none",stroke:c,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(a.x+a.width/2,a.y+a.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?u+": no other required targets in the admitted graph":"Required paths have not been prepared")}let L=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,L.get(e.datum?.source+""),L.get(e.datum?.target+"")].some(e=>e&&t.predicate(e))?.2:1}),overlays:Lb.createElement("g",{"aria-hidden":!0},A)}};import*as Rb from"react";import*as Tb from"react";var Cb=Tb.createElement,Db={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},zb=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",Eb={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},Nb={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},Ob=e=>null===e?"unmeasured":e+"",Fb=Rb.createElement,Wb=e=>{let{circuit:t,edition:i,reading:r,selection:o}=e.config;if(r.editionId!==i.id||i.analysisRevision!==t.atlas.analysisRevision)throw Error("Circuit render inputs must share an edition and analysis revision");let a=Qi(t,e.dimensions.width,e.dimensions.height),n=e.theme.semantic.text??"#273442",s=e.theme.semantic.surface??"#fff",l=er(e.theme.semantic,e.config.colors),c="modeled"===i.kind?l.modeled:l.observed,u={width:a.width,height:a.height,viewBox:`0 0 ${a.width} ${a.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},d=o?.analysisRevision===t.atlas.analysisRevision&&"directed-admitted"===o.relationScopeId?o.nodeId:void 0,h=Math.max(1,...r.entry.flows.map(e=>e.perSecond??0)),f=new Map(r.entry.flows.map(e=>[e.edgeId,e])),p=new Map(t.modules.map(e=>[e.nodeId,rr(t,i,r,e)])),g=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(p.get(t))?.2:1,y=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),m=_y(e.config.placementSeed??1),x=a.routes.filter(e=>(f.get(e.edgeId)?.perSecond??0)>0),b=e.config.reducedMotion?[]:Array.from({length:x.length?y:0},(e,t)=>{let i=x[t%x.length],o=Ji(i.points,(m()+r.requestedTime/10)%1);return Fb("circle",{key:"cue:"+t,cx:o.x,cy:o.y,r:2.3,fill:n,opacity:Math.max(g(i.source),g(i.target)),"data-circuit-particle":i.edgeId})}),v=a.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:rr(t,i,r,e.module)}));return{bodies:v,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:v.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:s,stroke:l.muted,strokeWidth:1,opacity:g(e.id)}),colliders:a.modules.flatMap(e=>hm({idPrefix:"queue:"+e.module.nodeId,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:a.modules.map(e=>({id:"sensor:"+e.module.nodeId,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:or(t,a,i,r),backgroundOverlays:Fb("svg",u,...a.routes.map(t=>{let i=f.get(t.edgeId),r=t.points[t.points.length-1],o=t.points[t.points.length-2],s=a.modules.find(e=>e.module.nodeId===t.source),u=a.modules.find(e=>e.module.nodeId===t.target),d=s.module.ports.filter(e=>"out"===e.direction).length<u.module.ports.filter(e=>"in"===e.direction).length,p=d?t.points[0]:r,y=d?p.x>=s.x+s.width:p.x>u.x,m=180*Math.atan2(r.y-o.y,r.x-o.x)/Math.PI,x=e.config.highlightedEdgeIds?.includes(t.edgeId),b=x?n:t.residual?l.residual:c,v="records"===i.unit?"rec":"attempts"===i.unit?"att":"roots";return Fb("g",{key:t.edgeId,"data-circuit-edge":t.edgeId,opacity:Math.max(g(t.source),g(t.target)),"data-source":t.source,"data-target":t.target,"data-flow":i.perSecond??"unmeasured","data-highlighted":x||void 0,"data-unit":i.unit+"/s"},Fb("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),Fb("path",{d:t.pathD,stroke:b,strokeWidth:null===i.perSecond?1.5:1+i.perSecond/h*7,strokeDasharray:null===i.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===i.perSecond?.35:.75}),Fb("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${r.x},${r.y}) rotate(${m})`,fill:"none",stroke:b}),Fb("text",{x:p.x+(y?5:-5),y:p.y-7,textAnchor:y?"start":"end",fontSize:8,fill:n},`${null===i.perSecond?"?":zb(i.perSecond)} ${v}/s`))})),overlays:Fb("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":r.observedAt},...a.sections.map(e=>Fb("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:n},e.id)),...tr(a,r,c,n,d,l,g),...b,ir(a,i,r,c,n,d),Fb("text",{x:a.width/2,y:a.height-8,textAnchor:"middle",fontSize:9,fill:n},`${"modeled"===i.kind?"Modeled":"Observed"} · ${r.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))}},jb=()=>null,Bb=ar(Qm,function({atlas:e,linkedHover:t,...i},r=Dy(e)){return{...i,linkedHover:Ui(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${r.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:r.sceneSeeds.nodes,edges:r.sceneSeeds.edges,layout:gm,layoutConfig:{braid:r}}},[600,400]),Yb=ar(Qm,function({width:e=920,height:t=440,title:i="Dependency X-Ray",description:r,summary:o,accessibleTable:a=!0,chartId:n,className:s,onObservation:l,linkedHover:c,linkedSelection:u,annotations:d,frameProps:h,onSelectNode:f,...p}){return{nodes:p.forest.sceneSeeds.nodes,edges:p.forest.sceneSeeds.edges,layout:Ib,layoutConfig:p,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:n,className:s,onObservation:l,linkedHover:Ui(c),selection:u,annotations:d,frameProps:h,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:r??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${p.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${p.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${p.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${p.forest.atlas.requiredPaths?.status??"not prepared"}. ${p.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:a}},[920,440],{top:12,right:24,bottom:12,left:12}),Xb=ar($b,function({width:e=980,height:t=860,title:i,description:r,summary:o,accessibleTable:a=!0,chartId:n,className:s,onObservation:l,linkedHover:c,annotations:u,frameProps:d,linkedSelection:h,onSelectNode:f,...p}){return{key:JSON.stringify([p.circuit.atlas.analysisRevision,p.circuit.order,p.circuit.backboneEdgeIds,e,t]),data:p.circuit.modules.map(e=>rr(p.circuit,p.edition,p.reading,e)),layout:Wb,layoutConfig:p,width:e,height:t,chartId:n,className:s,onObservation:l,linkedHover:Ui(c),annotations:u,frameProps:d,paused:!0,title:i??p.edition.label,description:r??`${p.edition.label}. ${p.edition.kind} aggregate interval tape at ${p.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??p.edition.assumptions.join(" "),accessibleTable:a,tooltip:!!(n||c||l)&&jb}},[980,860]);import*as Gb from"react";var Vb=Object.freeze([]),qb={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},Hb="__forecastSegment",Ub="__forecastOpacity",Zb="__semiotic_resolvedX",Kb="__semiotic_resolvedY",Qb="__compoundGroup",Jb={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=to({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:_i(r.theme).colors.categorical}),n=Pr(a.annotations,o.regression);return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...n&&n.length>0&&{annotations:n},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||io(e,t,i,r,o),showLegend:r.showLegend??!!t}}},ev={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Pr(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...a&&{annotations:a},pointStyle:r.pointStyle||ao(e,t,i,r,o),showLegend:r.showLegend??!!t}}};import{useMemo as tv,useCallback as iv,useState as rv,useId as ov,useEffect as av,useRef as nv}from"react";var sv="__semioticSelectionData";import{jsx as lv}from"react/jsx-runtime";var cv={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,r,o)=>{let a=yo(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),n=Math.max(1,a.seriesOrder.length),s=_i(r.theme),l=go({seriesOrder:a.seriesOrder,overallOrder:a.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:s.colors.categorical,themeNeutral:s.colors.textSecondary}),c={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:a.valueExtent,seriesOrder:a.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:l&&"object"==typeof l&&!Array.isArray(l)?l:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=r.xFormat,d=(e,t)=>{if(0===a.xValues.length)return"";let i=a.xValues[Math.max(0,Math.min(a.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=a.xValues.map((e,t)=>t),f=Array.from({length:n},(e,t)=>t+1),p=r.axes??[{orient:"left",tickValues:f,tickFormat:e=>e+"",label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:r.xLabel,tickAnchor:"edges"}];return{...r,chartType:"custom",data:a.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,a.xValues.length-1)],yExtent:[n+.5,.5],customLayout:_o,layoutConfig:c,colorAccessor:"__bumpSeries",colorScheme:l,xFormat:d,axes:p,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:po(r.annotations,a.xValues)}}},uv="__ma_unitized",dv="__ma_series",hv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=Array.isArray(o.series)?o.series:[],s=Po(n,i,_i(r.theme).colors.categorical),l=2===n.length,c=n.map(e=>e.extent||Lo(a,e.yAccessor)),u=[];for(let e of a)n.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),a=c[i],n=a[1]-a[0]||1;u.push({...e,[uv]:l?(o-a[0])/n:o,[dv]:t.label||"Series "+(i+1)})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?r+"":r.toFixed(1)},h=l?[{orient:"left",label:n[0].label,tickFormat:d(c[0],n[0].format)},{orient:"right",label:n[1].label,tickFormat:d(c[1],n[1].format)},{orient:"bottom"}]:void 0,f=/* @__PURE__ */new Map;n.forEach((e,t)=>{f.set(e.label||"Series "+(t+1),s[t])});let p=ur(dr({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>f.get((e[dv]??"")+"")||s[0],styleRules:o.styleRules,ruleContext:$o(o.xAccessor,n)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:uv,groupAccessor:dv,colorAccessor:dv,...h&&{axes:h},...l&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:s,lineStyle:p}}},fv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=o.xAccessor||"x",s="function"==typeof n?n:e=>e[n],l=a.some(e=>{let t=s(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=l?a.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(s(e)??t)+""})):a,u=o.styleRules?Vy(void 0,o.styleRules,Yy(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:l?"__waterfallX":n,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...l&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=a[Number(e)]?s(a[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},pv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.lineBy,n=o.fillArea,s=Array.isArray(n)?"mixed":n?"area":"line",l=_i(r.theme).colors.categorical,c=Io(e,a,i,r,o),u=to({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:a,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:r.annotations,themeCategorical:l,baseLineStyle:c}),d=r.pointStyle||To(u.data,u.colorAccessor,i,r,o),h=r.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let f=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:s,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(n)&&{areaGroups:n},...n&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},gv={frameType:"xy",layout:{margin:(e,t)=>Ir(t.marginDefaults,Lr(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?lr(e):[],n=o.timeAccessor||"time",s=o.valueAccessor||"value",l=o.categoryAccessor,c=oo(a,r,o,"explicit-then-alpha"),u=o.valueExtent||r.yExtent,d={..._r(o),...void 0!==o.cursor&&{cursor:o.cursor}},h={...d,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},f=Vy(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:a,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,a.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>nr(e,n,"time")??NaN,valueAccessor:e=>nr(e,s,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:u,invertY:"down"===o.direction,axes:Lr({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:l,barColors:c||r.barColors,colorScheme:c||r.colorScheme,barStyle:r.barStyle||h,areaStyle:r.areaStyle||(e=>({...f(e),...!l&&void 0!==o.fill&&{fill:o.fill},...d})),showLegend:r.showLegend??!!l}}},yv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.areaBy,n=to({data:Array.isArray(e)?lr(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:_i(r.theme).colors.categorical}),s=sr({data:e,safeData:n.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),l=br(o.semanticGradient),c=l?.stops.length?wr(l):mr(r.gradientFill),u=!1!==o.semanticLine?vr(l):void 0,d=r.pointStyle||To(s,a,i,r,o);return{chartType:"area",data:s,xAccessor:n.xAccessor,yAccessor:n.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:a,colorScheme:i,...r,...n.annotations.length>0&&{annotations:n.annotations},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||Ro(s,a,i,r,o),...d&&{pointStyle:d}}}},mv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.xAccessor||"x",n=o.seriesAAccessor||"a",s=o.seriesBAccessor||"b",l=e=>Sr(Ar(a,"x",e)),c=e=>Sr(Ar(n,"a",e)),u=e=>Sr(Ar(s,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,g=!1!==o.showLines,y=!1!==r.showLegend,m=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=r.legendPosition||"right",v=hr(Array.isArray(e)?e:[],l,c,u),w=[];if(g&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(let e of t){let t=l(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:gr({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:o.styleRules}),lineStyle:yr({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...y&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},xv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=t||o.areaBy,n="string"==typeof a&&Array.isArray(e)?$e(e,a,i):void 0,s="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{let t=null==a?void 0:_e(e,a,n),i=o.showLine??!0,r={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:s,...null==o.opacity?{}:{opacity:o.opacity}},l=o.styleRules;if(l?.length){let t=By(o.yAccessor),i=a?("function"==typeof a?a(e)??"":e[a]??"")+"":void 0;Object.assign(r,Gy(e,l,{value:t(e),category:i}))}return r}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||To(e,a,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:a,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!a}}},bv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[a]=r.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...r,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:Vy(void 0,o.styleRules,Yy(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(a/40))),extentPadding:r.extentPadding??(a>200?.1:.02)}}},vv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.xCenter,n=o.yCenter,s=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=l.stroke||"#999",h=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=Gb.createElement,g=s?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,l=null!=a?t.x(a):r/2,g=null!=n?t.y(n):o/2;if(null!=a&&!Number.isFinite(l)||null!=n&&!Number.isFinite(g))return null;let y=Math.max(0,Math.min(r,l)),m=Math.max(0,Math.min(o,g)),x=[{c:s.topLeft,x:0,y:0,w:y,h:m},{c:s.topRight,x:y,y:0,w:r-y,h:m},{c:s.bottomLeft,x:0,y:m,w:y,h:o-m},{c:s.bottomRight,x:y,y:m,w:r-y,h:o-m}],b=c?[p("text",{key:"ltl",x:8,y:8+u,fill:s.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.topLeft.label),p("text",{key:"ltr",x:r-8,y:8+u,fill:s.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.topRight.label),p("text",{key:"lbl",x:8,y:o-8,fill:s.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:s.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.bottomRight.label)]:[];return p(Gb.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("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),p("line",{key:"vc",x1:y,y1:0,x2:y,y2:o,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:r,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:r.pointStyle||o.pointStyle||io(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...g&&{svgPreRenderers:g}}}},wv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=$r(e,o),n=to({data:a.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:_i(r.theme).colors.categorical}),s=Pr(n.annotations,o.regression),l=o.pointRadius??4,c=Yy(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;let i=[];for(let e=0;t.length-1>e;e++){let r=t[e],o=t[e+1],a=Mr(e,t.length);100>t.length&&i.push(Gb.createElement("line",{key:"halo-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:l+2,strokeLinecap:"round",opacity:.5})),i.push(Gb.createElement("line",{key:"segment-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:a,strokeWidth:l,strokeLinecap:"round"}))}return Gb.createElement(Gb.Fragment,null,...i)}];return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:ur(e=>{let t=a.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?Mr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1};return u?.length&&Object.assign(o,Gy(e,u,c(e))),o},_r(o)),...r,...s&&s.length>0&&{annotations:s},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},svgPreRenderers:d}}},kv=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;let t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);let t=this._count+e._count,i=e._mean-this._mean;this._mean+=i*e._count/t,this._m2+=e._m2+i*i*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){let t=new e;return t.merge(this),t}get count(){return this._count}get mean(){return this._mean}get sum(){return this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Av=class e{constructor(e=10){let t=Math.max(4,Math.min(16,Math.floor(e)));this.p=t,this.m=1<<t,this.registers=new Uint8Array(this.m),this.alpha=.7213/(1+1.079/this.m),this.harmonicSum=this.m,this.zeros=this.m}add(e){let t=Co(e+""),i=t>>>32-this.p,r=Math.min(Math.clz32(t<<this.p),32-this.p)+1;this.updateRegister(i,r)}updateRegister(e,t){let i=this.registers[e];i>=t||(this.registers[e]=t,this.harmonicSum+=2**-t-2**-i,0===i&&this.zeros--)}merge(e){if(e.m===this.m)for(let t=0;this.m>t;t++)this.updateRegister(t,e.registers[t])}clone(){let t=new e(this.p);return t.registers.set(this.registers),t.harmonicSum=this.harmonicSum,t.zeros=this.zeros,t}count(){let e=this.alpha*this.m*this.m/this.harmonicSum;return Math.round(2.5*this.m>=e&&this.zeros>0?this.m*Math.log(this.m/this.zeros):e)}},Sv=class e{constructor(e=100){this.centroids=[],this.total=0,this.pending=0,this.compression=Math.max(20,e)}push(e){Number.isFinite(e)&&(this.centroids.push({mean:e,weight:1}),this.total+=1,this.pending++,this.pending>=2*this.compression&&this.compress())}merge(e){if(0===e.total)return;let t=0===this.total,i=e.centroids.length;for(let t=0;i>t;t++)this.centroids.push({...e.centroids[t]});this.total+=e.total,this.pending=t&&this.compression===e.compression?e.pending:this.pending+i,t||this.compress()}clone(){let t=new e(this.compression);return t.merge(this),t}quantile(e){if(0===this.total||Number.isNaN(e))return NaN;let t=Math.min(1,Math.max(0,e));this.compress();let i=t*this.total,r=this.centroids[0].weight/2;if(r>=i)return this.centroids[0].mean;for(let e=1;this.centroids.length>e;e++){let t=this.centroids[e-1],o=this.centroids[e],a=(t.weight+o.weight)/2,n=r+a;if(n>=i)return t.mean+(i-r)/a*(o.mean-t.mean);r=n}return this.centroids[this.centroids.length-1].mean}get count(){return this.total}compress(){if(0===this.pending||(this.pending=0,1>=this.centroids.length))return;this.centroids.sort((e,t)=>e.mean-t.mean);let e=0,t=0,i=this.total,r=this.compression;for(let o=1;this.centroids.length>o;o++){let a=this.centroids[e],n=this.centroids[o],s=(t+a.weight/2)/i;if(a.weight+n.weight>Math.max(1,4*i*s*(1-s)/r))t+=a.weight,this.centroids[++e]=n;else{let e=a.weight+n.weight;a.mean=(a.mean*a.weight+n.mean*n.weight)/e,a.weight=e}}this.centroids.length=e+1}},Mv=(e,t)=>e-t,_v=class{constructor(e,t){this.stats=new kv,this.digest=e?new Sv:null,this.hll=t?new Av:null}push(e,t){this.stats.push(e),this.digest?.push(e),this.hll&&this.hll.add(t??e)}merge(e){this.stats.merge(e.stats),this.digest?.merge(e.digest),this.hll?.merge(e.hll)}},Pv=class{constructor(e){this.windows=/* @__PURE__ */new Map,this.starts=[],this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;let t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0,this.percentiles=e.percentiles??[],this.wantDistinct=!0===e.distinct}newBucket(){return new _v(this.percentiles.length>0,this.wantDistinct)}push(e,t,i){!Number.isFinite(e)||!Number.isFinite(t)||(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t,i):this.pushFixed(e,t,i),this.prune())}pushFixed(e,t,i){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t,i);let r=this.hop,o=Math.floor(e/r);for(let a=Math.floor((e-this.size)/r)+1;o>=a;a++)this.bump(a*r,t,i)}bump(e,t,i){let r=this.windows.get(e);if(!r){if(this.windows.size>=this.retain&&this.starts[0]>e)return;r=this.newBucket(),this.windows.set(e,r),this.retain!==1/0&&zo(this.starts,e,Mv)}r.push(t,i)}pushSession(e,t,i){let r=e-this.gap,o=e+this.gap,a=0,n=this.sessions.length,s=this.sessions[n-1];if(s&&s.end>e)for(;n>a;){let e=a+n>>>1;r>this.sessions[e].end?a=e+1:n=e}else a=n,s&&s.end>=r&&o>=s.start&&a--;let l=this.sessions[a];if(!l||l.start>o){let r=this.newBucket();return r.push(t,i),void this.sessions.splice(a,0,{start:e,end:e,bucket:r})}l.bucket.push(t,i),l.start=Math.min(l.start,e),l.end=Math.max(l.end,e);let c=a+1;for(;this.sessions.length>c&&o>=this.sessions[c].start;){let e=this.sessions[c++];l.bucket.merge(e.bucket),l.end=Math.max(l.end,e.end)}c>a+1&&this.sessions.splice(a+1,c-a-1)}prune(){if(this.retain!==1/0){if("session"===this.type)return void(this.sessions.length>this.retain&&this.sessions.splice(0,this.sessions.length-this.retain));for(;this.windows.size>this.retain;)this.windows.delete(Eo(this.starts,Mv))}}emit(){if("session"===this.type)return this.sessions.map(e=>this.row(e.start,e.end,e.bucket,this.gap>this.latest-e.end));let e=[];for(let[t,i]of this.windows){let r=t+this.size;e.push(this.row(t,r,i,r>this.latest))}return e.sort((e,t)=>e.start-t.start),e}row(e,t,i,r){let o=i.stats,a={start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:r};if(i.digest){let e={};for(let t of this.percentiles)e[Do(t)]=i.digest.quantile(t);a.percentiles=e}return i.hll&&(a.distinct=i.hll.count()),a}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.starts=[],this.sessions=[],this.latest=-1/0}},$v={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Lv=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,Iv="time",Rv="value",Tv="__aggLower",Cv="__aggUpper",Dv="__aggPartial",zv="count",Ev="__aggStart",Nv="__aggEnd",Ov="__aggSeries",Fv=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){let r=nr(e,t,"time"),o=nr(e,i,"value");if(null==r||null==o)return;let a=null==this.seriesAccessor?"":("function"==typeof this.seriesAccessor?this.seriesAccessor(e):e[this.seriesAccessor])+"",n=this.groups.get(a);if(!n){if(n=Wo(this.config),!n)return;this.groups.set(a,n)}n.push(r,o)}emit(e){let t=[];for(let[i,r]of this.groups)for(let o of jo(r,e))t.push(null==this.seriesAccessor?o:{...o,[Ov]:i});return t}clear(){this.groups.clear()}},Wv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,n=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,s=Vy(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:n}),o.styleRules,Xo(o.xAccessor,o.yAccessor,o.valueAccessor)),l=("string"==typeof a?.colorScheme?a.colorScheme:void 0)??i,c=null!=a&&Object.hasOwn(a,"heatmapColorScale"),u=a?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===l&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:s,...r,...void 0!==l&&{colorScheme:l},...d&&{heatmapColorScale:d}}}},jv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Vo(e,o),n=o.aggregate,s=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:qo(o),l=Vy(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,Yy(s.timeAccessor,s.valueAccessor));return{chartType:"line",data:a,...r,...Ho(a,r,o),...s,groupAccessor:n&&null!=o.seriesAccessor?Ov:o.seriesAccessor,...n&&{windowMode:"growing",windowSize:Math.max(1,n.retain??Math.max(a.length,600)),band:Bo(n)?{y0Accessor:Tv,y1Accessor:Cv,perSeries:null!=o.seriesAccessor}:void 0},lineStyle:r.lineStyle||(e=>({...l(e),..._r(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))}}},Bv={...gv,buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?lr(e):[];return{...gv.buildProps(a,t,i,r,o),...Ho(a,r,o)}}},Yv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?lr(e):[];return{...Wv.buildProps(a,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...Ho(a,r,o),categoryAccessor:o.categoryAccessor}}},Xv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?lr(e):[],n=oo(a,r,o,"discovery"),s=Vy(void 0,o.styleRules,Yy(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:a,...r,...Ho(a,r,o),categoryAccessor:o.categoryAccessor,colorScheme:n||i||r.colorScheme,barColors:n,yScaleType:o.yScaleType,swarmStyle:{..._r(o),fill:o.fill,radius:o.radius,cursor:o.cursor},pointStyle:e=>({...s(e),..."function"==typeof o.pointStyle?o.pointStyle(e):{},..."function"==typeof r.pointStyle?r.pointStyle(e):r.pointStyle})}}},Gv={frameType:"xy",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?lr(e):[],n=fv.buildProps(a,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...n,...Ho(a,r,o),waterfallStyle:{...n.waterfallStyle,cursor:o.cursor}}}};import{useMemo as Vv,useCallback as qv,useRef as Hv}from"react";var Uv={RdBu:wx,PiYG:kx,PRGn:Ax,BrBG:Sx,RdYlBu:Mx,RdYlGn:_x,Spectral:Px},Zv="__likert_neutral_neg",Kv="__likert_neutral_pos",Qv={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,r,o,a)=>{let n=Array.isArray(a.levels)&&a.levels.length>=2?a.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==a.orientation,l=Ko(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n,Uo(a.categoryAccessor,"question"),a.levelAccessor?null:Uo(a.valueAccessor,"score"),a.levelAccessor?Uo(a.levelAccessor,"level"):null,a.levelAccessor?Uo(a.countAccessor,"count"):null,{category:"string"==typeof a.categoryAccessor?a.categoryAccessor:void 0,level:"string"==typeof a.levelAccessor?a.levelAccessor:void 0,count:"string"==typeof a.countAccessor?a.countAccessor:void 0,score:a.levelAccessor||"string"!=typeof a.valueAccessor?void 0:a.valueAccessor});s&&(l=Jo(Qo(l,n),n));let c=_i(o.theme).colors.diverging,u=Array.isArray(r)&&r.length>=n.length?r:Zo(n.length,c),d=new Map(n.map((e,t)=>[e,u[t]||"#888"])),h=n.length%2&&d.get(n[Math.floor(n.length/2)])||"#888",f="function"==typeof a.valueFormat?a.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",p=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:n.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),g=a.styleRules,y=o.pieceStyle;return{chartType:"bar",data:l,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:a.barPadding,showGrid:o.showGrid,oLabel:a.categoryLabel,rLabel:a.valueLabel||(s?void 0:"Percentage"),rFormat:f,...a.categoryFormat&&{oFormat:a.categoryFormat},...a.valueExtent&&{rExtent:a.valueExtent},...o,pieceStyle:ur((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,a={fill:i===Zv||i===Kv?h:d.get((r||i)+"")||"#888"};return g?.length&&Object.assign(a,Gy(e,g,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:r+"")})),"function"==typeof y?Object.assign(a,y(e,t)||{}):y&&"object"==typeof y&&Object.assign(a,y),a},_r(a)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}};import{jsx as Jv,jsxs as ew}from"react/jsx-runtime";import{Fragment as tw,jsx as iw,jsxs as rw}from"react/jsx-runtime";var ow={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=(i.startAngleDeg+(i.gMax===i.gMin?0:(Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin))-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,o=i.needleColor||t.colors.text,a=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];/* @__PURE__ */
|
|
340
|
+
return rw(tw,{children:[i.showNeedle&&/* @__PURE__ */rw(tw,{children:[
|
|
341
|
+
/* @__PURE__ */iw("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(r),y2:i.centerY+i.needleLength*Math.sin(r),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),
|
|
342
|
+
/* @__PURE__ */iw("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:o})]}),null!=i.contextValue&&/* @__PURE__ */iw("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:o,children:i.contextValue}),a.map((e,r)=>{let o=(i.startAngleDeg+(i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,a=i.innerRadius-1,n=i.radius+1,s=i.radius+10,l=((o+Math.PI/2)/(2*Math.PI)*12+12)%12,c=l>=11||1>l?"middle":5>l?"start":7>l?"middle":"end",u=l>=11||1>l?"auto":5>l?"middle":7>l?"hanging":"middle";/* @__PURE__ */
|
|
343
|
+
return rw("g",{children:[
|
|
344
|
+
/* @__PURE__ */iw("line",{x1:i.centerX+Math.cos(o)*a,y1:i.centerY+Math.sin(o)*a,x2:i.centerX+Math.cos(o)*n,y2:i.centerY+Math.sin(o)*n,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),
|
|
345
|
+
/* @__PURE__ */iw("text",{x:i.centerX+Math.cos(o)*s,y:i.centerY+Math.sin(o)*s,textAnchor:c,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+r)})]})},buildProps:(e,t,i,r,o)=>{let a=o.min??0,n=o.max??100,s=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=sa(s),h=o.thresholds,f=xr(r.gradientFill),p=na({min:a,max:n,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:f}),g=o.styleRules,[y,m]=r.size||[300,250],x=la(s),b=Math.min(10,Math.max(1,Math.min(y,m)/12)),v=Math.max(4,Math.min((y-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-l))),k=y/2-x.cx*v,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(a,Math.min(n,o.value??a)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",P=o.centerContent??r.centerContent,$=null!=P?"function"==typeof P?P(M,a,n):P:"sparkline"===o.mode||"context"===o.mode?void 0:ea({value:_,min:a,max:n,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:s,startAngle:d,oSort:!1,pieceStyle:ur((e,t)=>{let i={...p.pieceStyle(e,t)};return g?.length&&Object.assign(i,Gy(e,g,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},_r(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[y,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:y-k-S/2},...null!=$&&{centerContent:$},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:a,gMax:n,sweep:s,arcWidth:l,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:c,needleColor:o.needleColor,..."context"===o.mode&&null==P&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},aw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=Pr(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...a&&{annotations:a},gradientFill:ca(r.gradientFill),pieceStyle:ua(e,t,i,r,o)}}},nw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:a,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ca(r.gradientFill),pieceStyle:ua(e,a,i,r,o),showLegend:r.showLegend??!!a}}},sw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:a,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ca(r.gradientFill),pieceStyle:ua(e,a,i,r,o),showLegend:r.showLegend??!!a}}},lw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.categoryAccessor,n=By(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:a,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:ua(e,a,i,r,o,e=>{let t=n(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!a}}},cw={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,r,o)=>{let a=t||o.categoryAccessor,n=By(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:r.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:a,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:ua(e,a,i,r,o,e=>{let t=n(e);return null==t?void 0:Math.abs(t)})}}},uw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=o.valueAccessor||"value",s=a.map(e=>Number("function"==typeof n?n(e):e[n])).filter(Number.isFinite),l=s.length?[Math.min(...s),Math.max(...s)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:n,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:da(e,t,i,r,o,"count")}}},dw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:da(e,t,i,r,o)})},hw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...r,summaryStyle:ha(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},fw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:pa(e,t,i,r,o),showLegend:r.showLegend??!!t})},pw={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let a=Pr(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...a&&{annotations:a},pieceStyle:fa(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},gw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=o.seriesAccessor||t||"__radar",n=t||("__radar"===a?void 0:a),s=fa(e,n,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:n,colorScheme:i,connectorAccessor:a,connectorStyle:e=>{let t=s(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:s,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!n}}},yw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let a=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:a,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ca(r.gradientFill),pieceStyle:ua(e,a,i,r,o),showLegend:r.showLegend??!!a,barPadding:o.barPadding??40}}},mw={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:da(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},xw={frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a="vertical"===o.orientation,n=t||o.categoryAccessor;return{chartType:a?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:n,categoryAccessor:o.categoryAccessor,projection:a?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!a&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:a?40:0,colorScheme:i,...r,showAxes:a&&!1!==r.showAxes,showGrid:a,pieceStyle:ua(e,n,i,r,o),showLabels:o.showLabels??!0}}};import{scaleTime as bw}from"d3-scale";var vw={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},ww=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),kw=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},Aw=828*kw(8),Sw=3e3,Mw=/* @__PURE__ */new Map,_w=1e5,Pw=1e-9,$w=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;import{Fragment as Lw,jsx as Iw,jsxs as Rw}from"react/jsx-runtime";var Tw="var(--semiotic-grid, #94a3b8)",Cw="var(--semiotic-text-secondary, #475569)",Dw="var(--semiotic-text-secondary, #94a3b8)",zw=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,a=e.selection??null,n=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!cs(t,a,o);n.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!cs({__kind:"band",data:e.rawDatum,id:e.id},a,o);for(let i=0;e.gradientStubs.length>i;i++){let r=e.gradientStubs[i];n.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},r=!cs(i,a,o);n.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?.22:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let s=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&a?.isActive&&cs({__kind:"band",data:e.rawDatum,id:e.id},a,o),n=i?e.labelText:r?e.labelFullText:"";return n.trim()?[{x:e.labelX,y:e.labelY,text:n,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"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:n,labels:s}},Ew={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||r.nodeStyle||o.nodeStyle||cr(_r(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let a=Array.isArray(o.edges)?o.edges:[],n=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:ds([],a,o.sourceAccessor||"source",o.targetAccessor||"target"),s=_i(r.theme).colors.categorical,l=Se(i,s),c="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?n.map(e=>({...e,__ssrChordColorBy:t(e)})):n,d=t?$e(u,c,i??r.colorScheme??s):void 0,h=/* @__PURE__ */new Map,f=o.nodeIdAccessor||o.nodeIDAccessor||"id",p=(e,i)=>{let r,a=e?.data||e;if(t)r=_e(a,t,d);else{let t=(e.id??a?.[f]??"")+"";h.has(t)||h.set(t,h.size);let o=e.index??i??h.get(t);r=l[o%l.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},g=qy(o.styleRules,t,o.valueAccessor);return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:ur(o.nodeStyle||(g?(e,t)=>({...p(e,t),...g(e,t)}):p),_r(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},Nw={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=ps(o),n=_i(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l=o.nodeStyle??(e=>({fill:t?_e(e?.data||e,t,void 0):ho(void 0,n,i,void 0,s),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),c=qy(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=ur(c?(e,t)=>({...l(e),...c(e,t)}):l,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:a,...r,showLegend:(r.showLegend??!!t)&&!!t}}},Ow={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=_i(r.theme).colors.categorical,n=/* @__PURE__ */new Map,s=us(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrCirclePackColorBy:l(e)})):s,u=l?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?$e(c,u,i??r.colorScheme??a):void 0,h=o.showLabels??r.showLabels,f=r.nodeStyle||o.nodeStyle,p=Vy(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Tx[Number(e?.depth||0)%Tx.length]:t?l?_e({__ssrCirclePackColorBy:l(r)},"__ssrCirclePackColorBy",d??void 0):_e(r,t,d??void 0):ho(void 0,a,i,void 0,n),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,Xy(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fs(p,f,_r(o))}}},Fw={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=e??o.data,n=o.childrenAccessor||"children",s=o.nodeIdAccessor||o.nodeIDAccessor||"name",l=_i(r.theme).colors.categorical,c=i??r.colorScheme??l,u=Se(c,l),d=us(a,n),h="__ssrOrbitColorBy",f="function"==typeof t?t:null,p=t?$e(f?d.map(e=>({[h]:f(e)})):d,f?h:t,c):void 0,g=Vy(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:Tx[r%Tx.length]:t?f?_e({[h]:f(i)},h,p):_e(i,t,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,Xy(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:a,childrenAccessor:n,nodeIDAccessor:s,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?s:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:ur(g,_r(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},Ww={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,r,o,a)=>{let n=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=a.sourceAccessor||"source",l=a.targetAccessor||"target",c=a.valueAccessor||"value",u=a.nodeIdAccessor||"id",d=a.startTimeAccessor||"startTime",h=a.endTimeAccessor||"endTime",f=a.systemInTimeAccessor,p=a.systemOutTimeAccessor,g=a.xExtentAccessor||"xExtent",y=a.groupBy,m=a.edgeIdAccessor||"id",x=(e,t)=>"function"==typeof e?e(t):t[e],b=Array.isArray(a.edges)?a.edges:[],v=Array.isArray(a.nodes)?a.nodes:[],w=v.length>0?v:ds([],b,s,l),k=[n(a.domain?.[0]),n(a.domain?.[1])],A=w.map(e=>{let t=x(u,e)+"",i=x(g,e),r=a.nodeLabel?x(a.nodeLabel,e):t,o={id:t,label:null==r?t:r+"",__raw:e},s=y?x(y,e):null;if(null!=s&&s+""!=""&&(o.group=s+""),Array.isArray(i)&&2===i.length){let e=n(i[0]),t=n(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=b.map((e,t)=>{let i=x(m,e),r={id:null!=i?i+"":`${x(s,e)}-${x(l,e)}-${t}`,source:x(s,e)+"",target:x(l,e)+"",value:Number(x(c,e)),startTime:n(x(d,e)),endTime:n(x(h,e)),__raw:e};if(f){let t=n(x(f,e));Number.isFinite(t)&&(r.systemInTime=t)}if(p){let t=n(x(p,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[M,_]=o.size??[600,400],P=o.margin,$="vertical"===a.orientation?"vertical":"horizontal",L={...ns(!!o.title,!!a.showQualityReadout,Array.isArray(a.axisTicks)&&a.axisTicks.length>0,$),...P},I=(o.showLegend??!!t)&&!!t,R=o.legendPosition??"right";I&&("right"===R?L.right=Math.max(L.right,140):"left"===R?L.left=Math.max(L.left,140):"top"===R?L.top=Math.max(L.top,50):"bottom"===R&&(L.bottom=Math.max(L.bottom,80)));let T=L,C=M-T.left-T.right,D=_-T.top-T.bottom,z=Se(r,_i(o.theme).colors.categorical,sx),E="function"==typeof t?t:null,N=E?w.map(e=>({_cat:E(e)})):w,O=E?"_cat":"string"==typeof t?t:void 0,F=r??[...z],W=O?$e(N,O,F):null,j=/* @__PURE__ */new Map;for(let e of A)j.set(e.id,e.__raw);let B=(e,i)=>{if(t&&j.has(e)){let i=j.get(e);return E?_e({_cat:E(i)},"_cat",W??void 0):_e(i,"string"==typeof t?t:"id",W??void 0)}return z[i%z.length]},Y=i(I&&t?(()=>{let e=/* @__PURE__ */new Map;w.forEach((i,r)=>{let o=x(t,i),a=null==o?"":o+"";!a||e.has(a)||e.set(a,{label:a,color:B(x(u,i)+"",r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),X=!1!==a.showLabels&&("auto"!==a.showLabels||"auto"),{layout:G,layoutConfig:V,issues:q,xScale:H}=as({nodes:A,edges:S,domain:k,plotW:C,plotH:D,orientation:$,ribbonLane:a.ribbonLane||"both",ribbonMinRun:"auto"===a.ribbonMinRun||"number"==typeof a.ribbonMinRun?a.ribbonMinRun:0,edgeOpacity:"number"==typeof a.edgeOpacity?a.edgeOpacity:.35,colorOf:B,showLabels:X,styleRules:a.styleRules,colorBy:t,valueAccessor:c,layoutOpts:{pairing:a.pairing||"temporal",packing:a.packing||"reuse",laneOrder:a.laneOrder||"crossing-min",lifetimeMode:a.lifetimeMode||"half",maxValueScale:"number"==typeof a.maxValueScale?a.maxValueScale:void 0,lanePlacement:a.lanePlacement||"stack",nodeSizing:a.nodeSizing||"temporal",groupPadding:"number"==typeof a.groupPadding?a.groupPadding:0}});if(q.length>0){let e=q.map(va).join("; ");throw Error("ProcessSankey: data invalid — "+e)}let U=G?ss({layout:G,nodes:A,orientation:$,plotW:C,plotH:D,timelineExtent:"vertical"===$?D:C,axisTicks:Array.isArray(a.axisTicks)?a.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!a.showQualityReadout,showLaneRails:!!a.showLaneRails,timeFormat:"function"==typeof a.timeFormat?e=>a.timeFormat(e):void 0,colorOf:B,toTime:e=>n(e),xScale:e=>Number(H(e))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:zw,layoutConfig:V,sourceAccessor:s,targetAccessor:l,valueAccessor:c,nodeIDAccessor:u,colorBy:t,colorScheme:r,...U&&{backgroundGraphics:U},...o,showLegend:I,...Y&&{legend:Y,legendPosition:R},__legendIncludesAutomatic:!0,margin:T}}},jw={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,r,o)=>{let a=Array.isArray(o.nodes)?o.nodes:ds([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),n=_i(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrSankeyColorBy:t(e)})):a,u=t?$e(c,l,i??r.colorScheme??n):void 0,d=e=>({fill:t?_e(e?.data||e,t,u):ho(void 0,n,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=qy(o.styleRules,t,o.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=hs({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:f,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:ur(o.nodeStyle||f,_r(o)),edgeStyle:ur(o.edgeStyle||p,_r(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},Bw={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=_i(r.theme).colors.categorical,n=/* @__PURE__ */new Map,s=us(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreeColorBy:l(e)})):s,u=l?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?$e(c,u,i??r.colorScheme??a):void 0,h=!1!==o.showLabels,f=r.nodeStyle||o.nodeStyle,p=Vy(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Tx[Number(e?.depth||0)%Tx.length]:t?l?_e({__ssrTreeColorBy:l(r)},"__ssrTreeColorBy",d??void 0):_e(r,t,d??void 0):ho(void 0,a,i,void 0,n),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,Xy(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fs(p,f,_r(o))}}},Yw={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let a=_i(r.theme).colors.categorical,n=/* @__PURE__ */new Map,s=us(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreemapColorBy:l(e)})):s,u=l?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?$e(c,u,i??r.colorScheme??a):void 0,h=o.showLabels??r.showLabels,f=o.labelMode,p=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,g=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,y=r.nodeStyle||o.nodeStyle,m=Vy(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Tx[Number(e?.depth||0)%Tx.length]:t?l?_e({__ssrTreemapColorBy:l(r)},"__ssrTreemapColorBy",d??void 0):_e(r,t,d??void 0):ho(void 0,a,i,void 0,n),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,Xy(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:f,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=g&&{paddingTop:g},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:fs(m,y,_r(o))}}},Xw={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as Gw}from"d3-scale";var Vw={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a="string"==typeof i?i:"blues",n=bs(o.areas,o.valueAccessor,a),s=o.areaStyle??vs(n,o.areaOpacity??1),l=e=>"function"==typeof o.valueAccessor?o.valueAccessor(e):null!=o.valueAccessor?e?.properties?.[o.valueAccessor]??e?.[o.valueAccessor]:void 0,c=o.styleRules?Vy(s,o.styleRules,e=>({value:l(e)}),xs):s,u=!1!==r.showLegend&&n?{gradient:{colorFn:n.colorScale,domain:n.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:c,valueAccessor:o.valueAccessor,colorScheme:a,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&u?{legend:u}:{}}}},qw={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=e||o.points,n=o.pointStyle??ms(a,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),s=o.styleRules?Vy(n,o.styleRules,Xy(t,o.sizeBy)):n;return{points:a,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||Xw,pointStyle:s,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},Hw={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=e||o.points,n=o.pointStyle??ms(a,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),s=o.nodeIdAccessor||"id",l=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),c="sparkline"===o.mode,u="strip"===l,d=o.styleRules?Vy(n,o.styleRules,Xy(t)):n;return{points:a,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof d?d(e):d,i="function"==typeof s?s(e):e[s],r=null!=i&&i+""==o.center+"",a="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*a:a}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:s,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:l},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!c),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},Uw={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let a=(Array.isArray(e)?e:null)||o.flows||[],n=o.nodeIdAccessor||"id",s=o.valueAccessor||"value",l=o.xAccessor||"lon",c=o.yAccessor||"lat",u="function"==typeof l?l:e=>e[l],d="function"==typeof c?c:e=>e[c],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=/* @__PURE__ */new Map;for(let e of h)f.set(e[n]+"",e);let p=o.edgeColorBy??t,g="function"==typeof p,y=a.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=f.get(e.source+""),i=f.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?g?$e(y.map(e=>({[m]:p(e)})),m,i||"category10"):$e(y,p,i||"category10"):null,b=y.map(e=>Number(e[s]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?Nm(b):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:y,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||Xw,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:ys({valueAccessor:s,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>p&&x?_e(e,p,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}};import*as Zw from"react-dom/server";import*as Kw from"react";import*as Qw from"react-dom/server";var Jw=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){let t=[];for(let i of e){let e=this.push(i);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){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){let a=(r+o)%this._capacity,n=this.buffer[a];if(e(n)){let e;e="object"!=typeof n||null===n?n:Array.isArray(n)?[...n]:{...n},i.push(e),this.buffer[a]=t(n)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);return i}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}},ek=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(let i of e){let e=t?t(i):i;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}},tk=/^\d{4}-\d{1,2}$/,ik=/* @__PURE__ */Object.create(null),rk=typeof window>"u"||typeof document>"u",ok=/* @__PURE__ */new Set;import{scaleLinear as ak,scaleLog as nk,scaleSymlog as sk,scaleTime as lk}from"d3-scale";var ck=/* @__PURE__ */new WeakMap,uk=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dk=["scene-style","data-paint","accessibility","evidence"],hk=(e,t)=>({retainedData:e,invalidations:t}),fk=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gk=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mk=["scene-geometry","data-paint","accessibility","evidence"],xk=["scene-style","data-paint","accessibility","evidence"],bk=[],vk={chartType:hk("rebuild",fk),runtimeMode:hk("rebuild",fk),xAccessor:hk("rebuild",fk),yAccessor:hk("rebuild",fk),timeAccessor:hk("rebuild",fk),valueAccessor:hk("rebuild",fk),y0Accessor:hk("rebuild",fk),boundsAccessor:hk("rebuild",fk),band:hk("rebuild",fk),openAccessor:hk("rebuild",fk),highAccessor:hk("rebuild",fk),lowAccessor:hk("rebuild",fk),closeAccessor:hk("rebuild",fk),candlestickRangeMode:hk("rebuild",fk),accessorRevision:hk("rebuild",fk),groupAccessor:hk("rebuild",pk),categoryAccessor:hk("rebuild",pk),lineDataAccessor:hk("rebuild",pk),colorAccessor:hk("rebuild",xk),sizeAccessor:hk("rebuild",mk),symbolAccessor:hk("rebuild",mk),pointIdAccessor:hk("rebuild",mk),xScaleType:hk("preserve",gk),yScaleType:hk("preserve",gk),xExtent:hk("preserve",gk),invertY:hk("preserve",gk),yExtent:hk("preserve",gk),extentPadding:hk("preserve",gk),scalePadding:hk("preserve",gk),axisExtent:hk("preserve",gk),yAxisExtent:hk("preserve",gk),binSize:hk("preserve",gk),normalize:hk("preserve",gk),heatmapAggregation:hk("preserve",gk),heatmapXBins:hk("preserve",gk),heatmapYBins:hk("preserve",gk),arrowOfTime:hk("preserve",yk),baseline:hk("preserve",yk),stackOrder:hk("preserve",yk),sizeRange:hk("preserve",yk),curve:hk("preserve",yk),areaGroups:hk("preserve",yk),customLayout:hk("preserve",yk),layoutConfig:hk("preserve",yk),layoutMargin:hk("preserve",yk),symbolMap:hk("preserve",mk),showValues:hk("preserve",mk),heatmapValueFormat:hk("preserve",mk),trackHoverRows:hk("preserve",mk),lineStyle:hk("preserve",xk),pointStyle:hk("preserve",xk),areaStyle:hk("preserve",xk),barStyle:hk("preserve",xk),swarmStyle:hk("preserve",xk),waterfallStyle:hk("preserve",xk),candlestickStyle:hk("preserve",xk),boundsStyle:hk("preserve",xk),gradientFill:hk("preserve",xk),lineGradient:hk("preserve",xk),semanticLineStops:hk("preserve",xk),colorScheme:hk("preserve",xk),themeCategorical:hk("preserve",xk),themeSemantic:hk("preserve",xk),themeSequential:hk("preserve",xk),themeDiverging:hk("preserve",xk),barColors:hk("preserve",xk),decay:hk("preserve",xk),pulse:hk("preserve",xk),staleness:hk("preserve",xk),layoutSelection:hk("preserve",xk),annotations:hk("preserve",["overlay","accessibility","evidence"]),windowSize:hk("preserve",bk),windowMode:hk("preserve",bk),maxCapacity:hk("preserve",bk),clock:hk("preserve",bk),transition:hk("preserve",bk),introAnimation:hk("preserve",bk),onLayoutError:hk("preserve",bk)},wk=hk("preserve",yk),kk=class{constructor(){this.tracker=new Qy}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},uk)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},dk):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=ec(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...mk]):i.invalidations)}};import{quadtree as Ak}from"d3-quadtree";var Sk=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 i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=i)return void(this.tree=null);let o=Array(i),a=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[a++]=e);this.tree=Ak().x(e=>e.x).y(e=>e.y).addAll(o)}},Mk=class e{constructor(e){if(this.xExtent=new ek,this.yExtent=new ek,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=/* @__PURE__ */new Map,this.prevPathMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */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 kk,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.xIsDate=!1,this.spatialIndex=new Sk,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&Ds(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new Jw(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Cy(e.timeAccessor||e.xAccessor,"time"),this.getY=Cy(e.valueAccessor||e.yAccessor,"value")):(this.getX=Cy(e.xAccessor,"x"),this.getY=Cy(e.yAccessor,"y")),this.getGroup=uy(e.groupAccessor),this.getCategory=uy(e.categoryAccessor),this.getSize=e.sizeAccessor?Cy(e.sizeAccessor,"size"):void 0,this.getColor=uy(e.colorAccessor),this.getSymbol=uy(e.symbolAccessor),this.getY0=e.y0Accessor?Cy(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=dl(e),this.getPointId=uy(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?Cy(e.openAccessor,"open"):void 0,this.getHigh=Cy(e.highAccessor,"high"),this.getLow=Cy(e.lowAccessor,"low"),this.getClose=i?Cy(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new Jw(e.windowSize))}currentTime(){return this.config.clock?.()??Ps()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Xl(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let 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;let t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();let i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?Cy(this.config.timeAccessor||this.config.xAccessor,"time"):Cy(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){let t=e.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(t):t[i||"x"],o=r instanceof Date,a="string"==typeof r&&Number.isFinite(ws(r));if(this.xIsDate=o||a,a){let e="string"==typeof i?i:void 0;this.getX=e?t=>ks(t[e]):e=>ks(i(e))}}Yl(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Gl(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let 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&&this.growingCap>=5e4&&(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.`)))}let e=Gl(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),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){let{config:t,buffer:i}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let a=this.getBufferArray(),n=this.xExtent.extent,s=this.yExtent.extent,l="waterfall"===t.chartType&&i.size>0?Ll(a,this.getX,n,t.xExtent,t.xScaleType):Ml(n,t.xExtent),c=Ml(s,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=_l({config:t,groups:this.groupData(a),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=Pl(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!u&&i.size>0?c=$l(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=Il(c,a,this.resolvedRibbons),c=Rl(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=Tl(c,t.yExtent,!!u),({xDomain:l,yDomain:c}=Cl(l,c,t.xScaleType)),this.scales=zl({config:t,layout:e,xDomain:l,yDomain:c}),this._customLayoutFailedThisBuild=!1;let f=this.buildSceneNodes(e,a);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,a),this.config.pulse&&this.applyPulse(this.scene,a,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){let t=e.width/this.lastLayout.width,i=e.height/this.lastLayout.height;for(let e of this.scene)switch(e.type){case"line":for(let r of e.path)r[0]*=t,r[1]*=i;break;case"area":for(let r of e.topPath)r[0]*=t,r[1]*=i;for(let r of e.bottomPath)r[0]*=t,r[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}let r=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),n=this.scales.y.range(),s=Dl,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=n[1]>n[0];this.scales={x:s(this.config.xScaleType,r,a[0]>a[1]?[e.width-l,l]:[l,e.width-l]),y:s(this.config.yScaleType,o,c?[l,e.height-l]:[e.height-l,l])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??Rx},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},a=cl({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let n=a.result;this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null;let s=n.nodes??[];if(this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return ol({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[];let o={scales:r,config:i,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},a=(n=i.chartType,ik[n]?.buildScene);var n;if(!a)return rl(i.chartType),[];let s=il(a(o,t,e));return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=s.binBoundaries),s.nodes}resolveBoundsStyle(e,t){return Bl(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?Is(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=Rs(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&Ts(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&&Es(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory,getPointId:this.getPointId}}snapshotPositions(){Ks(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=Us(this.transitionContext,i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;let e=Qs(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;let t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=Js(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,tc(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=Nl(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=Ol(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return Wl(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return jl(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){let{color:i,groupColorCounter:r}=Fl({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,i}getBufferArray(){return(this._bufferDirty||!this._bufferArrayCache)&&(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=As(e),i=this.getPointId,r=e=>t.has(i(e));Vl(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");let i=As(e),r=this.getPointId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let a=this.buffer.update(e=>i.has(r(e)),t);if(0===a.length)return this.updateResults.recordNoop("update"),a;for(let e of a)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",a.length),a}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=/* @__PURE__ */new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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=/* @__PURE__ */new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let a="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,n=e&&t.valueAccessor||t.yAccessor,s=a||!Ty(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=a||!Ty(i,n);(s||l)&&(e?(this.getX=Cy(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Cy(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Cy(this.config.xAccessor,"x"),this.getY=Cy(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=dl(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!Ty(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?uy(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!Ty(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?uy(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!Ty(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Cy(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!Ty(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?uy(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!Ty(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?uy(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!Ty(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Cy(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!Ty(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=dl(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!Ty(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?uy(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in e&&!Ty(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ty(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ty(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ty(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Cy(this.config.openAccessor,"open"):void 0,this.getHigh=Cy(this.config.highAccessor,"high"),this.getLow=Cy(this.config.lowAccessor,"low"),this.getClose=t?Cy(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&uo(t.areaStyle)!==uo(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Mk.GROUP_COLOR_MAP_CAP=1e3;var _k=Mk;Jl(_k);var Pk=256,$k=/* @__PURE__ */new Map,Lk={line:function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(cc).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=ac(e.ribbons);if(a.length>0&&r.push(...nc(e,t,a)),o.length>0)for(let t of i)r.push(...sc(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,co(t.data)),a=yl(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);o&&o.length>0&&(a.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(a.curve=e.config.curve),e.config.lineGradient&&(a.strokeGradient=e.config.lineGradient),r.push(a)}return lc(e,i,r),r},area:function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=ac(e.ribbons);if(a.length>0&&r.push(...nc(e,t,a)),o.length>0)for(let t of i)r.push(...sc(e,t.data,t.key,o))}let o=e.scales.y.domain(),a=o[0],n=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),s=n&&n.length>0?(()=>{let t=n.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let a=e.scales.y(t),n=e.scales.y(i);return{y:Math.min(a,n),height:Math.abs(n-a),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,l=e.getY0?t=>e.getY0(t)??a:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,co(t.data)),o=ml(t.data,e.scales,e.getX,e.getY,a,i,t.key,l,e.getPointId),c=uc(e.config.gradientFill);c&&(o.fillGradient=c),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n&&n.length>0&&(o.colorThresholds=n,o.strokeColorBands=s),r.push(o)}return lc(e,i,r),r},stackedarea:function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=/* @__PURE__ */new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],a=[],n=0,s=0;for(let i of e)s>n?(r.push(i),n+=t.get(i.key)??0):(a.push(i),s+=t.get(i.key)??0);i.length=0,i.push(...a.reverse(),...r)}}else o();let a=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,n=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=vl(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,a,n,e.getPointId),c=s;if(e.config.pointStyle){let t=/* @__PURE__ */new WeakMap;for(let r of i){let i=l.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),a=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=a&&!Number.isNaN(a)&&i.has(r)&&t.set(o,i.get(r))}}lc(e,i,c,i=>t.get(i)??e.getY(i))}return c},mixed:function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||/* @__PURE__ */new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:a}=ac(e.ribbons);if(a.length>0&&r.push(...nc(e,t,a)),o.length>0)for(let t of i)r.push(...sc(e,t.data,t.key,o))}let a=e.scales.y.domain()[0],n=e.getY0?t=>e.getY0(t)??a:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,co(t.data)),o=ml(t.data,e.scales,e.getX,e.getY,a,i,t.key,n,e.getPointId),s=uc(e.config.gradientFill);s&&(o.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,co(t.data)),o=yl(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return lc(e,i,r),r},scatter:dc,bubble:dc,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return gc(e,t,i);if(0===t.length)return[];let r=Cy(e.config.valueAccessor,"value"),o=cy(e.config.xAccessor,"x"),a=cy(e.config.yAccessor,"y"),n=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){let i=t[e],r=o(i),u=a(i);l[e]=r,c[e]=u,n.has(r)||n.set(r,n.size),s.has(u)||s.set(u,s.size)}let u=n.size,d=s.size;if(0===u||0===d)return[];let h=Array.from(n.keys()),f=Array.from(s.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),g=f.every(e=>"number"==typeof e&&!isNaN(e)),y=4096;if(p&&g&&u*d>y&&t.length>y){let r=/* @__PURE__ */new Set;for(let o=0;t.length>o;o++){let a=n.get(l[o]),d=s.get(c[o]);if(void 0!==a&&void 0!==d&&(r.add(d*u+a),r.size>y))return gc({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(p){h.sort((e,t)=>Number(e)-Number(t)),n.clear();for(let e=0;h.length>e;e++)n.set(h[e],e)}if(g){f.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;f.length>e;e++)s.set(f[e],e)}let m=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=/* @__PURE__ */new Map,w=0;for(let e=0;t.length>e;e++){let i=t[e],o=n.get(l[e]),a=s.get(c[e]);if(void 0===o||void 0===a)continue;let d,h=r(i),f=a*u+o,p=v.get(f);void 0!==p?d=p:(d=w++,v.set(f,d)),m[d]=f,x[d]=h,b[d]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){let t=x[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];let S=e.config.heatmapColorScale,M=S?void 0:fc("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),_=i.width/u,P=i.height/d,$=e.config.showValues,L=e.config.heatmapValueFormat,I=[];for(let t=0;w>t;t++){let i=x[t];if(!isFinite(i))continue;let r=m[t],o=r%u,a=(r-o)/u,n=hc(i,k,A),s=S?S(i):M[n],l=b[t];I.push(pc(Sl(o*_,(d-1-a)*P,_,P,s,l,$?{value:i,showValues:!0,valueFormat:L}:{value:i}),l,e))}return I},bar:function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=hl(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||uo(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=/* @__PURE__ */new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],a=new Set(o),n=Array.from(t).filter(e=>!a.has(e)).sort(),s=o.filter(e=>t.has(e)),l=s.join("\0")+""+n.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...n],e.barCategoryCache={key:l,order:r})}let o=[],a=e.scales,[n,s]=a.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"!=typeof u||0>u?1:u,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity),l?.cursor&&(h.cursor=l.cursor);for(let t of i.values()){let i=Math.max(t.start,n),u=Math.min(t.end,s);if(i>=u)continue;let f=a.x(i),p=a.x(u),g=Math.abs(p-f),y=g>d+1?d:0,m=Math.min(f,p)+y/2,x=Math.max(g-y,1);if(x>0)if(r&&t.categories.size>0){let i=0;for(let n of r){let r=t.categories.get(n)||0;if(0===r)continue;let s=a.y(i),u=a.y(i+r),d=Math.min(s,u),f=Math.abs(s-u),p=(e.config.barColors?Pe(e.config.barColors,n):void 0)??l?.fill??c??"#4e79a7",g=no({binStart:t.start,binEnd:t.end,total:t.total,category:n,categoryValue:r},t.categoryRows?.get(n)),y=e.config.areaStyle?.(g)??{};o.push(Al(m,d,x,f,{fill:p,...h,...y},g,n)),i+=r}}else{let i=a.y(0),r=a.y(t.total),n=Math.min(i,r),s=Math.abs(i-r),u=l?.fill||c||"#007bff",d=no({binStart:t.start,binEnd:t.end,total:t.total},t.rows),f=e.config.areaStyle?.(d)??{};o.push(Al(m,n,x,s,{fill:u,...h,...f},d))}}let f=/* @__PURE__ */new Set;for(let e of i.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}},swarm:function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,a=r.fill??e.config.themeSemantic?.primary??"#007bff",n=r.opacity??.7,s=r.stroke,l=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),f=a;if(e.getCategory){let t=e.getCategory(r)+"";f=(e.config.barColors?Pe(e.config.barColors,t):void 0)??f}let{r:p,...g}=e.config.pointStyle?.(r)??{},y={type:"point",x:d,y:h,r:p??o,style:{fill:f,opacity:n,stroke:s,strokeWidth:l,cursor:c,...g},datum:r};e.getPointId&&(y.pointId=e.getPointId(r)+""),i.push(y)}return i},waterfall:function(e,t,i){let r=[],o=e.scales,a=e.config.waterfallStyle,n=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===n.length)return r;let s=a?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=a?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=a?.gap??1,u=a?.stroke,d=a?.strokeWidth,h=a?.opacity,f=0;for(let t=0;n.length>t;t++){let p=n[t],g=e.getX(p),y=e.getY(p),m=f+y,x=o.x(g),b=t>0?o.x(e.getX(n[t-1])):void 0,v=n.length-1>t?o.x(e.getX(n[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(0>=S){f=m;continue}let M=o.y(f),_=o.y(m),P=Math.min(M,_),$=Math.abs(M-_),L=0>y?l:s,I={...p,baseline:f,cumEnd:m,delta:y,_connectorStroke:a?.connectorStroke,_connectorWidth:a?.connectorWidth},R={fill:L,stroke:u,strokeWidth:d,opacity:h,cursor:a?.cursor,...e.config.areaStyle?.(I)};r.push(Al(A,P,S,$,R,I)),f=m}return r},candlestick:function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],a=e.config.candlestickStyle||{},n=a.rangeColor||"#6366f1",s=r?n:a.upColor||"#28a745",l=r?n:a.downColor||"#dc3545",c=r?n:a.wickColor||"#333",u=a.wickWidth||(r?2:1),d=a.bodyWidth??0;if(null==a.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;i.length>o;o++){let a=e.scales.x(i[o]),n=Math.abs(a-r);n>0&&t>n&&(t=n),r=a}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let n of t){let t=e.getX(n);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(n),f=e.getLow(n);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;let p=r?h:e.getOpen(n),g=r?f:e.getClose(n);if(!r&&(null==p||Number.isNaN(p)||null==g||Number.isNaN(g)))continue;let y=g>=p,m=e.config.pointStyle?.(n)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(g),highY:e.scales.y(h),lowY:e.scales.y(f),bodyWidth:d,upColor:x&&y?x:s,downColor:x&&!y?x:l,wickColor:b??(r&&x?x:c),wickWidth:v??u,isUp:y,style:{cursor:a.cursor,...m,...void 0!==w&&{opacity:w}},datum:n};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o},custom:()=>[]};import*as Ik from"react";import{area as Rk,line as Tk}from"d3-shape";import*as Ck from"react";import{jsx as Dk,jsxs as zk}from"react/jsx-runtime";var Ek={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};import*as Nk from"react";import{jsx as Ok}from"react/jsx-runtime";import{jsx as Fk,jsxs as Wk}from"react/jsx-runtime";var jk=/* @__PURE__ */new Set;import{scaleOrdinal as Bk}from"d3-scale";import{jsx as Yk,jsxs as Xk}from"react/jsx-runtime";import*as Gk from"react";var Vk=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),qk={INVALID_PROJECTION:"Check endpoint values and the scale domain, especially log-scale values.",INSUFFICIENT_SPACE:"Increase chart height or the label-side margin, or reduce the label font size.",TIED_ENDPOINTS:"Use connectors or a legend to distinguish series sharing an endpoint.",LABEL_OMITTED:"Consult the accessible series list; increase the label rail space to restore visible labels.",ESTIMATED_METRICS:"Load the intended font and remeasure before asserting collision-free text.",RENDER_FAILURE:"Inspect the annotation renderer; the placed label did not produce a node.",UNSUPPORTED_GEOMETRY:"Inspect custom-rendered text; its geometry has not been measured by the label solver.",LABEL_COLLISION:"Increase spacing or shorten the affected labels.",LABEL_OVERFLOW:"Increase the allocated bounds or shorten the affected labels."};import{jsx as Hk,jsxs as Uk}from"react/jsx-runtime";import{jsx as Zk,jsxs as Kk}from"react/jsx-runtime";var Qk="var(--semiotic-bg, #ffffff)";import{jsx as Jk}from"react/jsx-runtime";import{jsx as eA,jsxs as tA}from"react/jsx-runtime";import{jsx as iA,jsxs as rA}from"react/jsx-runtime";import{jsx as oA}from"react/jsx-runtime";var aA={secondary:0,primary:3},nA=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);import{jsx as sA}from"react/jsx-runtime";var lA={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};import{packEnclose as cA}from"d3-hierarchy";import{area as uA,curveBasis as dA,curveCardinal as hA,curveCatmullRom as fA,curveLinear as pA,curveMonotoneX as gA,curveMonotoneY as yA,curveStep as mA,curveStepAfter as xA,curveStepBefore as bA}from"d3-shape";import*as vA from"react";import{jsx as wA,jsxs as kA}from"react/jsx-runtime";var AA={linear:pA,monotoneX:gA,monotoneY:yA,step:mA,stepAfter:xA,stepBefore:bA,basis:dA,cardinal:hA,catmullRom:fA};import{jsx as SA,jsxs as MA}from"react/jsx-runtime";import{jsx as _A}from"react/jsx-runtime";import*as PA from"react";import{jsx as $A}from"react/jsx-runtime";var LA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];import{jsx as IA,jsxs as RA}from"react/jsx-runtime";var TA={right:110,left:110,top:50,bottom:80};import{jsx as CA,jsxs as DA}from"react/jsx-runtime";var zA={top:50,right:40,bottom:60,left:70},EA={top:20,right:80,bottom:20,left:80},NA={top:40,right:40,bottom:40,left:40},OA=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]);import{jsx as FA,jsxs as WA}from"react/jsx-runtime";import{Fragment as jA,jsx as BA,jsxs as YA}from"react/jsx-runtime";yc();import*as XA from"react-dom/server";import{jsx as GA,jsxs as VA}from"react/jsx-runtime";import{jsx as qA,jsxs as HA}from"react/jsx-runtime";import{jsx as UA,jsxs as ZA}from"react/jsx-runtime";var KA={top:4,bottom:4,left:4,right:4},QA={frameType:"xy",buildProps:Zd,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:a,rest:n}=Kd(e),[s,l]=a.size??[600,400],c=n.minimap&&"object"==typeof n.minimap?n.minimap:{},u=Jd(c.height,60),d=a.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},f={top:Jd(h.top,0),right:Jd(h.right,Jd(d?.right,20)),bottom:Jd(h.bottom,20),left:Jd(h.left,Jd(d?.left,40))},p=u+f.top+f.bottom,g=n.frameProps&&"object"==typeof n.frameProps?n.frameProps:{},y={...n,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y"},m={...a,size:[s,l],xExtent:g.xExtent??n.brushExtent??a.xExtent,yExtent:g.yExtent??n.yExtent??a.yExtent,_idPrefix:(a._idPrefix??"minimap")+"-detail"},x=pv.buildProps(i,r,o,m,y);Object.assign(x,g);let b={...a,size:[s,p],margin:f,title:void 0,description:(a.description??a.title??"Chart")+" overview minimap",showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:n.yExtent??a.yExtent,_idPrefix:(a._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;let v={...y,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=pv.buildProps(i,r,o,b,v);w.chartType=n.fillArea?"area":"line","function"==typeof c.lineStyle&&(w.lineStyle=c.lineStyle);let k={},A={},S=Id(x,k),M=Id(w,A),_=!0===n.renderBefore,P=_?0:l,$=""+th(S,0,_?p:0,"detail")+th(M,0,P,"overview"),L=l+p,I=Pi(_i(a.theme)),R="string"==typeof a.title?a.title:void 0,T="string"==typeof a.description?a.description:R||"Chart with overview minimap",C=yd(a),D=R?C+"-title":void 0,z=C+"-description",E="y"===c.brushDirection?"y":"x",N=Array.isArray(n.brushExtent)&&n.brushExtent.length>=2?[Number(n.brushExtent[0]),Number(n.brushExtent[1])]:null,O=A.evidence,F=null;if(N&&N.every(Number.isFinite)&&O){let e="x"===E?O.xDomain:O.yDomain;if(e&&e[0]!==e[1]){let t=Math.max(0,s-f.left-f.right),i=u,r=t=>(t-e[0])/(e[1]-e[0]);if("x"===E){let e=r(Math.min(...N))*t,o=r(Math.max(...N))*t;F=/* @__PURE__ */UA("rect",{className:"selection",x:f.left+e,y:P+f.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{let e=(1-r(Math.max(...N)))*i,o=(1-r(Math.min(...N)))*i;F=/* @__PURE__ */UA("rect",{className:"selection",x:f.left,y:P+f.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}let W=Zw.renderToStaticMarkup(
|
|
346
|
+
/* @__PURE__ */ZA("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:s,height:L,role:"img","aria-labelledby":[D,z].filter(Boolean).join(" "),style:{fontFamily:I.fontFamily},children:[R&&/* @__PURE__ */UA("title",{id:D,children:R}),
|
|
347
|
+
/* @__PURE__ */UA("desc",{id:z,children:T}),
|
|
348
|
+
/* @__PURE__ */UA("g",{dangerouslySetInnerHTML:{__html:$}}),F]}));if(t){let e=[k.evidence,A.evidence];t.evidence=mc({frameType:"xy",width:s,height:L,parts:e,title:R,description:T,xDomain:ih(e,"xDomain"),yDomain:ih(e,"yDomain")})}return W}},JA={MotifBraidChart:Bb,DependencyForestChart:Yb,FlowCircuitChart:Xb,Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,r,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...r,showAxes:!1,margin:r.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:cv,LineChart:pv,AreaChart:yv,DifferenceChart:mv,StackedAreaChart:xv,Scatterplot:Jb,CandlestickChart:bv,BubbleChart:ev,ConnectedScatterplot:wv,QuadrantChart:vv,Heatmap:Wv,WaterfallChart:fv,MultiAxisLineChart:hv,MinimapChart:QA,ScatterplotMatrix:{frameType:"xy",buildProps:Zd,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:a,rest:n}=Kd(e),s=Qd(i),l=Array.isArray(n.fields)?n.fields.filter(e=>"string"==typeof e):[],c=n.fieldLabels&&"object"==typeof n.fieldLabels?n.fieldLabels:{},u=eh(n.cellSize,150),d=Math.max(0,Jd(n.cellGap,4)),h=Math.max(0,Jd(n.pointRadius,2)),f=Math.max(0,Math.min(1,Jd(n.pointOpacity,.5))),p=eh(n.histogramBins,20),g="string"==typeof n.diagonal?n.diagonal:"histogram",y=40+l.length*u+l.length*d,m=l.length*u+40+l.length*d,x=_i(a.theme),b=Pi(x),v=oh(s,r,o,x),w="string"==typeof a.title?a.title:void 0,k="string"==typeof a.description?a.description:`Scatterplot matrix comparing ${l.length} fields`,A=w?28:0,S=n.showLegend??!!r?v.categories:[],M=e=>Math.max(72,30+7*e.length),_=0,P=0,$=S.map(e=>{let t=M(e);_>0&&_+t>y&&(P+=1,_=0);let i={label:e,x:_,y:24*P};return _+=t,i}),L=A+(S.length?24*(P+1)+4:0),I=L+m,R=[],T=[],C=0;l.forEach((e,t)=>{l.forEach((i,o)=>{let l=40+d+o*(u+d),y=L+t*(u+d);if(t===o){let t=ah({data:s,field:e,label:Pe(c,e)??e,cellSize:u,bins:p,diagonal:g,colorBy:r,color:v.color,x:l,y:y});return C+=t.visibleBars,void T.push(t.svg)}let m={},x=Id({chartType:"scatter",data:s,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:Vy(e=>({r:h,opacity:f,fill:v.color(e)}),n.styleRules,Yy(i,e)),margin:KA,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Pe(c,i)??i} versus ${Pe(c,e)??e} scatterplot`,theme:a.theme,_idPrefix:`${(a._idPrefix??"splom")+""}-${t}-${o}`},m);R.push(m.evidence),T.push(th(x,l,y,`cell-${e}-${i}`))})});let D=yd(a),z=w?D+"-title":void 0,E=D+"-description",N=Zw.renderToStaticMarkup(
|
|
349
|
+
/* @__PURE__ */ZA("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:y,height:I,role:"img","aria-labelledby":[z,E].filter(Boolean).join(" "),style:{fontFamily:b.fontFamily},children:[w&&/* @__PURE__ */UA("title",{id:z,children:w}),
|
|
350
|
+
/* @__PURE__ */UA("desc",{id:E,children:k}),
|
|
351
|
+
/* @__PURE__ */UA("rect",{width:y,height:I,fill:b.background}),w&&/* @__PURE__ */UA("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:b.text,children:w}),$.map(e=>{let t=s.find(t=>r&&rh(t,r)===e.label),i=t?v.color(t):Ix;/* @__PURE__ */
|
|
352
|
+
return ZA("g",{transform:`translate(${e.x},${A+e.y})`,children:[
|
|
353
|
+
/* @__PURE__ */UA("circle",{cx:5,cy:8,r:5,fill:i}),
|
|
354
|
+
/* @__PURE__ */UA("text",{x:14,y:12,fontSize:11,fill:b.text,children:e.label})]},e.label)}),l.map((e,t)=>{let i=L+t*(u+d)+u/2;/* @__PURE__ */
|
|
355
|
+
return UA("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Pe(c,e)??e},"row-"+e)}),l.map((e,t)=>/* @__PURE__ */UA("text",{x:40+d+t*(u+d)+u/2,y:L+l.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Pe(c,e)??e},"column-"+e)),
|
|
356
|
+
/* @__PURE__ */UA("g",{dangerouslySetInnerHTML:{__html:T.join("")}})]}));return t&&(t.evidence=mc({frameType:"xy",width:y,height:I,parts:R,additionalMarkCountByType:C>0?{histogram:C}:void 0,title:w,description:k,categories:v.categories.length?v.categories:void 0,legendItems:S.length||void 0})),N}},TemporalHistogram:gv,RealtimeLineChart:jv,RealtimeHistogram:Bv,RealtimeHeatmap:Yv,RealtimeSwarmChart:Xv,RealtimeWaterfallChart:Gv,XYCustomChart:Zm,BarChart:aw,StackedBarChart:nw,GroupedBarChart:sw,PieChart:lw,DonutChart:cw,Histogram:uw,BoxPlot:dw,ViolinPlot:hw,SwarmPlot:fw,DotPlot:pw,SwimlaneChart:yw,RidgelinePlot:mw,LikertChart:Qv,FunnelChart:xw,RadarChart:gw,GaugeChart:ow,OrdinalCustomChart:Km,ParallelCoordinatesRecipe:Jm,CalendarHeatmapRecipe:ex,ForceDirectedGraph:Nw,NetworkCustomChart:Qm,SankeyDiagram:jw,ProcessSankey:Ww,ChordDiagram:Ew,TreeDiagram:Bw,Treemap:Yw,CirclePack:Ow,OrbitDiagram:Fw,ChoroplethMap:Vw,ProportionalSymbolMap:qw,FlowMap:Uw,DistanceCartogram:Hw,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,r,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},GaltonBoardChart:vb,EventDropChart:wb,UnitPileChart:kb,CollisionSwarmChart:Ab,ProcessFlowChart:Sb,GauntletChart:Mb,CrucibleChart:_b,PacketFlowChart:Pb,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:Zd,renderStatic:function(e,t){let{data:i,common:r,rest:o}=Vd(e),a=qd(i),[n,s]=r.size??[920,620],l="string"==typeof r.title?r.title:"Dependency chain reaction",c=Bd({data:a,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=_i(r.theme),d=Pi(u),h=yd(r),f=h+"-title",p=h+"-description";if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=XA.renderToStaticMarkup(
|
|
357
|
+
/* @__PURE__ */HA("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:n,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{fontFamily:d.fontFamily},children:[
|
|
358
|
+
/* @__PURE__ */qA("title",{id:f,children:l}),
|
|
359
|
+
/* @__PURE__ */qA("desc",{id:p,children:e}),
|
|
360
|
+
/* @__PURE__ */qA("rect",{width:n,height:s,fill:d.background}),
|
|
361
|
+
/* @__PURE__ */qA("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:l}),c.diagnostics.map((e,t)=>/* @__PURE__ */qA("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=mc({frameType:"physics",width:n,height:s,parts:[],title:l,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=Xd(c,{width:n,height:s}),y=Ed(c,"snapshot",Cd(o.currentTime,1/0),!0),m=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],x=new Set(m),b=m[0]??null,v=b&&"none"!==o.insight?Gd(c,b,{completedTaskIDs:y.completed}):null,w=new Set(v?.downstreamTaskIDs??[]),k=Hd(o.seed,31),A=Ud(c,y,r.description),S=XA.renderToStaticMarkup(
|
|
362
|
+
/* @__PURE__ */qA(Td,{machine:c,layout:g,runtime:y,downstreamSet:w,selectedSet:x,width:n,height:s,seed:k,reduced:!0,onSelectTask:()=>{}})),M=void 0===r.theme?{}:jy(u),_=XA.renderToStaticMarkup(
|
|
363
|
+
/* @__PURE__ */HA("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:n,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{...M,fontFamily:d.fontFamily},children:[
|
|
364
|
+
/* @__PURE__ */qA("title",{id:f,children:l}),
|
|
365
|
+
/* @__PURE__ */qA("desc",{id:p,children:A}),
|
|
366
|
+
/* @__PURE__ */qA("rect",{width:n,height:s,fill:d.background}),
|
|
367
|
+
/* @__PURE__ */qA("text",{x:n/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:l}),
|
|
368
|
+
/* @__PURE__ */qA("g",{dangerouslySetInnerHTML:{__html:S}})]}));return t&&(t.evidence=mc({frameType:"physics",width:n,height:s,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:l,description:A,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),_}},PhysicsCustomChart:$b};import*as eS from"react";import{jsx as tS}from"react/jsx-runtime";var iS=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);import*as rS from"react-dom/server";import{scaleBand as oS,scaleLinear as aS}from"d3-scale";var nS=class{constructor(){this.colorSchemeMap=/* @__PURE__ */new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:Pe(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Rx,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};import{quantileSorted as sS}from"d3-array";import{scaleLinear as lS}from"d3-scale";var cS={bar:function(e,t){let{scales:i,columns:r,config:o,getR:a,getStack:n,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,f=o.normalize,p=[];if(n){let e=/* @__PURE__ */new Set;for(let t of Object.values(r))for(let i of t.pieceData){let t=n(i);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(let e of Object.values(r)){let t=/* @__PURE__ */new Map;for(let i of e.pieceData){let e=n?n(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let r=t.get(e);r.total+=a(i),r.pieces.push(i)}let i=0;if(f)for(let e of t.values())i+=Math.abs(e.total);let r=0,o=0;for(let a of p){let c=t.get(a);if(!c)continue;let p=c.total;f&&i>0&&(p/=i);let g=s(c.pieces[0],n?a:e.name),y={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(d){let t=l(0>p?o:r+p),i=0>p?l(o+p)-l(o):l(r)-l(r+p);u.push(Al(e.x,t,e.width,Math.abs(i),g,y,a)),0>p?o+=p:r+=p}else if(h){let t=l(0>p?o+p:r),i=0>p?l(o)-l(o+p):l(r+p)-l(r);u.push(Al(t,e.x,Math.abs(i),e.width,g,y,a)),0>p?o+=p:r+=p}}}let g="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=g?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=/* @__PURE__ */new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){let t=e.reduce(g?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=ch(o.roundedTop,t,g);i>0&&(t.roundedTop=i)}if(i.length>0){let e=i.reduce(g?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=ch(o.roundedTop,e,g);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:a,getGroup:n,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h=[],f=/* @__PURE__ */new Set;for(let e of Object.values(r))for(let t of e.pieceData){let e=n?n(t):"_default";f.has(e)||(f.add(e),h.push(e))}let p=h.length||1;for(let e of Object.values(r)){let t=e.width/p,i=.2*t,r=t-i,o=/* @__PURE__ */new Map;for(let t of e.pieceData){let e=n?n(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let n=0;h.length>n;n++){let c=o.get(h[n])||[];for(let o of c){let c=a(o),f=s(o,h[n]);if(d){let a=e.x+n*t+i/2,s=l(0),d=l(c);u.push(Al(a,Math.min(s,d),r,Math.abs(s-d),f,o,h[n]))}else{let a=e.x+n*t+i/2,s=l(0),d=l(c);u.push(Al(Math.min(s,d),a,Math.abs(d-s),r,f,o,h[n]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=a(e.datum),i=ch(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:a,resolvePieceStyle:n}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d="radial"===l,h=a.length>0,f=uh(e),p=2*Math.PI,g=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,l=t.__rIndex??0,y=t.__rValue??o(t),m=h&&a[l]||s,x=n(t,e.name),b=x.r||5;if(d){let t=g+(e.pctStart+e.pct/2)*p,o=m(y);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=m(y)):(i=m(y),r=e.middle);dh(c,f,t,i,r,b,x)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:a}=e,{r:n,projection:s}=i,l=[],c="vertical"===s,u=uh(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;e.pieceData.length>i;i++){let r=e.pieceData[i],s=o(r),d=a(r,e.name),h=d.r||4,f=(7919*i%100/100-.5)*t*.8;dh(l,u,r,c?e.middle+f:n(s),c?n(s):e.middle+f,h,d)}}return l},pie:hh,donut:hh,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=ph(i),{min:o,max:l,q1:h,median:f,q3:p}=r,g=p-h,y=h-1.5*g,m=p+1.5*g,x=i.find(e=>e>=y)??o,b=l;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){b=i[e];break}r.min=x,r.max=b;let v=n(fh(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=a(e);if(y>i||i>m){let r=u?t.middle:s(i),o=u?s(i):t.middle;w.push({px:r,py:o,value:i,datum:e})}}if(c.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:s(x),q1Pos:s(h),medianPos:s(f),q3Pos:s(p),maxPos:s(b),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/d||1,f=gh(t,r,o,l,d),p=Fm(f,1),g=e.width/2*.9;if(u){i=`M ${e.middle} ${s(r)}`;for(let t=0;d>t;t++){let o=s(r+(t+.5)*l);i+=` L ${e.middle+f[t]/p*g} ${o}`}i+=` L ${e.middle} ${s(o)}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l);i+=` L ${e.middle-f[t]/p*g} ${o}`}i+=" Z"}else{i=`M ${s(r)} ${e.middle}`;for(let t=0;d>t;t++)i+=` L ${s(r+(t+.5)*l)} ${e.middle-f[t]/p*g}`;i+=` L ${s(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)i+=` L ${s(r+(t+.5)*l)} ${e.middle+f[t]/p*g}`;i+=" Z"}let y,m=ph(t),x=n(fh(e.pieceData,e.name,m),e.name);h&&t.length>=4&&(y={q1Pos:s(m.q1),medianPos:s(m.median),q3Pos:s(m.q3),centerPos:e.middle,isVertical:u});let b=u?{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))}:{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,iqrLine:y,stats:m,style:x,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:s}=i,l=[],c=o.bins||25,u=o.normalize,d=s.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=Nm(t),o=null!=h&&isFinite(h)?h:i,d=null!=f&&isFinite(f)?f:r,p=(d-o)/c||1,g=gh(t,o,d,p,c),y=t.length,m=Fm(g,1);for(let t=0;c>t;t++){if(0===g[t])continue;let i=(u?g[t]/y:g[t]/m)*e.width*.9,r=s(o+t*p),a=s(o+(t+1)*p),c=Math.min(r,a),d=Math.abs(a-r),h=e.x+e.width-i,f={...e.pieceData[0],bin:t,count:g[t],range:[o+t*p,o+(t+1)*p],category:e.name,data:e.pieceData},x=n(f,e.name);l.push(Al(c,h,d,i,x,f,e.name))}}return l},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:a,resolveSummaryStyle:n}=e,{r:s,projection:l}=i,c=[],u=o.bins||20,d="horizontal"===l,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/u||1,f=gh(t,r,o,l,u),p=Fm(f,1),g=ph(t),y=n(fh(e.pieceData,e.name,g),e.name),m=e.width*h;if(d){let t=e.x+e.width;i=`M ${s(r)} ${t}`;for(let e=0;u>e;e++)i+=` L ${s(r+(e+.5)*l)} ${t-f[e]/p*m}`;i+=` L ${s(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${s(r)}`;for(let e=0;u>e;e++){let o=s(r+(e+.5)*l);i+=` L ${t+f[e]/p*m} ${o}`}i+=` L ${t} ${s(o)} Z`}let x=d?{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width}:{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,stats:g,style:{...y,fillOpacity:y.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:a}=e,{r:n,projection:s}=i,l=[],c="horizontal"===s;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,s]=i,u=a(t,e.name);if(c){let i=n(Math.min(r,s)),o=n(Math.max(r,s));l.push(Al(i,e.x,o-i,e.width,u,t,e.name))}else{let i=n(Math.max(r,s)),o=n(Math.min(r,s));l.push(Al(e.x,i,e.width,o-i,u,t,e.name))}}return l},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:a}=e,n=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return n;let u=[],d=/* @__PURE__ */new Set;for(let e of c)for(let t of e.pieceData){let e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}let h=u.length>1&&"_default"!==u[0],f=[],p=0;for(let e of c){let t=/* @__PURE__ */new Map,i=0;for(let a of e.pieceData){let e=o?o(a):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let n=t.get(e),s=r(a);n.total+=s,n.pieces.push(a),i+=s}f.push({col:e,groups:t,stepTotal:i}),h||i>p&&(p=i)}if(h)for(let e of f){let t=0,i=0;for(let r=0;u.length>r;r++){let o=e.groups.get(u[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>p&&(p=r)}if(0===p)return n;let g=/* @__PURE__ */new Map;for(let e of u){let t=f[0].groups.get(e);g.set(e,t?.total??0)}let y=f[0].stepTotal,m=h?.95*s:.9*t.width,x=lS().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3,v=/* @__PURE__ */new Map;for(let t=0;f.length>t;t++){let i=f[t],r=i.col,o=0===t,c=r.width,d=.55*c,p=r.x+(c-d)/2,m=/* @__PURE__ */new Map;if(h){let e=0;for(let t of u){let r=i.groups.get(t);r&&(e+=x(r.total))}let t=s,c=s;for(let h=0;u.length>h;h++){let f=u[h],y=i.groups.get(f);if(!y)continue;let b=x(y.total),v=h%2==0,w=v?t:c-b;v?t+=b:c-=b;let k=a(y.pieces[0],f),A=g.get(f)??y.total,S={...y.pieces[0],__funnelValue:y.total,__funnelPercent:A>0?y.total/A*100:0,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:f};l&&(0===h&&(S.__funnelStepLabel=r.name,S.__funnelStepLabelX=s,S.__funnelStepLabelY=p,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=p,S.__funnelBarW=b),n.push(Al(w,p,b,d,k,S,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{let e=i.stepTotal,t=x(e),c=s-t/2,h=u[0],f="_default"!==h,g=i.groups.get(h)?.pieces[0]??r.pieceData[0],b=f?h:r.name,v=a(g,b),w=y>0?e/y*100:0,k={...g,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:f?h:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=p,k.__funnelBarW=t),n.push(Al(c,p,t,d,v,k,b)),m.set(h,{x:c,y:p,w:t,h:d})}if(t>0&&v.size>0){let t=h?u:[u[0]];for(let o of t){let t=v.get(o),s=m.get(o);if(!t||!s)continue;let l=(()=>{let e=i.groups.get(o);return a(e?e.pieces[0]:r.pieceData[0],"_default"===o?r.name:o)})(),c={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:b,cursor:l.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};n.push(c)}}v=m}return n},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:a,scales:n}=e,s=[],l=n.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;let c=[],u=/* @__PURE__ */new Set;for(let e of l)for(let t of e.pieceData){let e=o?o(t):"_default";u.has(e)||(u.add(e),c.push(e))}let d=c.length>1&&"_default"!==c[0],h=[];for(let e of l){let t=/* @__PURE__ */new Map,i=0;for(let a of e.pieceData){let e=o?o(a):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let n=t.get(e),s=r(a);n.total+=s,n.pieces.push(a),i+=s}h.push({col:e,groups:t,stepTotal:i})}let f=/* @__PURE__ */new Map;for(let e of c){let t=h[0]?.groups.get(e);f.set(e,t?.total??0)}let p=n.r,g=d?c.length:1,y=d?.15:0;for(let e=0;h.length>e;e++){let t=h[e],i=t.col,r=0===e,o=e>0?h[e-1]:null,n=i.width/g,l=n*y,u=n-l;for(let e=0;c.length>e;e++){let h=c[e],g=t.groups.get(h);if(!g)continue;let y=g.total,m=f.get(h)??y,x=m>0?y/m*100:0,b=o?.groups.get(h)?.total??y,v=r?0:Math.max(0,b-y),w=i.x+e*n+l/2,k=p(y),A=p(0)-k,S=a(g.pieces[0],d?h:i.name),M={...g.pieces[0],__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(y+v)};if(s.push(Al(w,k,u,A,S,M,d?h:i.name)),v>0){let e=p(y+v),t=k-e,r={...S},o={...g.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};s.push(Al(w,e,u,t,r,o,d?h:i.name))}}}return s},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:a,resolvePieceStyle:n}=e,{r:s,projection:l}=i,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",f=/* @__PURE__ */new Map,p=t=>{let i=f.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return f.set(t,o),o},g=e.config.trackFill;if(g){let e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[i,o]=s.range(),a=Math.min(i,o),n=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?Al(a,i.x,n,i.width,r,null,"__track__"):Al(i.x,a,i.width,n,r,null,"__track__"),s=p(i);s>0&&(o.cornerRadii={tl:s,tr:s,br:s,bl:s}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=p(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let l,f=a?a(i):e.name,p=n(i,f);if(u){let o=s(t),a=s(t+r);l=Al(o,e.x,a-o,e.width,p,i,f)}else{let o=s(t+r),a=s(t);l=Al(e.x,o,e.width,a-o,p,i,f)}d&&(l.fillGradient=d,l.roundedEdge=h),c.push(l),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}},uS=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dS=["scene-style","data-paint","accessibility","evidence"],hS=(e,t)=>({retainedData:e,invalidations:t}),fS=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pS=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gS=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yS=["scene-geometry","data-paint","accessibility","evidence"],mS=["scene-style","data-paint","accessibility","evidence"],xS=[],bS={chartType:hS("rebuild",fS),runtimeMode:hS("rebuild",fS),categoryAccessor:hS("rebuild",fS),valueAccessor:hS("rebuild",fS),oAccessor:hS("rebuild",fS),rAccessor:hS("rebuild",fS),stackBy:hS("rebuild",fS),groupBy:hS("rebuild",fS),timeAccessor:hS("rebuild",fS),accessorRevision:hS("rebuild",fS),colorAccessor:hS("rebuild",mS),symbolAccessor:hS("rebuild",yS),connectorAccessor:hS("rebuild",yS),dataIdAccessor:hS("rebuild",yS),projection:hS("preserve",pS),extentPadding:hS("preserve",pS),axisExtent:hS("preserve",pS),rExtent:hS("preserve",pS),oExtent:hS("preserve",pS),multiAxis:hS("preserve",pS),normalize:hS("preserve",pS),bins:hS("preserve",pS),oSort:hS("preserve",gS),barPadding:hS("preserve",gS),roundedTop:hS("preserve",gS),baselinePadding:hS("preserve",gS),innerRadius:hS("preserve",gS),cornerRadius:hS("preserve",gS),startAngle:hS("preserve",gS),sweepAngle:hS("preserve",gS),trackFill:hS("preserve",gS),showOutliers:hS("preserve",gS),showIQR:hS("preserve",gS),amplitude:hS("preserve",gS),connectorOpacity:hS("preserve",gS),showLabels:hS("preserve",gS),dynamicColumnWidth:hS("rebuild",gS),customLayout:hS("preserve",gS),layoutConfig:hS("preserve",gS),layoutMargin:hS("preserve",gS),symbolMap:hS("preserve",yS),pieceStyle:hS("preserve",mS),summaryStyle:hS("preserve",mS),connectorStyle:hS("preserve",mS),gradientFill:hS("preserve",mS),colorScheme:hS("preserve",mS),themeCategorical:hS("preserve",mS),themeSemantic:hS("preserve",mS),themeSequential:hS("preserve",mS),themeDiverging:hS("preserve",mS),barColors:hS("preserve",mS),decay:hS("preserve",mS),pulse:hS("preserve",mS),staleness:hS("preserve",mS),layoutSelection:hS("preserve",mS),windowSize:hS("preserve",xS),windowMode:hS("preserve",xS),clock:hS("preserve",xS),transition:hS("preserve",xS),introAnimation:hS("preserve",xS),onLayoutError:hS("preserve",xS)},vS=hS("preserve",gS),wS=class{constructor(){this.tracker=new Qy}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},uS)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},dS):this.recordNoop("restyle")}recordConfig(e){let t=bh(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as kS}from"d3-quadtree";var AS=class{constructor(e){this.rExtent=new ek,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new wS,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new nS,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=/* @__PURE__ */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=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */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 Jw(e.windowSize),this.getO=uy(e.categoryAccessor||e.oAccessor,"category");let t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Cy(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new ek)):(this.getR=Cy(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=uy(e.stackBy),this.getGroup=uy(e.groupBy),this.getColor=uy(e.colorAccessor),this.getSymbol=uy(e.symbolAccessor),this.getConnector=uy(e.connectorAccessor),this.getDataId=uy(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Jw(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Xl(t,r):null)}currentTime(){return this.config.clock?.()??Ps()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Yl(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Gl(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=Gl(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),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){let 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){let 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){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.multiScales,a=this.columns;if(0===i.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=/* @__PURE__ */new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);let n,s,l=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(l),d=this.computeValueDomain(l,u),h="horizontal"===c,f="radial"===c,p=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===c?e.width:e.height):.1));if(f){n=oS().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;s=aS().domain(d).range([r,i])}else h?(n=oS().domain(u).range([0,e.height]).padding(p),s=aS().domain(d).range([0,e.width])):(n=oS().domain(u).range([0,e.width]).padding(p),s=aS().domain(d).range([e.height,0]));this.scales={o:n,r:s,projection:c},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,o)=>{let a=this.rExtents[o];a.dirty&&a.recalculate(i,r);let[n,s]=a.extent;n===1/0&&(n=0,s=1);let l=s-n,c=l>0?l*(t.extentPadding??.05):1;return n-=c,s+=c,n>0&&(n=0),h?aS().domain([n,s]).range([0,e.width]):aS().domain([n,s]).range([e.height,0])}):[];let g=l;this.rAccessors.length>1&&(g=l.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(g,u,n,c,e),this._customLayoutFailedThisBuild=!1;let y=this.buildSceneNodes(g,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,this.columns=a):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,l),this.config.pulse&&this.applyPulse(this.scene,l),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){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=/* @__PURE__ */new Set;for(let t of e)o.add(this.getO(t))}let a=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return a}if(!1===r)return a;if("function"==typeof r)return a.sort(r);let n=/* @__PURE__ */new Map;for(let t of e){let e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return a.sort("asc"===r?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return yh({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,i,r,o){return mh({data:e,oExtent:t,oScale:i,projection:r,layout:o,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.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){let i=this.buildLayoutContext(e,t),r=cl({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let a=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of a)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(a,this.config.layoutSelection??null)}return ol({label:"ordinal customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=cS[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...lh(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Re(i.colorScheme,i.themeCategorical,Rx),a=this.scales;return{data:e,scales:{o:a.o,r:a.r,projection:a.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:"radial"===a.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:i.themeSemantic??{},categorical:[...o]},resolveColor:Te(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?Is(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=Rs(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=xh(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=vh(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;let i=t.length;if(1>=i)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&sh(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Es(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=/* @__PURE__ */new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;this.scene.length>o;o++){let a=this.scene[o],n=this.getNodeKey(a,t);n&&("rect"===a.type?this.prevPositionMap.set(n,r?{x:a.x,y:i,w:a.w,h:0,opacity:a.style.opacity??1}:{x:i,y:a.y,w:0,h:a.h,opacity:a.style.opacity??1}):"point"===a.type?this.prevPositionMap.set(n,{x:a.x,y:a.y,r:0,opacity:0}):"wedge"===a.type&&(void 0===e&&(e=a.startAngle),this.prevPositionMap.set(n,{x:a.cx,y:a.cy,startAngle:e,endAngle:e,innerRadius:a.innerRadius,outerRadius:a.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();let e=/* @__PURE__ */new Map;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(let e=0;this.scene.length>e;e++){let o=this.scene[e],a=this.getNodeKey(o,r);if(!a)continue;o._transitionKey=a;let n=this.prevPositionMap.get(a);if("point"===o.type)n?(i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.x!==o.x||n.y!==o.y||void 0!==n.r&&n.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=n.x,o.y=n.y,void 0!==n.r&&(o.r=n.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)n?(i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.x!==o.x||n.y!==o.y||n.w!==o.w||n.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=n.x,o.y=n.y,o.w=n.w??o.w,o.h=n.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(n)i.add(a),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(n.startAngle!==o.startAngle||n.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=n.startAngle,o.endAngle=n.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(a,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;let t=Ms(e,this.activeTransition),i=Ss(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=_s(r?r.opacity??1:0,e._targetOpacity,i)}let r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=_s(r.x,e._targetX,i),e.y=_s(r.y,e._targetY,i)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=_s(r.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=_s(r?r.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;let r=this.prevPositionMap.get(t);if(!r)continue;e.x=_s(r.x,e._targetX,i),e.y=_s(r.y,e._targetY,i),void 0!==r.w&&(e.w=_s(r.w,e._targetW,i),e.h=_s(r.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style={...e.style,opacity:_s(r?r.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=_s(r.startAngle,e._targetStartAngle,i),e.endAngle=_s(r.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(let 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){let 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,ic(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=As(e),i=this.getDataId,r=e=>t.has(i(e));Vl(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");let i=As(e),r=this.getDataId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let a=this.buffer.update(e=>i.has(r(e)),t);if(0===a.length)return this.updateResults.recordNoop("update"),a;for(let e of a)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",a.length),a}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=/* @__PURE__ */new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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&&!Ty(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Ty(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ty(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Ty(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=uy(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],a=Array.isArray(i)?i:[i];if(o=r.length!==a.length||r.some((e,t)=>!Ty(e,a[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Cy(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new ek)):(this.getR=Cy(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ty(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?uy(this.config.stackBy):void 0),"groupBy"in e&&!Ty(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?uy(this.config.groupBy):void 0),"colorAccessor"in e&&!Ty(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?uy(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ty(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?uy(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ty(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?uy(this.config.connectorAccessor):void 0),(r||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Jl(AS);import*as SS from"react";import*as MS from"react";import{arc as _S}from"d3-shape";var PS=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});import{jsx as $S,jsxs as LS}from"react/jsx-runtime";import{jsx as IS,jsxs as RS}from"react/jsx-runtime";import{jsx as TS,jsxs as CS}from"react/jsx-runtime";import{Fragment as DS,jsx as zS,jsxs as ES}from"react/jsx-runtime";import*as NS from"react-dom/server";var OS=/* @__PURE__ */Object.create(null);import{min as FS}from"d3-array";import{min as WS,max as jS,sum as BS,mean as YS,group as XS,groups as GS}from"d3-array";import{interpolateNumber as VS}from"d3-interpolate";import{line as qS,curveLinearClosed as HS}from"d3-shape";var US=e=>{let t,i,r,o,a,n,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,a=e.source.x1,n=e.target.x0,s=VS(a,n),l=s(.5),c=s(.5),`M${t},${a}C${t},${l} ${i},${c} ${i},${n}L${r},${n}C${r},${c} ${o},${l} ${o},${a}Z`;let u=e.sankeyWidth/2,d=VS(e.source.x1,e.target.x0),{pathD:h}=Wn({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(.5),cp2X:d(.5)});return h},ZS=/* @__PURE__ */new Set,KS=/* @__PURE__ */new WeakMap,QS={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(Jh))-1:0},justify:ef},JS={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o,a="vertical"===i.orientation?"down":"right",n=i.nodeAlign||"justify",s=i.nodeWidth??15,l=i.nodePaddingRatio??.05,c=i.iterations??100,u=e.map(e=>({...e})),d=t.map(e=>({...e,source:hy(e.source),target:hy(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));o="down"===a?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let h=Ef().extent(o).links(d).nodes(u).nodeAlign(QS[n]||ef).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(l),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(let r of u)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(let r of d){if(!r.circular||!r.circularPathData)continue;let a=r.circularPathData,n=(r._circularWidth??r.width??0)/2;e>a.leftFullExtent-n&&(e=a.leftFullExtent-n),a.rightFullExtent+n>t&&(t=a.rightFullExtent+n),i>a.verticalFullExtent-n&&(i=a.verticalFullExtent-n),a.verticalFullExtent+n>o&&(o=a.verticalFullExtent+n)}let a=t-e,n=o-i,s=r[0],l=r[1];if(a>0&&n>0&&(0>e||0>i||t>s||o>l)){let t=Math.min(s/a,l/n),r=-e*t+(s-a*t)/2,o=-i*t+(l-n*t)/2;for(let e of u)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(let e of d)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){let i=e.circularPathData;i.sourceX=i.sourceX*t+r,i.targetX=i.targetX*t+r,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+r,i.leftFullExtent=i.leftFullExtent*t+r,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+r,i.leftInnerExtent=i.leftInnerExtent*t+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}let f=/* @__PURE__ */new Map;for(let t of e)f.set(t.id,t);for(let e of u){let 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)}let p=/* @__PURE__ */new Map;for(let e of t)if(e._edgeKey)p.set(e._edgeKey,e);else{let t=hy(e.source),i=hy(e.target);p.set(`${t}\0${i}`,e)}for(let e of d){let t=hy(e.source),i=hy(e.target),r=p.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=a;let o=f.get(t),n=f.get(i);o&&(r.source=o),n&&(r.target=n)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",a=i.nodeStyle,n=i.edgeStyle,s=i.edgeOpacity??.5,l=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:sx,u=/* @__PURE__ */new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],f=[],p=/* @__PURE__ */new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;let r=a?a(Of(t,"nodeStyle")):{},n={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};p.set(t.id,("string"==typeof n.fill?n.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:n,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:n,datum:t,id:t.id,label:t.id})}let g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of g){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?p.get(r.id)||u.get(r.id)||o:p.get(t.id)||u.get(t.id)||o;let a,c=n?n(Of(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){let t=e.circularPathData,i=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),n=c.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+r},${t.sourceY-i}L${t.sourceX+r},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:n,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-a},${t.targetY-i}L${t.targetX-a},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:n,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}a=e.circular&&e.circularPathData?Nf(e):US(e),a&&h.push({type:"bezier",pathD:a,bezierCache:e.bezier,style:{fill:c.fill||o,fillOpacity:c.fillOpacity??s,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity,cursor:c.cursor},datum:e})}if(!1!==i.showLabels){let t=dy(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,a=i.y1-i.y0;if(0>=e||0>=a)continue;let n,s,l,c=t?t(i):i.id;c&&("down"===o?(n=i.y0+(i.y1-i.y0)/2,s=i.x1+14,l="start"):(r[0]/2>i.x0+e/2?(n=i.x0-6,l="end"):(n=i.x1+6,l="start"),s=i.y0+a/2),f.push({x:n,y:s,text:c+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11}))}}return{sceneNodes:d,sceneEdges:h,labels:f}}};zh("sankey",JS);import{forceSimulation as eM,forceCenter as tM,forceX as iM,forceY as rM,forceLink as oM,forceManyBody as aM,forceCollide as nM}from"d3-force";var sM={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,a=r[0]/2,n=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){let i=/* @__PURE__ */new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=Wf(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=Bf(e.id),a=o%360*(Math.PI/180),n=(10+o%20)*s;e.x=t/r.length+n*Math.cos(a),e.y=i/r.length+n*Math.sin(a)}else{let t=Bf(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=a+r*Math.cos(i),e.y=n+r*Math.sin(i)}}}else{let t=2.399963229728653;for(let i=0;e.length>i;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*s,o=i*t;r.x=a+e*Math.cos(o),r.y=n+e*Math.sin(o)}}}let f=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=im(i.nodeSize,i.nodeSizeRange,e),g=e=>p(e);if(f>0){let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=hy(e.source),i=hy(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=oM().strength(e=>{let t=e.weight,i=hy(e.source),r=hy(e.target),a=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*a))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?g(t):0)+(i?g(i):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),p=eM();if((void 0!==i.random||void 0!==i.seed)&&p.randomSource(i.random??Ff(i.seed)),p.force("charge",aM().strength(e=>{let t=c.get(e.id)??0;return-15*s*g(e)*Math.sqrt(t+1)})).force("collide",nM(e=>g(e)+3*s).strength(.9).iterations(2)).force("center",tM(a,n).strength(.8)).force("x",iM(a).strength(l)).force("y",rM(n).strength(l)).force("bounds",jf(r,g)),p.nodes(e),t.length>0){let e=t.map(e=>({...e,source:hy(e.source),target:hy(e.target)}));d.links(e),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;f>e;++e)p.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=g(t),i=f>0?2:0,o=Math.min(r[0]/2,e+i),a=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(a,Math.min(r[1]-a,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let y=/* @__PURE__ */new Map;for(let t of e)y.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,a=i.edgeStyle,n=im(i.nodeSize,i.nodeSizeRange,e),s=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:sx,l=/* @__PURE__ */new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=n(Of(t,"nodeSize")),r=o?o(Of(t,"nodeStyle")):{},a={fill:r.fill||l.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}let h=/* @__PURE__ */new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=a?a(Of(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){let t=dy(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=n(Of(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};zh("force",sM);import{chord as lM,ribbon as cM}from"d3-chord";import{arc as uM}from"d3-shape";var dM=sx,hM={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let{padAngle:o=.01,groupWidth:a=20,sortGroups:n}=i,s=Math.min(r[0],r[1])/2,l=s-a,c=r[0]/2,u=r[1]/2,d=Yf(i.valueAccessor),h=/* @__PURE__ */new Map;for(let t=0;e.length>t;t++)h.set(e[t].id,t);let f=e.length,p=Array.from({length:f},()=>Array(f).fill(0));for(let e of t){let t=hy(e.source),i=hy(e.target),r=h.get(t),o=h.get(i);if(void 0===r||void 0===o)continue;let a=d(e);p[r][o]=a}let g=lM().padAngle(o);n&&g.sortGroups(n);let y=g(p),m=y.groups,x=uM().innerRadius(l).outerRadius(s);for(let t of m){let i=e[t.index],r=x.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});i.x=r[0]+c,i.y=r[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}let b=/* @__PURE__ */new Map;for(let t of e)b.set(t.id,t);for(let e of t){let t=hy(e.source),i=hy(e.target),r=b.get(t),o=b.get(i);r&&(e.source=r),o&&(e.target=o)}let v=/* @__PURE__ */new Map;for(let e of t){let t=hy(e.source),i=hy(e.target);v.set(`${t}\0${i}`,e)}for(let t of y){let i=e[t.source.index].id,r=e[t.target.index].id,o=v.get(`${i}\0${r}`)||v.get(`${r}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:a=.5}=i,n=Math.min(r[0],r[1])/2,s=n-o,l=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:dM,p=/* @__PURE__ */new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});let g=cM().radius(s),y=[],m=[],x=[];for(let t=0;e.length>t;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(Of(i,"nodeStyle")):{},a={fill:("string"==typeof o.fill?o.fill:void 0)||p.get(i.id)||f[t%f.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};y.push({type:"arc",cx:l,cy:c,innerR:s,outerR:n,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(let e of t){let t=e.__chordData;if(!t)continue;let r=g(t);if(!r)continue;let o=Xf(r,l,c),n=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",s=d?d(Of(e,"edgeStyle")):{};if(d)n=("string"==typeof s.fill?s.fill:void 0)||n;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?n=p.get(i.id)||n:t&&(n=p.get(t.id)||n)}m.push({type:"ribbon",pathD:o,style:{fill:n,fillOpacity:s.fillOpacity??a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity,cursor:s.cursor},datum:e})}if(!1!==i.showLabels){let t=dy(i.nodeLabel),r=n+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let a=(e.startAngle+e.endAngle)/2,n=a-Math.PI/2;x.push({x:l+Math.cos(n)*r,y:c+Math.sin(n)*r,text:o+"",anchor:a>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:y,sceneEdges:m,labels:x}}};zh("chord",hM);import{hierarchy as fM,tree as pM,cluster as gM,treemap as yM,pack as mM,partition as xM,treemapBinary as bM}from"d3-hierarchy";var vM=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],wM={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let a=i.chartType,n=qf(i.childrenAccessor),s=i.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=fM(o,n);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));let[u,d]=r;switch(a){case"tree":rp(c,i,u,d);break;case"cluster":op(c,i,u,d);break;case"treemap":ap(c,i,u,d);break;case"circlepack":np(c,i,u,d);break;case"partition":sp(c,i,u,d)}let h=c.descendants();e.length=0,t.length=0;let f=/* @__PURE__ */new Map;for(let t=0;h.length>t;t++){let r=h[t],o={id:Hf(r,i,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?lp(o,r,i):"treemap"===a||"partition"===a?cp(o,r):"circlepack"===a&&up(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===a||"cluster"===a)for(let e of h)if(e.parent){let i=f.get(e.parent),r=f.get(e);i&&r&&t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.nodeStyle||(()=>({})),a=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return Jf(e,t,i,r,o,a);case"treemap":case"partition":return ep(e,i,0,o);case"circlepack":return tp(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};zh("tree",wM),zh("cluster",wM),zh("treemap",wM),zh("circlepack",wM),zh("partition",wM);import{pie as kM}from"d3-shape";var AM={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&yp(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,a=i.edgeStyle,n=i.nodeSize,s="number"==typeof n?()=>n:"function"==typeof n?n:()=>6,l=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=dp(i),r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,t);let o=/* @__PURE__ */new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let a=48,n={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;a>o;o++){let s=o/a*Math.PI*2,l=(o+1)/a*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(s),y1:t+i*Math.cos(s)*r,x2:e+i*Math.sin(l),y2:t+i*Math.cos(l)*r,style:n,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=s(Of(t,"nodeSize")),r=o?o(Of(t,"nodeStyle")):{};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let d=/* @__PURE__ */new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=a?a(Of(e,"edgeStyle")):{};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor},datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=s(Of(i,"nodeSize"));if(4>=e)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:l,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(mp(e,i),!0)};zh("orbit",AM);import*as SM from"react";import{arc as MM}from"d3-shape";import{jsx as _M,jsxs as PM}from"react/jsx-runtime";import{Fragment as $M,jsxs as LM}from"react/jsx-runtime";zh("sankey",JS),zh("force",sM),zh("chord",hM),zh("tree",wM),zh("cluster",wM),zh("treemap",wM),zh("circlepack",wM),zh("partition",wM),zh("orbit",AM);var IM=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);import*as RM from"react-dom/server";import{geoPath as TM}from"d3-geo";import{quadtree as CM}from"d3-quadtree";import{geoMercator as DM,geoEqualEarth as zM,geoAlbersUsa as EM,geoOrthographic as NM,geoNaturalEarth1 as OM,geoEquirectangular as FM}from"d3-geo";var WM={mercator:DM,equalEarth:zM,albersUsa:EM,orthographic:NM,naturalEarth:OM,equirectangular:FM};import{scaleLinear as jM}from"d3-scale";var BM=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],YM=["scene-style","data-paint","accessibility","evidence"],XM=(e,t)=>({retainedData:e,invalidations:t}),GM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],VM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qM=["scene-geometry","data-paint","accessibility","evidence"],HM=["scene-style","data-paint","accessibility","evidence"],UM=["overlay","accessibility","evidence"],ZM=[],KM={xAccessor:XM("rebuild",GM),yAccessor:XM("rebuild",GM),lineDataAccessor:XM("rebuild",GM),pointIdAccessor:XM("rebuild",qM),lineIdAccessor:XM("rebuild",qM),windowSize:XM("rebuild",GM),projection:XM("preserve",VM),projectionExtent:XM("preserve",VM),fitPadding:XM("preserve",VM),lineType:XM("preserve",VM),flowStyle:XM("preserve",VM),graticule:XM("preserve",VM),projectionTransform:XM("preserve",VM),customLayout:XM("preserve",VM),layoutConfig:XM("preserve",VM),layoutMargin:XM("preserve",VM),areaStyle:XM("preserve",HM),pointStyle:XM("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:XM("preserve",HM),colorScheme:XM("preserve",HM),themeCategorical:XM("preserve",HM),themeDiverging:XM("preserve",HM),themeSemantic:XM("preserve",HM),themeSequential:XM("preserve",HM),decay:XM("preserve",HM),pulse:XM("preserve",HM),layoutSelection:XM("preserve",HM),annotations:XM("preserve",UM),autoPlaceAnnotations:XM("preserve",UM),clock:XM("preserve",ZM),transition:XM("preserve",ZM),introAnimation:XM("preserve",ZM),onLayoutError:XM("preserve",ZM)},QM=XM("preserve",VM),JM=class{constructor(){this.tracker=new Qy}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},BM)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},YM):this.recordNoop("restyle")}recordConfig(e,t={}){let i=Gp(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as e_,geoGraticule as t_,geoInterpolate as i_}from"d3-geo";var r_=class e{constructor(e){var t;this.updateResults=new JM,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */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.config=(t=e,{...t,fitPadding:qp(t.fitPadding)})}currentTime(){return this.config.clock?.()??Ps()}getConfiguredWindowSize(){let e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),a=this.currentTime();this.pointBuffer=new Jw(e),this.timestampBuffer=new Jw(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??a)})}this.retainNewestLines(e)}updateConfig(e){let t="fitPadding"in(a=e)?{...a,fitPadding:qp(a.fitPadding)}:a,i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);var a;this.config={...this.config,...t};let n=this.getConfiguredWindowSize(),s=this.streaming&&n!==r;s&&(this.resizeStreamingWindow(n),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),a=r.slice(-o.length),n=this.currentTime();this.pointBuffer=new Jw(t),this.timestampBuffer=new Jw(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(a[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();Gl(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();for(let i of e)Gl(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!r.has(i(e)+"")||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){let{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(i(e)+"");Vl(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(i(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,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=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,a=this.baseScale,n=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=Rp(t.projection),this.geoPath=TM(this.projection),this.fitProjection(e),this.geoPath=TM(this.projection);let c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=a,this.baseTranslate=n,this.baseRotation=s):(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){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=Tp(i.xAccessor,"lon"),a=Tp(i.yAccessor,"lat"),n=this.getPoints();if(n.length>0){let e=n.map(e=>[o(e),a(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let s=Cp(i.lineDataAccessor);for(let e of this.lineData){let t=s(e);if(t&&t.length>0){let e=t.map(e=>[o(e),a(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[a,n]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,n],[a,n],[a,o],[r,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*r),t.translate([e.width/2,e.height/2])}else{let o=i.fitPadding??0,a=e.width*o,n=e.height*o;t.fitExtent([[a,n],[e.width-a,e.height-n]],{type:"FeatureCollection",features:r})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,a=i.scale(),n=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=TM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(a),i.translate(n),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,a=i.scale(),n=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=TM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(a),i.translate(n),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,a=[...i.rotate()];i.rotate(e),this.geoPath=TM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(a),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let t=this.projection;!t||!t.rotate||t.rotate(e)}hasProjection(){return null!=this.projection}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,i=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);let r=Array(i),o=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(r[o++]=e);this._quadtree=CM().x(e=>e.x).y(e=>e.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Re(t.colorScheme,t.themeCategorical,Rx),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Te(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},a=cl({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let n=a.result,s=n.nodes??[];if(this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this._baseStyles=/* @__PURE__ */new WeakMap,this.hasCustomRestyle)for(let e of s){this._baseStyles.set(e,e.style);let i=n.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return ol({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,Vp({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=Bp(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;i.length>r;r++){let o=Is(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",a=t.glowRadius??4,n=!1;for(let s=0;i.length>s&&r.length>s;s++){let l=Cs(t,r[s],e);n=zs(i[s],l,o,a)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Es(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(0>=t)return;let i=/* @__PURE__ */new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.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)&&(o=!0))}for(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=Ms(e,this.activeTransition),i=Ss(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.y;e.x=_s(e.x,e._targetX,i),e.y=_s(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let e of r)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}};r_.QUADTREE_THRESHOLD=500;var o_=r_;Jl(o_);import*as a_ from"react";import{jsx as n_,jsxs as s_}from"react/jsx-runtime";import{jsx as l_,jsxs as c_}from"react/jsx-runtime";import{Fragment as u_,jsx as d_,jsxs as h_}from"react/jsx-runtime";import*as f_ from"react-dom/server.browser";var p_={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};import{jsx as g_,jsxs as y_}from"react/jsx-runtime";var m_={top:0,right:0,bottom:0,left:0};import{jsx as x_}from"react/jsx-runtime";import{scaleLinear as b_}from"d3-scale";import{jsx as v_,jsxs as w_}from"react/jsx-runtime";var k_={top:0,right:0,bottom:0,left:0};import*as A_ from"react-dom/server";import{jsx as S_,jsxs as M_}from"react/jsx-runtime";var __={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},P_={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=__[i],o=Cg(e.width,r.width),a=Cg(e.height,r.height),n="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,s="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,l="center"===s?"middle":"end"===s?"end":"start",c="center"===s?o/2:"end"===s?o-n:n,u=_i(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=Pg("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":Ig(h(d),"string"==typeof e.prefix?e.prefix:void 0,"string"==typeof e.suffix?e.suffix:void 0),p=void 0===d?void 0:Tg(d,e.thresholds),g="string"==typeof e.color?e.color:Dg(p?.level??"neutral",p?.color,u),y="string"==typeof e.label?e.label:void 0,m="string"==typeof e.caption?e.caption:void 0,x="string"==typeof e.unit?e.unit:void 0,b=[void 0===d?void 0:zg(e,d,h),void 0===d?void 0:Eg(e,d,h),p?.label].filter(Boolean).join(" · "),v="string"==typeof e.description&&e.description||[y,f,x,b].filter(Boolean).join(", "),w="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,k="string"==typeof e.borderColor?e.borderColor:u.colors.border,A=n+r.labelSize,S=A+r.captionSize+4,M="presentation"===i?a/2+.32*r.valueSize:"thumbnail"===i?a/2+.34*r.valueSize:Math.min(a-n-(b?26:4),(r.showHeader&&(y||m)?m?S+10:A+14:n)+r.valueSize),_=c+("start"===l?Math.max(r.valueSize,f.length*r.valueSize*.55):0),P=A_.renderToStaticMarkup(
|
|
369
|
+
/* @__PURE__ */M_("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:a,viewBox:`0 0 ${o} ${a}`,role:"img","aria-label":v,"data-semiotic-component":"BigNumber",children:[
|
|
370
|
+
/* @__PURE__ */S_("title",{children:y??f}),"string"==typeof e.description&&/* @__PURE__ */S_("desc",{children:e.description}),
|
|
371
|
+
/* @__PURE__ */S_("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?a-1:a,rx:r.border?8:0,fill:w,stroke:r.border?k:"none"}),r.showHeader&&y&&/* @__PURE__ */S_("text",{x:c,y:A,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:y}),r.showHeader&&m&&/* @__PURE__ */S_("text",{x:c,y:S,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:m}),
|
|
372
|
+
/* @__PURE__ */S_("text",{x:c,y:M,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:g,"data-mark-type":"value",children:f}),x&&void 0!==d&&"start"===l&&/* @__PURE__ */S_("text",{x:_+6,y:M,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:x}),r.showDetail&&b&&/* @__PURE__ */S_("text",{x:c,y:Math.min(a-n,M+r.detailSize+10),textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:b})]}));return t&&(t.evidence=wc({frameType:"value",width:o,height:a,marks:void 0===d?[]:[{type:"value"}],title:y,description:v})),P}};import*as $_ from"react-dom/server";import{jsx as L_,jsxs as I_}from"react/jsx-runtime";import{Fragment as R_,jsx as T_}from"react/jsx-runtime";var C_=/* @__PURE__ */new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),D_=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi,z_=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],E_=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];import*as N_ from"react-dom/server";import{Fragment as O_,jsx as F_,jsxs as W_}from"react/jsx-runtime";yc();export{Jg as generateFrameSVGs,ey as generateFrameSequence,oy as generatePhysicsFrameSVGs,Ug as renderChart,Zg as renderChartWithEvidence,Qg as renderDashboard,Yg as renderGeoToStaticSVG,Bg as renderNetworkToStaticSVG,jg as renderOrdinalToStaticSVG,Fg as renderToStaticSVG,Wg as renderXYToStaticSVG,_i as resolveTheme,qg as serializeSvgPrecision,Pi as themeStyles};
|