semiotic 3.8.5 → 3.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +37 -10
- package/README.md +83 -56
- package/ai/behaviorContracts.cjs +88 -3
- package/ai/componentMetadata.cjs +5 -10
- package/ai/dist/mcp-server.js +99 -10
- package/ai/examples.md +198 -9
- package/ai/schema.json +2002 -165
- package/ai/surface-manifest.json +14 -10
- package/ai/system-prompt.md +9 -3
- package/dist/{chunk-chartContainerDataAudit-74TLKIP6.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +1 -0
- package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
- package/dist/chunk-chunk-3NGIKFD6.module.min.js +1 -0
- package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
- package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
- package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
- package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
- package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
- package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
- package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
- package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
- package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
- package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
- package/dist/chunk-chunk-DIVE2DRA.module.min.js +2 -0
- package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
- package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
- package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
- package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
- package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
- package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
- package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
- package/dist/{chunk-chunk-LJLS6DY7.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
- package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
- package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
- package/dist/{chunk-chunk-I36PJ4OC.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
- package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
- package/dist/chunk-chunk-MX35T6RX.module.min.js +2 -0
- package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
- package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
- package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
- package/dist/{chunk-chunk-TMWIZL3K.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
- package/dist/chunk-chunk-ONMLEXHR.module.min.js +2 -0
- package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
- package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
- package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
- package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
- package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
- package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
- package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
- package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
- package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
- package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
- package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
- package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
- package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
- package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
- package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
- package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
- package/dist/components/ai/chartCapabilities.d.ts +5 -3
- package/dist/components/ai/conversationArc.d.ts +2 -176
- package/dist/components/ai/conversationArcTypes.d.ts +202 -0
- package/dist/components/ai/readerGrounding.d.ts +12 -0
- package/dist/components/ai/vacpAdapter.d.ts +13 -0
- package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
- package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
- package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
- package/dist/components/ai/vacpAdapterState.d.ts +3 -0
- package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
- package/dist/components/ai/vacpTypes.d.ts +160 -0
- package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +1 -1
- package/dist/components/charts/index.d.ts +7 -4
- package/dist/components/charts/ordinal/BarChart.d.ts +7 -14
- package/dist/components/charts/ordinal/GaugeChart.d.ts +3 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +3 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -14
- package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
- package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
- package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
- package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
- package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
- package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
- package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
- package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
- package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -4
- package/dist/components/charts/shared/gaugeGradient.d.ts +4 -8
- package/dist/components/charts/shared/gradient.d.ts +35 -0
- package/dist/components/charts/shared/hatchFill.d.ts +3 -10
- package/dist/components/charts/shared/hooks.d.ts +2 -50
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -2
- package/dist/components/charts/shared/useChartLegend.d.ts +65 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +12 -0
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +6 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +25 -42
- package/dist/components/charts/xy/BumpChart.capability.d.ts +11 -0
- package/dist/components/charts/xy/BumpChart.d.ts +161 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +3 -10
- package/dist/components/charts/xy/Heatmap.d.ts +3 -0
- package/dist/components/charts/xy/LineChart.d.ts +6 -8
- package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
- package/dist/components/data/portability/index.d.ts +2 -0
- package/dist/components/geometry/bumpRibbonGeometry.d.ts +36 -0
- package/dist/components/legendLayout.d.ts +75 -1
- package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
- package/dist/components/recipes/geographicGrid.d.ts +100 -0
- package/dist/components/recipes/physics.d.ts +2 -0
- package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
- package/dist/components/semiotic-ai.d.ts +6 -4
- package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/components/semiotic-experimental.d.ts +6 -3
- package/dist/components/semiotic-geo.d.ts +5 -0
- package/dist/components/semiotic-network.d.ts +1 -0
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-physics.d.ts +10 -6
- package/dist/components/semiotic-realtime-core.d.ts +1 -0
- package/dist/components/semiotic-recipes-core.d.ts +6 -1
- package/dist/components/semiotic-server-edge.d.ts +1 -1
- package/dist/components/semiotic-server.d.ts +1 -1
- package/dist/components/semiotic-xy.d.ts +4 -0
- package/dist/components/semiotic.d.ts +4 -4
- package/dist/components/server/renderEvidence.d.ts +1 -1
- package/dist/components/server/renderToStaticSVG.d.ts +2 -1
- package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
- package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
- package/dist/components/server/serverChartConfigShared.d.ts +16 -0
- package/dist/components/server/serverChartConfigs.d.ts +3 -2
- package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
- package/dist/components/server/serverChartConfigsXY.d.ts +1 -1
- package/dist/components/server/staticLegend.d.ts +10 -2
- package/dist/components/server/staticSVGChrome.d.ts +14 -6
- package/dist/components/server/staticValue.d.ts +8 -0
- package/dist/components/stream/GeoSVGOverlay.d.ts +4 -10
- package/dist/components/stream/NetworkSVGOverlay.d.ts +2 -6
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -6
- package/dist/components/stream/SVGOverlay.d.ts +2 -6
- package/dist/components/stream/StalenessBadge.d.ts +2 -6
- package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
- package/dist/components/stream/geoTypes.d.ts +3 -6
- package/dist/components/stream/legendRenderer.d.ts +10 -6
- package/dist/components/stream/ordinalTypes.d.ts +7 -31
- package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
- package/dist/components/stream/physics/PhysicsKernel.d.ts +1 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +2 -6
- package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -6
- package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
- package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
- package/dist/components/stream/pipelineConfig.d.ts +7 -15
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +9 -69
- package/dist/components/stream/renderers/cornerRadii.d.ts +2 -9
- package/dist/components/stream/renderers/thresholdLineSegments.d.ts +12 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +3 -5
- package/dist/components/stream/types.d.ts +34 -56
- package/dist/components/stream/xySceneBuilders/areaGradient.d.ts +4 -20
- package/dist/components/stream/xySceneBuilders/types.d.ts +6 -6
- package/dist/components/types/legendTypes.d.ts +31 -6
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +6 -4
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/semiotic-experimental-vacp.min.js +1 -0
- package/dist/semiotic-experimental-vacp.module.min.js +1 -0
- package/dist/semiotic-experimental.d.ts +6 -3
- package/dist/semiotic-experimental.min.js +2 -1
- package/dist/semiotic-experimental.module.min.js +2 -1
- package/dist/semiotic-geo.d.ts +5 -0
- package/dist/semiotic-network.d.ts +1 -0
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/semiotic-physics.d.ts +10 -6
- package/dist/semiotic-realtime-core.d.ts +1 -0
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -1
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.d.ts +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-server.d.ts +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +4 -0
- package/dist/semiotic.d.ts +4 -4
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +18 -2
- package/spec/README.md +94 -2
- package/spec/bindings/README.md +14 -3
- package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
- package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
- package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
- package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
- package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
- package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
- package/dist/chunk-chunk-4AANPFOX.module.min.js +0 -2
- package/dist/chunk-chunk-5I3UZV4Q.module.min.js +0 -2
- package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
- package/dist/chunk-chunk-74CCPVXB.module.min.js +0 -1
- package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
- package/dist/chunk-chunk-ANYDWOZF.module.min.js +0 -1
- package/dist/chunk-chunk-AVBI6GDT.module.min.js +0 -1
- package/dist/chunk-chunk-BANTPINB.module.min.js +0 -2
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
- package/dist/chunk-chunk-C57LR3YG.module.min.js +0 -1
- package/dist/chunk-chunk-CKMD5NV3.module.min.js +0 -2
- package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
- package/dist/chunk-chunk-CWQ5YIHX.module.min.js +0 -2
- package/dist/chunk-chunk-E6TXX6MI.module.min.js +0 -1
- package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
- package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
- package/dist/chunk-chunk-K3DMEW22.module.min.js +0 -1
- package/dist/chunk-chunk-KT2VAZMZ.module.min.js +0 -1
- package/dist/chunk-chunk-L6EA5V3G.module.min.js +0 -2
- package/dist/chunk-chunk-LJPCLYSC.module.min.js +0 -2
- package/dist/chunk-chunk-LRIFN2HK.module.min.js +0 -1
- package/dist/chunk-chunk-N5DDKCCF.module.min.js +0 -1
- package/dist/chunk-chunk-NEVE562N.module.min.js +0 -1
- package/dist/chunk-chunk-NLO44TOS.module.min.js +0 -2
- package/dist/chunk-chunk-PZJ2SBLL.module.min.js +0 -2
- package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
- package/dist/chunk-chunk-QUJ6TTLY.module.min.js +0 -1
- package/dist/chunk-chunk-RBIDBUT4.module.min.js +0 -2
- package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
- package/dist/chunk-chunk-RFLAG356.module.min.js +0 -1
- package/dist/chunk-chunk-RPU4IZAV.module.min.js +0 -2
- package/dist/chunk-chunk-SKMBCFIL.module.min.js +0 -2
- package/dist/chunk-chunk-TAE7W424.module.min.js +0 -2
- package/dist/chunk-chunk-TUBMTZMU.module.min.js +0 -2
- package/dist/chunk-chunk-UFFEXJQY.module.min.js +0 -1
- package/dist/chunk-chunk-XSCHTS4D.module.min.js +0 -2
- package/dist/chunk-chunk-XXWSHGPL.module.min.js +0 -2
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
- package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
- package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +0 -1
- package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{needsDataCanvasPaint as e,paintCanvasBackground as t}from"./chunk-chunk-TMWIZL3K.module.min.js";import{StalenessBadge as r,attachUpdateResultStore as n,buildNavGraph as o,composeOverlays as i,computeDecayOpacity as a,createCustomLayoutFailureDiagnostic as s,extractNetworkNavPoints as c,filterAnnotationsByStatus as l,findHitPointInQuadtree as u,formatVal as d,getHitRadius as h,hitTestRect as y,networkGlyphRenderer as f,nextNetworkIndex as g,normalizeAngle as p,paintSceneWithBackend as m,renderCirclePulse as v,renderRectPulse as x,renderSceneWithBackend as k,resolvePosition as b,useConfigSync as S,useLayoutSelectionSync as _,useStableShallow as w,useStalenessCheck as A,warnCustomLayoutDiagnostics as L}from"./chunk-chunk-XXWSHGPL.module.min.js";import{CustomLayoutSelectionProvider as E,wrapWithCustomLayoutSelection as P}from"./chunk-chunk-5UKL5W76.module.min.js";import{commonJsWorkerModuleUrl as D}from"./chunk-chunk-SV4XAZ3Q.module.min.js";import{buildResolveColor as M,resolveCustomLayoutPalette as R}from"./chunk-chunk-LJLS6DY7.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as N,AriaLiveTooltip as T,CanvasFrameBackground as C,DEFAULT_COLORS as W,FlippingTooltip as I,FocusRing as $,NetworkAccessibleDataTable as z,SceneRevisionDiagnosticsObserver as F,ScreenReaderSummary as B,SkipToTableLink as O,TITLE_BASELINE as Y,UpdateResultTracker as X,annotationActivationProps as j,annotationLayout as H,buildHoverData as G,computeEasing as V,computeNetworkAriaLabel as q,computeRawProgress as Q,createDefaultAnnotationRules as K,createSeededFrameRandom as Z,defaultTooltipStyle as U,emitClickObservations as J,emitHoverObservations as ee,filterSparseArray as te,getDevicePixelRatio as re,isAnnotationActivationTarget as ne,isInteractiveKeyboardTarget as oe,isServerEnvironment as ie,lerp as ae,networkLabelToSVG as se,networkSceneEdgeToSVG as ce,networkSceneNodeToSVG as le,now as ue,observationInputType as de,prepareCanvas as he,renderAnnotationPass as ye,renderLegendFromConfig as fe,resolveCSSColor as ge,resolveCanvasFill as pe,runSceneBuild as me,schemeCategory10 as ve,smartTooltipEntries as xe,symbolPathString as ke,symbolRadius as be,useAnnotationActivationOptions as Se,useFrame as _e,useFrameCanvasHost as we,useSceneRevisionDiagnostics as Ae}from"./chunk-chunk-CWQ5YIHX.module.min.js";import{getMinMax as Le}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as Ee}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as Pe}from"./chunk-chunk-KTWEBFMX.module.min.js";import{renderLoadingState as De,useHydration as Me,useWasHydratingFromSSR as Re}from"./chunk-chunk-ACLDBMRH.module.min.js";import*as Ne from"react";import{useRef as Te,useState as Ce,useEffect as We,useMemo as Ie,useCallback as $e,useImperativeHandle as ze,forwardRef as Fe,memo as Be}from"react";var Oe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ye={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Xe=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const r=this._freeIndices.pop();if(void 0===r)return null;const n=this.particles[r];return n.active=!0,n.t=0,n.offset=t()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,r,n){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=r[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(n?n[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?je(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)t.length>r?this.particles[r]=t[r]:(this.particles[r]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(r));this.capacity=e}};function je(e,t,r,n){if(e.circular&&e.segments)return void function(e,t,r,n,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),c=a-s,[l,u,d,h]=e[s];He(l,u,d,h,c,o);const y=h.x-l.x,f=h.y-l.y,g=Math.sqrt(y*y+f*f);if(g>.001){const e=y/g;o.x+=-f/g*r*n*2,o.y+=e*r*n*2}}(e.segments,t,r,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[o,i,a,s]=e.points;He(o,i,a,s,t,n);const c=s.x-o.x,l=s.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;n.x+=-l/u*r*e.halfWidth*2,n.y+=t*r*e.halfWidth*2}}function He(e,t,r,n,o,i){const a=1-o,s=a*a,c=s*a,l=o*o,u=l*o;i.x=c*e.x+3*s*o*t.x+3*a*l*r.x+u*n.x,i.y=c*e.y+3*s*o*t.y+3*a*l*r.y+u*n.y}function Ge(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function Ve(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,r){var o=[].concat(r).concat(e);t?t(o):n.push(o)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var f=i[t];y.length>f;++f){var g=y[f];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,c.push(g),l.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>a[g]||s[t].push(a[g])}i[t]=f}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(f=c.length-1;f>=0;--f){var x=c[f];if(o[x]=!1,p.push(x),m.push(s[x]),v+=s[x].length,a[x]=d.length,x===t){c.length=f;break}}d.push(p);var k=Array(v);for(f=0;m.length>f;f++)for(var b=0;m[f].length>b;b++)k[--v]=m[f][b];h.push(k)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var f=h[c];if(0!==f.length){f.sort(function(e,t){return e-t}),l=[f[0]];for(var g=1;f.length>g;g++)f[g]!==f[g-1]&&l.push(f[g]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],r=a);var c=o[r];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var f=0;s.length>f;f++)for(var g=0;s[f].length>g;g++){var p=s[f][g];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return t?void 0:n}function qe(e){return e.y0-e.y1>0?"up":"down"}function Qe(e,t){return t(e.source)==t(e.target)}function Ke(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function Ze(e){return e.target.x0-e.source.x1}function Ue(e,t){var r=et(e),n=Ze(t)/Math.tan(r);return"up"==qe(e)?e.y1-n:e.y1+n}function Je(e,t){var r=et(e),n=Ze(t)/Math.tan(r);return"up"==qe(e)?e.y1+n:e.y1-n}function et(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function tt(e,t){return t(e)}function rt(e){return ot(e.source)}function nt(e){return ot(e.target)}function ot(e){return(e.y0+e.y1)/2}function it(e){return e.virtual?0:e.value}function at(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!Qe(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!Qe(e,t)?n+1:n}),r+n}function st(e){return e.target.depth}function ct(e,t){return e.sourceLinks.length?e.depth:t-1}function lt(e,t){return e.y0-t.y0}function ut(e,t){return t.y0-e.y0}function dt(e,t){return e.y1-t.y1}function ht(e,t){return t.y1-e.y1}function yt(e,t){return gt(e.source,t.source)||e.index-t.index}function ft(e,t){return gt(e.target,t.target)||e.index-t.index}function gt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function pt(e,t){return mt(e)==mt(t)?"bottom"==e.circularLinkType?ut(e,t):lt(e,t):mt(t)-mt(e)}function mt(e){return e.target.column-e.source.column}function vt(e,t){return xt(e)==xt(t)}function xt(e){return e.y0-e.y1>0?"up":"down"}import{min as kt}from"d3-array";function bt(e,t,r,n,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=kt(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),St(i.links.filter(function(e){return"top"==e.circularLinkType}),t,r),St(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,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,Qe(e,t)&&Ke(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+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 a=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?ut:lt);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),a=e.target.column,(l=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?ht:dt),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=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?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,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),i}function St(e,t,r){e.sort(pt);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Qe(e,t)&&Ke(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&_t(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function _t(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as wt,max as At,sum as Lt,mean as Et,group as Pt,groups as Dt}from"d3-array";function Mt(e){return function(){return e}}function Rt(e){return e.index}function Nt(e){return e.nodes}function Tt(e){return e.links}function Ct(e,t,r){var n=Dt(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ot(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ot(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?r.idx-n.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?at(t,r)-at(e,r):"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==n.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==at(t,r)?(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)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function Wt(e,t,r,n,o,i){var a=Dt(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,c=i;c>0;--c)l(s*=.99,r),u();function l(t,r){var n=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&at(o,r)>0){var c=Et(o.sourceLinks,nt),l=Et(o.targetLinks,rt),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-ot(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==n-1&&1==i)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=Et(o.sourceLinks,nt),y=Et(o.targetLinks,rt),f=((h&&y?(h+y)/2:h||y)-ot(o))*t;o.y0+=f,o.y1+=f}})})}function u(){a.forEach(function(r){var i,a,s,c=e.y0,l=r.length;for(r.sort(t||gt),s=0;l>s;++s)(a=c-(i=r[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-e.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=r[s]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function It(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ft),e.targetLinks.sort(yt)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=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=r+e.width/2,r+=e.width)})})}function $t(){var e=0,t=0,r=1,n=1,o=24,i=8,a=null,s=Rt,c=ct,l=void 0,u=32,d=2,h=Nt,y=Tt;function f(){var f={nodes:h.apply(null,arguments),links:y.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=r,h.y1=n,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return Pt(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=Ge(r,n)),"object"!=typeof o&&(o=e.target=Ge(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=Ve(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(h,l),function(e,t){var r=0,n=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:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){tt(e,t)!=tt(o.source,t)&&tt(e,t)!=tt(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),Qe(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Lt(e.sourceLinks,it),Lt(e.targetLinks,it)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(h,l,c);var y=i;if(null!==a){var f=Dt(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=At(f,function(e){return e.length});g>1&&(y=Math.max(1,(n-t)*a/(g-1)))}(function(e,t,r){var n=Dt(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=wt(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Lt(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=At(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/i),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(h,y,o),Ct(h,l,s),Wt(h,l,s,y,y,u),It(h),bt(h,s,d,10,8),Ct(h,l,s),Wt(h,l,s,y,y,u),It(h),bt(h,s,d,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return tt(r.source,t)==tt(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!vt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=Ue(t,e);return e.y1-r}if(t.target.column>e.target.column)return Ue(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return tt(r.target,t)==tt(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!vt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=Je(t,e);return e.y0-r}if(t.source.column>e.source.column)return Je(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,r=e.links,n=!1,o=!1;if(r.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){let n=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=wt(t,function(e){return e.y0}),a=At(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1)}),r.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=n(e.y0)-e.y0;e.y0=n(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(h),bt(h,s,d,10,8)}(f),f}return f.update=function(e){return It(e),bt(e,s,d,10,8),e},f.nodeWidth=function(e){return arguments.length?(o=+e,f):o},f.nodePadding=function(e){return arguments.length?(i=+e,f):i},f.nodePaddingRatio=function(e){return arguments.length?(a=+e,f):a},f.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Mt(e),f):h},f.links=function(e){return arguments.length?(y="function"==typeof e?e:Mt(e),f):y},f.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Mt(e),f):s},f.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Mt(e),f):c},f.nodeSort=function(e){return arguments.length?(l=e,f):l},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.circularLinkGap=function(e){return arguments.length?(d=+e,f):d},f.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],r=+o[1][0],n=+o[1][1],f):[[e,t],[r,n]]},f.size=function(o){return arguments.length?(e=t=0,r=+o[0],n=+o[1],f):[r-e,n-t]},f}import{interpolateNumber as zt}from"d3-interpolate";import{line as Ft,curveLinearClosed as Bt}from"d3-shape";function Ot(e){const{sx:t,sTop:r,sBot:n,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:c}=e,l=(r+n)/2,u=(i+a)/2;return{pathD:[`M${t},${r}`,`C${s},${r} ${c},${i} ${o},${i}`,`L${o},${a}`,`C${c},${a} ${s},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:s,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(n-r)/2}}}var Yt=e=>{let t,r,n,o,i,a,s,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=zt(i,a),c=s(.5),l=s(.5),`M${t},${i}C${t},${c} ${r},${l} ${r},${a}L${n},${a}C${n},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,d=zt(e.source.x1,e.target.x0),{pathD:h}=Ot({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};function Xt(e){const t=e.sankeyWidth/2,r=(e._circularWidth??e.sankeyWidth)/2,n=e.circularPathData;if(!n)return null;if("down"===e.direction)return null;if(e._circularStub){const r=n.sourceX,o=n.sourceY,i=n.targetX,a=n.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-r))),c=Math.max(15,Math.min(40,.33*(i-n.leftFullExtent)));return`M${r},${o-t}L${r+s},${o-t}L${r+s},${o+t}L${r},${o+t}ZM${i},${a-t}L${i-c},${a-t}L${i-c},${a+t}L${i},${a+t}Z`}const o=n.sourceX,i=n.sourceY,a=n.targetX,s=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(r,15));return`M${o},${i-d*t}L${c},${i-d*t}L${c+r},${i-d*t+d*h}L${c+r},${u+d*r-d*h}L${c+r-h},${u+d*r}L${l-r+h},${u+d*r}L${l-r},${u+d*r-d*h}L${l-r},${s-d*t+d*h}L${l-r+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${l+r},${s+d*t}L${l+r},${u-d*r}L${c-r},${u-d*r}L${c-r},${i+d*t}L${o},${i+d*t}Z`}var jt=new Set,Ht=new WeakMap;function Gt(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=Ht.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,Ht.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;jt.has(e)||(jt.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}var Vt={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(st))-1:0},justify:ct};function qt(e){return"string"==typeof e?e:e.id}var Qt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o="vertical"===r.orientation?"down":"right",i=r.nodeAlign||"justify",a=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const h=$t().extent(d).links(u).nodes(l).nodeAlign(Vt[i]||ct).nodeId(e=>e.id).nodeWidth(a).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of l)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(n._circularWidth??n.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,s=n[0],c=n[1];if(i>0&&a>0&&(0>e||0>r||t>s||o>c)){const t=Math.min(s/i,c/a),n=-e*t+(s-i*t)/2,o=-r*t+(c-a*t)/2;for(const e of l)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of l){const t=y.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const f=new Map;for(const e of t)f.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=qt(e.source),r=qt(e.target),n=f.get(e._edgeKey?e._edgeKey:`${t}\0${r}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=e.width??0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=o;const i=y.get(t),a=y.get(r);i&&(n.source=i),a&&(n.target=a)}}},buildScene(e,t,r,n){const o="vertical"===r.orientation?"down":"right",i=r.nodeStyle,a=r.edgeStyle,s=r.edgeOpacity??.5,c=r.edgeColorBy||"source",l=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:ve,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],y=[],f=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=i?i(Gt(t,"nodeStyle")):{},a={fill:n.fill||u.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};f.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:a,datum:t,id:t.id,label:t.id})}const g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of g){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?f.get(n.id)||u.get(n.id)||o:f.get(t.id)||u.get(t.id)||o;const i=a?a(Gt(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+n},${t.sourceY-r}L${t.sourceX+n},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-a},${t.targetY-r}L${t.targetX-a},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Xt(e):Yt(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==r.showLabels){const t=(p=r.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=t?t(r):r.id;if(!a)continue;let s,c,l;"down"===o?(s=r.y0+(r.y1-r.y0)/2,c=r.x1+14,l="start"):(n[0]/2>r.x0+e/2?(s=r.x0-6,l="end"):(s=r.x1+6,l="start"),c=r.y0+i/2),y.push({x:s,y:c,text:a+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:h,labels:y}}};import{forceSimulation as Kt,forceCenter as Zt,forceX as Ut,forceY as Jt,forceLink as er,forceManyBody as tr,forceCollide as rr}from"d3-force";import{scaleLinear as nr}from"d3-scale";var or={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o=r.forceStrength??.1,i=n[0]/2,a=n[1]/2,s=Math.max(.1,Math.min(1,Math.min(n[0],n[1])/200)),c=Math.min(.5,.06+1.8*(1-s)),l=r.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=l?.get(t.id);e?u++:r?(t.x=r.x,t.y=r.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of d){const n=ir(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=ar(e.id),i=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=ar(e.id),r=t%360*(Math.PI/180),n=(15+t%30)*s;e.x=i+n*Math.cos(r),e.y=a+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5)*s,o=r*t;n.x=i+e*Math.cos(o),n.y=a+e*Math.sin(o)}}}const y=r.__skipForceSimulation||0===r.iterations?0:h?40:r.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=sr(r.nodeSize,r.nodeSizeRange,e),g=e=>f(e);if(y>0){const l=new Map,u=new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id;l.set(t,(l.get(t)??0)+1),l.set(r,(l.get(r)??0)+1)}const d=er().strength(e=>{const t=e.weight,r="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(l.get("string"==typeof e.source?e.source:e.source.id)??1,l.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*n))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,r="string"==typeof e.target?u.get(e.target):e.target,n=(t?g(t):0)+(r?g(r):0)+Math.max(6,12*s);return Math.max(16,40*s,n)}).id(e=>e.id),f=Kt();if(void 0===r.random&&void 0===r.seed||f.randomSource(r.random??Z(r.seed)),f.force("charge",tr().strength(e=>{const t=l.get(e.id)??0;return-15*s*g(e)*Math.sqrt(t+1)})).force("collide",rr(e=>g(e)+3*s).strength(.9).iterations(2)).force("center",Zt(i,a).strength(.8)).force("x",Ut(i).strength(c)).force("y",Jt(a).strength(c)).force("bounds",function(e,t,r=2,n=.6){let o=[];const i=i=>{const a=n*Math.max(i,.2);for(const n of o){const o=n.x??e[0]/2,i=n.y??e[1]/2,s=n.vx??0,c=n.vy??0,l=t(n)+r,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),y=Math.max(e[1]/2,e[1]-l),f=o+s,g=i+c;u>f?n.vx=s+(u-f)*a:f>d&&(n.vx=s+(d-f)*a),h>g?n.vy=c+(h-g)*a:g>y&&(n.vy=c+(y-g)*a)}};return i.initialize=e=>{o=e},i}(n,g)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));d.links(e),f.force("link",d)}h?f.alpha(.3):.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;y>e;++e)f.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=g(t),r=y>0?2:0,o=Math.min(n[0]/2,e+r),i=Math.min(n[1]/2,e+r);t.x=Math.max(o,Math.min(n[0]-o,t.x)),t.y=Math.max(i,Math.min(n[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.edgeStyle,a=sr(r.nodeSize,r.nodeSizeRange,e),s=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:ve,c=new Map;e.forEach((e,t)=>{c.set(e.id,s[t%s.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Gt(t,"nodeSize")),n=o?o(Gt(t,"nodeStyle")):{},i={fill:n.fill||c.get(t.id)||r.themeSemantic?.primary||"#007bff",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),n="object"==typeof e.target?e.target:h.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=i?i(Gt(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==r.showLabels){const t=(y=r.nodeLabel)?"function"==typeof y?y:e=>e[y]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=a(Gt(r,"nodeSize"));d.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var y;return{sceneNodes:l,sceneEdges:u,labels:d}}};function ir(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function ar(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function sr(e,t,r){if(r.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],o=[];for(const t of r){const r=t.data?.[e];"number"==typeof r&&o.push(r)}if(0===o.length)return()=>n[0];const[i,a]=Le(o);if(i===a)return()=>(n[0]+n[1])/2;const s=nr().domain([i,a]).range(n).clamp(!0);return t=>{const r=t.data?.[e];return null==r||"number"!=typeof r?n[0]:s(r)}}import{chord as cr,ribbon as lr}from"d3-chord";import{arc as ur}from"d3-shape";var dr=ve,hr={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,s=Math.min(n[0],n[1])/2,c=s-i,l=n[0]/2,u=n[1]/2,d=(h=r.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const f=e.length,g=Array.from({length:f},()=>Array.from({length:f},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=y.get("string"==typeof e.source?e.source:e.source.id),n=y.get(t);if(void 0===r||void 0===n)continue;const o=d(e);g[r][n]=o}const p=cr().padAngle(o);a&&p.sortGroups(a);const m=p(g),v=m.groups,x=ur().innerRadius(c).outerRadius(s);for(const t of v){const r=e[t.index],n=x.centroid({innerRadius:c,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});r.x=n[0]+l,r.y=n[1]+u,r.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=k.get("string"==typeof e.source?e.source:e.source.id),n=k.get(t);r&&(e.source=r),n&&(e.target=n)}const b=new Map;for(const e of t)b.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const r=e[t.source.index].id,n=e[t.target.index].id,o=b.get(`${r}\0${n}`)||b.get(`${n}\0${r}`);o&&(o.__chordData=t)}},buildScene(e,t,r,n){const{groupWidth:o=20,edgeOpacity:i=.5}=r,a=Math.min(n[0],n[1])/2,s=a-o,c=n[0]/2,l=n[1]/2,u=r.nodeStyle,d=r.edgeStyle,h=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:dr,f=new Map;e.forEach((e,t)=>{f.set(e.id,y[t%y.length])});const g=lr().radius(s),p=[],m=[],v=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.__arcData;if(!n)continue;let o;o=u?u(Gt(r,"nodeStyle")).fill||f.get(r.id)||y[t%y.length]:f.get(r.id)||y[t%y.length];const i=u?u(Gt(r,"nodeStyle")):{};p.push({type:"arc",cx:c,cy:l,innerR:s,outerR:a,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=g(t);if(!n)continue;const o=yr(n,c,l);let a=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";if(d)a=d(Gt(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===h&&r?a=f.get(r.id)||a:t&&(a=f.get(t.id)||a)}const s=d?d(Gt(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,n=a+12;for(const r of e){const e=r.__arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;v.push({x:c+Math.cos(a)*n,y:l+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}};function yr(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}import{hierarchy as fr,tree as gr,cluster as pr,treemap as mr,pack as vr,partition as xr,treemapBinary as kr}from"d3-hierarchy";var br=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Sr(e){const[t,r,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)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}function _r(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function wr(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ar(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:br}function Lr(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 Er(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}var Pr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;if(!o)return;const i=r.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),s=r.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,l=fr(o,a);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(i){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=gr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=pr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"treemap":!function(e,t,r,n){const o=t.padding??4,i=t.paddingTop??0,a=mr().size([r,n]).tile(kr).padding(o);i>0&&a.paddingTop(i),a(e)}(l,r,u,d);break;case"circlepack":!function(e,t,r,n){const o=t.padding??4;vr().size([r,n]).padding(o)(e)}(l,r,u,d);break;case"partition":!function(e,t,r,n){xr().size([r,n]).padding(t.padding??1)(e)}(l,r,u,d)}const h=l.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;h.length>t;t++){const n=h[t],o={id:_r(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?Dr(o,n,r):"treemap"===i||"partition"===i?Mr(o,n):"circlepack"===i&&Rr(o,n),o.__hierarchyNode=n,e.push(o),y.set(n,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const r=y.get(e.parent),n=y.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){const a=[],s=[],c=[],l=r.treeOrientation||"vertical",u="radial"===l,d=n[0]/2,h=n[1]/2,y="number"==typeof(f=r.nodeSize)?f:5;var f;for(const t of e){let e=t.x,n=t.y;u&&(e+=d,n+=h);const i=o(Gt(t,"nodeStyle"));let s=i.fill||Lr(r);if(r.colorByDepth&&void 0!==t.depth){const e=Ar(r);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:n,r:y,style:{fill:s,stroke:i.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const g=r.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,a=t.y,c=n.x,y=n.y;u&&(o+=d,a+=h,c+=d,y+=h);const f=Er(o,a,c,y,l),p=i(Gt(e,"edgeStyle"));s.push({type:"curved",pathD:f,style:{fill:"none",stroke:p.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??g},datum:e})}if(!1!==r.showLabels){const t=wr(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===l?(r.data?.children&&0!==r.data.children.length?(n=a-y-6,i="end"):(n=a+y+6,i="start"),o=s):(n=a,o=s+y+14,i="middle");c.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:c}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=n(Gt(r,"nodeStyle"));let s=a.fill||Lr(t);if(t.colorByDepth&&void 0!==r.depth){const e=Ar(t);s=e[r.depth%e.length]}o.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=wr(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const l=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=r?r(s):s.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=n(Gt(s,"nodeStyle")).fill||Lr(t);if(t.colorByDepth&&void 0!==s.depth){const e=Ar(t);d=e[s.depth%e.length]}const h="string"==typeof d?Sr(d):t.themeSemantic?.text??"#000";i.push(l?{x:s.x0+e/2,y:s.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/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:i}}(e,r,0,o);case"circlepack":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.__radius??5;if(0>=e)continue;const i=n(Gt(r,"nodeStyle"));let a=i.fill||Lr(t);if(t.colorByDepth&&void 0!==r.depth){const e=Ar(t);a=e[r.depth%e.length]}o.push({type:"circle",cx:r.x,cy:r.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=wr(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=r?r(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let c=n(Gt(o,"nodeStyle")).fill||Lr(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ar(t);c=e[o.depth%e.length]}if(s){const r="string"==typeof c?Sr(c):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:r})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Dr(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(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 Mr(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 Rr(e,t){const r=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}import{pie as Nr}from"d3-shape";function Tr(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Cr={sankey:Qt,force:or,chord:hr,tree:Pr,cluster:Pr,treemap:Pr,circlepack:Pr,partition:Pr,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(r.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),c=r.orbitSize??2.95,l=r.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=Tr(r);h.metaMap.clear(),n.length=0,o.length=0;const y=new Map;function f(e){const t=y.get(e)??0;return y.set(e,t+1),0===t?e:`${e}__${t}`}const g=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=f(a(e));n.push({id:v,x:g,y:p,x0:g,x1:g,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,c,l,y,g,p){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,k=0,b=0;for(;v>k;)k+=s[Math.min(b,s.length-1)],b++,x++;let S=0;for(let v=0;x>v;v++){const k=s[Math.min(v,s.length-1)],b=m.slice(S,S+k);if(!b.length)break;const _=(v+1)/x,w={id:r,depth:g,data:t,parentId:r},A=p?y/u(w)*_:y*_,L=Nr().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(b),E=d(w);for(let t=0;b.length>t;t++){const i=(L[t].startAngle+L[t].endAngle)/2,s=b[t],u=f(a(s)),d=c+A*Math.sin(i),y=l+A*Math.cos(i)*E;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:g,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:g,parentId:r,eccentricity:E}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(s,u,d,y,A,g+1,!0)}S+=k}}(e,v,g,p,m,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],c=[],l=[];if(!1!==r.orbitShowRings){const t=Tr(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(l),y2:t+r*Math.cos(l)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Gt(t,"nodeSize")),n=o?o(Gt(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:n.fill||r.themeSemantic?.primary||"#6366f1",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),r="object"==typeof e.target?e.target:u.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=a(Gt(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t?r.data?.[t]??r.id:r.id;l.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:c,labels:l}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){const r=Tr(t),n=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,a=n*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=s.get(e.parentId);if(!n)continue;const c=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(c),t.y=n.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)}};function Wr(e){return Cr[e]}import{quadtree as Ir}from"d3-quadtree";function $r(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function zr(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Fr(e))return!1;return!0}return Fr(t.points)}function Fr(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Br}from"d3-interpolate";var Or="rgba(34, 197, 94, 0.7)",Yr=2e3,Xr=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jr=["scene-style","data-paint","accessibility","evidence"],Hr=(e,t)=>({retainedData:e,invalidations:t}),Gr=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vr=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Qr=["scene-style","data-paint","accessibility","evidence"],Kr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Zr=[],Ur={chartType:Hr("rebuild",Gr),nodeIDAccessor:Hr("rebuild",Gr),sourceAccessor:Hr("rebuild",Gr),targetAccessor:Hr("rebuild",Gr),valueAccessor:Hr("rebuild",Gr),edgeIdAccessor:Hr("rebuild",Gr),childrenAccessor:Hr("rebuild",Gr),hierarchySum:Hr("rebuild",Gr),orientation:Hr("preserve",Vr),nodeAlign:Hr("preserve",Vr),nodePaddingRatio:Hr("preserve",Vr),nodeWidth:Hr("preserve",Vr),edgeSort:Hr("preserve",Vr),iterations:Hr("preserve",Vr),forceStrength:Hr("preserve",Vr),padAngle:Hr("preserve",Vr),groupWidth:Hr("preserve",Vr),sortGroups:Hr("preserve",Vr),treeOrientation:Hr("preserve",Vr),edgeType:Hr("preserve",Vr),padding:Hr("preserve",Vr),paddingTop:Hr("preserve",Vr),orbitMode:Hr("preserve",Vr),orbitSize:Hr("preserve",Vr),orbitSpeed:Hr("preserve",Vr),orbitRevolution:Hr("preserve",Vr),orbitRevolutionStyle:Hr("preserve",Vr),orbitEccentricity:Hr("preserve",Vr),orbitShowRings:Hr("preserve",Vr),orbitAnimated:Hr("preserve",Vr),customNetworkLayout:Hr("preserve",Vr),layoutConfig:Hr("preserve",Vr),nodeSize:Hr("preserve",qr),nodeSizeRange:Hr("preserve",qr),colorByDepth:Hr("preserve",qr),nodeLabel:Hr("preserve",Kr),showLabels:Hr("preserve",Kr),labelMode:Hr("preserve",Kr),nodeStyle:Hr("preserve",Qr),edgeStyle:Hr("preserve",Qr),colorBy:Hr("preserve",Qr),colorScheme:Hr("preserve",Qr),themeCategorical:Hr("preserve",Qr),themeSemantic:Hr("preserve",Qr),edgeColorBy:Hr("preserve",Qr),edgeOpacity:Hr("preserve",Qr),showParticles:Hr("preserve",Qr),particleStyle:Hr("preserve",Qr),decay:Hr("preserve",Qr),pulse:Hr("preserve",Qr),thresholds:Hr("preserve",Qr),staleness:Hr("preserve",Qr),layoutSelection:Hr("preserve",Qr),clock:Hr("preserve",Zr),random:Hr("preserve",Zr),seed:Hr("preserve",Zr),tensionConfig:Hr("preserve",Zr),transition:Hr("preserve",Zr),introAnimation:Hr("preserve",Zr),onLayoutError:Hr("preserve",Zr),__skipForceSimulation:Hr("preserve",Zr),__hierarchyRoot:Hr("preserve",Zr),__orbitState:Hr("preserve",Zr),__previousPositions:Hr("preserve",Zr)},Jr=Hr("preserve",Vr),en=class{constructor(){this.tracker=new X}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}},Xr)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jr):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const r=new Set;for(const n of e){const e=Ur[n]??Jr;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)r.add(t)}return{retainedData:t,invalidations:r}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},tn=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new en,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Oe,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Xe(2e3))}currentTime(){return this.config.clock?.()??ue()}updateConfig(e){const t=this.config,r={...t,...e};t.__orbitState&&(r.__orbitState=t.__orbitState),t.__hierarchyRoot&&(r.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(r.layoutSelection=t.layoutSelection);const n=[...new Set([...Object.keys(t),...Object.keys(r)])].filter(e=>t[e]!==r[e]);this.config=r,this.tensionConfig={...Oe,...r.tensionConfig},!r.showParticles||"sankey"!==r.chartType&&!r.customNetworkLayout||this.particlePool||(this.particlePool=new Xe(2e3)),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,r,n){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...$r(e),data:t})}for(let e=0;t.length>e;e++){const r=t[e],n=l(r)+"",o=u(r)+"",i=d(r),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(n)||this.nodes.set(n,{...$r(n),data:r}),this.nodes.has(o)||this.nodes.set(o,{...$r(o),data:r});const c=`${n}\0${o}\0${e}`,h={source:n,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:c};r&&"object"==typeof r&&zr(r.bezier)&&(h.bezier=r.bezier),this.edges.set(c,h)}n?.deferLayout||this.runLayout(r),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,r,n){return this.ingestBounded(e,t,r,n),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,r]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=r.x,e.y=r.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,$r(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,$r(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=Wr(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values());const n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of r)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(r,n,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of r)this.nodes.set(e.id,e);for(let e=0;n.length>e;e++){const t=n[e],r=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=r,this.edges.set(r,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const r=e.get(t.id);r&&(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,r=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&r.length>0&&a>0){const t=e[0]/2,r=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=r,e._prevY1=r;for(const e of this.edges.values())e._prevY0=r,e._prevY1=r,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:r,restyleEdge:n,baseStyles:o,selection:i}){const a=!(!r&&!n);if(r)for(const t of e){const e=o.get(t)??t.style,n=r(t,i);t.style=n?{...e,...n}:e}if(n)for(const e of t){const t=o.get(e)??e.style,r=n(e,i);e.style=r?{...t,...r}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:r,nodes:n,edges:o,previousResult:i,revision:a}){const c=R(e.colorScheme,e.themeCategorical,ve),l={nodes:n,edges:o,dimensions:{width:r[0],height:r[1],plot:{x:0,y:0,width:r[0],height:r[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...c]},resolveColor:M(c,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const r=null!==i,n=s("network",t,r,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:n,preservedLastGoodScene:r}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const r=t.result;return this.sceneNodes=r.sceneNodes??[],this.sceneEdges=r.sceneEdges??[],this.labels=r.labels??[],this.customLayoutOverlays=r.overlays??null,this.customLayoutHtmlMarks=r.htmlMarks??[],this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=r.restyle,this._customRestyleEdge=r.restyleEdge,this.hasCustomRestyle=!(!r.restyle&&!r.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const r=new WeakMap;for(const t of e)r.set(t,t.style);for(const e of t)r.set(e,e.style);return r}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void L({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=Wr(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const r=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,n=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,r=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>r&&(r=e.r));if(this._maxNodeRadius=r,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const n=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(n[o++]=e);this._nodeQuadtree=Ir().x(e=>e.cx).y(e=>e.cy).addAll(n)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=Wr(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Wr(this.config.chartType);if(!r?.tick)return!1;const n=r.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=r.hierarchical?Array.from(this.edges.values()):this.edgesArray;return r.tick(n,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Q(e,this.transition),r=V(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ae(e._prevX0,e._targetX0,r),e.x1=ae(e._prevX1,e._targetX1,r),e.y0=ae(e._prevY0,e._targetY0,r),e.y1=ae(e._prevY1,e._targetY1,r));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=ae(e._prevY0,e._targetY0,r),e.y1=ae(e._prevY1,e._targetY1,r),e.sankeyWidth=ae(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const r=e?.get(t.id);r&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const r=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(r){e._prevY0=r.y0,e._prevY1=r.y1,e._prevSankeyWidth=r.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,r=.5){const n="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!n||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(!r)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,r,n=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=r.x0,s=Br(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(n)},{x:e.y1,y:s(1-n)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=r.x0,s=Br(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(n),y:e.y0},{x:s(1-n),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,n,o,r))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const r=t.duration??500,n=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const c=i-s;r>c&&(t._pulseIntensity=1-c/r,t._pulseColor=n,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const c=e.edgeTimestamps.get(`${a}\0${s}`);if(!c)continue;const l=i-c;r>l&&(t._pulseIntensity=1-l/r,t._pulseColor=n)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const r=e.nodeTimestamps.size;if(1>=r)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let r=0;e.cache.sortedNodes.length>r;r++)t.set(e.cache.sortedNodes[r][0],r);e.cache.ageMap=t}const n=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=n.get(e);if(void 0===i)continue;const s=a(t,i,r);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===Or&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=Yr)return;const r=1-t/Yr;for(const t of e.sceneNodes){const n=t.id;n&&e.addedNodes.has(n)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,r),t._pulseColor=Or,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,r=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&Yr>r-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const r=t.warningColor??"#f59e0b",n=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const c=t.metric(s);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=r):l=n,l&&(i.style={...i.style,fill:l},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const r of e){const e=t.metric(r);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const r=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>r-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const r=this.nodes.get(e);if(!r)return this.updateResults.recordNoop("update"),null;const n=r.data?{...r.data}:{};return r.data=t(r.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),n}updateEdge(e,t,r){const n=this.config.valueAccessor,o="function"==typeof n?n:n?e=>e[n]:e=>e.value,i=[];for(const[,n]of this.edges)if(("string"==typeof n.source?n.source:n.source.id)===e&&("string"==typeof n.target?n.target:n.target.id)===t){i.push(n.data?{...n.data}:{}),n.data=r(n.data??{});const e=o(n.data);null!=e&&(n.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const r=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const n="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};tn.QUADTREE_THRESHOLD=500;var rn=tn;n(rn);import*as nn from"react";import{Fragment as on,jsx as an,jsxs as sn}from"react/jsx-runtime";function cn(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y,legendPosition:f="right",legendLayout:g,foregroundGraphics:p,sceneNodes:m,annotations:v,onAnnotationActivate:x,onObservation:k,chartId:b,chartType:S,autoPlaceAnnotations:_,svgAnnotationRules:w}=e,A=Se({onAnnotationActivate:x,onObservation:k,chartId:b,chartType:S}),L=nn.useMemo(()=>{const e=(m||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,r=e.cy??e.y;if("number"!=typeof t||"number"!=typeof r)return null;const n=Pe(e.glyph,e.size);return{x:t+n.centerDx,y:r+n.centerDy,r:Math.max(1,n.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),r=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof r?null:{x:t,y:r,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,be(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),r=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:r,...t}]:[]});return{scales:null,width:t,height:r,frameType:"network",pointNodes:e,sceneNodes:m}},[r,m,t]),E=nn.useMemo(()=>{if(!v)return v;const e=l(v);return _?H({annotations:e,context:L,..."object"==typeof _?_:{}}):e},[v,_,L]),P=nn.useMemo(()=>K("network"),[]),D=E?ye(E.filter(e=>"widget"!==e.type),P,w,L):null,M=!0===E?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return sn(on,{children:[M&&an("style",{children:N},"annotation-widget-disclosure-style"),sn("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[an("title",{children:"string"==typeof s?s:"Network Chart"}),an("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),sn("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>an("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),D,p]}),s&&"string"==typeof s?an("text",{x:n/2,y:Y,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?an("foreignObject",{x:0,y:0,width:n,height:i.top,children:s}):null,fe({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:f,title:s,legendLayout:g,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y})]}),E?.filter(e=>"widget"===e.type&&e.nodeId&&m).map((e,t)=>{const r=!0===e._annotationDeferred,n=m.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!n)return null;const o=i.left+(n.cx??(null!=n.x&&null!=n.w?n.x+n.w/2:n.x??0)),a=i.top+(n.cy??(null!=n.y&&null!=n.h?n.y+n.h/2:n.y??0)),s=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,d=e.content??an("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return an("div",{...j(e,A),className:r?"annotation-deferred":void 0,"data-annotation-disclosure":r?"deferred":void 0,style:{position:"absolute",left:o+s-l/2,top:a+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}cn.displayName="NetworkSVGOverlay";import*as ln from"react";import{jsx as un}from"react/jsx-runtime";var dn={position:"absolute",top:0,left:0,pointerEvents:"none"};function hn({marks:e,margin:t,selection:r=null,overscan:n=400}){const o=ln.useRef(null),i=function(e,t,r){const[n,o]=ln.useState(null);return ln.useLayoutEffect(()=>{const e=t.current,r=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:r,overflowY:n}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${n} ${r}`))return t;t=t.parentElement}return null}(e);if(!e||!r)return void o(null);let n=0;const i=()=>{n=0;const t=r.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===n&&(n=window.requestAnimationFrame(i))};i(),r.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(r),()=>{0!==n&&window.cancelAnimationFrame(n),r.removeEventListener("scroll",a),s.disconnect()}},[t,e,r]),ln.useMemo(()=>{if(!e||!n)return e;const{scroll:t,originX:o,originY:i}=n,a=t.left-r,s=t.right+r,c=t.top-r,l=t.bottom+r;return e.filter(e=>{const t=o+e.x,r=i+e.y;return!(a>t+e.width||t>s||c>r+e.height||r>l)})},[e,n,r])}(e,o,n);if(!e||0===e.length)return null;const a=un("div",{className:"semiotic-network-html-marks",ref:o,style:{...dn,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>un("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=r?un(E,{value:r,children:a}):a}import{jsx as yn,jsxs as fn}from"react/jsx-runtime";function gn({props:e,store:t,responsiveRef:r,size:n,margin:o,adjustedWidth:a,adjustedHeight:s,resolvedBackground:c,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:y,className:f,description:g,title:p,responsiveWidth:m,responsiveHeight:v,summary:x,background:b,renderMode:S,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:E,legendHighlightedCategory:D,legendIsolatedCategories:M,layoutSelection:R,annotations:N,onAnnotationActivate:T,annotationObservationCallback:C,onObservation:W,chartId:I,autoPlaceAnnotations:$,svgAnnotationRules:z}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),r=e?y||(Array.isArray(h)?void 0:h):void 0;if(e&&r)t.ingestHierarchy(r,[a,s]),t.buildScene([a,s]);else{const e=te(d),r=Array.isArray(h)?te(h):[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[a,s]),t.buildScene([a,s]))}}const F=t?.sceneNodes??[],O=t?.sceneEdges??[],Y=t?.labels??[];return fn("div",{ref:r,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:m?"100%":n[0],height:v?"100%":n[1]},children:[yn(B,{summary:x}),fn("svg",{xmlns:"http://www.w3.org/2000/svg",width:n[0],height:n[1],style:{position:"absolute",left:0,top:0},children:[c&&yn("g",{transform:`translate(${o.left},${o.top})`,children:c}),fn("g",{transform:`translate(${o.left},${o.top})`,children:[b&&yn("rect",{x:0,y:0,width:a,height:s,fill:b}),O.map((e,t)=>k({node:e,index:t,renderMode:S,fallback:()=>ce(e,t)})).filter(Boolean),F.map((e,t)=>k({node:e,index:t,renderMode:S,fallback:()=>le(e,t)})).filter(Boolean),Y.map((e,t)=>se(e,t)).filter(Boolean)]})]}),yn(cn,{width:a,height:s,totalWidth:n[0],totalHeight:n[1],margin:o,labels:Y,sceneNodes:F,title:p,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:E,legendHighlightedCategory:D,legendIsolatedCategories:M,foregroundGraphics:i(l,P(t?.customLayoutOverlays,R??null)),annotations:N,onAnnotationActivate:T,onObservation:C??W,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:$,svgAnnotationRules:z,annotationFrame:0}),yn(hn,{marks:t?.customLayoutHtmlMarks,margin:o,selection:R??null})]})}function pn(e,t,r,n,o=4e4){return"sync"!==e&&("worker"===e||n*(t+r)>=o)}function mn(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function vn(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var xn=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):D("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,r=t.requestId,n=null!=r?this.pending.get(r):this.pending.values().next().value;if(n){if(null!=r?this.pending.delete(r):this.pending.clear(),n.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void n.reject(e)}n.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(vn());const r=this.nextRequestId;this.nextRequestId+=1;const n={requestId:r,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(r),t?.removeEventListener("abort",i),o(vn())},a=()=>t?.removeEventListener("abort",i);this.pending.set(r,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(n)}catch(e){this.pending.delete(r),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},kn=null;function bn(e,t){return mn()?t?.aborted?Promise.reject(vn()):(kn&&!kn.isDead||(kn=new xn),kn).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}import{jsx as Sn,jsxs as _n}from"react/jsx-runtime";var wn=/^(value|amount|total|count|weight|score)$/i;function An({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?_n("div",{className:"semiotic-tooltip",style:U,children:[_n("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&_n("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const r=t.__hierarchyNode;if(r){const e=[];let n=r;for(;n;){const r=n.data?.name??n.data?.id??t.id;null!=r&&e.unshift(r+""),n=n.parent}e.length>1&&e.shift();const o=e.length-1;return _n("div",{className:"semiotic-tooltip",style:U,children:[Sn("div",{children:e.map((e,t)=>_n("span",{children:[t>0&&Sn("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?Sn("strong",{children:e}):Sn("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&Sn("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const n=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=xe(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>wn.test(e.key));return _n("div",{className:"semiotic-tooltip",style:U,children:[Sn("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>_n("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",d(e.value)]},e.key)),!s&&null!=t.value&&t.value>0&&_n("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),n>0&&_n("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",n,o!==n&&` (weighted: ${o.toLocaleString()})`]})]})}function Ln(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function En(e,t){if(!t.pathD)return;e.save();const r=Ln(t);if(t.style.fill&&"none"!==t.style.fill){const n=t._gradient;if(n){const r=e.createLinearGradient(n.x0,0,n.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=ge(e,i)||i;r.addColorStop(0,1===n.from?a:"transparent"),r.addColorStop(1,1===n.to?a:"transparent"),e.fillStyle=r,e.globalAlpha=o}else e.fillStyle=pe(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(r)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(r)),e.restore()}function Pn(e,t){e.save();const r=t.style.stroke||"#999";e.strokeStyle=ge(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Dn(e,t){if(!t.pathD)return;e.save();const r=Ln(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=pe(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(r)),e.restore()}function Mn(e,t){if(!t.pathD)return;e.save();const r=Ln(t),n=t.style.stroke||"#999";e.strokeStyle=ge(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=pe(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(r)),e.restore()}An.ownsChrome=!0;var Rn=new Map;function Nn(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let r=Rn.get(t);return r||(r=new Path2D(ke(e.symbolType,e.size)),Rn.size>256&&Rn.clear(),Rn.set(t,r)),r}catch{return null}}function Tn(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>h(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=y(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=p(Math.atan2(o,n)),s=p(e.startAngle),c=p(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);case"symbol":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>h(be(e.size),n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"glyph":return function(e,t,r,n=30){if(null==e.datum)return null;const o=Pe(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,c=r-a,l=Math.sqrt(s*s+c*c);return l>h(o.radius,n)?null:{type:"node",datum:e.datum,x:i,y:a,distance:l}}(e,t,r,n);default:return null}}var Cn=null,Wn=null;function In(){return Wn||((Cn=document.createElement("canvas")).width=1,Cn.height=1,Wn=Cn.getContext("2d")),Wn}function $n(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function zn(e,t,r){switch(e.type){case"bezier":return function(e,t,r){if(!e.pathD)return null;const n=$n(e),o=In();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt((t-s)**2+(r-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;const n=$n(e),o=In();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);default:return null}}function Fn(e){const{clientX:t,clientY:r,canvasRect:n,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:d,hitRadius:h=30}=e,y=t-n.left-o.left,f=r-n.top-o.top;if(0>y||y>i||0>f||f>a)return{kind:"miss-outside"};const g=function(e,t,r,n,o=30,i,a=0){let s=null,c=o,l=1/0;if(i){const e=u(i,r,n,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Tn(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;l>r&&(s=e,l=r)}else c>e.distance&&(s=e,c=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=zn(e,r,n);t&&c>t.distance&&(s=t,c=t.distance)}return s}(s,c,y,f,h,l,d);return g?{kind:"hit",hover:G(g.datum||{},g.x,g.y,{nodeOrEdge:g.type})}:{kind:"miss"}}import{useCallback as Bn}from"react";var On="StreamNetworkFrame";import{jsx as Yn,jsxs as Xn}from"react/jsx-runtime";var jn={top:20,right:80,bottom:20,left:80},Hn={top:40,right:40,bottom:40,left:40},Gn=new Set(["chord","force","circlepack","orbit"]),Vn=[800,600],qn=Be(Fe(function(n,a){const{chartType:s,nodes:l,edges:u,data:d,initialEdges:h,nodeIDAccessor:y="id",sourceAccessor:p="source",targetAccessor:k="target",valueAccessor:L="value",edgeIdAccessor:E,childrenAccessor:D,hierarchySum:M,orientation:R="horizontal",nodeAlign:N="justify",nodePaddingRatio:Y=.05,nodeWidth:X=15,iterations:j=300,forceStrength:H=.1,layoutExecution:V="auto",layoutLoadingContent:Q,onLayoutStateChange:K,padAngle:Z=.01,groupWidth:U=20,sortGroups:ae,edgeSort:se,treeOrientation:ce="vertical",edgeType:le="curve",padding:ue,paddingTop:ye,tensionConfig:fe,showParticles:ve=!1,particleStyle:xe,renderMode:ke,nodeStyle:be,edgeStyle:Se,colorBy:Le,colorScheme:Pe="category10",edgeColorBy:Fe="source",edgeOpacity:Be=.5,colorByDepth:Xe=!1,nodeSize:je=8,nodeSizeRange:He=[5,20],nodeLabel:Ge,showLabels:Ve=!0,labelMode:qe,size:Qe=Vn,responsiveWidth:Ke,responsiveHeight:Ze,margin:Ue,className:Je,background:et,enableHover:tt=!0,tooltipContent:rt,customHoverBehavior:nt,customClickBehavior:ot,onObservation:it,annotationObservationCallback:at,chartId:st,onTopologyChange:ct,annotations:lt,onAnnotationActivate:ut,autoPlaceAnnotations:dt,svgAnnotationRules:ht,legend:yt,legendPosition:ft,legendLayout:gt,legendHoverBehavior:pt,legendClickBehavior:mt,legendHighlightedCategory:vt,legendIsolatedCategories:xt,title:kt,foregroundGraphics:bt,backgroundGraphics:St,decay:_t,pulse:wt,transition:At,animate:Lt,staleness:Et,frameScheduler:Pt,clock:Dt,random:Mt,seed:Rt,paused:Nt=!1,suspendWhenHidden:Tt=!0,thresholds:Ct,accessibleTable:Wt=!0,description:It,summary:$t,orbitMode:zt,orbitSize:Ft,orbitSpeed:Bt,orbitRevolution:Ot,orbitRevolutionStyle:Yt,orbitEccentricity:Xt,orbitShowRings:jt,orbitAnimated:Ht,customNetworkLayout:Gt,onLayoutError:Vt,layoutConfig:qt,layoutSelection:Qt}=n,Kt=Gn.has(s)?Hn:jn,Zt=Te(!0),Ut=_e({sizeProp:Qe,responsiveWidth:Ke,responsiveHeight:Ze,userMargin:Ue,marginDefault:Kt,title:kt,legend:yt,legendPosition:ft,foregroundGraphics:bt,backgroundGraphics:St,animate:Lt,transitionProp:At,frameScheduler:Pt,clock:Dt,random:Mt,seed:Rt,paused:Nt,suspendWhenHidden:Tt,themeDirtyRef:Zt}),{reducedMotionRef:Jt,responsiveRef:er,size:tr,margin:rr,adjustedWidth:nr,adjustedHeight:or,resolvedForeground:ir,resolvedBackground:ar,transition:cr,introEnabled:lr,tableId:ur,rafRef:dr,renderFnRef:hr,scheduleRender:yr,frameRuntime:fr,currentTheme:gr}=Ut,pr=Me(),mr=Re(),vr=Ie(()=>te(l),[l]),xr=Ie(()=>Array.isArray(u)?te(u):u,[u]),kr=Ie(()=>({...Oe,...fe}),[fe]),br=Ie(()=>({...Ye,...xe}),[xe]),Sr=Ie(()=>{return{chartType:(e={chartType:s,clock:fr.now,random:Mt,seed:Rt,nodeIDAccessor:y,sourceAccessor:p,targetAccessor:k,valueAccessor:L,edgeIdAccessor:E,childrenAccessor:D,hierarchySum:M,orientation:R,nodeAlign:N,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:H,padAngle:Z,groupWidth:U,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:ue,paddingTop:ye,tensionConfig:kr,showParticles:ve,particleStyle:br,nodeStyle:be,edgeStyle:Se,nodeLabel:Ge,showLabels:Ve,labelMode:qe,colorBy:Le,colorScheme:Pe,edgeColorBy:Fe,edgeOpacity:Be,colorByDepth:Xe,nodeSize:je,nodeSizeRange:He,decay:_t,pulse:wt,transition:cr,introAnimation:lr,staleness:Et,thresholds:Ct,orbitMode:zt,orbitSize:Ft,orbitSpeed:Bt,orbitRevolution:Ot,orbitRevolutionStyle:Yt,orbitEccentricity:Xt,orbitShowRings:jt,orbitAnimated:Ht,customNetworkLayout:Gt,onLayoutError:Vt,layoutConfig:qt,currentTheme:gr}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Ee(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[s,fr.now,Mt,Rt,y,p,k,L,E,D,M,R,N,Y,X,j,H,Z,U,ae,se,ce,le,ue,ye,kr,ve,br,be,Se,Ge,Ve,qe,Le,Pe,Fe,Be,Xe,je,He,_t,wt,cr,lr,Et,Ct,zt,Ft,Bt,Ot,Yt,Xt,jt,Ht,Gt,Vt,qt,gr]),_r=w(Sr),wr=w({chartType:(Ar={chartType:s,nodeIDAccessor:y,sourceAccessor:p,targetAccessor:k,valueAccessor:L,edgeIdAccessor:E,childrenAccessor:D,hierarchySum:M,orientation:R,nodeAlign:N,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:H,padAngle:Z,groupWidth:U,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:ue,paddingTop:ye,random:Mt,seed:Rt,tensionConfig:kr,customNetworkLayout:Gt,orbitMode:zt,orbitSize:Ft,orbitEccentricity:Xt}).chartType,nodeIDAccessor:Ar.nodeIDAccessor,sourceAccessor:Ar.sourceAccessor,targetAccessor:Ar.targetAccessor,valueAccessor:Ar.valueAccessor,edgeIdAccessor:Ar.edgeIdAccessor,childrenAccessor:Ar.childrenAccessor,hierarchySum:Ar.hierarchySum,orientation:Ar.orientation,nodeAlign:Ar.nodeAlign,nodePaddingRatio:Ar.nodePaddingRatio,nodeWidth:Ar.nodeWidth,iterations:Ar.iterations,forceStrength:Ar.forceStrength,padAngle:Ar.padAngle,groupWidth:Ar.groupWidth,sortGroups:Ar.sortGroups,edgeSort:Ar.edgeSort,treeOrientation:Ar.treeOrientation,edgeType:Ar.edgeType,padding:Ar.padding,paddingTop:Ar.paddingTop,random:Ar.random,seed:Ar.seed,tensionConfig:Ar.tensionConfig,customNetworkLayout:Ar.customNetworkLayout,orbitMode:Ar.orbitMode,orbitSize:Ar.orbitSize,orbitEccentricity:Ar.orbitEccentricity});var Ar;const Lr=Te(0),Er=Te(0),Pr=Te(!1),Dr=Te(null);Dr.current||(Dr.current=new rn(_r));const Mr=Ae("StreamNetworkFrame"),Rr=$e((e,t,r=!1)=>me(Mr.current,e,()=>e.buildScene(t),r),[Mr]),[Nr,Tr]=Ce(null),[Cr,Wr]=Ce(0),[Ir,$r]=Ce(0),[zr,Fr]=Ce(!1),[Br,Or]=Ce(!1),Yr=Te(0),Xr=Te(null),jr=Te(!1),Hr=Te(K);Hr.current=K;const Gr=Te(_r);Gr.current=_r;const Vr=Te(null),qr=Te(new Map),Qr=Te(0),Kr=$e(e=>function(e){const{node:t,colorBy:r,colorScheme:n,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof r)return r(t)+"";if("string"==typeof r&&t.data){const e=t.data[r];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(n)?n:W;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(n)?n:W,s=r?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:Le,colorScheme:Pe,nodeColorMap:qr.current,colorIndexRef:Qr}),[Le,Pe]),Zr=$e(e=>{Qr.current=function(e){const{sceneNodes:t,nodes:r,nodeColorMap:n,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&n.set(e.id,e.style.fill);const i=Array.isArray(o)?o:W,a=Array.from(r);for(let e=0;a.length>e;e++){const t=a[e];n.has(t.id)||n.set(t.id,i[e%i.length])}return a.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qr.current,colorScheme:Pe})},[Pe]),Ur=$e((e,t)=>{Rr(e,t),Zr(e),Zt.current=!1,e.markStylePaintPending()},[Rr,Zr]),Jr=(en=gr,en?.colors?.border||en?.colors?.secondary||en?.colors?.primary||"#999");var en;const tn=$e(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Dr.current?.nodes),[]),nn=$e(e=>function(e){const{edge:t,edgeColorBy:r,getNodeColor:n,resolveEndpoint:o,fallback:i}=e;if("function"==typeof r)return r(t);const a=o(t.source),s=o(t.target);return"target"===r&&s?n(s):a?n(a):i}({edge:e,edgeColorBy:Fe,getNodeColor:Kr,resolveEndpoint:tn,fallback:Jr}),[Fe,Kr,Jr,tn]),on=$e(e=>function(e){const{edge:t,particleStyleColor:r,particleColorBy:n,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:c}=e;if("function"==typeof r){const e=s(t.source);return e?r(t,e):c}if(!o)return i(t);const l=n,u=s(t.source),d=s(t.target);return"target"===l&&d?a(d):u?a(u):c}({edge:e,particleStyleColor:br.color,particleColorBy:br.colorBy,hasExplicitParticleColorBy:!!xe?.colorBy,getEdgeColor:nn,getNodeColor:Kr,resolveEndpoint:tn,fallback:Jr}),[xe?.colorBy,br.color,br.colorBy,Kr,nn,Jr,tn]),an=function(e,t,r,n,o){return("sankey"===e||t)&&r||n||o}(s,!!Gt,ve,!!wt,Dr.current?.isAnimating??!1);S(Dr,_r,Zt,yr),_(Dr,Qt,Zt,yr),We(()=>{const e=Dr.current;e&&(Ur(e,[nr,or]),yr())},[gr,nr,or,Ur,yr]);const sn=$e(()=>{const e=Dr.current;if(e&&(e.runLayout([nr,or]),Ur(e,[nr,or]),Wr(e.layoutVersion),ct)){const{nodes:t,edges:r}=e.getLayoutData();ct(t,r)}},[nr,or,Ur,ct]),ln=Te(!1),un=$e((e=!1)=>!(!e&&!ln.current||(ln.current=!1,sn(),0)),[sn]),dn=$e(()=>un(!1),[un]),yn=$e(e=>{const t=Dr.current;if(!t)return!1;let r=!1,n=ln.current;for(const o of e)null!=o&&"object"==typeof o&&(r=!0,t.ingestEdge(o)&&(n=!0));const o=un(n);return r||o},[un]),fn=$e(e=>{if(null==e||"object"!=typeof e)return;const t=Dr.current;t&&(t.ingestEdge(e)&&(ln.current=!0),fr.isActive?yr():dn())},[dn,fr,yr]),vn=$e(e=>{yn(e)&&yr()},[yn,yr]);We(()=>fr.subscribe(()=>{fr.isActive||dn()}),[dn,fr]);const xn=$e(()=>{ln.current=!1,Dr.current?.clear(),qr.current.clear(),Qr.current=0,Wr(Dr.current?.layoutVersion??0),Tr(null),Vr.current=null,Zt.current=!0,yr()},[yr]),kn=$e(()=>{const e=Dr.current;e&&(e.tension+=999,un(!0),yr())},[un,yr]);ze(a,()=>({push:fn,pushMany:vn,removeNode:e=>{const t=Dr.current?.removeNode(e)??!1;if(t){const t=Vr.current?.data?"function"==typeof y?y(Vr.current.data):Vr.current.data[y]:void 0;Vr.current&&"node"===Vr.current.nodeOrEdge&&t===e&&(Vr.current=null,Tr(null)),qr.current.delete(e)}return un(t)&&(Zt.current=!0,yr()),t},removeEdge:(e,t)=>{const r=Dr.current?.removeEdge(e,t)??!1;if(r&&Vr.current&&"edge"===Vr.current.nodeOrEdge){const r=Vr.current.data;let n;n=void 0!==t?("object"==typeof r?.source?r.source.id:r?.source)===e&&("object"==typeof r?.target?r.target.id:r?.target)===t:!E||!r||("function"==typeof E?E:e=>e?.[E])(r)===e,n&&(Vr.current=null,Tr(null))}return un(r)&&(Zt.current=!0,yr()),r},updateNode:(e,t)=>{const r=Dr.current?.updateNode(e,t)??null;return un(null!==r)&&(Zt.current=!0,yr()),r},updateEdge:(e,t,r)=>{const n=Dr.current?.updateEdge(e,t,r)??[];return un(n.length>0)&&(Zt.current=!0,yr()),n},clear:xn,getTopology:()=>(dn(),Dr.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(dn(),Dr.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(dn(),Dr.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{dn();const e=Dr.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:kn,getTension:()=>(dn(),Dr.current?.tension??0)}),[fn,vn,xn,kn,dn,un,y,yr,E]);const Sn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(s),_n=Sn?d||(Array.isArray(u)?void 0:u):void 0;We(()=>{const e=Dr.current;if(!e)return;const t=++Yr.current;if(Xr.current?.abort(),Xr.current=null,Sn&&_n)ln.current=!1,e.ingestHierarchy(_n,[nr,or]),Ur(e,[nr,or]),Or(!1),Hr.current?.("ready"),yr();else{const r=vr,n=Array.isArray(xr)?xr:[];if(null==l&&null==u||(ln.current=!1),0===r.length&&0===n.length)return null==l&&null==u||0>=e.nodes.size&&0>=e.edges.size||xn(),Or(!1),void Hr.current?.("ready");const o=[nr,or],i="force"===s&&!Gt&&mn()&&!Mt&&pn(V,r.length,n.length,j);if(i&&mr&&!jr.current&&e.sceneNodes.length>0)return jr.current=!0,Or(!1),Hr.current?.("ready"),Zt.current=!0,void yr();if(i){const i=new AbortController;Xr.current=i;const a=e._lastPositionSnapshot;e.ingestBounded(r,n,o,{deferLayout:!0});const s=e.getLayoutData(),c=function(e,t,r,n,o){const i=sr(r.nodeSize,r.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id,n=e.data?.weight,o="number"==typeof n&&Number.isFinite(n)?n:e.value;return{source:t,target:r,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:r.iterations,forceStrength:r.forceStrength,seed:r.seed},size:n}}(s.nodes,s.edges,Gr.current,o,a);return Or(!0),Hr.current?.("pending"),bn(c,i.signal).then(({positions:r})=>{t===Yr.current&&(e.applyForceLayoutPositions(r,o),Ur(e,o),Or(!1),Hr.current?.("ready"),Wr(e.layoutVersion),yr())}).catch(r=>{"AbortError"!==r.name&&t===Yr.current&&(e.runLayout(o),Ur(e,o),Or(!1),Hr.current?.("error"),Wr(e.layoutVersion),yr())}),()=>i.abort()}e.ingestBounded(r,n,o),Ur(e,o),Or(!1),Hr.current?.("ready"),yr()}},[vr,xr,l,u,d,_n,Sn,nr,or,wr,V,j,mr,s,Gt,Mt,yr,xn,Ur]);const wn=Ne.useRef(!1);We(()=>{wn.current||h&&h.length>0&&(wn.current=!0,vn(h))},[h,vn]);const{customHoverBehavior:Ln,customClickBehavior:Rn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:r,chartId:n}){return{customHoverBehavior:Bn((t,o)=>{e?.(t,o),ee({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:On,chartId:n,context:o})},[e,r,n]),customClickBehavior:Bn((e,o)=>{t?.(e,o),J({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:On,chartId:n,context:o})},[t,r,n])}}({customHoverBehavior:nt,customClickBehavior:ot,onObservation:it,chartId:st}),{hoverHandlerRef:Tn,hoverLeaveRef:Cn,onPointerMove:Wn,onPointerLeave:In}=Ut,$n=()=>!Gt||(Dr.current?.hasCustomRestyle??!1);Tn.current=e=>{if(!tt)return;const t=$n(),r=eo.current;if(!r)return;const n=Dr.current;if(!n)return;const o=Fn({clientX:e.clientX,clientY:e.clientY,canvasRect:r.getBoundingClientRect(),margin:rr,adjustedWidth:nr,adjustedHeight:or,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?(Vr.current=o.hover,Tr(o.hover),Ln&&(Ln(o.hover),t&&(Zt.current=!0)),t&&yr()):Vr.current&&(Vr.current=null,Tr(null),Ln&&(Ln(null),t&&(Zt.current=!0)),t&&yr())},Cn.current=()=>{if(Vr.current){const e=$n();Vr.current=null,Tr(null),Ln&&(Ln(null),e&&(Zt.current=!0)),e&&yr()}};const zn=Te(()=>{});zn.current=e=>{if(ne(e.target))return;if(!ot&&!it)return;const t=eo.current;if(!t)return;const r=Dr.current;if(!r)return;const n=Fn({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rr,adjustedWidth:nr,adjustedHeight:or,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===n.kind?Rn(n.hover,{type:"activate",inputType:de(e.nativeEvent.pointerType)}):"miss"===n.kind&&Rn(null)};const qn=$e(e=>zn.current(e),[]),Qn=Te(-1),Kn=Te(null),Zn=Te(-1),Un=$e(e=>{if(oe(e))return;const t=Dr.current;if(!t)return;const r=()=>{Qn.current=-1,Kn.current=null,Zn.current=-1,Vr.current=null,Tr(null),Ln&&(Ln(null),Zt.current=!0),yr()},n=c(t.sceneNodes);if(0===n.length)return void(0>Qn.current||r());const i=o(n);let a=Qn.current;if(i.flat.length>a||(r(),a=-1)," "===e.key&&a>=0){e.preventDefault();const t=i.flat[a];return void Rn(G(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>a){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Qn.current=0,Zn.current=-1;const t=i.flat[0];Kn.current={shape:t.shape,w:t.w,h:t.h};const r=G(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vr.current=r,Tr(r),Ln&&(Ln(r,{type:"focus",inputType:"keyboard"}),Zt.current=!0),void yr()}const s=b(i,a),l=g(e.key,s,i,t.sceneEdges??[],Zn);if(null===l)return;if(e.preventDefault(),0>l)return void r();Qn.current=l;const u=i.flat[l];Kn.current={shape:u.shape,w:u.w,h:u.h};const d={data:u.datum||{},x:u.x,y:u.y,__semioticHoverData:!0,nodeOrEdge:"node"};Vr.current=d,Tr(d),Ln&&(Ln(d,{type:"focus",inputType:"keyboard"}),Zt.current=!0),yr()},[Rn,Ln,yr]),Jn=$e(e=>{Qn.current=-1,Kn.current=null,Wn(e)},[Wn]);hr.current=()=>{if(dr.current=null,dn(),!fr.isActive)return;const r=eo.current;if(!r)return;const n=Dr.current;n&&function(r){const{canvas:n,store:o,sceneRevisionDiagnostics:i,size:a,margin:s,adjustedWidth:c,adjustedHeight:l,background:u,renderMode:d,hasBackgroundGraphics:h=!1,dirtyRef:y,lastFrameTimeRef:g,now:p,random:k,reducedMotion:b,showParticles:S,isContinuous:_,animate:w,decay:A,pulse:L,thresholds:E,staleness:P,particleStyle:D,getParticleColor:M,pendingAnnotationFrameRef:R,lastAnnotationFrameTimeRef:N,setAnnotationFrame:T,scheduleNextFrame:C,syncColorMap:W}=r,I=n.getContext("2d");if(!I)return;const $=g.current?Math.min((p-g.current)/1e3,.1):.016;g.current=p;const z=o.advanceTransition(b?p+1e6:p),F=!b&&z,B=!b&&o.tickAnimation([c,l],$),O=y.current,Y=i?.beforeCompute(o.getLastUpdateResult(),F),X=z||O||B;X&&(o.buildScene([c,l]),O&&W?.()),Y&&i?.afterCompute(Y,X,!1);const j=S&&!b&&!!o.particlePool,H=!!A||!!L||!!E||!1!==w&&o.hasActiveTopologyDiff||o.hasActivePulses||o.hasActiveThresholds,G=o.consumeStylePaintPending(),V=e({dirtyOrRebuilt:O,transitioning:F,animationTicked:B,continuous:j||_,liveEncoding:H,forced:G}),Q=!!P&&o.lastIngestTime>0&&p-o.lastIngestTime>(P?.threshold??5e3);if(V){const e=re();if(!he(n,a,s,e))return;if(I.clearRect(-s.left,-s.top,a[0],a[1]),t(I,{background:u,hasBackgroundGraphics:h,width:c,height:l}),A&&o.applyDecay(),L&&o.applyPulse(p),E&&o.applyThresholds(p),!1!==w&&o.applyTopologyDiff(p),Q&&(I.globalAlpha=P?.dimOpacity??.5),m({context:I,nodes:o.sceneEdges,renderMode:d,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const r of t)switch(r.type){case"bezier":En(e,r);break;case"line":Pn(e,r);break;case"ribbon":Dn(e,r);break;case"curved":Mn(e,r)}}(I,e)}),m({context:I,nodes:o.sceneNodes,renderMode:d,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=pe(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),x(e,t),e.restore())}}(I,t),function(e,t){for(const r of t){if("circle"!==r.type)continue;const t=r;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=pe(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),v(e,t),e.restore())}}(I,t),function(e,t){for(const r of t){if("arc"!==r.type)continue;const t=r;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=pe(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(I,t),function(e,t){const r=e.globalAlpha;for(const n of t){if("symbol"!==n.type)continue;const t=n;if(0>=t.size)continue;const o=Nn(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=r*i*(t.style.fillOpacity??1),e.fillStyle=pe(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=r*i,e.strokeStyle=ge(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(I,t),f(I,t)}}),j&&!Q){const e=o.edgesArray;if(e.length>0){!function(e,t,r,n,o=Math.random){const i=n.spawnRate??.1,a=n.maxPerEdge??50;for(let n=0;t.length>n;n++){const s=t[n];if(!s.bezier)continue;if(e.countForEdge(n)>=a)continue;const c=s.value*i*r*(s.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let d=l;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(n)<a;t++)e.spawn(n,o)}}(o.particlePool,e,$,D,k);const t=.5*(D.speedMultiplier??1);let r;if(D.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}o.particlePool.step($,t,e,r),function(e,t,r,n,o){const i=n.radius??3;e.globalAlpha=n.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const c=r[s.edgeIndex];if(!c)continue;let l;l="string"==typeof n.color&&"inherit"!==n.color?n.color:o(c),e.fillStyle=ge(e,l)||l,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(I,o.particlePool,e,D,M)}}Q&&(I.globalAlpha=1)}y.current=!1,(O||F||B)&&n.setAttribute("aria-label",q(o.sceneNodes?.length??0,o.sceneEdges?.length??0,"Network chart"));const K=O||F||B||R.current;K&&p-N.current>=33?(T(e=>e+1),N.current=p,R.current=!1):R.current=!!K,(_||F||null!=o.transition||B||o.hasActivePulses||o.hasActiveThresholds||!1!==w&&o.hasActiveTopologyDiff||R.current)&&C()}({canvas:r,store:n,sceneRevisionDiagnostics:Mr.current,size:tr,margin:rr,adjustedWidth:nr,adjustedHeight:or,background:et,renderMode:ke,hasBackgroundGraphics:!!St,dirtyRef:Zt,lastFrameTimeRef:Lr,now:fr.now(),random:fr.random,reducedMotion:!!Jt.current,showParticles:ve,isContinuous:an,animate:Lt,decay:_t,pulse:wt,thresholds:Ct,staleness:Et,particleStyle:br,getParticleColor:on,pendingAnnotationFrameRef:Pr,lastAnnotationFrameTimeRef:Er,setAnnotationFrame:$r,scheduleNextFrame:()=>{yr()},syncColorMap:()=>Zr(n)})};const{canvasRef:eo}=we(Ut,{hydrated:pr,wasHydratingFromSSR:mr,storeRef:Dr,dirtyRef:Zt,skipInitialCanvasPaintInvalidation:!0,canvasPaintDependencies:[s,nr,or,et,St,ke,yr]});A(Et,Dr,Zt,yr,zr,Fr);const to=tt&&Nr?Yn(I,{x:Nr.x,y:Nr.y,containerWidth:nr,containerHeight:or,margin:rr,className:"stream-network-tooltip",zIndex:2,children:rt?rt(Nr):Yn(An,{data:Nr})}):null;if(ie||!pr&&mr)return Yn(gn,{props:n,store:Dr.current,responsiveRef:er,size:tr,margin:rr,adjustedWidth:nr,adjustedHeight:or,resolvedBackground:ar,resolvedForeground:ir});const ro=Dr.current;return Xn("div",{ref:er,className:"stream-network-frame"+(Je?" "+Je:""),role:"group","aria-label":It||("string"==typeof kt?kt:"Network chart"),tabIndex:0,"aria-busy":Br||void 0,style:{position:"relative",width:Ke?"100%":tr[0],height:Ze?"100%":tr[1],overflow:"visible"},onKeyDown:Un,children:["production"!==process.env.NODE_ENV&&Dr.current&&Yn(F,{store:Dr.current,diagnostics:Mr.current}),Wt&&Yn(O,{tableId:ur}),Wt&&Yn(z,{nodes:ro?.sceneNodes??[],edges:ro?.sceneEdges??[],chartType:"Network chart",tableId:ur,chartTitle:"string"==typeof kt?kt:void 0}),Yn(B,{summary:$t}),Yn(T,{hoverPoint:Nr}),Xn("div",{role:"img","aria-label":It||("string"==typeof kt?kt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:tt?Jn:void 0,onMouseLeave:tt?In:void 0,onClick:ot||it?qn:void 0,children:[Br&&!1!==Q&&Yn("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:De(!0,tr[0],tr[1],Q)}),Yn(C,{size:tr,margin:rr,overflowVisible:!0,children:ar}),Yn("canvas",{ref:eo,"aria-label":q(ro?.sceneNodes?.length??0,ro?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Yn(cn,{width:nr,height:or,totalWidth:tr[0],totalHeight:tr[1],margin:rr,labels:ro?.labels||[],sceneNodes:ro?.sceneNodes,title:kt,legend:yt,legendPosition:ft,legendLayout:gt,legendHoverBehavior:pt,legendClickBehavior:mt,legendHighlightedCategory:vt,legendIsolatedCategories:xt,foregroundGraphics:i(ir,P(Dr.current?.customLayoutOverlays,Qt??null)),annotations:lt,onAnnotationActivate:ut,onObservation:at??it,chartId:st,chartType:"StreamNetworkFrame",autoPlaceAnnotations:dt,svgAnnotationRules:ht,annotationFrame:Ir}),Yn(hn,{marks:ro?.customLayoutHtmlMarks,margin:rr,selection:Qt??null}),Yn($,{active:Qn.current>=0,hoverPoint:Nr,margin:rr,size:tr,shape:Kn.current?.shape,width:Kn.current?.w,height:Kn.current?.h}),to,Et?.showBadge&&Yn(r,{isStale:zr,position:Et.badgePosition})]})]})}));qn.displayName="StreamNetworkFrame";var Qn=qn;export{Ot as buildRibbonGeometry,pn as shouldUseForceWorker,mn as canUseForceWorker,bn as runForceLayoutWorker,Qn as StreamNetworkFrame_default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{StreamXYFrame_default as e}from"./chunk-chunk-CKMD5NV3.module.min.js";import{buildCustomBehaviorProps as t}from"./chunk-chunk-XXWSHGPL.module.min.js";import{normalizeLinkedBrush as n,useBrushSelection as i,useChartLegendAndMargin as s,useChartMode as o,useChartSelection as r}from"./chunk-chunk-CWQ5YIHX.module.min.js";import{renderEmptyState as a,renderLoadingState as l}from"./chunk-chunk-ACLDBMRH.module.min.js";var c=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},u=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,i=Math.floor(e/n);for(let s=Math.floor((e-this.size)/n)+1;i>=s;s++)this.bump(s*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new c,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,i=new c;i.push(t);let s=e,o=e;const r=[],a={start:s,end:o,stats:i};for(const t of this.sessions)e-n>t.end||t.start>e+n?r.push(t):(a.stats.merge(t.stats),s>t.start&&(s=t.start),t.end>o&&(o=t.end));a.start=s,a.end=o,r.push(a),r.sort((e,t)=>e.start-t.start),this.sessions=r}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const i=t+this.size;e.push(this.row(t,i,n,i>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,i){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:i}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function m(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function h(e,t,n,i=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const s=m(e,n),o=e.stddev*i;return[s-o,s+o]}var d={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},p=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function g(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;p.lastIndex=0;let n,i=0,s=0;for(;null!==(n=p.exec(t));){const e=parseFloat(n[1]),t=d[n[2]];if(null==t||!Number.isFinite(e))return null;i+=e*t,s+=n[0].length}return s!==t.length?null:i>0?i:null}var v=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const i of this.held)this.getTime(i)>e?n.push(i):t.push(i);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as f,useImperativeHandle as w,forwardRef as y,useCallback as b,useState as x,useEffect as A}from"react";import{jsx as _,jsxs as k}from"react/jsx-runtime";var H={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},S={opacity:.7,marginRight:4};function z(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function I(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function C(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=z(o,t,"time"),a=z(o,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]})]})}}function T(e,t){return null!=e?e:Math.max(t?.length??0,200)}var R="time",P="value",M="__aggLower",F="__aggUpper",N="__aggPartial",D="count",E="__aggStart",B="__aggEnd";function O(e,t){const n=t.stat??"mean",i=t.band??"none",s=t.sigma??1;return e.emit().map(e=>{const t={[R]:(e.start+e.end)/2,[P]:m(e,n),[D]:e.count,[N]:e.partial,[E]:e.start,[B]:e.end},o=h(e,i,n,s);return o&&(t[M]=o[0],t[F]=o[1]),t})}import{jsx as j}from"react/jsx-runtime";function L(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isFinite(s)?s:null}var W=y(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:m,className:h,arrowOfTime:d="right",windowMode:p="sliding",windowSize:y,data:_,timeAccessor:k,valueAccessor:H,timeExtent:S,valueExtent:z,extentPadding:I,stroke:N="#007bff",strokeWidth:D=2,strokeDasharray:E,opacity:B,background:W,tooltipContent:V,tooltip:$,onHover:X,annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:G,tickFormatTime:K,tickFormatValue:Q,decay:U,pulse:J,staleness:Z,transition:ee,linkedHover:te,selection:ne,onObservation:ie,chartId:se,loading:oe,loadingContent:re,emptyContent:ae,emphasis:le,legendPosition:ce,aggregate:ue,eventTime:me}=n,he=s.showAxes,de=s.enableHover,pe=m??s.marginDefaults,ge=c??[s.width,s.height],ve=V??$??C({timeAccessor:k,valueAccessor:H}),fe=f(null),{customHoverBehavior:we}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ie,chartType:"RealtimeLineChart",chartId:se}),ye=b(e=>{X&&X(e),we(e)},[X,we]),be=null!=ue,[xe,Ae]=x([]),_e=f(null),ke=f(ue);ke.current=ue;const He=f(be);He.current=be;const Se=f(xe);Se.current=xe;const ze=f({timeAccessor:k,valueAccessor:H});ze.current={timeAccessor:k,valueAccessor:H},A(()=>{if(!be)return void(_e.current=null);const e=ke.current,t=function(e){const t=e.window??"tumbling",n=g("session"===t?e.gap??e.size:e.size);if(null==n)return null;const i=null!=e.hop?g(e.hop):void 0,s=null!=e.gap?g(e.gap):void 0;return new u({window:t,size:n,hop:i??void 0,gap:s??void 0,retain:e.retain})}(e);if(_e.current=t,t&&_){const{timeAccessor:e,valueAccessor:n}=ze.current;for(const i of _){const s=L(i,e,"time"),o=L(i,n,"value");null!=s&&null!=o&&t.push(s,o)}}Ae(t?O(t,e):[])},[be?[ue.window??"tumbling",ue.size,ue.hop??"",ue.gap??"",ue.retain??""].join("|"):"",be,_]),A(()=>{be&&_e.current&&Ae(O(_e.current,ke.current))},[ue?.stat,ue?.band,ue?.sigma]);const Ie=b(e=>{const t=_e.current,n=ke.current;if(!t||!n)return;const{timeAccessor:i,valueAccessor:s}=ze.current;for(const n of e){const e=L(n,i,"time"),o=L(n,s,"value");null!=e&&null!=o&&t.push(e,o)}Ae(O(t,n))},[]),Ce=null!=me,Te=f(null),Re=f(me);Re.current=me;const Pe=f(Ce);Pe.current=Ce;const Me=f(ie);Me.current=ie;const Fe=f(se);Fe.current=se,A(()=>{Te.current=Ce?function(e){const t=g(e.lateness);return null==t?null:new v({lateness:t,getTime:e=>L(e,ze.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(Re.current):null},[Ce?`${me.lateness}|${me.latePolicy??"drop"}`:"",Ce]);const Ne=b(e=>{0!==e.length&&(He.current?Ie(e):fe.current?.pushMany(e))},[Ie]),De=b(e=>{const t=Te.current;if(!Pe.current||!t)return void Ne(e);const n=[];for(const i of e){const e=t.push(i);if(e.released.length&&n.push(...e.released),e.late.length){const n=Me.current;if(n){const{timeAccessor:i}=ze.current,s=Re.current?.latePolicy??"drop";for(const o of e.late)n({type:"late-data",datum:o,eventTime:L(o,i,"time")??NaN,watermark:t.watermark,policy:s,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:Fe.current})}}}Ne(n)},[Ne]);w(i,()=>({push:e=>De([e]),pushMany:e=>De(e),remove:e=>He.current?[]:fe.current?.remove(e)??[],update:(e,t)=>He.current?[]:fe.current?.update(e,t)??[],clear:()=>{Te.current?.clear(),He.current?(_e.current?.clear(),Ae([])):fe.current?.clear()},getData:()=>He.current?Se.current:fe.current?.getData()??[],getScales:()=>fe.current?.getScales()??null}),[De]);const Ee=l(oe,ge[0],ge[1],re),Be=Ee?null:a(be?void 0:_,ge[0],ge[1],ae),Oe={stroke:N,strokeWidth:D,strokeDasharray:E};null!=B&&(Oe.opacity=B);const je=T(y,_),Le=be?xe:_,We=be?R:k,Ve=be?P:H,$e=be&&ue&&"none"!==(ue.band??"none")?{y0Accessor:M,y1Accessor:F,perSeries:!1}:void 0;return Ee||Be||j(e,{ref:fe,chartType:"line",runtimeMode:"streaming",size:ge,margin:pe,className:le?`${h||""} semiotic-emphasis-${le}`.trim():h,arrowOfTime:d,windowMode:be?"growing":p,windowSize:be?Math.max(1,ue?.retain??Math.max(xe.length,600)):je,data:Le,timeAccessor:We,valueAccessor:Ve,xExtent:S,yExtent:z,extentPadding:I,band:$e,lineStyle:Oe,showAxes:he,background:W,hoverAnnotation:de,tooltipContent:ve,...t({linkedHover:te,selection:ne,onObservation:ie,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ye}),annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:G,tickFormatTime:K,tickFormatValue:Q,decay:U,pulse:J,staleness:Z,transition:ee,pointIdAccessor:n.pointIdAccessor,legendPosition:ce})});W.displayName="RealtimeLineChart";import{useRef as V,useImperativeHandle as $,forwardRef as X,useCallback as Y,useMemo as q}from"react";function G(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const s=Number(i);return Number.isFinite(s)?s:null}import{jsx as K}from"react/jsx-runtime";var Q=X(function(c,u){const m=o(c.mode,{width:c.size?.[0]??c.width,height:c.size?.[1]??c.height,showAxes:c.showAxes,showLegend:c.showLegend,enableHover:null!=c.enableHover?!!c.enableHover:void 0,linkedHover:c.linkedHover,mobileInteraction:c.mobileInteraction,mobileSemantics:c.mobileSemantics,responsiveRules:c.responsiveRules}),{binSize:h,size:d,margin:p,className:g,arrowOfTime:v="right",windowMode:f="sliding",windowSize:w,data:y,timeAccessor:b,valueAccessor:x,direction:A="up",timeExtent:C,valueExtent:R,extentPadding:P,categoryAccessor:M,colors:F,fill:N,stroke:D,strokeWidth:E,opacity:B,gap:O,background:j,tooltipContent:L,tooltip:W,onHover:X,annotations:Q,autoPlaceAnnotations:U,svgAnnotationRules:J,tickFormatTime:Z,tickFormatValue:ee,linkedHover:te,selection:ne,decay:ie,pulse:se,staleness:oe,transition:re,onObservation:ae,chartId:le,loading:ce,loadingContent:ue,emptyContent:me,emphasis:he,legendPosition:de,legend:pe,brush:ge,onBrush:ve,linkedBrush:fe}=c,we=m.showAxes,ye=m.enableHover,be=d??[m.width,m.height],xe=q(()=>F?e=>F[e]??N??"#999":void 0,[F,N]),{legend:Ae,margin:_e,legendPosition:ke}=s({data:y??[],colorBy:M,colorScale:xe,showLegend:m.showLegend,legendPosition:de,userMargin:p,defaults:m.marginDefaults,additionalLegend:pe}),He=L??W??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null;if(null==i?.binStart||null==i?.binEnd){const e=z(i,t,"time"),s=z(i,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(e)]}),k("div",{children:[_("span",{style:S,children:"y:"}),I(s)]})]})}return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"range:"}),I(i.binStart),"–",I(i.binEnd)]}),null!=i.total&&k("div",{children:[_("span",{style:S,children:"count:"}),I(i.total)]}),null!=i.category&&k("div",{children:[_("span",{style:S,children:"category:"}),I(i.category)]})]})}}({timeAccessor:b,valueAccessor:x}),Se=V(null),{customHoverBehavior:ze}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ae,chartType:"RealtimeHistogram",chartId:le}),Ie=Y(e=>{X&&X(e),ze(e)},[X,ze]),Ce=!0===ge?{dimension:"x",snap:"bin"}:"x"===ge?{dimension:"x"}:"object"==typeof ge?ge:void 0,Te=n(fe),Re="string"==typeof b?b:"time",Pe=i({name:Te?.name||"__unused_hist_brush__",xField:Te?.xField||Re,...Te?.yField?{yField:Te.yField}:{}}),Me=V(Pe.brushInteraction);Me.current=Pe.brushInteraction;const Fe=Y(e=>{if(ve&&ve(e),ae&&ae(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}),Te){const t=Me.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[ve,ae,le,Te]);$(u,()=>({push:e=>Se.current?.push(e),pushMany:e=>Se.current?.pushMany(e),remove:e=>Se.current?.remove(e)??[],update:(e,t)=>Se.current?.update(e,t)??[],clear:()=>Se.current?.clear(),getData:()=>Se.current?.getData()??[],getScales:()=>Se.current?.getScales()??null}),[]);const Ne=l(ce,be[0],be[1],ue),De=Ne?null:a(y,be[0],be[1],me),Ee={};null!=N&&(Ee.fill=N),null!=D&&(Ee.stroke=D),null!=E&&(Ee.strokeWidth=E),null!=B&&(Ee.opacity=B),null!=O&&(Ee.gap=O);const Be=he?`${g||""} semiotic-emphasis-${he}`.trim():g,Oe=T(w,y),je=q(()=>"down"!==A?R:function({data:e,valueAccessor:t,timeAccessor:n,binSize:i,valueExtent:s,extentPadding:o}){if(s)return[s[1],s[0]];if(!e||0===e.length)return;const r=new Map;for(const s of e){const e=G(s,n,"time"),o=G(s,t,"value");if(null==e||null==o)continue;const a=Math.floor(e/i)*i;r.set(a,(r.get(a)??0)+o)}let a=0;for(const e of r.values())a=Math.max(a,e);return[a>0?a+a*(o??.1):1,0]}({data:y,valueAccessor:x,timeAccessor:b,binSize:h,valueExtent:R,extentPadding:P}),[A,y,x,b,h,R,P]);return Ne||De||K(e,{ref:Se,chartType:"bar",runtimeMode:"streaming",size:be,margin:_e,className:Be,arrowOfTime:v,windowMode:f,windowSize:Oe,data:y,timeAccessor:b,valueAccessor:x,xExtent:C,yExtent:je,extentPadding:P,binSize:h,categoryAccessor:M,barColors:F,barStyle:Ee,showAxes:we,background:j,hoverAnnotation:ye,tooltipContent:He,...t({linkedHover:te,selection:ne,onObservation:ae,forceHoverBehavior:!0,mobileInteraction:m.mobileInteraction,customHoverBehavior:Ie}),annotations:Q,autoPlaceAnnotations:U,svgAnnotationRules:J,tickFormatTime:Z,tickFormatValue:ee,decay:ie,pulse:se,staleness:oe,transition:re,pointIdAccessor:c.pointIdAccessor,legend:Ae,legendPosition:ke,brush:Ce||(fe?{dimension:"x"}:void 0),onBrush:Ce||fe?Fe:void 0})});function U(e){return K(Q,{...e,windowMode:"growing"})}Q.displayName="RealtimeHistogram",U.displayName="TemporalHistogram";var J=Q;import{useRef as Z,useImperativeHandle as ee,forwardRef as te,useCallback as ne}from"react";import{jsx as ie}from"react/jsx-runtime";var se=te(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,colors:_,radius:k,fill:H,opacity:S,stroke:z,strokeWidth:I,pointStyle:R,background:P,tooltipContent:M,tooltip:F,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,linkedHover:L,selection:W,onObservation:V,chartId:$,loading:X,loadingContent:Y,emptyContent:q,emphasis:G,legendPosition:K}=n,Q=s.showAxes,U=s.enableHover,J=u??s.marginDefaults,te=c??[s.width,s.height],se=M??F??C({timeAccessor:v,valueAccessor:f}),oe=Z(null),{customHoverBehavior:re}=r({selection:W,linkedHover:L,unwrapData:!0,onObservation:V,chartType:"RealtimeSwarmChart",chartId:$}),ae=ne(e=>{N&&N(e),re(e)},[N,re]);ee(i,()=>({push:e=>oe.current?.push(e),pushMany:e=>oe.current?.pushMany(e),remove:e=>oe.current?.remove(e)??[],update:(e,t)=>oe.current?.update(e,t)??[],clear:()=>oe.current?.clear(),getData:()=>oe.current?.getData()??[],getScales:()=>oe.current?.getScales()??null}),[]);const le=l(X,te[0],te[1],Y),ce=le?null:a(g,te[0],te[1],q),ue={};null!=k&&(ue.radius=k),null!=H&&(ue.fill=H),null!=S&&(ue.opacity=S),null!=z&&(ue.stroke=z),null!=I&&(ue.strokeWidth=I);const me=R,he=G?`${m||""} semiotic-emphasis-${G}`.trim():m,de=T(p,g);return le||ce||ie(e,{ref:oe,chartType:"swarm",runtimeMode:"streaming",size:te,margin:J,className:he,arrowOfTime:h,windowMode:d,windowSize:de,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,barColors:_,swarmStyle:ue,pointStyle:me,showAxes:Q,background:P,hoverAnnotation:U,tooltipContent:se,...t({linkedHover:L,selection:W,onObservation:V,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ae}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,legendPosition:K,pointIdAccessor:n.pointIdAccessor})});se.displayName="RealtimeSwarmChart";import{useRef as oe,useImperativeHandle as re,forwardRef as ae,useCallback as le}from"react";import{jsx as ce}from"react/jsx-runtime";var ue=ae(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,extentPadding:b,positiveColor:x,negativeColor:A,connectorStroke:C,connectorWidth:R,gap:P,stroke:M,strokeWidth:F,opacity:N,background:D,tooltipContent:E,tooltip:B,onHover:O,annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,linkedHover:X,selection:Y,onObservation:q,chartId:G,loading:K,loadingContent:Q,emptyContent:U,emphasis:J,legendPosition:Z}=n,ee=s.showAxes,te=s.enableHover,ne=u??s.marginDefaults,ie=c??[s.width,s.height],se=E??B??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null,s=z(i,t,"time"),o=i?.delta??z(i,n,"value"),r=i?.cumEnd,a="number"==typeof o?0>o?I(o):"+"+I(o):I(o);return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(s)]}),k("div",{children:[_("span",{style:S,children:"Δ:"}),a]}),null!=r&&k("div",{children:[_("span",{style:S,children:"total:"}),I(r)]})]})}}({timeAccessor:v,valueAccessor:f}),ae=oe(null),{customHoverBehavior:ue}=r({selection:Y,linkedHover:X,unwrapData:!0,onObservation:q,chartType:"RealtimeWaterfallChart",chartId:G}),me=le(e=>{O&&O(e),ue(e)},[O,ue]);re(i,()=>({push:e=>ae.current?.push(e),pushMany:e=>ae.current?.pushMany(e),remove:e=>ae.current?.remove(e)??[],update:(e,t)=>ae.current?.update(e,t)??[],clear:()=>ae.current?.clear(),getData:()=>ae.current?.getData()??[],getScales:()=>ae.current?.getScales()??null}),[]);const he=l(K,ie[0],ie[1],Q),de=he?null:a(g,ie[0],ie[1],U),pe={};null!=x&&(pe.positiveColor=x),null!=A&&(pe.negativeColor=A),null!=C&&(pe.connectorStroke=C),null!=R&&(pe.connectorWidth=R),null!=P&&(pe.gap=P),null!=M&&(pe.stroke=M),null!=F&&(pe.strokeWidth=F),null!=N&&(pe.opacity=N);const ge=J?`${m||""} semiotic-emphasis-${J}`.trim():m,ve=T(p,g);return he||de||ce(e,{ref:ae,chartType:"waterfall",runtimeMode:"streaming",size:ie,margin:ne,className:ge,arrowOfTime:h,windowMode:d,windowSize:ve,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,extentPadding:b,waterfallStyle:pe,showAxes:ee,background:D,hoverAnnotation:te,tooltipContent:se,...t({linkedHover:X,selection:Y,onObservation:q,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:me}),annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,legendPosition:Z,pointIdAccessor:n.pointIdAccessor})});ue.displayName="RealtimeWaterfallChart";import{useRef as me,useImperativeHandle as he,forwardRef as de,useCallback as pe}from"react";import{jsx as ge}from"react/jsx-runtime";var ve=de(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,timeExtent:y,valueExtent:b,extentPadding:x,heatmapXBins:A=20,heatmapYBins:C=20,aggregation:R="count",background:P,tooltipContent:M,tooltip:F,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,linkedHover:$,selection:X,onObservation:Y,chartId:q,loading:G,loadingContent:K,emptyContent:Q,emphasis:U,legendPosition:J}=n,Z=s.showAxes,ee=s.enableHover,te=u??s.marginDefaults,ne=c??[s.width,s.height],ie=M??F??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=o?.xCenter??z(o,t,"time"),a=o?.yCenter??z(o,n,"value"),l=o?.count,c=o?.sum,u=o?.value,m=o?.agg??"count";return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]}),null!=l&&k("div",{children:[_("span",{style:S,children:"count:"}),I(l)]}),"sum"===m&&null!=c&&k("div",{children:[_("span",{style:S,children:"sum:"}),I(c)]}),"mean"===m&&null!=u&&k("div",{children:[_("span",{style:S,children:"mean:"}),I(u)]})]})}}({timeAccessor:v,valueAccessor:f}),se=me(null),{customHoverBehavior:oe}=r({selection:X,linkedHover:$,unwrapData:!0,onObservation:Y,chartType:"RealtimeHeatmap",chartId:q}),re=pe(e=>{N&&N(e),oe(e)},[N,oe]);he(i,()=>({push:e=>se.current?.push(e),pushMany:e=>se.current?.pushMany(e),remove:e=>se.current?.remove(e)??[],update:(e,t)=>se.current?.update(e,t)??[],clear:()=>se.current?.clear(),getData:()=>se.current?.getData()??[],getScales:()=>se.current?.getScales()??null}),[]);const ae=l(G,ne[0],ne[1],K),le=ae?null:a(g,ne[0],ne[1],Q),ce=U?`${m||""} semiotic-emphasis-${U}`.trim():m,ue=T(p,g);return ae||le||ge(e,{ref:se,chartType:"heatmap",runtimeMode:"streaming",size:ne,margin:te,className:ce,arrowOfTime:h,windowMode:d,windowSize:ue,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,xExtent:y,yExtent:b,extentPadding:x,heatmapXBins:A,heatmapYBins:C,heatmapAggregation:R,showAxes:Z,background:P,hoverAnnotation:ee,tooltipContent:ie,...t({linkedHover:$,selection:X,onObservation:Y,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:re}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,legendPosition:J,pointIdAccessor:n.pointIdAccessor})});ve.displayName="RealtimeHeatmap";export{c as RunningStats,u as WindowAccumulator,m as statValue,h as bandBounds,g as parseWindowDuration,v as ReorderBuffer,W as RealtimeLineChart,Q as RealtimeHistogram,U as TemporalHistogram,J as RealtimeTemporalHistogram,se as RealtimeSwarmChart,ue as RealtimeWaterfallChart,ve as RealtimeHeatmap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{annotationBudget as e,annotationDensity as t,isNoteAnnotation as n}from"./chunk-chunk-U66USBWU.module.min.js";import{symbol as i,symbolCircle as o,symbolCross as s,symbolDiamond as r,symbolSquare as a,symbolStar as c,symbolTriangle as f,symbolWye as d}from"d3-shape";var l={circle:o,square:a,triangle:f,diamond:r,star:c,cross:s,wye:d},u=["circle","triangle","diamond","star","square","chevron","cross","wye"];function h(e,t,n){if(n)return n;const s=e??"circle";return"chevron"===s?function(e){const t=1.5*b(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):i(l[s]??o,Math.max(1,t))()??""}function b(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var y=new Map;function p(e,t,n){if(!n&&"circle"===(e??"circle"))return b(t);const i=n?"p:"+n:`${e}:${Math.round(t)}`,o=y.get(i);if(null!=o)return o;const s=(n??h(e,t)).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let r=0;if(s)for(let e=0;s.length>e+1;e+=2){const t=+s[e],n=+s[e+1],i=Math.sqrt(t*t+n*n);i>r&&(r=i)}return r>0||(r=b(t)),y.size>512&&y.clear(),y.set(i,r),r}var m=[40,40],x=[.5,.5];function g(e,t){const[n,i]=e.viewBox??m,[o,s]=e.anchor??x,r=i>0?i:1,a=Math.max(0,t)/r,c=(n>0?n:r)*a,f=r*a;return{width:c,height:f,scale:a,offsetX:-o*c,offsetY:-s*f}}function v(e,t){const n=g(e,t),i=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of i){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function w(e,t,n,i){if("none"!==e)return"color"===e||null==e?t??i:"accent"===e?n:e}var M=null;function k(e){if("undefined"==typeof Path2D)return null;M||(M=new Map);const t=M.get(e);if(t)return t;const n=new Path2D(e);return M.size>1024&&M.clear(),M.set(e,n),n}function I(e,t,n=0,i="horizontal"){const[o,s]=e.viewBox??m,r=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>r?r>0||1>a?"vertical"===i?{x:0,y:s*(1-a),width:o,height:s*(a-r)}:{x:o*r,y:0,width:o*(a-r),height:s}:null:{x:0,y:0,width:0,height:0}}function A(e,t){const n=g(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function S(e,t,n,i,o,s=e=>e){for(const r of t.parts){const t=k(r.d);if(!t)continue;const a=r.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const f=o?"none"===r.fill?void 0:o:w(r.fill,n,i);f&&(e.fillStyle=s(f),e.fill(t));const d=o?r.stroke&&"none"!==r.stroke?o:void 0:w(r.stroke??"none",n,i);d&&(e.strokeStyle=s(d),e.lineWidth=r.strokeWidth??1,e.lineCap=r.strokeLinecap??"butt",e.lineJoin=r.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function V(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function $(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function T(e){return null==e?null:e+""}function N(e,t,n){return t.stickyPositionCache?.set(e,n),n}function P(e,t,n){const i=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const o=n.pointNodes[i];if(o.pointId===e.pointId)return N(t,n,{x:o.x,y:o.y})}const i=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],i=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!i||!o)return null;const s=n[e.xAccessor||"x"],r=n[e.yAccessor||"y"];return null==s||null==r?null:{x:i(s),y:o(r)}}(n);return i?N(t,n,i):null}if("semantic"===i){const i=function(e,t,n){const i=function(e){return T(e.provenance?.stableId??e.stableId)}(e);if(!i)return null;const o=n.pointNodes?.find(e=>T(e.pointId)===i);if(o)return N(t,n,{x:o.x,y:o.y});const s=n.data?.find(e=>function(e){return T(e.stableId??e.id??e.provenance?.stableId)}(e)===i);if(!s)return null;const r=V(s,n),a=$(s,n);return null==r||null==a?null:N(t,n,{x:r,y:a})}(e,t,n);if(i)return i}let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,s=t.y)}if(null!=o&&null!=s||(o=V(e,n),s=$(e,n)),null!=o&&null!=s)return N(t,n,{x:o,y:s});if("sticky"===i){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function W(e,t,n,i=50){return!(-i>e||e>(n.width||0)+i||-i>t||t>(n.height||0)+i)}var j=32,C=6,D=4,F=8,z=72;var L={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function X(e){if(!Y(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Y(e){return n(e)}function q(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),i=e.split(/\s+/).filter(Boolean),o=[];let s="";for(const e of i)s&&s.length+e.length+1>n?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function B(e,t,n,i,o){const s=e+n,r=t+i;return Math.abs(n)>Math.abs(i)?{x:0>n?s-o.width-4:s+4,y:0>i?r-o.height:r,width:o.width,height:o.height}:{x:0>n?s-o.width:s,y:0>i?r-o.height-4:r+4,width:o.width,height:o.height}}function O(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function R(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function U(e,t,n,i,o,s,r,a){const c=O(e,r);let f=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,i){const o=Math.max(0,i-e.x),s=Math.max(0,i-e.y);return(o+Math.max(0,e.x+e.width-(t-i)))*e.height+(s+Math.max(0,e.y+e.height-(n-i)))*e.width}(c,o,s,a);for(const e of n)f+=12*R(c,e);for(const e of i)f+=4*R(c,e);return f}function G(n){const{annotations:i,context:o,defaultOffset:s=j,notePadding:r=C,markPadding:a=D,edgePadding:c=F,preserveManualOffsets:f=!0,routeLongConnectors:d=!0,connectorThreshold:l=z,density:u,progressiveDisclosure:h=!1,redundantCues:b=!1,responsive:y,mobile:p,cohesion:m,audience:x}=n,g=o.width||0,v=o.height||0,w="object"==typeof p?p:{},M=w.breakpoint??480,k=!!p&&M>=g,I=k&&!1!==w.preferShortText?i.map(X):i,A=k&&!u?{maxAnnotations:w.maxAnnotations??("callout-list"===w.strategy?1:2),minVisible:w.minVisible??1}:u,S=h||k&&(!1!==w.progressiveDisclosure||"callout-list"===w.strategy),V=k&&!y?w.responsive??{minWidth:M}:y,$=k&&!m?w.cohesion:m;if(0===I.length||0>=g||0>=v)return I.slice();const T=[],N=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(o,a);let W=!1;const R=I.map((e,t)=>{if(!Y(e))return e;const n=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=e.pointId??e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,s=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&s){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=s([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?P(e,t,n):{x:e.x,y:e.y}}(e,t,o);if(!n)return e;const i=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...q("string"==typeof e.title?e.title:void 0,t),...q("string"==typeof e.label?e.label:void 0,t)],i=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*i)+10),height:Math.max(18,16*n.length+6)}}(e);if(f&&("number"==typeof(a=e).dx||"number"==typeof a.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return T.push(O(B(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,i),r)),e}var a;let u=null,h=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(s)){const t=U(B(n.x,n.y,e.dx,e.dy,i),e,T,N,g,v,r,c);h>t&&(u=e,h=t)}if(!u)return e;const b=O(B(n.x,n.y,u.dx,u.dy,i),r);T.push(b);const y=Math.hypot(u.dx,u.dy),p=d&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return W=!0,{...e,dx:u.dx,dy:u.dy,...p?{connector:p}:{}}}),G=W?R:I.slice();let _=G;if(b){let e=!1;const t=G.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});_=e?t:G}{let e=!1;const t=_.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?L[t.source]??t.source:null,i="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!i)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,i].filter(Boolean).join(" · "),s="string"==typeof e.label?e.label:"";return s.includes(`(${o})`)?e:{...e,label:s?`${s} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});_=e?t:_}const H=new Set;if(A){const n="object"==typeof A?A:{},i=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(x),o=1===i?n:{...n,maxAnnotations:Math.max(0,Math.round((n.maxAnnotations??e(g,v,n))*i))},{deferred:s}=t({annotations:_,width:g,height:v,...o});for(const e of s)H.add(e)}if(V&&("object"==typeof V&&"number"==typeof V.minWidth?V.minWidth:480)>=g)for(const e of _)Y(e)&&"secondary"===e.emphasis&&H.add(e);if(H.size>0)for(const e of _)!0===e?.defensive&&H.delete(e);let J;return J=0===H.size?_:S?_.map(e=>H.has(e)?{...e,_annotationDeferred:!0}:e):_.filter(e=>!H.has(e)),$?function(e,t){let n=!1;const i=e.map(e=>Y(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?i:e}(J,$):J}var _={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function H(e,t){const n={...e};for(const e of t)n[_[e]]++;return n}function J(e,t,n){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:H(n,i)}}var Z=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=J({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=J(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}};function E(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function K(e,t,n){const i=e=>e.toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function Q(e){const t=e.map(E),n=t.length-1;return e=>{if(0>=e){const[e,n,i]=t[0];return K(e,n,i)}if(e>=1){const[e,i,o]=t[n];return K(e,i,o)}const i=e*n,o=Math.floor(i),s=i-o,[r,a,c]=t[o],[f,d,l]=t[o+1];return K(Math.round(r+(f-r)*s),Math.round(a+(d-a)*s),Math.round(c+(l-c)*s))}}var ee=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],te=["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],ne=["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],ie=Q(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),oe=Q(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),se=Q(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),re=Q(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ae=Q(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ce=Q(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),fe=Q(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),de=Q(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),le=Q(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),ue=Q(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),he=Q(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),be=Q(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ye={blues:ie,reds:oe,greens:se,viridis:fe,oranges:re,purples:ae,greys:ce,plasma:de,inferno:le,magma:ue,cividis:he,turbo:be};function pe(e){return e&&ye[e]||ie}var me=Q(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),xe=Q(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),ge=Q(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ve=Q(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),we=Q(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Me=Q(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ke=Q(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Ie=()=>"undefined"!=typeof performance?performance.now():Date.now();function Ae(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 Se(e,t){const n=e();return Number.isFinite(n)?n:t}var Ve=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Ie,this.lastWallTime=Se(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Se(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Ie;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Se(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Ae(n)))}};export{ee as schemeCategory10,te as schemeTableau10,ne as schemeSet3,fe as interpolateViridis,ye as SEQUENTIAL_INTERPOLATORS,pe as getSequentialInterpolator,me as interpolateRdBu,xe as interpolatePiYG,ge as interpolatePRGn,ve as interpolateBrBG,we as interpolateRdYlBu,Me as interpolateRdYlGn,ke as interpolateSpectral,u as SYMBOL_SEQUENCE,h as symbolPathString,b as symbolRadius,p as symbolExtent,Z as UpdateResultTracker,m as DEFAULT_GLYPH_VIEWBOX,x as DEFAULT_GLYPH_ANCHOR,g as glyphPlacement,v as glyphExtent,w as resolveGlyphPaint,I as glyphFractionClipRect,A as glyphHitGeometry,S as drawGlyphParts,V as resolveX,$ as resolveY,P as resolveAnchoredPosition,W as isInBounds,G as annotationLayout,Ae as createSeededFrameRandom,Ve as FrameRuntime};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function e(e,n,r=e.responsiveRules){if(!Array.isArray(r)||0===r.length)return{props:e,matches:[]};const o=r.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:n}=t,r=e.width,o=e.height,i=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),a=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}(t.rule,n)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:o.reduce((e,n)=>function(e,n){const r={...e,...n};for(const o of["margin","frameProps","mobileSemantics","style"])t(e[o])&&t(n[o])&&(r[o]={...e[o],...n[o]});return"string"==typeof e.className&&"string"==typeof n.className&&(r.className=`${e.className} ${n.className}`),r}(e,n.rule.transform),e),matches:o}}function n(t,e){return t===e}function r(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function o(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function i(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var a=/^\d{4}-\d{1,2}$/;function s(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=a.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function u(t){return t instanceof Date?t.getTime():"string"==typeof t?s(t):+t}var c=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),l=new Set(["label","callout","callout-circle","callout-rect"]);function f(t){return"string"==typeof t?.type?t.type:""}function d(t){return!!t&&"object"==typeof t&&c.has(f(t))}function h(t){return l.has(f(t))&&!function(t){return Array.isArray(t?.disable)&&t.disable.includes("connector")}(t)}function p(t,e,n={}){return Number.isFinite(e)&&e>0?Number.isNaN(t)?"fresh":t===1/0?"expired":0>t||e*(n.fresh??1)>t?"fresh":e*(n.aging??1.5)>t?"aging":e*(n.stale??3)>t?"stale":"expired":"fresh"}function m(t,e={}){const n=!0===e.showRetractedAnnotations,r=!0===e.showSupersededAnnotations,o=new Set;for(const e of t){const t=e?.lifecycle?.supersedes;t&&"retracted"!==e?.lifecycle?.status&&o.add(t)}return t.filter(t=>{if("retracted"===t?.lifecycle?.status&&!n)return!1;const e=t?.provenance?.stableId;return!(e&&o.has(e)&&!r)})}function y(t,e){const n=t.length,r=e.length,o=Array(r+1);for(let t=0;r>=t;t++)o[t]=t;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=t[i-1]===e[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function b(t,e,n=3){let r,o=n+1;for(const n of e){const e=y(t.toLowerCase(),n.toLowerCase());o>e&&(o=e,r=n)}return o>n?void 0:r}function g(t){return t.length>3?[t[0],t[Math.floor(t.length/2)],t[t.length-1]]:[...t]}function v(t,e){if(0===e.length)return null;const n=t.toLowerCase();return e.find(t=>t.toLowerCase().includes(n)||n.includes(t.toLowerCase()))||(b(t,e,3)??null)}function A({componentName:t,data:e,accessors:n,requiredProps:r}){if(r)for(const[e,n]of Object.entries(r))if(null==n)return`${t}: ${e} is required. Provide a field name or function.`;if(null==e)return null;if(!Array.isArray(e)&&"object"==typeof e)return t+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(e)||0===e.length)return t+": No data provided. Pass a non-empty array to the data prop.";if(n){const r=g(e).find(t=>t&&"object"==typeof t);if(r){const e=Object.keys(r);for(const[o,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in r)){const n=v(i,e),r=n?` Try ${o}="${n}".`:"";return`${t}: ${o} "${i}" not found in data. Available fields: ${e.join(", ")}.${r}`}}}return null}function x({componentName:t,data:e,dataLabel:n="data"}){return null==e?`${t}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(e)?`${t}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function N({componentName:t,nodes:e,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==e&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return t+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!e||!Array.isArray(e)||0===e.length))return t+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&e&&e.length>0){const n=g(e).find(t=>t&&"object"==typeof t);if(n){const e=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=v(o,e),i=n?` Try ${r}="${n}".`:"";return`${t}: ${r} "${o}" not found in node data. Available fields: ${e.join(", ")}.${i}`}}}return null}import{createContext as w,useCallback as $,useContext as j,useMemo as M,useRef as O,useSyncExternalStore as P}from"react";import{jsx as S}from"react/jsx-runtime";function C(t){let e=null;const n=()=>(e||(e=w(null)),e),r=I(t);return[function({children:e,initialState:r}){const o=O(r),i=M(()=>I(t,o.current),[]),a=n();return S(a.Provider,{value:i,children:e})},(t,e)=>{const o=n(),i=j(o)??r,a=O(t);a.current=t;const s=O({hasValue:!1,value:void 0}),u=$(()=>{const t=a.current(i.getState()),n=s.current;return n.hasValue&&e&&e(n.value,t)?n.value:(s.current={hasValue:!0,value:t},t)},[i,e]),c=$(()=>a.current(i.getState()),[i]);return P(i.subscribe,u,c)}]}function I(t,e){const n=new Set;let r={...t(function(t){const e=t(r);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){r={...r,...e};for(const t of n)t()}}),...e??{}};return{getState:()=>r,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}import*as k from"react";var[T,R]=C(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function L(t){const e=R(t=>t.pushObservation),n=k.useCallback(n=>{t.onObservation?.(n),e?.(n)},[t,e]);return k.useMemo(()=>({...t,onObservation:n}),[n,t])}function q(t){const e=t.provenance,n=t.id??t.stableId??e?.stableId;return null==n||""===n?void 0:n+""}function D(t,e={}){const n=q(t);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(t){const e=t.nativeEvent;return"touch"===e.pointerType?"touch":0===e.detail?"keyboard":"pointer"}(r);e.onAnnotationActivate?.({annotation:t,annotationId:n,chartId:e.chartId,inputType:o}),n&&e.onObservation&&e.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:e.chartType??"unknown",chartId:e.chartId})}}}function F(t){return t instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]")}function H(t){return"primary"===t?.emphasis||!0===t?.defensive}function V(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function W(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const r=t?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(e+=15*Math.max(0,Math.min(1,r))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}function B(t){const{annotations:e,width:n,height:r}=t,o=Math.max(0,t.minVisible??1),i=V(n,r,t),a=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,d(n))};var n}),s=a.filter(t=>t.note);if(0===s.length||i>=s.length)return{visible:e.slice(),deferred:[],budget:i};const u=s.filter(t=>H(t.annotation)),c=s.filter(t=>!H(t.annotation)).sort((t,e)=>W(e.annotation)-W(t.annotation)||t.index-e.index),l=Math.min(c.length,Math.max(Math.max(0,i-u.length),Math.max(0,o-u.length))),f=new Set([...u.map(t=>t.index),...c.slice(0,l).map(t=>t.index)]),h=[],p=[];for(const{annotation:t,index:e,note:n}of a)!n||f.has(e)?h.push(t):p.push(t);return{visible:h,deferred:p,budget:i}}function E(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}export{e as resolveResponsiveRules,C as createStore,n as accessorsEquivalent,r as resolveAccessor,o as resolveRawAccessor,i as resolveStringAccessor,s as parseDateLikeString,u as coerceDateLikeValue,p as bandFromAge,R as useObservationSelector,L as useAnnotationActivationOptions,q as annotationStableId,D as annotationActivationProps,F as isAnnotationActivationTarget,f as annotationType,d as isNoteAnnotation,h as annotationDrawsConnector,V as annotationBudget,B as annotationDensity,m as filterAnnotationsByStatus,b as closestMatch,A as validateArrayData,x as validateObjectData,N as validateNetworkData,E as mulberry32};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let i;return this._size===this._capacity?i=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,i}pushMany(t){const i=[];for(const s of t){const t=this.push(s);void 0!==t&&i.push(t)}return i}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const i=(this.head-this._size+this._capacity)%this._capacity;for(let s=0;this._size>s;s++)t(this.buffer[(i+s)%this._capacity],s)}toArray(){const t=Array(this._size),i=(this.head-this._size+this._capacity)%this._capacity;for(let s=0;this._size>s;s++)t[s]=this.buffer[(i+s)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const i=this.toArray();let s=0,e=[];i.length>t&&(s=i.length-t,e=i.slice(0,s)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=s;i.length>t;t++)this.push(i[t]);return e}update(t,i){const s=[],e=(this.head-this._size+this._capacity)%this._capacity;for(let h=0;this._size>h;h++){const r=(e+h)%this._capacity,a=this.buffer[r];if(t(a)){let t;t="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},s.push(t),this.buffer[r]=i(a)}}return s}remove(t){const i=[],s=[];if(this.forEach(e=>{t(e)?s.push(e):i.push(e)}),0===s.length)return s;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of i)this.push(t);return s}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}},i=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,i){this._min=1/0,this._max=-1/0;for(const s of t){const t=i?i(s):s;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function s(t,i,s){return s.x>t||t>s.x+s.w||s.y>i||i>s.y+s.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:s.x+s.w/2,cy:s.y+s.h/2}}function e(t,i=30){return Math.max((t??4)+5,12,i)}function h(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function r(t,i){const s=h(t);if(!s)return!1;const e=h(i);return!e||s.getFullYear()!==e.getFullYear()||s.getMonth()!==e.getMonth()}function a(t){let i=t%(2*Math.PI);return 0>i&&(i+=2*Math.PI),i}export{t as RingBuffer,i as IncrementalExtent,s as hitTestRect,e as getHitRadius,r as isTimeLandmark,a as normalizeAngle};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getMinMax as t}from"./chunk-chunk-JJ2OOIET.module.min.js";function a(t=240){const a=360-t,n=180+a/2,h=n*Math.PI/180;return{sweepRad:t*Math.PI/180,gapDeg:a,startAngleDeg:n,startAngleRad:h,offsetRad:-Math.PI/2+h}}function n(t,a,n,h,s){const e=n-a||1;return s+(Math.max(a,Math.min(n,t))-a)/e*h}function h(n=240){const{sweepRad:h,offsetRad:s}=a(n),e=[[Math.cos(s),Math.sin(s)],[Math.cos(s+h),Math.sin(s+h)],[0,0]];for(let t=0;2*Math.PI>t;t+=Math.PI/2)((t-s)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>h+.001||e.push([Math.cos(t),Math.sin(t)]);const o=e.map(t=>t[0]),M=e.map(t=>t[1]),[c,i]=t(o),[m,r]=t(M);return{minX:c,maxX:i,minY:m,maxY:r,width:i-c,height:r-m,cx:(c+i)/2,cy:(m+r)/2}}export{a as sweepToAngles,n as valueToAngle,h as computeArcBoundingBox};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t){let n=1/0,o=-1/0;for(const e of t)n>e&&(n=e),e>o&&(o=e);return[n,o]}function n(t,n=1/0){let o=n;for(const n of t)o>n&&(o=n);return o}function o(t,n=-1/0){let o=n;for(const n of t)n>o&&(o=n);return o}function e(t,n=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const e=Math.round(parseInt(o[1],16)*(1-n)),r=Math.round(parseInt(o[2],16)*(1-n)),a=Math.round(parseInt(o[3],16)*(1-n));return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function r(t,n=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const e=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*n),r=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*n),a=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*n);return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}var a="__forecastSegment",s="__forecastOpacity";function i(n,o,e,r){const a=o.uncertaintyOpacity,i=o.confidenceAccessor;if(!a&&!i)return;const l="object"==typeof a?a:{},c=l.min??.15,f=l.max??1;if(i){const t="function"==typeof i?i:t=>t[i];for(const o of n){const n=t(o);null!=n&&Number.isFinite(n)&&(o[s]=c+Math.max(0,Math.min(1,n))*(f-c))}return}const u=n.map(t=>{const n=e(t),o=r(t);return null!=n&&null!=o&&Number.isFinite(n)&&Number.isFinite(o)?Math.abs(n-o):NaN}),p=u.filter(t=>Number.isFinite(t));if(0===p.length)return;const[h,y]=t(p),d=y-h;n.forEach((t,n)=>{const o=u[n];Number.isFinite(o)&&(t[s]=f-(d>0?(o-h)/d:0)*(f-c))})}function l(t,n){return"function"==typeof n?n(t):!!t[n]}function c(t){return[{type:"anomaly-band",threshold:t.threshold??2,showBand:!1!==t.showBand,fill:t.bandColor||"#6366f1",fillOpacity:t.bandOpacity??.1,anomalyColor:t.anomalyColor||"#ef4444",anomalyRadius:t.anomalyRadius??6,label:t.label}]}function f(t,n,e,r,s){return(c=r).isTraining||c.isForecast||c.isAnomaly||c.upperBounds||c.lowerBounds?function(t,n,o,e,r){const{isTraining:s,isForecast:c,isAnomaly:f,upperBounds:u,lowerBounds:p,color:h="#6366f1",bandOpacity:y=.15,anomalyColor:d="#ef4444",anomalyRadius:b=6,label:g}=e,m=t.map(t=>{let n="observed";return c&&l(t,c)?n="forecast":s&&l(t,s)&&(n="training"),{...t,[a]:n}}),_=e._groupBy,k=[];if(_){const t=new Map;for(const n of m){const o=n[_]??"__default";t.has(o)||t.set(o,[]),t.get(o).push(n)}const n=[];for(const[,o]of t)for(let t=0;o.length-1>t;t++)o[t][a]!==o[t+1][a]&&(n.push({...o[t+1],[a]:o[t][a]}),n.push({...o[t],[a]:o[t+1][a]}));k.push(...m,...n)}else for(let t=0;m.length>t;t++)k.push(m[t]),m.length-1>t&&m[t][a]!==m[t+1][a]&&(k.push({...m[t+1],[a]:m[t][a]}),k.push({...m[t],[a]:m[t+1][a]}));if(e.trainUnderline){const t=[];for(const n of k)"training"===n[a]&&t.push({...n,[a]:"training-base"});k.unshift(...t)}const O=[];if(u&&p){const t="string"==typeof u?u:"__envUpper",n="string"==typeof p?p:"__envLower";if("function"==typeof u||"function"==typeof p)for(const o of k)"function"==typeof u&&(o[t]=u(o)),"function"==typeof p&&(o[n]=p(o));O.push({type:"envelope",upperAccessor:t,lowerAccessor:n,fill:h,fillOpacity:y,label:g})}if(e.uncertaintyOpacity||e.confidenceAccessor){const t=u?"function"==typeof u?u:t=>t[u]:()=>{},n=p?"function"==typeof p?p:t=>t[p]:()=>{};i(k.filter(t=>"forecast"===t[a]),e,t,n)}if(f){const t=e.anomalyStyle,n={type:"highlight",filter:t=>l(t,f)};t?(n.style=t,n.r=b):"function"==typeof d?(n.style=t=>{const n=d(t);return{stroke:n,strokeWidth:1.5,fill:n,fillOpacity:.7}},n.r=b):(n.color=d,n.r=b,n.style={stroke:d,strokeWidth:1.5,fill:d,fillOpacity:.7}),O.push(n)}return r&&O.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label}),{processedData:k,annotations:O}}(t,0,0,r,s):function(t,n,e,r,s){const{trainEnd:l,steps:c=10,confidence:f=.95,color:u="#6366f1",bandOpacity:p=.15,label:h}=r;if(null==l)return{processedData:t,annotations:[]};const y=[],d=[];for(const o of t)o[n]>l?d.push({...o,[a]:"observed"}):y.push({...o,[a]:"training"});const b=y.map(t=>[t[n],t[e]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,n)=>t[0]-n[0]),g=[],m=[];if(b.length>=3){const s=b.length;let l=0,y=0,d=0,_=0;for(const[t,n]of b)l+=t,y+=n,d+=t*t,_+=t*n;const k=s*d-l*l;if(Math.abs(k)>1e-12){const d=(s*_-l*y)/k,O=(y-d*l)/s,w=t=>O+d*t,S=b.map(([t,n])=>n-w(t)).reduce((t,n)=>t+n*n,0),M=Math.sqrt(S/Math.max(s-2,1)),B=b.reduce((t,n)=>t+n[0],0)/s,F=b.reduce((t,n)=>t+(n[0]-B)**2,0),v=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,C=o(t.map(t=>t[n]).filter(t=>null!=t&&isFinite(t))),D=b.length>1?(b[s-1][0]-b[0][0])/(s-1):1;for(let t=1;c>=t;t++){const o=C+t*D,r=w(o),i=M*Math.sqrt(1+1/s+(F>0?(o-B)**2/F:0))*v;m.push({[n]:o,[e]:r,[a]:"forecast",__forecastUpper:r+i,__forecastLower:r-i})}i(m,r,t=>t.__forecastUpper,t=>t.__forecastLower),g.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:p,label:h})}}g.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&g.push({type:"anomaly-band",threshold:s.threshold??2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:s.bandOpacity??.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:s.anomalyRadius??6,label:s.label});const _=[];if(_.push(...y),y.length>0&&d.length>0&&_.push({...y[y.length-1],[a]:"observed"}),_.push(...d),m.length>0){const t=d.length>0?d[d.length-1]:y[y.length-1];t&&_.push({...t,[a]:"forecast"}),_.push(...m)}return{processedData:_,annotations:g}}(t,n,e,r,s);var c}function u(t,n){const o=n.trainDasharray??"8,4",i=n.forecastDasharray??"4,4",l=n.color||"#6366f1",c=n.trainOpacity,f=n.forecastOpacity,u=n.trainStroke,p=n.trainLinecap,h=n.trainUnderline;return n=>{const y=t(n),d=n[a];if("training"===d){let t=y.stroke;return"darken"===u?t=e(y.stroke||"#666",.5):u&&(t=u),{...y,stroke:t,strokeDasharray:o,...p&&{strokeLinecap:p},...null!=c&&{strokeOpacity:c}}}if("training-base"===d){let t=y.stroke||"#666";return"lighten"===h&&(t=r(t,.4)),{...y,stroke:t,strokeDasharray:void 0}}if("forecast"===d){const t=n[s],o=null!=t?t:f;return{...y,stroke:l,strokeDasharray:i,...null!=o&&{strokeOpacity:o}}}return y}}export{t as getMinMax,n as getMin,o as getMax,e as darkenColor,r as lightenColor,a as SEGMENT_FIELD,s as FORECAST_OPACITY_FIELD,i as stampForecastOpacity,c as buildAnomalyAnnotations,f as buildForecast,u as createSegmentLineStyle};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{buildColorStopGradient as t,resolveCSSColor as e,resolveCanvasFill as l,resolveCurveFactory as n}from"./chunk-chunk-CWQ5YIHX.module.min.js";import{line as o}from"d3-shape";function i(t,e,l){let n=l;for(const l of e)"lesser"===l.thresholdType?l.value>t&&(n=l.color):t>l.value&&(n=l.color);return n}function s(t,e,l,n,o,i){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const l=e[t][0]-e[t-1][0],n=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(l*l+n*n))}const a=s[s.length-1];if(0===a)return;const h=Math.min(.2*a,40);t.strokeStyle=l,t.lineWidth=n,t.lineCap=i;for(let l=0;e.length-1>l;l++){const n=(s[l]+s[l+1])/2;let i=o;h>n&&(i*=n/h),h>a-n&&(i*=(a-n)/h),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[l][0],e[l][1]),t.lineTo(e[l+1][0],e[l+1][1]),t.stroke()}}var a=(a,h,r,p)=>{const c=h.filter(t=>"line"===t.type);for(const h of c){if(2>h.path.length)continue;const r=h._introClipFraction;void 0!==r&&1>r&&(a.save(),a.beginPath(),a.rect(0,0,p.width*r,p.height),a.clip());const c=h.style.stroke||"#007bff",f=e(a,c)||c,u=h.style.strokeWidth||2,y=h.colorThresholds,g=h.rawValues;if(a.setLineDash(h.style.strokeDasharray?h.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=h.style.opacity&&(a.globalAlpha=h.style.opacity),a.lineWidth=u,a.lineCap=h.style.strokeLinecap||"butt",h.style._edgeFade){s(a,h.path,f,u,h.style.opacity??1,h.style.strokeLinecap||"butt"),a.globalAlpha=1,a.setLineDash([]),a.lineCap="butt";continue}const k=n(h.curve),b=y&&y.length>0&&g&&g.length===h.path.length,d=h._decayOpacities;if(d&&d.length===h.path.length&&!b){a.strokeStyle=f;const t=h.style.opacity??1;for(let e=0;h.path.length-1>e;e++)a.globalAlpha=.5*(d[e]+d[e+1])*t,a.beginPath(),a.moveTo(h.path[e][0],h.path[e][1]),a.lineTo(h.path[e+1][0],h.path[e+1][1]),a.stroke()}else if(b){let t=function(t,e,l){a.beginPath(),a.strokeStyle=t,a.moveTo(e,l),r=!0},e=function(){r&&(a.stroke(),r=!1)},l=null,n=null,o=null,s=null,r=!1;for(let r=0;h.path.length>r;r++){const[p,c]=h.path[r],u=g[r],k=i(u,y,f);if(null!==l&&null!==s&&null!==o){if(k===s)a.lineTo(p,c);else{const s=[];for(const t of y){const e=t.value;(o>e||e>u)&&(e>o||u>e)||o===e||u===e||s.push({t:(e-o)/(u-o)})}s.sort((t,e)=>t.t-e.t);for(const h of s){const s=l+(p-l)*h.t,r=n+(c-n)*h.t,g=i(o+(u-o)*Math.min(h.t+1e-4,1),y,f);a.lineTo(s,r),e(),t(g,s,r)}a.lineTo(p,c)}l=p,n=c,o=u,s=k}else t(k,p,c),l=p,n=c,o=u,s=k}e()}else{a.beginPath();const e=h.strokeGradient&&h.path.length>=2?t(a,h.strokeGradient,h.path[0][0],0,h.path[h.path.length-1][0],0):null;if(a.strokeStyle=e||f,k)o().x(t=>t[0]).y(t=>t[1]).curve(k).context(a)(h.path);else{const[t,e]=h.path[0];a.moveTo(t,e);for(let t=1;h.path.length>t;t++)a.lineTo(h.path[t][0],h.path[t][1])}a.stroke()}if(h.style.fill&&h.style.fillOpacity&&h.style.fillOpacity>0){if(a.beginPath(),a.globalAlpha=h.style.fillOpacity,a.fillStyle=l(a,h.style.fill,h.style.fill),k&&!b)o().x(t=>t[0]).y(t=>t[1]).curve(k).context(a)(h.path);else{const[t,e]=h.path[0];a.moveTo(t,e);for(let t=1;h.path.length>t;t++)a.lineTo(h.path[t][0],h.path[t][1])}const t=h.path[0][0];a.lineTo(h.path[h.path.length-1][0],p.height),a.lineTo(t,p.height),a.closePath(),a.fill()}void 0!==r&&1>r&&a.restore(),a.globalAlpha=1,a.setLineDash([]),a.lineCap="butt"}};function h(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const l="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||l||null:l||e.stroke||null}export{a as lineCanvasRenderer,h as resolveNodeColor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createSeededFrameRandom as t,schemeCategory10 as e}from"./chunk-chunk-5RKXZQ2P.module.min.js";import{getMinMax as o}from"./chunk-chunk-JJ2OOIET.module.min.js";import*as n from"react";import{jsx as r}from"react/jsx-runtime";var s={isActive:!1,predicate:()=>!0},i=n.createContext(null);function a({value:t,children:e}){return r(i.Provider,{value:t,children:e})}function c(){return n.useContext(i)??s}function l(t,e){return null!=t?r(a,{value:e,children:t}):t}import{forceSimulation as f,forceCenter as u,forceX as h,forceY as d,forceLink as g,forceManyBody as y,forceCollide as m}from"d3-force";import{scaleLinear as p}from"d3-scale";var x=new Set,M=new WeakMap;function S(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let o=M.get(t);if(o){const t=o.get(e);if(t)return t}else o=new Map,M.set(t,o);const n=new Proxy(t,{get(t,o,n){if("string"==typeof o&&!(o in t)&&t.data&&o in t.data){const t=`${e}:${o}`;x.has(t)||(x.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,o,n)}});return o.set(e,n),n}var b={supportsStreaming:!0,hierarchical:!1,computeLayout(e,o,n,r){if(0===e.length)return;const s=n.forceStrength??.1,i=r[0]/2,a=r[1]/2,c=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-c)),p=n.__previousPositions;let x=0;const M=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=p?.get(t.id);e?x++:o?(t.x=o.x,t.y=o.y,x++):M.push(t)}const S=x>0&&.3>=(e.length>0?M.length/e.length:1);if(S){const t=new Map;for(const o of e)t.set(o.id,o);for(const e of M){const n=v(e.id,o,t);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const r=k(e.id),s=r%360*(Math.PI/180),i=(10+r%20)*c;e.x=t/n.length+i*Math.cos(s),e.y=o/n.length+i*Math.sin(s)}else{const t=k(e.id),o=t%360*(Math.PI/180),n=(15+t%30)*c;e.x=i+n*Math.cos(o),e.y=a+n*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5)*c,r=o*t;n.x=i+e*Math.cos(r),n.y=a+e*Math.sin(r)}}}const b=n.__skipForceSimulation||0===n.iterations?0:S?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),_=w(n.nodeSize,n.nodeSizeRange,e),z=t=>_(t);if(b>0){const p=new Map,x=new Map;for(const t of e)p.set(t.id,0),x.set(t.id,t);for(const t of o){const e="string"==typeof t.source?t.source:t.source.id,o="string"==typeof t.target?t.target:t.target.id;p.set(e,(p.get(e)??0)+1),p.set(o,(p.get(o)??0)+1)}const M=g().strength(t=>{const e=t.weight,o="string"==typeof t.target?t.target:t.target.id,n=Math.max(1,Math.min(p.get("string"==typeof t.source?t.source:t.source.id)??1,p.get(o)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*s/(.1*n))}).distance(t=>{const e="string"==typeof t.source?x.get(t.source):t.source,o="string"==typeof t.target?x.get(t.target):t.target,n=(e?z(e):0)+(o?z(o):0)+Math.max(6,12*c);return Math.max(16,40*c,n)}).id(t=>t.id),v=f();if(void 0===n.random&&void 0===n.seed||v.randomSource(n.random??t(n.seed)),v.force("charge",y().strength(t=>{const e=p.get(t.id)??0;return-15*c*z(t)*Math.sqrt(e+1)})).force("collide",m(t=>z(t)+3*c).strength(.9).iterations(2)).force("center",u(i,a).strength(.8)).force("x",h(i).strength(l)).force("y",d(a).strength(l)).force("bounds",function(t,e,o=2,n=.6){let r=[];const s=s=>{const i=n*Math.max(s,.2);for(const n of r){const r=n.x??t[0]/2,s=n.y??t[1]/2,a=n.vx??0,c=n.vy??0,l=e(n)+o,f=Math.min(t[0]/2,l),u=Math.max(t[0]/2,t[0]-l),h=Math.min(t[1]/2,l),d=Math.max(t[1]/2,t[1]-l),g=r+a,y=s+c;f>g?n.vx=a+(f-g)*i:g>u&&(n.vx=a+(u-g)*i),h>y?n.vy=c+(h-y)*i:y>d&&(n.vy=c+(d-y)*i)}};return s.initialize=t=>{r=t},s}(r,z)),v.nodes(e),o.length>0){const t=o.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));M.links(t),v.force("link",M)}S?v.alpha(.3):.1>v.alpha()&&v.alpha(1),v.stop();for(let t=0;b>t;++t)v.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=z(t),o=b>0?2:0,n=Math.min(r[0]/2,e+o),s=Math.min(r[1]/2,e+o);t.x=Math.max(n,Math.min(r[0]-n,t.x)),t.y=Math.max(s,Math.min(r[1]-s,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const R=new Map;for(const t of e)R.set(t.id,t);for(const t of o){if("string"==typeof t.source){const e=R.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=R.get(t.target);e&&(t.target=e)}}},buildScene(t,o,n,r){const s=n.nodeStyle,i=n.edgeStyle,a=w(n.nodeSize,n.nodeSizeRange,t),c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:e,l=new Map;t.forEach((t,e)=>{l.set(t.id,c[e%c.length])});const f=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=a(S(e,"nodeSize")),o=s?s(S(e,"nodeStyle")):{},r={fill:o.fill||l.get(e.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of o){const e="object"==typeof t.source?t.source:d.get(t.source),o="object"==typeof t.target?t.target:d.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=i?i(S(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:t})}if(!1!==n.showLabels){const e=(g=n.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const o of t){if(null==o.x||null==o.y)continue;const t=e?e(o):o.id;if(!t)continue;const n=a(S(o,"nodeSize"));h.push({x:o.x,y:o.y-n-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var g;return{sceneNodes:f,sceneEdges:u,labels:h}}};function v(t,e,o){const n=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,s="string"==typeof r.target?r.target:r.target.id;let i=null;if(e===t?i=s:s===t&&(i=e),i){const t=o.get(i);!t||0===t.x&&0===t.y||n.push({x:t.x,y:t.y})}}return n}function k(t){let e=0;for(let o=0;t.length>o;o++)e=(e<<5)-e+t.charCodeAt(o)|0;return Math.abs(e)}function w(t,e,n){if(n.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],s=[];for(const e of n){const o=e.data?.[t];"number"==typeof o&&s.push(o)}if(0===s.length)return()=>r[0];const[i,a]=o(s);if(i===a)return()=>(r[0]+r[1])/2;const c=p().domain([i,a]).range(r).clamp(!0);return e=>{const o=e.data?.[t];return null==o||"number"!=typeof o?r[0]:c(o)}}export{a as CustomLayoutSelectionProvider,c as useCustomLayoutSelection,l as wrapWithCustomLayoutSelection,S as wrapWithDataHint,b as forceLayoutPlugin,w as resolveNodeSizeFn};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{darkenColor as t,lightenColor as o}from"./chunk-chunk-2JGJ5GUG.module.min.js";import{getMax as n,getMinMax as e}from"./chunk-chunk-JJ2OOIET.module.min.js";var r="__forecastSegment",a="__forecastOpacity";function s(t,o,n,r){const s=o.uncertaintyOpacity,i=o.confidenceAccessor;if(!s&&!i)return;const l="object"==typeof s?s:{},c=l.min??.15,f=l.max??1;if(i){const o="function"==typeof i?i:t=>t[i];for(const n of t){const t=o(n);null!=t&&Number.isFinite(t)&&(n[a]=c+Math.max(0,Math.min(1,t))*(f-c))}return}const u=t.map(t=>{const o=n(t),e=r(t);return null!=o&&null!=e&&Number.isFinite(o)&&Number.isFinite(e)?Math.abs(o-e):NaN}),p=u.filter(t=>Number.isFinite(t));if(0===p.length)return;const[h,y]=e(p),d=y-h;t.forEach((t,o)=>{const n=u[o];Number.isFinite(n)&&(t[a]=f-(d>0?(n-h)/d:0)*(f-c))})}function i(t,o){return"function"==typeof o?o(t):!!t[o]}function l(t){return[{type:"anomaly-band",threshold:t.threshold??2,showBand:!1!==t.showBand,fill:t.bandColor||"#6366f1",fillOpacity:t.bandOpacity??.1,anomalyColor:t.anomalyColor||"#ef4444",anomalyRadius:t.anomalyRadius??6,label:t.label}]}function c(t,o,e,a,l){return(c=a).isTraining||c.isForecast||c.isAnomaly||c.upperBounds||c.lowerBounds?function(t,o,n,e,a){const{isTraining:l,isForecast:c,isAnomaly:f,upperBounds:u,lowerBounds:p,color:h="#6366f1",bandOpacity:y=.15,anomalyColor:d="#ef4444",anomalyRadius:m=6,label:b}=e,g=t.map(t=>{let o="observed";return c&&i(t,c)?o="forecast":l&&i(t,l)&&(o="training"),{...t,[r]:o}}),k=e._groupBy,_=[];if(k){const t=new Map;for(const o of g){const n=o[k]??"__default";t.has(n)||t.set(n,[]),t.get(n).push(o)}const o=[];for(const[,n]of t)for(let t=0;n.length-1>t;t++)n[t][r]!==n[t+1][r]&&(o.push({...n[t+1],[r]:n[t][r]}),o.push({...n[t],[r]:n[t+1][r]}));_.push(...g,...o)}else for(let t=0;g.length>t;t++)_.push(g[t]),g.length-1>t&&g[t][r]!==g[t+1][r]&&(_.push({...g[t+1],[r]:g[t][r]}),_.push({...g[t],[r]:g[t+1][r]}));if(e.trainUnderline){const t=[];for(const o of _)"training"===o[r]&&t.push({...o,[r]:"training-base"});_.unshift(...t)}const O=[];if(u&&p){const t="string"==typeof u?u:"__envUpper",o="string"==typeof p?p:"__envLower";if("function"==typeof u||"function"==typeof p)for(const n of _)"function"==typeof u&&(n[t]=u(n)),"function"==typeof p&&(n[o]=p(n));O.push({type:"envelope",upperAccessor:t,lowerAccessor:o,fill:h,fillOpacity:y,label:b})}if(e.uncertaintyOpacity||e.confidenceAccessor){const t=u?"function"==typeof u?u:t=>t[u]:()=>{},o=p?"function"==typeof p?p:t=>t[p]:()=>{};s(_.filter(t=>"forecast"===t[r]),e,t,o)}if(f){const t=e.anomalyStyle,o={type:"highlight",filter:t=>i(t,f)};t?(o.style=t,o.r=m):"function"==typeof d?(o.style=t=>{const o=d(t);return{stroke:o,strokeWidth:1.5,fill:o,fillOpacity:.7}},o.r=m):(o.color=d,o.r=m,o.style={stroke:d,strokeWidth:1.5,fill:d,fillOpacity:.7}),O.push(o)}return a&&O.push({type:"anomaly-band",threshold:a.threshold??2,showBand:!1!==a.showBand,fill:a.bandColor||"#6366f1",fillOpacity:a.bandOpacity??.1,anomalyColor:a.anomalyColor||"#ef4444",anomalyRadius:a.anomalyRadius??6,label:a.label}),{processedData:_,annotations:O}}(t,0,0,a,l):function(t,o,e,a,i){const{trainEnd:l,steps:c=10,confidence:f=.95,color:u="#6366f1",bandOpacity:p=.15,label:h}=a;if(null==l)return{processedData:t,annotations:[]};const y=[],d=[];for(const n of t)n[o]>l?d.push({...n,[r]:"observed"}):y.push({...n,[r]:"training"});const m=y.map(t=>[t[o],t[e]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,o)=>t[0]-o[0]),b=[],g=[];if(m.length>=3){const i=m.length;let l=0,y=0,d=0,k=0;for(const[t,o]of m)l+=t,y+=o,d+=t*t,k+=t*o;const _=i*d-l*l;if(Math.abs(_)>1e-12){const d=(i*k-l*y)/_,O=(y-d*l)/i,w=t=>O+d*t,B=m.map(([t,o])=>o-w(t)).reduce((t,o)=>t+o*o,0),F=Math.sqrt(B/Math.max(i-2,1)),v=m.reduce((t,o)=>t+o[0],0)/i,C=m.reduce((t,o)=>t+(o[0]-v)**2,0),D=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,A=t.map(t=>t[o]).filter(t=>null!=t&&isFinite(t)),M=n(A),N=m.length>1?(m[i-1][0]-m[0][0])/(i-1):1;for(let t=1;c>=t;t++){const n=M+t*N,a=w(n),s=F*Math.sqrt(1+1/i+(C>0?(n-v)**2/C:0))*D;g.push({[o]:n,[e]:a,[r]:"forecast",__forecastUpper:a+s,__forecastLower:a-s})}s(g,a,t=>t.__forecastUpper,t=>t.__forecastLower),b.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:p,label:h})}}b.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&b.push({type:"anomaly-band",threshold:i.threshold??2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:i.bandOpacity??.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:i.anomalyRadius??6,label:i.label});const k=[];if(k.push(...y),y.length>0&&d.length>0&&k.push({...y[y.length-1],[r]:"observed"}),k.push(...d),g.length>0){const t=d.length>0?d[d.length-1]:y[y.length-1];t&&k.push({...t,[r]:"forecast"}),k.push(...g)}return{processedData:k,annotations:b}}(t,o,e,a,l);var c}function f(n,e){const s=e.trainDasharray??"8,4",i=e.forecastDasharray??"4,4",l=e.color||"#6366f1",c=e.trainOpacity,f=e.forecastOpacity,u=e.trainStroke,p=e.trainLinecap,h=e.trainUnderline;return e=>{const y=n(e),d=e[r];if("training"===d){let o=y.stroke;return"darken"===u?o=t(y.stroke||"#666",.5):u&&(o=u),{...y,stroke:o,strokeDasharray:s,...p&&{strokeLinecap:p},...null!=c&&{strokeOpacity:c}}}if("training-base"===d){let t=y.stroke||"#666";return"lighten"===h&&(t=o(t,.4)),{...y,stroke:t,strokeDasharray:void 0}}if("forecast"===d){const t=e[a],o=null!=t?t:f;return{...y,stroke:l,strokeDasharray:i,...null!=o&&{strokeOpacity:o}}}return y}}export{r as SEGMENT_FIELD,a as FORECAST_OPACITY_FIELD,s as stampForecastOpacity,l as buildAnomalyAnnotations,c as buildForecast,f as createSegmentLineStyle};
|