semiotic 3.4.2 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +114 -9
- package/README.md +45 -4
- package/ai/behaviorContracts.cjs +311 -0
- package/ai/chartSuggestions.cjs +291 -0
- package/ai/cli.js +255 -30
- package/ai/componentMetadata.cjs +107 -0
- package/ai/dist/mcp-server.js +907 -227
- package/ai/schema.json +3954 -2537
- package/ai/system-prompt.md +23 -4
- package/dist/components/LinkedCharts.d.ts +5 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/charts/custom/NetworkCustomChart.d.ts +64 -0
- package/dist/components/charts/custom/OrdinalCustomChart.d.ts +71 -0
- package/dist/components/charts/custom/XYCustomChart.d.ts +59 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +93 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +51 -4
- package/dist/components/charts/geo/FlowMap.d.ts +55 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +53 -0
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +34 -2
- package/dist/components/charts/network/CirclePack.d.ts +36 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +130 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +37 -0
- package/dist/components/charts/network/SankeyDiagram.d.ts +51 -2
- package/dist/components/charts/network/TreeDiagram.d.ts +37 -2
- package/dist/components/charts/network/Treemap.d.ts +36 -2
- package/dist/components/charts/ordinal/BarChart.d.ts +113 -1
- package/dist/components/charts/ordinal/BoxPlot.d.ts +33 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +36 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +33 -0
- package/dist/components/charts/ordinal/FunnelChart.d.ts +40 -0
- package/dist/components/charts/ordinal/GaugeChart.d.ts +45 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +40 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +97 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +44 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +90 -1
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +29 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +40 -0
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +38 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +62 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +34 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +22 -4
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -2
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +24 -3
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +12 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +14 -0
- package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +67 -0
- package/dist/components/charts/realtime/resolveWindowSize.d.ts +26 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +91 -0
- package/dist/components/charts/shared/colorPalettes.d.ts +62 -0
- package/dist/components/charts/shared/colorUtils.d.ts +9 -10
- package/dist/components/charts/shared/numberFormat.d.ts +58 -0
- package/dist/components/charts/shared/sparseArray.d.ts +27 -0
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +113 -0
- package/dist/components/charts/shared/timeFormat.d.ts +60 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +84 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +28 -0
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +6 -19
- package/dist/components/charts/shared/useStreamingLegend.d.ts +27 -11
- package/dist/components/charts/shared/validateProps.d.ts +2 -2
- package/dist/components/charts/shared/validationMap.d.ts +2 -1
- package/dist/components/charts/shared/withChartWrapper.d.ts +13 -4
- package/dist/components/charts/xy/AreaChart.d.ts +44 -1
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -0
- package/dist/components/charts/xy/CandlestickChart.d.ts +37 -6
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +28 -0
- package/dist/components/charts/xy/Heatmap.d.ts +4 -0
- package/dist/components/charts/xy/LineChart.d.ts +12 -0
- package/dist/components/charts/xy/MinimapChart.d.ts +58 -0
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +27 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +21 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +38 -2
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +16 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +61 -1
- package/dist/components/realtime/types.d.ts +2 -4
- package/dist/components/recipes/bullet.d.ts +86 -0
- package/dist/components/recipes/calendar.d.ts +43 -0
- package/dist/components/recipes/dagre.d.ts +56 -0
- package/dist/components/recipes/flextree.d.ts +55 -0
- package/dist/components/recipes/marimekko.d.ts +55 -0
- package/dist/components/recipes/parallelCoordinates.d.ts +97 -0
- package/dist/components/recipes/recipeUtils.d.ts +27 -0
- package/dist/components/recipes/waffle.d.ts +46 -0
- package/dist/components/semiotic-ai.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +3 -0
- package/dist/components/semiotic-ordinal.d.ts +3 -0
- package/dist/components/semiotic-recipes.d.ts +24 -0
- package/dist/components/semiotic-xy.d.ts +3 -0
- package/dist/components/semiotic.d.ts +2 -2
- package/dist/components/server/renderToStaticSVG.d.ts +8 -2
- package/dist/components/server/serverChartConfigs.d.ts +47 -1
- package/dist/components/server/staticAnnotations.d.ts +6 -0
- package/dist/components/store/ObservationStore.d.ts +1 -3
- package/dist/components/store/SelectionStore.d.ts +1 -3
- package/dist/components/store/ThemeStore.d.ts +4 -4
- package/dist/components/store/TooltipStore.d.ts +1 -3
- package/dist/components/store/createStore.d.ts +4 -2
- package/dist/components/stream/CanvasHitTester.d.ts +10 -8
- package/dist/components/stream/DataSourceAdapter.d.ts +9 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +9 -0
- package/dist/components/stream/GeoTileRenderer.d.ts +14 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +25 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +12 -0
- package/dist/components/stream/PipelineStore.d.ts +51 -0
- package/dist/components/stream/SVGOverlay.d.ts +12 -0
- package/dist/components/stream/SceneGraph.d.ts +15 -1
- package/dist/components/stream/SceneToSVG.d.ts +1 -1
- package/dist/components/stream/categoryDomain.d.ts +4 -0
- package/dist/components/stream/composeOverlays.d.ts +15 -0
- package/dist/components/stream/customLayout.d.ts +76 -0
- package/dist/components/stream/customLayoutPalette.d.ts +29 -0
- package/dist/components/stream/geoTypes.d.ts +13 -0
- package/dist/components/stream/hoverUtils.d.ts +4 -10
- package/dist/components/stream/networkCustomLayout.d.ts +67 -0
- package/dist/components/stream/networkTypes.d.ts +45 -0
- package/dist/components/stream/ordinalCustomLayout.d.ts +84 -0
- package/dist/components/stream/ordinalTypes.d.ts +35 -1
- package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +9 -1
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +92 -0
- package/dist/components/stream/sampleCurvePath.d.ts +9 -0
- package/dist/components/stream/types.d.ts +44 -1
- package/dist/components/stream/useHydration.d.ts +89 -0
- package/dist/components/stream/useStableShallow.d.ts +1 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
- package/dist/geo.min.js +2 -1
- package/dist/geo.module.min.js +2 -1
- package/dist/network.min.js +2 -1
- package/dist/network.module.min.js +2 -1
- package/dist/ordinal.min.js +2 -1
- package/dist/ordinal.module.min.js +2 -1
- package/dist/realtime.min.js +2 -1
- package/dist/realtime.module.min.js +2 -1
- package/dist/semiotic-ai.d.ts +69 -65
- package/dist/semiotic-ai.min.js +2 -1
- package/dist/semiotic-ai.module.min.js +2 -1
- package/dist/semiotic-data.d.ts +4 -4
- package/dist/semiotic-geo.d.ts +15 -15
- package/dist/semiotic-network.d.ts +19 -16
- package/dist/semiotic-ordinal.d.ts +31 -28
- package/dist/semiotic-realtime.d.ts +17 -17
- package/dist/semiotic-recipes.d.ts +24 -0
- package/dist/semiotic-recipes.min.js +1 -0
- package/dist/semiotic-recipes.module.min.js +1 -0
- package/dist/semiotic-server.d.ts +6 -6
- package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +1 -0
- package/dist/semiotic-themes.d.ts +3 -3
- package/dist/semiotic-themes.min.js +2 -1
- package/dist/semiotic-themes.module.min.js +2 -1
- package/dist/semiotic-utils.d.ts +23 -23
- package/dist/semiotic-utils.min.js +2 -1
- package/dist/semiotic-utils.module.min.js +2 -1
- package/dist/semiotic-xy.d.ts +27 -24
- package/dist/semiotic.d.ts +63 -63
- package/dist/semiotic.min.js +2 -1
- package/dist/semiotic.module.min.js +2 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/canvasMock.d.ts +34 -5
- package/dist/xy.min.js +2 -1
- package/dist/xy.module.min.js +2 -1
- package/package.json +38 -17
- package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +0 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useEffect as l,createContext as s,useContext as a,useCallback as c,useSyncExternalStore as u,useState as d,forwardRef as h,useImperativeHandle as f,useId as g}from"react";import{select as y}from"d3-selection";import{brushX as p,brushY as v,brush as m}from"d3-brush";import{scaleLinear as x,scaleLog as b,scaleTime as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{schemeCategory10 as A,interpolateTurbo as S,interpolateCividis as _,interpolateMagma as M,interpolateInferno as P,interpolatePlasma as C,interpolateGreys as T,interpolatePurples as D,interpolateOranges as E,interpolateViridis as L,interpolateGreens as O,interpolateReds as $,interpolateBlues as N}from"d3-scale-chromatic";import{bin as I,min as W,groups as z,max as Y,sum as R,mean as B,group as j}from"d3-array";import{packEnclose as F,hierarchy as H,partition as X,pack as G,treemap as V,treemapBinary as q,cluster as U,tree as K}from"d3-hierarchy";import{area as Z,curveCatmullRom as Q,curveCardinal as J,curveBasis as tt,curveStepBefore as et,curveStepAfter as nt,curveStep as it,curveMonotoneY as ot,curveMonotoneX as rt,curveLinear as lt,arc as st,line as at,curveNatural as ct,pie as ut}from"d3-shape";import dt from"regression";import{interpolateNumber as ht}from"d3-interpolate";import{forceLink as ft,forceSimulation as gt,forceManyBody as yt,forceCenter as pt,forceX as vt,forceY as mt}from"d3-force";import{ribbon as xt,chord as bt}from"d3-chord";function kt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function wt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function At({width:e,height:n,totalWidth:i,totalHeight:s,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:x,streaming:b}){const k=o(null),w=o(null),A=o(d);A.current=d;const S=o(u);S.current=u;const _=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),M=o(_);M.current=_;const P=o(!1),C=o(null);return l(()=>{if(!k.current)return;const t=y(k.current).select(".brush-g"),i="x"===c?p():"y"===c?v():m();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(P.current)return;const r=S.current;if(!r)return;if(!o.selection)return C.current=null,void A.current(null);let l,s;if("x"===c){const[t,e]=o.selection;l=[r.x.invert(t),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(0)]}else if("y"===c){const[t,n]=o.selection;l=[r.x.invert(0),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;l=[r.x.invert(t),r.x.invert(n)],s=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===o.type||"brush"===o.type&&x)){const e=M.current;e&&e.length>0?l=function(t,e){return 0===e.length?t:[kt(t[0],e),wt(t[1],e)]}(l,e):h&&h>0&&(l=[Math.floor(l[0]/h)*h,Math.ceil(l[1]/h)*h]);const n=r.x(l[0]),s=r.x(l[1]);if(P.current=!0,"x"===c)t.call(i.move,[n,s]);else if("xy"===c){const e=o.selection;t.call(i.move,[[n,e[0][1]],[s,e[1][1]]])}P.current=!1}const a={x:l,y:s};C.current=a,A.current(a)}),t.call(i),w.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),w.current=null}},[e,n,c,f,h,x]),l(()=>{if(!(b&&u&&w.current&&C.current))return;if(!k.current)return;if("y"===c)return;const t=C.current,e=u.x.domain()[0],n=y(k.current).select(".brush-g");if(e>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=M.current;t&&t.length>0?i=wt(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);o=!0}const r=u.x(i),l=u.x(t.x[1]);if(P.current=!0,"x"===c)n.call(w.current.move,[r,l]);else{const e=u.y(t.y[1]),i=u.y(t.y[0]);n.call(w.current.move,[[r,e],[l,i]])}if(P.current=!1,o){const e={x:[i,t.x[1]],y:t.y};C.current=e,A.current(e)}},[u,b,c,f,h]),t("svg",{ref:k,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class St{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function _t(e){const n=s(null),i=Mt(e);return[function({children:i}){const o=r(()=>Mt(e),[]);return t(n.Provider,{value:o,children:i})},t=>{var e;const r=null!==(e=a(n))&&void 0!==e?e:i,l=o(t);l.current=t;const s=c(()=>l.current(r.getState()),[r]),d=c(()=>l.current(r.getState()),[r]);return u(r.subscribe,s,d)}]}function Mt(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}function Pt(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Ct(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:Tt})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const Tt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Dt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Et={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Lt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Tt,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Ot,$t]=_t(t=>({theme:Dt,setTheme(e){t(t=>{if("light"===e)return{theme:Dt};if("dark"===e)return{theme:Et};if("high-contrast"===e)return{theme:Lt};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Et:Dt;return{theme:Ct(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}}return{theme:Ct(Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})}))}})}}));class Nt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,l=this.buffer[r];if(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[r]=e(l)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class It{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(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 Wt(t,e,n,i,o){const r=new Map;for(const l of t){const t=e(l),s=n(l);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=s,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+s)}}return r}function zt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Yt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Rt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const jt=A,Ft=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Ht(t,e,n){var i,o,r;if(1>=n)return 1;const l=null!==(i=t.minOpacity)&&void 0!==i?i:.1,s=n-1-e;switch(t.type){case"linear":return l+(1-s/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,s/e)*(1-l)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>s?1:l;default:return 1}}function Xt(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function Gt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Vt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function qt(t,e,n){return t+(e-t)*n}function Ut(t,e,n){var i,o,r,l;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Kt(t,e,n,i,o,r){const l=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||l.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}l.sort((t,e)=>t.px-e.px);const s=Array(l.length),a=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];s[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:s,rawValues:a,style:o,datum:c,group:r}}function Zt(t,e,n,i,o,r,l,s){const a=[];for(const r of t){const t=n(r),l=i(r);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=s?s(r):o;a.push({px:c,topY:e.y(l),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:l}}function Qt(t,e,n,i,o,r,l){const s=n(t),a=i(t);if(null==s||null==a||Number.isNaN(s)||Number.isNaN(a))return null;const c={type:"point",x:e.x(s),y:e.y(a),r:o,style:r,datum:t};return void 0!==l&&(c.pointId=l),c}function Jt(t,e,n,i,o,r,l){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:l}}function te(t,e,n,i,o,r,l){const s={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==l?void 0:l.showValues)&&(s.showValues=!0,s.value=l.value,l.valueFormat&&(s.valueFormat=l.valueFormat)),s}function ee(t,e,n){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const l=t.getBounds(n),s=t.scales.x(e);if(l&&0!==l)i.push([s,t.scales.y(r+l)]),o.push([s,t.scales.y(r-l)]);else{const e=t.scales.y(r);i.push([s,e]),o.push([s,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function ne(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const l of i.data){let i=t.config.pointStyle(l);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const s=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(l)+"":void 0,c=Qt(l,t.scales,t.getX,r,s,i,a);c&&n.push(c)}}}const ie={blues:N,reds:$,greens:O,viridis:L,oranges:E,purples:D,greys:T,plasma:C,inferno:P,magma:M,cividis:_,turbo:S},oe=new Map;class re{constructor(t){if(this.xExtent=new It,this.yExtent=new It,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=t,this.buffer=new Nt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Yt(t.timeAccessor||t.xAccessor,"time"),this.getY=Yt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Yt(t.xAccessor,"x"),this.getY=Yt(t.yAccessor,"y")),this.getGroup=Bt(t.groupAccessor),this.getCategory=Bt(t.categoryAccessor),this.getSize=t.sizeAccessor?Yt(t.sizeAccessor,"size"):void 0,this.getColor=Bt(t.colorAccessor),this.getBounds=t.boundsAccessor?Yt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?Yt(t.y0Accessor,"y0"):void 0,this.getPointId=Bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Yt(t.openAccessor,"open"):void 0,this.getHigh=Yt(t.highAccessor,"high"),this.getLow=Yt(t.lowAccessor,"low"),this.getClose=n?Yt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new Nt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Yt(this.config.timeAccessor||this.config.xAccessor,"time"):Yt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,i,o,r,l,s;const{config:a,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),d=this.xExtent.extent,h=this.yExtent.extent;let f=a.xExtent?[null!==(n=a.xExtent[0])&&void 0!==n?n:d[0],null!==(i=a.xExtent[1])&&void 0!==i?i:d[1]]:d,g=a.yExtent?[null!==(o=a.yExtent[0])&&void 0!==o?o:h[0],null!==(r=a.yExtent[1])&&void 0!==r?r:h[1]]:h;const y=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!y&&c.size>0)if(a.normalize)g=[0,1+a.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)g=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;let i=0;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const r=(n.get(t)||0)+o;n.set(t,r),r>i&&(i=r)}g=[0,i+(i>0?i*a.extentPadding:1)],this._stackExtentCache={key:t,yDomain:g}}}else if("bar"===a.chartType&&a.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,i,o){const r=Wt(t,e,n,i,o);if(0===r.size)return[0,0];let l=0;for(const t of r.values())t.total>l&&(l=t.total);return[0,l]}(c,this.getX,this.getY,a.binSize,this.getCategory);g=[0,t+t*a.extentPadding]}else if("waterfall"===a.chartType&&!y&&c.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(c,this.getY),n=e-t,i=n>0?n*a.extentPadding:1;g=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!y&&g[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}const t=g[1]-g[0],e=t>0?t*a.extentPadding:1,n=null===(l=a.yExtent)||void 0===l?void 0:l[0],i=null===(s=a.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-e,null!=i?g[1]:g[1]+e],"log"===a.yScaleType&&0>=g[0]&&h[0]>0&&(g[0]=null!=n?g[0]:h[0]/(1+a.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===a.xScaleType){const t=Date.now();f=[t-864e5,t]}else f=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const p="streaming"===a.runtimeMode,v=Math.max(0,Math.min(a.scalePadding||0,Math.min(t.width,t.height)/2-1));if(p)if("x"==("up"===(m=a.arrowOfTime)||"down"===m?"y":"x")){const e="right"===a.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:x().domain(f).range(e),y:x().domain(g).range([t.height-v,v])}}else{const e="down"===a.arrowOfTime?[v,t.height-v]:[t.height-v,v];this.scales={x:x().domain(g).range([v,t.width-v]),y:x().domain(f).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?k().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)};this.scales={x:e(a.xScaleType,f,[v,t.width-v]),y:e(a.yScaleType,g,[t.height-v,v])}}var m;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,re.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?k().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)},a=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=l[1]>l[0];this.scales={x:s(this.config.xScaleType,i,r[0]>r[1]?[t.width-a,a]:[a,t.width-a]),y:s(this.config.yScaleType,o,c?[a,t.height-a]:[t.height-a,a])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:i,scales:o}=this;if(!o||0===e.length)return[];const r={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const n=ee(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Kt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return ne(t,i,o),o}(r,e);case"area":return function(t,e){const n=t.groupData(e),i=[],o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=Zt(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),i.push(l)}return ne(t,n,i),i}(r,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set,r=t.scales.y.domain()[0],l=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=Zt(e.data,t.scales,t.getX,t.getY,r,n,e.key,l);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Kt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return ne(t,n,i),i}(r,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:r}=function(t,e,n,i,o,r,l){var s;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const c=Array.from(a).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let d;if(r){d=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(s=u.get(i.key))||void 0===s?void 0:s.get(e))||0;d.set(e,n||1)}}const h=[],f=new Map,g=new Map;for(const t of c)g.set(t,0);for(const n of t){const t=u.get(n.key),i=[],s=[],a=new Map;for(const n of c){let o=t.get(n)||0;const l=g.get(n);r&&(o/=d.get(n));const c=l+o,u=e.x(n);s.push([u,e.y(l)]),i.push([u,e.y(c)]),g.set(n,c),a.set(n,c)}f.set(n.key,a);const y={type:"area",topPath:i,bottomPath:s,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(y.curve=l),h.push(y)}return{nodes:h,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,i),l=o;if(t.config.pointStyle){const e=new WeakMap;for(const i of n){const n=r.get(i.key);if(n)for(const o of i.data){const i=t.getX(o),r=t.getY(o);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!n.has(i)||e.set(o,n.get(i))}}const i=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};ne(t,n,l,i)}return l}(r,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let l=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);l=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(l&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=l(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=Qt(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(r,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const l=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),s=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Yt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/l,y=(f-h||1)/s,p=l*s;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/g),l-1),d=Math.min(Math.floor((r-h)/y),s-1);if(0>a||0>d)continue;const f=d*l+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,A=n.height/s,S=t.config.showValues,_=t.config.heatmapValueFormat,M=[];for(let t=0;s>t;t++){const e=t*l;for(let n=0;l>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-x)/k;M.push(te(n*w,(s-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i]},S?{value:o,showValues:!0,valueFormat:_}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const i=Yt(t.config.valueAccessor,"value"),o=Rt(t.config.xAccessor,"x"),r=Rt(t.config.yAccessor,"y"),l=new Map,s=new Map,a=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);a[t]=i,c[t]=u,l.has(i)||l.set(i,l.size),s.has(u)||s.set(u,s.size)}const u=l.size,d=s.size;if(0===u||0===d)return[];const h=Array.from(l.keys()),f=Array.from(s.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),l.clear();for(let t=0;h.length>t;t++)l.set(h[t],t)}if(y){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(a[t]),r=s.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,v[g]=d,m[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ie?t:"blues";let n=oe.get(e);if(n)return n;n=Array(256);const i=ie[e]||N;for(let t=0;256>t;t++)n[t]=i(t/255);return oe.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/d,P=t.config.showValues,C=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;T.push(te(i*_,(d-1-(n-i)/u)*M,_,M,A[Math.min((e-k)*S+.5|0,255)],m[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return T}(r,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Wt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),l=Array.from(e).filter(t=>!i.has(t)).sort(),s=n.filter(t=>e.has(t)),a=s.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...s,...l],t.barCategoryCache={key:a,order:r})}const l=[],s=t.scales,[a,c]=s.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=s.x(n),y=s.x(o),p=Math.abs(y-h),v=p>f+1?f:0,m=Math.min(h,y)+v/2,x=Math.max(p-v,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=s.y(n),c=s.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";l.push(Jt(m,Math.min(a,c),x,Math.abs(a-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=s.y(0),n=s.y(e.total);l.push(Jt(m,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of o.values())y.add(t.start),y.add(t.end);return{nodes:l,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(r,e);return this._barCategoryCache=null!==(n=r.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,l,s;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(l=c.opacity)&&void 0!==l?l:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let l=d;if(t.getCategory){const e=t.getCategory(n);l=(null===(s=t.config.barColors)||void 0===s?void 0:s[e])||l}const c={type:"point",x:o,y:r,r:u,style:{fill:l,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(r,e);case"waterfall":return function(t,e,n){var i,o,r,l,s,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",y=null!==(a=null!==(l=null==h?void 0:h.negativeColor)&&void 0!==l?l:null===(s=t.config.themeSemantic)||void 0===s?void 0:s.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),l=b+r;let s;s=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==s?d.x(o+s):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=l;continue}const A=d.y(b),S=d.y(l),_=Math.min(A,S),M=Math.abs(A-S),P={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(P.opacity=x),u.push(Jt(k,_,w,M,P,Object.assign(Object.assign({},i),{baseline:b,cumEnd:l,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=l}return u}(r,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],l=t.config.candlestickStyle||{},s=l.rangeColor||"#6366f1",a=o?s:l.upColor||"#28a745",c=o?s:l.downColor||"#dc3545",u=o?s:l.wickColor||"#333",d=l.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=l.bodyWidth)&&void 0!==i?i:0;if(null==l.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),l=t.getLow(n);if(null==i||Number.isNaN(i)||null==l||Number.isNaN(l))continue;const s=o?i:t.getOpen(n),h=o?l:t.getClose(n);if(!o&&[s,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(l),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(y.isRange=!0),r.push(y)}return r}(r,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Ht(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const l=new Map;for(let t=0;n.length>t;t++)l.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const s=l.get(e[n]);null!=s?(i[n]=Ht(t,s,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let s=!1;for(let n=0;e.length>n;n++){const i=l.get(e[n]);null!=i?(o[n]=Ht(t,i,r),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=Ht(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const s=Ht(t,e,r);if("heatcell"===n.type)n.style={opacity:s};else if("candlestick"===n.type)n._decayOpacity=s;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*s})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const l="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const s=Xt(t,r,l);s>o&&(o=s)}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=Xt(t,o,l);r>0&&(n._pulseIntensity=r,n._pulseColor=s,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,l,s;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=Ut(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=Ut(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_,M,P,C,T,D,E,L,O,$,N,I,W,z,Y,R,B,j,F,H,X;if(0===i.size&&0===o.size)return n;const G=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let V=!1;const q=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],D=Ut(t,r,e);if(!D)continue;if(r._transitionKey=D,"line"===r.type||"area"===r.type){const t=o.get(D);if(t){if(U.add(D),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}r._targetOpacity=null!==(l=r.style.opacity)&&void 0!==l?l:1,r._startOpacity=null!==(a=null!==(s=t.opacity)&&void 0!==s?s:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const E=i.get(D);if("point"===r.type)if(E){q.add(D);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,E.x===t.x&&E.y===t.y&&E.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=E.x,r.y=E.y,r.r=null!==(d=E.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(E){q.add(D);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=E.x,r.y=E.y,r.w=null!==(g=E.w)&&void 0!==g?g:r.w,r.h=null!==(y=E.h)&&void 0!==y?y:r.h,V=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(E){q.add(D);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=E.x,r.y=E.y,r.w=null!==(x=E.w)&&void 0!==x?x:r.w,r.h=null!==(b=E.h)&&void 0!==b?b:r.h,V=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(E&&null!=E.openY){q.add(D);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(E.x!==t.x||E.openY!==t.openY||E.closeY!==t.closeY||E.highY!==t.highY||E.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=E.x,r.openY=E.openY,r.closeY=null!==(_=E.closeY)&&void 0!==_?_:r.closeY,r.highY=null!==(M=E.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(P=E.lowY)&&void 0!==P?P:r.lowY,V=!0)}else r._targetOpacity=null!==(T=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(D=e.opacity)&&void 0!==D?D:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}for(const[t,e]of i)if(!q.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==($=e.w)&&void 0!==$?$:0,h:null!==(N=e.h)&&void 0!==N?N:0,style:{opacity:null!==(I=e.opacity)&&void 0!==I?I:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(W=e.w)&&void 0!==W?W:0,h:null!==(z=e.h)&&void 0!==z?z:0,fill:"#999",datum:null,style:{opacity:null!==(Y=e.opacity)&&void 0!==Y?Y:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(R=e.openY)&&void 0!==R?R:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(B=e.closeY)&&void 0!==B?B:i,highY:null!==(j=e.highY)&&void 0!==j?j:i,lowY:null!==(F=e.lowY)&&void 0!==F?F:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:G}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,l,s,a,c;if(!n.activeTransition)return!1;const u=Vt(t,n.activeTransition),d=Gt(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=qt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=qt(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=qt(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==n.w&&(t.w=qt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=qt(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:qt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==n.w&&(t.w=qt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=qt(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:qt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=qt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=qt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=qt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=qt(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:qt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=qt(e[i][0],n[i][0],d),t.path[i][1]=qt(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:qt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=qt(e[n][0],i[n][0],d),t.topPath[n][1]=qt(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=qt(n[e][0],o[e][0],d),t.bottomPath[e][1]=qt(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||Ft,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const l=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:l,fillOpacity:.7,stroke:l,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||Ft;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>re.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let l=!1;Object.assign(this.config,t);const s="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(s||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const a=s||!zt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),c=s||!zt(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(a||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Yt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Yt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Yt(this.config.xAccessor,"x"),this.getY=Yt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!zt(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Bt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!zt(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Bt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!zt(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Yt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!zt(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Bt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!zt(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Yt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!zt(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Bt(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!zt(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!zt(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!zt(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!zt(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Yt(this.config.openAccessor,"open"):void 0,this.getHigh=Yt(this.config.highAccessor,"high"),this.getLow=Yt(this.config.lowAccessor,"low"),this.getClose=e?Yt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0}if(!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function le(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function se(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function ae(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function ce(t,e){const n=ae(t);if(!n)return!1;const i=ae(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function ue(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function de(t,e,n,i=30,o,r=0){let l=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),l=e-r,s=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>s||l>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,l=t.y-n,s=Math.sqrt(r*r+l*l);se(t.r,i)>=s&&d>s&&(u=t,d=s),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,r);t&&(l={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(o)break;t=fe(r,e,n,i);break;case"line":t=ge(r,e,n,i);break;case"rect":t=pe(r,e,n);break;case"heatcell":t=ve(r,e,n);break;case"area":if(!1===r.interactive)break;t=xe(r,e,n);break;case"candlestick":t=me(r,e,n)}t&&i>t.distance&&(l&&t.distance>=l.distance||(l=t))}return l}function he(t,e,n){if(0===t.length)return null;const i=be(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[l,s]=t[o],[a,c]=t[r];return a===l?s:s+Math.max(0,Math.min(1,(e-l)/(a-l)))*(c-s)}function fe(t,e,n,i=30){const o=e-t.x,r=n-t.y,l=Math.sqrt(o*o+r*r);return l>se(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function ge(t,e,n,i=30){var o,r,l,s;if(0===t.path.length)return null;const a=be(t.path,e);if(0>a)return null;const[c,u]=t.path[a];let d;if(t.path.length>1){let i=1/0;const o=Math.max(0,a-1),r=Math.min(t.path.length-2,a);for(let l=o;r>=l;l++){const[o,r]=t.path[l],[s,a]=t.path[l+1],c=ye(e,n,o,r,s,a);i>c&&(i=c)}d=i}else{const t=e-c,i=n-u;d=Math.sqrt(t*t+i*i)}const h=null!==(s=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==s?s:1;return d>Math.max(5,h/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:c,y:u,distance:d}}function ye(t,e,n,i,o,r){const l=o-n,s=r-i,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*l+(e-i)*s)/a;c=Math.max(0,Math.min(1,c));const u=i+c*s;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function pe(t,e,n){const i=le(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function ve(t,e,n){const i=le(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function me(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,l=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+l*l)}}return null}function xe(t,e,n){if(0===t.topPath.length)return null;const i=be(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],l=e-o,s=n-r,a=Math.sqrt(l*l+s*s);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function be(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function ke(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:l}}function we(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function Ae(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?Se(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Se(n,n.groups[t-1],r[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Se(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function _e(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function Me(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function Pe(t,e,n,i,o,r){l(()=>{if(!t)return;const l=setInterval(()=>{var l;const s=e.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(l=t.threshold)&&void 0!==l?l:5e3,u=a-s.lastIngestTime>c;u!==o&&(r(u),n.current=!0,i())},1e3);return()=>clearInterval(l)},[t,o,i])}re.GROUP_COLOR_MAP_CAP=1e3,re.QUADTREE_THRESHOLD=500;const Ce={fill:e=>t("rect",{style:e,width:16,height:16}),line:e=>t("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Te(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,Ce[n])(i(t,e)),o}function De(){return t("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ee(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Le=(n,i,o,r,l,s,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=n,y=[];let p=0;const v=!(!i&&!o),m="isolate"===d||void 0===d&&null!=l;return g.forEach((n,d)=>{const x=Te(n,d,h,f),b=Ee(n,r,l),k=l&&l.size>0&&l.has(n.label);y.push(e("g",{transform:`translate(0,${p})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?c===s&&d===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&m?k||!1:void 0,"aria-current":v&&!m&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+g.length)%g.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:v?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,k&&t(De,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),p+=22}),y};function Oe({config:n,orientation:o="vertical",width:r=100}){const{colorFn:l,domain:s,label:a,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:l(s[0]+n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),a&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:l(s[1]-n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[a&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])})]})}function $e(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical"}=n,[g,y]=i.useState(0),[p,v]=i.useState(0),m=i.useCallback((t,e)=>{y(t),v(e)},[]),x="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t("g",{className:"legend-item",transform:`translate(0,${d})`,children:Le(e,i,o,r,l,s,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h})=>{let f=0;const g=[];n.forEach((n,i)=>{let y=0;n.label&&(y+=16);const p=((n,i,o,r,l,s,a,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let v=0,m=0;const x=!(!i&&!o),b="isolate"===d||void 0===d&&null!=l;y.forEach((n,d)=>{const k=Te(n,d,f,g),w=Ee(n,r,l),A=l&&l.size>0&&l.has(n.label),S=26+7*n.label.length;h&&h>0&&v>0&&v+S>h&&(m++,v=0),p.push(e("g",{transform:`translate(${v},${22*m})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:x?c===s&&d===a?0:-1:void 0,role:x?"option":void 0,"aria-selected":x&&b?A||!1:void 0,"aria-current":x&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:x?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(d+("ArrowRight"===t.key?1:-1)+y.length)%y.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:x?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:x?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:x?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[x&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,A&&t(De,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),v+=S});let k=0,w=0;for(const t of y){const e=26+7*t.label.length;h&&h>0&&w>0&&w+e>h?(k=Math.max(k,w),w=e):w+=e}k=Math.max(k,w);const A=m+1;return{items:p,offset:k,totalRows:A,totalHeight:22*A}})(n,r,l,s,a,c,u,i,d,h,o);y+=p.offset+5,g.push(Object.assign(Object.assign({label:n.label},p),{offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight})),f+=y+12});let y=f>o?0:Math.max(0,(o-f)/2);const p=[];return g.forEach((e,o)=>{const r=n[o];r.label&&(p.push(t("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),y+=16),p.push(t("g",{className:"legend-item",transform:`translate(${y},0)`,children:e.items},"legend-group-"+o)),y+=e.offset+5,n[o+1]&&p.push(t("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),t("g",{children:p})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}),b=!(!r&&!l);return e("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==c&&(void 0!==c||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),x]})}function Ne(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ie(t){return"object"==typeof t&&null!==t&&"gradient"in t}function We(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:l="right",title:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===l||"bottom"===l;let g,y;return"left"===l?(g=4,y=r.top):"top"===l?(g=0,y=s?32:8):"bottom"===l?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t("g",{transform:`translate(${g}, ${y})`,children:Ie(n)?t(Oe,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):Ne(n)?t($e,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function ze(t){return"string"==typeof t?{type:t}:t}function Ye({orient:n,config:i,values:o,scale:l,size:s,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=r(()=>{if(0===o.length)return null;const i=l.domain(),r=s-8;if("boxplot"===c.type){const i=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],l=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*l),whiskerHigh:Math.min(e[n-1],r+1.5*l)}}(o);if(!i)return null;const{q1:s,median:a,q3:d,whiskerLow:h,whiskerHigh:f}=i,g=Math.min(.5*r,20),y=(r-g)/2+4;if(u){const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="top"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:m+v*(y+g/2),x2:p,y2:m+v*(y+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:m+v*y,x2:u,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:p,y1:m+v*y,x2:p,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?m-y-g:m+y,width:Math.abs(o-i),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?m-y-g:m+y,x2:r,y2:"top"===n?m-y:m+y+g,stroke:c.fill,strokeWidth:2})]})}{const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="left"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:m+v*(y+g/2),y1:u,x2:m+v*(y+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:u,x2:m+v*(y+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:p,x2:m+v*(y+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?m-y-g:m+y,y:Math.min(i,o),width:g,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?m-y-g:m+y,y1:r,x2:"left"===n?m-y:m+y+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=I().domain(i).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(s,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+s),width:o,height:Math.abs(s),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),s=l((t.x0+t.x1)/2);i.push(u?`${s},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${s}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const s=o.length/h*(r/2),a=l((o.x0+o.x1)/2);i.push(u?`${a},${"top"===n?-(e+s):e+s}`:`${"left"===n?-(e+s):e+s},${a}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,l,c,s,a,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Re(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let l="";for(const t of o)l&&l.length+1+t.length>i?(r.push(l),l=t):l=l?`${l} ${t}`:t;return l&&r.push(l),r}function Be(t,e,n,i){return"curly"===t?i?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function je(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:l,title:s,orientation:a,align:c,wrap:u=120,noWrap:d}=n;if(!l&&!s)return t("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>i?"end":"start";const y=16,p=s?d?[s]:Re(s,u):[],v=l?d?[l]:Re(l,u):[],m="leftRight"===h?"end"===g?-4:4:0;let x=0;const b=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:p.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-title")),x=p.length*y),v.length>0&&b.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:x,children:v.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-label"));let w=null;if((s||l)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===g?(n=-e,i=0):"middle"===g&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+v.length)*y+(v.length>0?y:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,p.length+v.length-1)*y;let S=0;return"topBottom"===h?S=0>o?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+y+(v.length>0&&p.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:b}),w]})}function Fe(e,n,i,o,r){var l;const s=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&s.push(t("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&s.push(t("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,l=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;s.push(t("line",{x1:o,y1:(n.y1||0)-l,x2:o,y2:(n.y2||0)-l,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-l;s.push(t("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(t("line",{x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&s.push(t("path",{d:Be((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:s})}function He(e,n,i,o,r,l){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==l?void 0:l.radius)){if("callout-rect"===r&&l){const t=l.width||0,i=l.height||0;if(t>0||i>0){const o=t/2,r=i/2,l=e-o,s=n-r;if(0!==l||0!==s){const e=Math.abs(l),n=Math.abs(s),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+l*h,c=r+s*h}}}else if("bracket"===r&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(l.radius||0)+(l.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);a=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(n-c,2))>.5&&(s.push(t("line",{x1:a,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,l=Math.atan2(n-c,e-a);s.push(t("path",{d:`M${a},${c}L${a+i*Math.cos(l+r)},${c+i*Math.sin(l+r)}L${a+i*Math.cos(l-r)},${c+i*Math.sin(l-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t("g",{className:"annotation-connector",children:s})}function Xe(t){const{x:n=0,y:i=0,dx:o,dy:r,nx:l,ny:s,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=l&&(m=l-n),null!=s&&(x=s-i);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return e("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&He(m,x,c,h,b,u),!v.has("subject")&&Fe(b,u,h,n,i),!v.has("note")&&je(a,m,x,h)]}))}function Ge(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,l="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),s=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:s});return t(Xe,Object.assign({"data-testid":"semiotic-annotation"},r,{type:l}),"multi-annotation-"+i)});return t("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t(Xe,Object.assign({"data-testid":"semiotic-annotation",events:s},o,{type:l}),c)}function Ve(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function qe(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function Ue(t,e,n){var i,o,r,l;const s=t.anchor||"fixed";if("latest"===s){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,l;const s=t.data;if(!s||0===s.length)return null;const a=s[s.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let a=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(a=e.x,c=e.y)}if(null!=a&&null!=c||(a=Ve(t,n),c=qe(t,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:a,y:c}),{x:a,y:c};if("sticky"===s){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function Ke(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const Ze={linear:lt,monotoneX:rt,monotoneY:ot,step:it,stepAfter:nt,stepBefore:et,basis:tt,cardinal:J,catmullRom:Q};let Qe={positions:new Map};const Je=new Set;function tn(){for(const t of Je)t()}function en(t,e){const n=Qe.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Qe.positions);i.delete(t),Qe={positions:i},tn()}function nn(t,e){const n=Qe.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Qe.positions);i.delete(t),Qe={positions:i},tn()}function on(){return Qe}function rn(t){return Je.add(t),()=>Je.delete(t)}const ln={positions:new Map};function sn(){return()=>{}}function an(){return ln}function cn(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function un(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let l="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${i+4*o}`,l+=`L${Math.min(n,e)},${i}`}return l}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let l=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);l+=`L${i+4*o},${Math.min(8*t+4,n)}`,l+=`L${i},${Math.min(e,n)}`}return l}}function dn(n){const{width:i,height:o,totalWidth:l,totalHeight:s,margin:a,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g}=n,y=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||f||hn,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=c.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),l=r.map(t=>t.valueOf()),s=r.map((t,e)=>({value:t,pixel:c.x(t),label:n(t,e,l)})),a=s.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return fn(s,Math.max(55,a+8))},[c,d,f,i]),p=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||g||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return fn(c.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:c.y(t),label:n(t)})),22)},[c,d,g,o]),v=h&&c,m=u&&c;if(!v&&!m)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),b=null==d?void 0:d.find(t=>"left"===t.orient),k=m&&(!x||!1!==x.baseline),w=m&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,S=(null==b?void 0:b.jaggedBase)||!1,_="var(--semiotic-border, #ccc)";return t("svg",{width:l,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${a.left},${a.top})`,children:[v&&(()=>{var n,r;const l=cn(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),s=cn(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l},"xgrid-"+n)),p.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:_,strokeWidth:1}),A&&t("path",{d:un("bottom",i,o),fill:"none",stroke:_,strokeWidth:1}),w&&!S&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:_,strokeWidth:1}),S&&t("path",{d:un("left",i,o),fill:"none",stroke:_,strokeWidth:1})]})})}function hn(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function fn(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function gn(i){var s,a;const{width:c,height:d,totalWidth:h,totalHeight:f,margin:g,scales:y,showAxes:p,axes:v,xLabel:m,yLabel:x,yLabelRight:b,xFormat:k,yFormat:w,showGrid:A,title:S,legend:_,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:T,legendPosition:D="right",foregroundGraphics:E,marginalGraphics:L,xValues:O,yValues:$,annotations:N,svgAnnotationRules:I,xAccessor:W,yAccessor:z,annotationData:Y,pointNodes:R,curve:B,underlayRendered:j,linkedCrosshairName:H,linkedCrosshairSourceId:X,children:G}=i,V=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||k||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=y.x.ticks(Math.min(i,Math.max(2,Math.floor(c/70)))),r=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:y.x(t),label:n(t,e,r)})),s=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),a=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=fn(l,a);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=y.x.domain()[1],e=y.x(t),i=u[u.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,u.length,r);a>e-i&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[p,y,v,k,c]),q=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||w||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=fn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=y.y.domain()[1],e=y.y(t),i=o[o.length-1].pixel;if(Math.abs(e-i)>1){const r=n(t);22>Math.abs(e-i)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:r})}}return o},[p,y,v,w,d]),U=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||w||hn,i=null!==(t=e.ticks)&&void 0!==t?t:5;return fn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.y(t),label:n(t)})),22)},[p,y,v,w,d]),K=o(new Map),Q=o(null!==(s=null==N?void 0:N.length)&&void 0!==s?s:0),J=null!==(a=null==N?void 0:N.length)&&void 0!==a?a:0;Q.current!==J&&(Q.current=J,K.current=new Map);const tt=r(()=>{if(!N||0===N.length)return null;const n=function(n,i,o){var r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_,M,P,C,T,D,E,L,O,$,N,I,W,z,Y,R,B,j,H,X,G,V,q,U,K,Q,J,tt;switch(n.type){case"label":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return Ke(r,l,o)?t(Ge,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"label",connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"callout":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return Ke(r,l,o)?t(Ge,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"callout-circle",subject:{radius:n.radius||12},connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"x-threshold":{const r=Ve(n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:r+4,y:a,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"y-threshold":{const r=qe(n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"right";let a,c;return"left"===s?(a=4,c="start"):"center"===s?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:a,y:r-4,textAnchor:c,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"enclose":{const r=(n.coordinates||[]).map(t=>({x:Ve(Object.assign(Object.assign({},t),{type:"point"}),o),y:qe(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=F(r),s=n.padding||10;return e("g",{children:[t("circle",{cx:l.x,cy:l.y,r:l.r+s,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:l.x,y:l.y-l.r-s-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"rect-enclose":{const r=(n.coordinates||[]).map(t=>({x:Ve(Object.assign(Object.assign({},t),{type:"point"}),o),y:qe(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=n.padding||10,s=r.map(t=>t.x),a=r.map(t=>t.y),c=Math.min(...s)-l,u=Math.max(...s)+l,d=Math.min(...a)-l,h=Math.max(...a)+l;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"highlight":{const e=o.data||[],r="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],l={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:r.map((e,i)=>{const r=Ve(e,o),s=qe(e,o);if(null==r||null==s)return null;const a="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||l;return t("circle",Object.assign({cx:r,cy:s,r:a},c),"hl-"+i)})},"ann-"+i)}case"bracket":{const e=Ve(n,o),r=qe(n,o);return t(Ge,{noteData:{x:null!=e?e:0,y:null!=r?r:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+i)}case"trend":{const h=o.data||[];if(2>h.length)return null;const f=o.xAccessor||"x",g=o.yAccessor||"y",y=h.map(t=>[t[f],t[g]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const p=null!==(l=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==l?l:null===(s=o.scales)||void 0===s?void 0:s.time,v=null!==(c=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=o.scales)||void 0===u?void 0:u.value;if(!p||!v)return null;const m=n.method||"linear";let x;x="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),s=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){s.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))s.push([e,h/u]);else{const t=(u*g-d*h)/y;s.push([e,(h-t*d)/u+t*e])}}return s}(y,null!==(d=n.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?dt.polynomial(y,{order:n.order||2}):dt.linear(y)).points;const b=x.map(([t,e])=>`${p(t)},${v(e)}`).join(" "),k=n.color||"#6366f1";return e("g",{children:[t("polyline",{points:b,fill:"none",stroke:k,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:p(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11,children:n.label})]},"ann-"+i)}case"band":{const r=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value,l=null!==(y=null==r?void 0:r(n.y0))&&void 0!==y?y:0,s=null!==(p=null==r?void 0:r(n.y1))&&void 0!==p?p:o.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(l,s),width:o.width||0,height:Math.abs(s-l),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(l,s)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+i)}case"envelope":{const r=o.data||[];if(2>r.length)return null;const l=o.xAccessor||"x",s=null!==(m=null===(v=o.scales)||void 0===v?void 0:v.x)&&void 0!==m?m:null===(x=o.scales)||void 0===x?void 0:x.time,a=null!==(k=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==k?k:null===(w=o.scales)||void 0===w?void 0:w.value;if(!s||!a)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=r.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[l]-e[l]);if(2>h.length)return null;const f=Ze[o.curve||"linear"]||lt,g=Z().x(t=>s(t[l])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!g)return null;const y=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:y,fillOpacity:null!==(A=n.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:s(h[h.length-1][l])+4,y:a(h[h.length-1][c])-4,fill:y,fontSize:11,children:n.label})]},"ann-"+i)}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const l=o.yAccessor||"y",s=null!==(_=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==_?_:null===(M=o.scales)||void 0===M?void 0:M.time,a=null!==(C=null===(P=o.scales)||void 0===P?void 0:P.y)&&void 0!==C?C:null===(T=o.scales)||void 0===T?void 0:T.value;if(!s||!a)return null;const c=r.map(t=>t[l]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(D=n.threshold)&&void 0!==D?D:2,g=u-f*h,y=!1!==n.showBand,p=n.fill||"#6366f1",v=null!==(E=n.fillOpacity)&&void 0!==E?E:.1,m=n.anomalyColor||"#ef4444",x=null!==(L=n.anomalyRadius)&&void 0!==L?L:6,b=a(u+f*h),k=a(g),w=r.filter(t=>{const e=t[l];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[y&&t("rect",{x:0,y:Math.min(b,k),width:o.width||0,height:Math.abs(k-b),fill:p,fillOpacity:v}),w.map((e,n)=>{const i=Ve(e,o),r=qe(e,o);return null==i||null==r?null:t("circle",{cx:i,cy:r,r:x,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(b,k)-4,textAnchor:"end",fill:p,fontSize:11,children:n.label})]},"ann-"+i)}case"forecast":{const r=o.data||[];if(3>r.length)return null;const l=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==($=null===(O=o.scales)||void 0===O?void 0:O.x)&&void 0!==$?$:null===(N=o.scales)||void 0===N?void 0:N.time,c=null!==(W=null===(I=o.scales)||void 0===I?void 0:I.y)&&void 0!==W?W:null===(z=o.scales)||void 0===z?void 0:z.value;if(!a||!c)return null;const u=r.map(t=>[t[l],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=dt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const l=(t*o-e*n)/r,s=(n-l*e)/t;d=t=>s+l*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),y=u.reduce((t,e)=>t+e[0],0)/h,p=u.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),v=null!==(Y=n.confidence)&&void 0!==Y?Y:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(R=n.steps)&&void 0!==R?R:5,b=u[h-1][0],k=(b-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(p>0?Math.pow(t-y,2)/p:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${a(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${c(t.yLower)}`).join(" L")} Z`,_=A.map(t=>`${a(t.x)},${c(t.yCenter)}`).join(" "),M=`${a(b)},${c(d(b))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(B=n.fillOpacity)&&void 0!==B?B:.15,stroke:"none"}),t("polyline",{points:`${M} ${_}`,fill:"none",stroke:P,strokeWidth:null!==(j=n.strokeWidth)&&void 0!==j?j:2,strokeDasharray:null!==(H=n.strokeDasharray)&&void 0!==H?H:"6,3"}),n.label&&A.length>0&&t("text",{x:a(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+i)}case"widget":{let e=null,r=null;if(null!=n.px&&null!=n.py)e=n.px,r=n.py;else{const t=Ue(n,i,o);if(!t)return null;e=t.x,r=t.y}if(null==e||null==r)return null;if(!Ke(e,r,o))return null;const l=null!==(X=n.dx)&&void 0!==X?X:0,s=null!==(G=n.dy)&&void 0!==G?G:0,a=null!==(V=n.width)&&void 0!==V?V:32,c=null!==(q=n.height)&&void 0!==q?q:32,u=null!==(U=n.content)&&void 0!==U?U:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+l-a/2,y:r+s-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+i)}case"text":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return t("text",{x:r+(n.dx||0),y:l+(n.dy||0),fill:n.color||"var(--semiotic-text, #333)",fontSize:n.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label},"ann-text-"+i)}case"category-highlight":{const r=n.category;if(null==r)return null;const l=null===(K=o.scales)||void 0===K?void 0:K.o,s=null===(Q=o.scales)||void 0===Q?void 0:Q.x,a=null===(J=o.scales)||void 0===J?void 0:J.y,c=(null==l?void 0:l.bandwidth)?l:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!c)return null;const u=c(r);if(null==u)return null;const d=c.bandwidth(),h=n.color||"var(--semiotic-primary, #4589ff)",f=null!==(tt=n.opacity)&&void 0!==tt?tt:.15,g=n.label;return e("g",(o.projection?"vertical"===o.projection:c===s)?{children:[t("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&t("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&t("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+i)}default:return null}},i={scales:y?{x:y.x,y:y.y,time:y.x,value:y.y}:null,timeAxis:"x",xAccessor:W,yAccessor:z,width:c,height:d,data:Y,frameType:"xy",pointNodes:R,curve:B,stickyPositionCache:K.current};return N.map((t,e)=>{if(I){const o=I(t,e,i);return null!=o?o:n(t,e,i)}return n(t,e,i)}).filter(Boolean)},[N,I,c,d,W,z,Y,y,R,B]),et=function(t){var e;const n=u(t?rn:sn,t?on:an,t?on:an);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(H);return l(()=>{if(!(null==et?void 0:et.locked)||!H)return;const t=t=>{"Escape"===t.key&&nn(H)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==et?void 0:et.locked,H]),p||S||_||E||L||tt&&tt.length>0||A||G||et?e("svg",{role:"img",width:h,height:f,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof S?S:"XY Chart"}),t("desc",{children:"string"==typeof S?S+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[A&&y&&!j&&(()=>{var n,i;const o=cn(null===(n=null==v?void 0:v.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=cn(null===(i=null==v?void 0:v.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[V.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:d,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),q.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:c,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),p&&y&&(()=>{const i=null==v?void 0:v.find(t=>"left"===t.orient),o=null==v?void 0:v.find(t=>"bottom"===t.orient),r=!i||!1!==i.baseline,l=!o||!1!==o.baseline,s=(null==i?void 0:i.jaggedBase)||!1,a=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,h=null==i?void 0:i.landmarkTicks,f="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",k=!!(null==o?void 0:o.autoRotate)&&V.length>1&&(()=>{const t=c/Math.max(V.length-1,1),e=V.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})();return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!j&&l&&!a&&t("line",{x1:0,y1:d,x2:c,y2:d,stroke:f,strokeWidth:1}),!j&&a&&t("path",{d:un("bottom",c,d),fill:"none",stroke:f,strokeWidth:1}),V.map((n,i)=>{const o=!!u&&("function"==typeof u?u(n.value,i):ce(n.value,i>0?V[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${d})`,children:[t("line",{y2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:k?10:18,textAnchor:k?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},transform:k?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:n.label})})]},"xtick-"+i)}),m&&t("text",{x:c/2,y:d+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:m}),!j&&r&&!s&&t("line",{x1:0,y1:0,x2:0,y2:d,stroke:f,strokeWidth:1}),!j&&s&&t("path",{d:un("left",c,d),fill:"none",stroke:f,strokeWidth:1}),q.map((n,i)=>{const o=!!h&&("function"==typeof h?h(n.value,i):ce(n.value,i>0?q[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==i?void 0:i.label)||x;return e?t("text",{x:15-g.left,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-g.left}, ${d/2})`,style:{userSelect:"none"},children:e}):null})(),(()=>{const i=null==v?void 0:v.find(t=>"right"===t.orient);if(!i||0===U.length)return null;const o=i.landmarkTicks,r=i.label||b;return e(n,{children:[!1!==i.baseline&&t("line",{x1:c,y1:0,x2:c,y2:d,stroke:f,strokeWidth:1}),U.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):ce(n.value,i>0?U[i-1].value:void 0));return e("g",{transform:`translate(${c},${n.pixel})`,children:[t("line",{x2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:c+g.right-15,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${c+g.right-15}, ${d/2})`,style:{userSelect:"none"},children:r})]})})()]})})(),tt,L&&y&&O&&$&&e(n,{children:[L.top&&t("g",{transform:"translate(0, 0)",children:t(Ye,{orient:"top",config:ze(L.top),values:O,scale:y.x,size:g.top,length:c})}),L.bottom&&t("g",{transform:`translate(0, ${d})`,children:t(Ye,{orient:"bottom",config:ze(L.bottom),values:O,scale:y.x,size:g.bottom,length:c})}),L.left&&t("g",{transform:"translate(0, 0)",children:t(Ye,{orient:"left",config:ze(L.left),values:$,scale:y.y,size:g.left,length:d})}),L.right&&t("g",{transform:`translate(${c}, 0)`,children:t(Ye,{orient:"right",config:ze(L.right),values:$,scale:y.y,size:g.right,length:d})})]}),E,et&&et.sourceId!==X&&(null==y?void 0:y.x)&&(()=>{const e=y.x(et.xValue);if(null==e||0>e||e>c)return null;const n=et.locked;return t("line",{x1:e,y1:0,x2:e,y2:d,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),G]}),S&&t("text",{x:h/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof S?S:null}),We({legend:_,totalWidth:h,totalHeight:f,margin:g,legendPosition:D,title:S,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:T})]}):null}function yn(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const pn="undefined"==typeof window||"undefined"==typeof document,vn=i.createContext(null);function mn(){return i.useContext(vn)}const xn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function bn(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const i=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of l)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function kn(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const wn=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},An={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Sn={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},_n={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Mn={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Pn={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Cn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Tn={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Dn({scene:n,chartType:o,tableId:r,chartTitle:l}){var s;const[a,c]=i.useState(!1),u=mn(),d=null!==(s=null==u?void 0:u.visible)&&void 0!==s&&s,h=a||d,f=i.useRef(null),g=l?"Data summary for "+l:r?`Data summary for ${o} ${r}`:"Data summary for "+o,y=i.useCallback(()=>{a||d||c(!0)},[a,d]),p=i.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[d]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:xn}):null;if(!h)return t("div",{id:r,tabIndex:-1,onFocus:y,style:xn,role:"region","aria-label":g,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const v=function(t){var e,n,i,o,r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_;const M=[];if(!Array.isArray(t))return M;for(const P of t)if(P&&"object"==typeof P)try{switch(P.type){case"point":M.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;M.push({label:"Bar",values:{category:r,value:null!=l?l:""}});break}case"heatcell":M.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":M.push({label:"Wedge",values:{category:null!==(a=null!==(l=null===(r=P.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:null===(s=P.datum)||void 0===s?void 0:s.label)&&void 0!==a?a:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":M.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(g=P.cy)&&void 0!==g?g:P.y}});break;case"arc":M.push({label:"Arc",values:{id:null!==(p=null===(y=P.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m:P.y}});break;case"candlestick":M.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":M.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(_=null===(S=P.datum)||void 0===S?void 0:S.value)&&void 0!==_?_:""}})}}catch(t){}return M}(n),m=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(v),x=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${wn(t.min)} to ${wn(t.max)}, mean ${wn(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(v.length,m),b=v.slice(0,5),k=new Set;for(const t of b)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return e("div",{ref:f,id:r,tabIndex:-1,onBlur:p,style:An,role:"region","aria-label":g,children:[t("button",{type:"button",onClick:()=>{d&&u&&u.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:_n,children:"×"}),t("div",{role:"note",style:Sn,children:x}),e("table",{role:"table","aria-label":"Sample data for "+o,style:Mn,children:[e("caption",{style:Tn,children:["First ",b.length," of ",v.length," data points"]}),t("thead",{children:e("tr",{children:[t("th",{style:Pn,children:"type"}),w.map(e=>t("th",{style:Pn,children:e},e))]})}),t("tbody",{children:b.map((n,i)=>e("tr",{children:[t("td",{style:Cn,children:n.label}),w.map(e=>{return t("td",{style:Cn,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":wn(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]})]})}function En({nodes:n,edges:o,chartType:r,tableId:l,chartTitle:s}){var a,c,u,d,h,f,g,y,p,v,m,x,b,k;const[w,A]=i.useState(!1),S=mn(),_=null!==(a=null==S?void 0:S.visible)&&void 0!==a&&a,M=w||_,P=s?"Data summary for "+s:l?`Data summary for ${r} ${l}`:"Data summary for "+r,C=i.useRef(null),T=i.useCallback(()=>{w||_||A(!0)},[w,_]),D=i.useCallback(t=>{var e;_||(null===(e=C.current)||void 0===e?void 0:e.contains(t.relatedTarget))||A(!1)},[_]);if(!n||0===n.length)return l?t("span",{id:l,tabIndex:-1,style:xn}):null;if(!M)return t("div",{id:l,tabIndex:-1,onFocus:T,style:xn,role:"region","aria-label":P,children:e("button",{type:"button",onClick:()=>A(!0),children:["View data summary (",n.length," nodes, ",o.length," edges)"]})});const E=Array.isArray(n)?n:[],L=Array.isArray(o)?o:[],O=new Map,$=new Map,N=new Map,I=new Map;for(const t of L){if(!t||"object"!=typeof t)continue;const e=null!==(c=t.datum)&&void 0!==c?c:t,n="object"==typeof e.source?null===(u=e.source)||void 0===u?void 0:u.id:e.source,i="object"==typeof e.target?null===(d=e.target)||void 0===d?void 0:d.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";$.set(t,(null!==(h=$.get(t))&&void 0!==h?h:0)+1),I.set(t,(null!==(f=I.get(t))&&void 0!==f?f:0)+o)}if(null!=i&&""!==i){const t=i+"";O.set(t,(null!==(g=O.get(t))&&void 0!==g?g:0)+1),N.set(t,(null!==(y=N.get(t))&&void 0!==y?y:0)+o)}}const W=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(v=null===(p=e.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:e.id,i=null!=n?n+"":"node-"+t,o=null!==(m=O.get(i))&&void 0!==m?m:0,r=null!==(x=$.get(i))&&void 0!==x?x:0,l=null!==(b=N.get(i))&&void 0!==b?b:0,s=null!==(k=I.get(i))&&void 0!==k?k:0;W.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:l+s,wInDeg:l,wOutDeg:s})}W.sort((t,e)=>e.degree-t.degree);let z=0,Y=0;if(W.length>0){let t=0;for(const e of W)t+=e.degree,e.degree>Y&&(Y=e.degree);z=t/W.length}const R=L.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),B=[`${W.length} nodes, ${L.length} edges.`];W.length>0&&B.push(`Mean degree: ${wn(z)}, max degree: ${Y}.`);const j=W.slice(0,5);return e("div",{ref:C,id:l,tabIndex:-1,onBlur:D,style:An,role:"region","aria-label":P,children:[t("button",{type:"button",onClick:()=>{_&&S&&S.setVisible(!1),A(!1)},"aria-label":"Close data summary",style:_n,children:"×"}),t("div",{role:"note",style:Sn,children:B.join(" ")}),e("table",{role:"table","aria-label":"Node degree summary for "+r,style:Mn,children:[e("caption",{style:Tn,children:["Top ",j.length," of ",W.length," nodes by degree"]}),t("thead",{children:e("tr",{children:[t("th",{style:Pn,children:"id"}),t("th",{style:Pn,children:"degree"}),t("th",{style:Pn,children:"in"}),t("th",{style:Pn,children:"out"}),R&&t("th",{style:Pn,children:"w. degree"}),R&&t("th",{style:Pn,children:"w. in"}),R&&t("th",{style:Pn,children:"w. out"})]})}),t("tbody",{children:j.map((n,i)=>e("tr",{children:[t("td",{style:Cn,children:n.id}),t("td",{style:Cn,children:n.degree}),t("td",{style:Cn,children:n.inDeg}),t("td",{style:Cn,children:n.outDeg}),R&&t("td",{style:Cn,children:wn(n.wDegree)}),R&&t("td",{style:Cn,children:wn(n.wInDeg)}),R&&t("td",{style:Cn,children:wn(n.wOutDeg)})]},i))})]})]})}function Ln({summary:e}){return e?t("div",{role:"note",style:xn,children:e}):null}function On({tableId:e}){return t("a",{href:"#"+e,style:xn,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,xn)},children:"Skip to data table"})}function $n({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:xn,children:n})}const Nn="var(--semiotic-focus, #005fcc)";function In({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:l,height:s}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=l&&null!=s){const e=Math.max(l,4),n=Math.max(s,4);u=t("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Nn,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Nn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Nn,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Wn({x:e,y:n,containerWidth:o,containerHeight:r,margin:l,children:s,className:a="stream-frame-tooltip",zIndex:c=1}){const u=i.useRef(null),[d,h]=i.useState(null);i.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,a,o,r]);let f;return f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,t("div",{ref:u,className:a,style:{position:"absolute",left:l.left+e,top:l.top+n,transform:f,pointerEvents:"none",zIndex:c,width:"max-content"},children:s})}const zn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Yn=new WeakMap;let Rn=0,Bn=!1,jn=null,Fn=null,Hn=null;function Xn(t,e){var n,i;if(!e)return e;const o=zn.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(Bn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Bn=!0;const t=()=>{Rn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(jn=new MutationObserver(t),jn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Fn=window.matchMedia("(prefers-color-scheme: dark)"),Hn=t,"function"==typeof Fn.addEventListener?Fn.addEventListener("change",Hn):"function"==typeof Fn.addListener&&Fn.addListener(Hn)}catch(t){}}();let l=Yn.get(r);l&&l.version===Rn||(l={version:Rn,map:new Map},Yn.set(r,l));const s=l.map.get(e);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return l.map.set(e,a),a}function Gn(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Vn(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return l(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[s,a]=function(t,e,n){const i=o(null),[r,s]=d(null);return l(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),u=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=a[0]-u.left-u.right,f=a[1]-u.top-u.bottom,g=Gn(t.foregroundGraphics,a,u),y=Gn(t.backgroundGraphics,a,u),p=$t(t=>t.theme),{transition:v,introEnabled:m}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),x="semiotic-table-"+i.useId(),b=o(0),k=o(()=>{}),w=c(()=>{b.current||(b.current=requestAnimationFrame(()=>k.current()))},[]);l(()=>()=>{b.current&&(cancelAnimationFrame(b.current),b.current=0)},[]);const A=o(()=>{}),S=o(()=>{}),_=o(null),M=o(0),P=c(()=>{M.current=0;const t=_.current;_.current=null,t&&A.current(t)},[]),C=c(t=>{_.current={clientX:t.clientX,clientY:t.clientY},0===M.current&&(M.current=requestAnimationFrame(P))},[P]),T=c(()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0),S.current()},[]);l(()=>()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0)},[]);const D=t.themeDirtyRef;return l(()=>{D&&(Rn++,D.current=!0,w())},[p,w,D]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:a,margin:u,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:v,introEnabled:m,tableId:x,rafRef:b,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:C,onPointerLeave:T}}function qn(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,l=e[1]*i,s=e[0]+"px",a=e[1]+"px";return t.style.width!==s&&(t.style.width=s),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===l||(t.width=r,t.height=l),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function Un(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Kn(t){switch(t){case"monotoneX":return rt;case"monotoneY":return ot;case"cardinal":return J;case"catmullRom":return Q;case"step":return it;case"stepBefore":return et;case"stepAfter":return nt;case"basis":return tt;case"natural":return ct;default:return null}}function Zn(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Qn(t,e,n,i,o,r){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+i*i))}const s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(l[n]+l[n+1])/2;let r=o;a>i&&(r*=i/a),a>s-i&&(r*=(s-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const Jn=(t,e,n,i)=>{var o,r;const l=e.filter(t=>"line"===t.type);for(const s of l){if(2>s.path.length)continue;const a=s._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=s.style.stroke||"#007bff",u=Xn(t,c)||c,d=s.style.strokeWidth||2,h=s.colorThresholds,f=s.rawValues;if(t.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(t.globalAlpha=s.style.opacity),t.lineWidth=d,t.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const v=null!==(o=s.style.opacity)&&void 0!==o?o:1;Qn(t,s.path,u,d,v,s.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=Kn(s.curve),y=h&&h.length>0&&f&&f.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!y){t.strokeStyle=u;const m=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let x=0;s.path.length-1>x;x++)t.globalAlpha=.5*(p[x]+p[x+1])*m,t.beginPath(),t.moveTo(s.path[x][0],s.path[x][1]),t.lineTo(s.path[x+1][0],s.path[x+1][1]),t.stroke()}else if(y){let b=null,k=null,w=null,A=null,S=!1;function _(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),S=!0}function M(){S&&(t.stroke(),S=!1)}for(let P=0;s.path.length>P;P++){const[C,T]=s.path[P],D=f[P],E=Zn(D,h,u);if(null!==b&&null!==A&&null!==w){if(E===A)t.lineTo(C,T);else{const L=[];for(const O of h){const $=O.value;(w>$||$>D)&&($>w||D>$)||w===$||D===$||L.push({t:($-w)/(D-w)})}L.sort((t,e)=>t.t-e.t);for(const N of L){const I=b+(C-b)*N.t,W=k+(T-k)*N.t,z=Zn(w+(D-w)*Math.min(N.t+1e-4,1),h,u);t.lineTo(I,W),M(),_(z,I,W)}t.lineTo(C,T)}b=C,k=T,w=D,A=E}else _(E,C,T),b=C,k=T,w=D,A=E}M()}else{if(t.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)t.strokeStyle=u;else{const Y=t.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const R of s.strokeGradient.colorStops)Y.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);t.strokeStyle=Y}if(g)at().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[B,j]=s.path[0];t.moveTo(B,j);for(let F=1;s.path.length>F;F++)t.lineTo(s.path[F][0],s.path[F][1])}t.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=s.style.fillOpacity,t.fillStyle=("string"==typeof s.style.fill?Xn(t,s.style.fill):s.style.fill)||s.style.fill,g&&!y)at().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[X,G]=s.path[0];t.moveTo(X,G);for(let V=1;s.path.length>V;V++)t.lineTo(s.path[V][0],s.path[V][1])}const H=s.path[0][0];t.lineTo(s.path[s.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ti(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function ei(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ni(t,e,n=.3){ei(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function ii(t,e,n=.6){var i,o,r,l,s;if(!ei(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(s=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==s?s:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function oi(t,e,n,i=.35){ei(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ri(t){switch(t){case"monotoneX":return rt;case"monotoneY":return ot;case"cardinal":return J;case"catmullRom":return Q;case"step":return it;case"stepBefore":return et;case"stepAfter":return nt;case"basis":return tt;case"natural":return ct;default:return null}}function li(t,e){const n=ri(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const i=Z().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const si=(t,e,n,i)=>{var o,r,l;const s=e.filter(t=>"area"===t.type);for(const e of s){if(2>e.topPath.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,i.width*n,i.height),t.clip());const s=e.style.fill||"#4e79a7",a=e._decayOpacities;if(a&&a.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=s;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(a[i]+a[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(a[n]+a[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const c=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(li(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=t.createLinearGradient(0,n,0,i);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||o.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const[n,i,r]=ti(t,"string"==typeof s?s:"#4e79a7");o.addColorStop(0,`rgba(${n},${i},${r},${e.fillGradient.topOpacity})`),o.addColorStop(1,`rgba(${n},${i},${r},${e.fillGradient.bottomOpacity})`)}t.fillStyle=o,t.globalAlpha=c}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*c,t.fillStyle=s}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(li(t,e),oi(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=c,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke;else{const n=t.createLinearGradient(e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);for(const t of e.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,t.offset)),t.color);t.strokeStyle=n}t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=ri(e.curve);if(t.beginPath(),n)at().x(t=>t[0]).y(t=>t[1]).curve(n).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1}},ai=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=("string"==typeof e.style.fill?Xn(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?Xn(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),ii(t,e),t.globalAlpha=1}}finally{t.restore()}}};function ci(t,e,n){const i=e.fillGradient;if(!i)return null;const o=e.roundedEdge;let r=e.x,l=e.y,s=e.x,a=e.y+e.h;if("bottom"===o?(l=e.y+e.h,a=e.y):"right"===o?(r=e.x+e.w,l=e.y,s=e.x,a=e.y):"left"===o&&(r=e.x,l=e.y,s=e.x+e.w,a=e.y),"colorStops"in i){const e=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;const n=t.createLinearGradient(r,l,s,a);for(const t of e)n.addColorStop(t.offset,t.color);return n}const c=t.createLinearGradient(r,l,s,a),[u,d,h]=ti(t,n);return c.addColorStop(0,`rgba(${u},${d},${h},${i.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${i.bottomOpacity})`),c}const ui=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)di(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=("string"==typeof e.style.fill?Xn(t,e.style.fill):e.style.fill)||Xn(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?ci(t,e,n):null;t.fillStyle=i||n;const o=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:r,y:l,w:s,h:a}=e;switch(e.roundedEdge){case"right":t.moveTo(r,l),t.lineTo(r+s-o,l),t.arcTo(r+s,l,r+s,l+o,o),t.lineTo(r+s,l+a-o),t.arcTo(r+s,l+a,r+s-o,l+a,o),t.lineTo(r,l+a);break;case"left":t.moveTo(r+s,l),t.lineTo(r+o,l),t.arcTo(r,l,r,l+o,o),t.lineTo(r,l+a-o),t.arcTo(r,l+a,r+o,l+a,o),t.lineTo(r+s,l+a);break;case"bottom":t.moveTo(r,l),t.lineTo(r+s,l),t.lineTo(r+s,l+a-o),t.arcTo(r+s,l+a,r+s-o,l+a,o),t.lineTo(r+o,l+a),t.arcTo(r,l+a,r,l+a-o,o);break;default:t.moveTo(r,l+a),t.lineTo(r,l+o),t.arcTo(r,l,r+o,l,o),t.lineTo(r+s-o,l),t.arcTo(r+s,l,r+s,l+o,o),t.lineTo(r+s,l+a)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=("string"==typeof e.style.fill?Xn(t,e.style.fill):e.style.fill)||Xn(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?ci(t,e,n):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ni(t,e),t.globalAlpha=1}};function di(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,l=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,l,i,o,o)}else{const r=o+i,l=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,l,o,o)}t.restore()}function hi(t,e,n,i){return Object.assign(Object.assign(Object.assign({},function(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}(t)),{data:t,x:e,y:n,time:e,value:n}),i)}function fi(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function gi(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const yi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pi(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${yi[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${yi[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const vi={line:[si,Jn,ai],area:[si,ai],stackedarea:[si,ai],scatter:[ai],bubble:[ai],heatmap:[(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Xn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ni(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):gi(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=fi(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}}],bar:[ui],swarm:[ai],waterfall:[(t,e,n,i)=>{var o,r,l;ui(t,e);const s=e.filter(t=>"rect"===t.type);if(2>s.length)return;const a=s[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=Xn(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const i=s[e],o=s[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{var o,r,l;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const s=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(l=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==l?l:1);1!==s&&(t.globalAlpha=s);const a=Xn(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=Xn(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}}],mixed:[si,Jn,ai]},mi={top:20,right:20,bottom:30,left:40},xi={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function bi(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const ki={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function wi({hover:n}){const i=t=>Number.isInteger(t)?t+"":t.toFixed(2);return e("div",{className:"semiotic-tooltip",style:ki,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:i(n.value)}),t("div",{style:{opacity:.7,fontSize:11},children:i(n.time)})]})}const Ai=h(function(n,s){var a,u,h,g,y,p,v,m,x,b,k;const{chartType:w,runtimeMode:A,data:S,chunkThreshold:_,chunkSize:M,xAccessor:P,yAccessor:C,colorAccessor:T,sizeAccessor:D,groupAccessor:E,lineDataAccessor:L,curve:O,normalize:$,binSize:N,valueAccessor:I,arrowOfTime:W="right",windowMode:z="sliding",windowSize:Y=200,timeAccessor:R,xExtent:B,yExtent:j,extentPadding:F=.1,scalePadding:H,sizeRange:X,size:G=[500,300],responsiveWidth:V,responsiveHeight:q,margin:U,className:K,background:Z,lineStyle:Q,pointStyle:J,areaStyle:tt,barStyle:et,waterfallStyle:nt,swarmStyle:it,barColors:ot,colorScheme:rt,boundsAccessor:lt,boundsStyle:st,y0Accessor:at,gradientFill:ct,lineGradient:ut,areaGroups:dt,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,showAxes:vt=!0,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:wt,yFormat:_t,tickFormatTime:Mt,tickFormatValue:Ct,hoverAnnotation:Tt,tooltipContent:Dt,customHoverBehavior:Et,customClickBehavior:Lt,enableHover:Ot,hoverRadius:$t=30,tooltipMode:Nt,annotations:It,svgAnnotationRules:Wt,showGrid:zt,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:Vt,svgPreRenderers:qt,title:Ut,categoryAccessor:Kt,brush:Zt,onBrush:Qt,decay:Jt,pulse:te,transition:ee,animate:ne,staleness:ie,heatmapAggregation:oe,heatmapXBins:le,heatmapYBins:se,showValues:ae,heatmapValueFormat:ce,marginalGraphics:ue,pointIdAccessor:fe,xScaleType:ge,yScaleType:ye,accessibleTable:pe=!0,description:ve,summary:me,linkedCrosshairName:xe,linkedCrosshairSourceId:Se}=n,_e=o(!1),Ce=Vn({sizeProp:G,responsiveWidth:V,responsiveHeight:q,userMargin:U,marginDefault:mi,animate:ne,transitionProp:ee,themeDirtyRef:_e}),{reducedMotionRef:Te,responsiveRef:De,size:Ee,currentTheme:Le,transition:Oe,introEnabled:$e,tableId:Ne,rafRef:Ie,renderFnRef:We,scheduleRender:ze}=Ce;let Ye=Ce.margin;if(ue){const t=60,e=Object.assign({},Ce.margin);ue.top&&t>e.top&&(e.top=t),ue.bottom&&t>e.bottom&&(e.bottom=t),ue.left&&t>e.left&&(e.left=t),ue.right&&t>e.right&&(e.right=t),Ye=e}const Re="function"==typeof Gt?Gt({size:Ee,margin:Ye}):Gt,Be="function"==typeof Xt?Xt({size:Ee,margin:Ye}):Xt,je=Ee[0]-Ye.left-Ye.right,Fe=Ee[1]-Ye.top-Ye.bottom,He=null!=Tt?Tt:Ot,Xe=o(null),Ge=o(null),[Ve,qe]=d(0),[Ue,Ke]=d(null),Ze=o(null),Qe=o(null),[Je,tn]=d(null),en=o(xi.primary),[nn,on]=d(!1),[rn,ln]=d([]),[sn,an]=d([]),cn="streaming"===A||["bar","swarm","waterfall"].includes(w),un=r(()=>{var t,e,n;return{chartType:w,runtimeMode:cn?"streaming":"bounded",windowSize:Y,windowMode:z,arrowOfTime:cn?W:"right",extentPadding:F,scalePadding:H,xAccessor:cn?void 0:P,yAccessor:cn?void 0:C,timeAccessor:cn?R:void 0,valueAccessor:I,colorAccessor:T,sizeAccessor:D,groupAccessor:E||(L?"_lineGroup":void 0),categoryAccessor:Kt,lineDataAccessor:L,xScaleType:ge,yScaleType:ye,xExtent:B,yExtent:j,sizeRange:X,binSize:N,normalize:$,boundsAccessor:lt,boundsStyle:st,y0Accessor:at,gradientFill:!0===ct?{topOpacity:.8,bottomOpacity:.05}:!1===ct?void 0:ct,areaGroups:dt?new Set(dt):void 0,lineGradient:ut,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,lineStyle:Q,pointStyle:J,areaStyle:tt,swarmStyle:it,waterfallStyle:nt,colorScheme:rt,barColors:ot,barStyle:et,annotations:It,decay:Jt,pulse:te,transition:Oe,introAnimation:$e,staleness:ie,heatmapAggregation:oe,heatmapXBins:le,heatmapYBins:se,showValues:ae,heatmapValueFormat:ce,pointIdAccessor:fe,curve:O,themeCategorical:null===(t=null==Le?void 0:Le.colors)||void 0===t?void 0:t.categorical,themeSemantic:Pt(Le),themeSequential:null===(e=null==Le?void 0:Le.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Le?void 0:Le.colors)||void 0===n?void 0:n.diverging}},[w,Y,z,W,F,H,P,C,R,I,ge,ye,T,D,E,Kt,L,B,j,X,N,$,lt,st,at,ct,ut,dt,ht,ft,gt,yt,pt,Q,J,tt,it,nt,et,rt,ot,It,Jt,te,null==Oe?void 0:Oe.duration,null==Oe?void 0:Oe.easing,$e,ie,oe,le,se,ae,ce,cn,fe,O,Le]),hn=o(null);hn.current||(hn.current=new re(un)),l(()=>{var t;null===(t=hn.current)||void 0===t||t.updateConfig(un),_e.current=!0,ze()},[un,ze]);const fn=o(null);fn.current||(fn.current=new St(t=>{const e=hn.current;e&&e.ingest(t)&&(_e.current=!0,ze())},{chunkThreshold:_,chunkSize:M})),l(()=>{var t;null===(t=fn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:_,chunkSize:M})},[_,M]);const vn=c(t=>{var e;null===(e=fn.current)||void 0===e||e.push(t)},[]),mn=c(t=>{var e;null===(e=fn.current)||void 0===e||e.pushMany(t)},[]),xn=c(()=>{var t,e;null===(t=fn.current)||void 0===t||t.clear(),null===(e=hn.current)||void 0===e||e.clear(),_e.current=!0,ze()},[ze]);f(s,()=>({push:vn,pushMany:mn,remove:t=>{var e,n,i;null===(e=fn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=hn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(Ze.current&&o.some(t=>{var e;return t===(null===(e=Ze.current)||void 0===e?void 0:e.data)})&&(Ze.current=null,tn(null)),_e.current=!0,ze()),o},update:(t,e)=>{var n,i,o;null===(n=fn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=hn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(_e.current=!0,ze()),r},clear:xn,getData:()=>{var t,e,n;return null===(t=fn.current)||void 0===t||t.flush(),null!==(n=null===(e=hn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=hn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=hn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[vn,mn,xn,ze]),l(()=>{var t,e;if(S){if(L&&S.length>0&&"object"==typeof S[0]&&null!==S[0]){const e="string"==typeof L?L:"coordinates";if(Array.isArray(S[0][e])){const n=[];for(const t of S){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=fn.current)||void 0===t||t.setBoundedData(n))}}null===(e=fn.current)||void 0===e||e.setBoundedData(S)}},[S,L]);const{hoverHandlerRef:kn,hoverLeaveRef:wn,onPointerMove:An,onPointerLeave:Sn}=Ce;kn.current=t=>{if(!He)return;const e=Xe.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ye.left,o=t.clientY-n.top-Ye.top;if(0>i||i>je||0>o||o>Fe)return void(Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&(Et(null),_e.current=!0),ze()));const r=hn.current;if(!r||0===r.scene.length)return;const l=de(r.scene,i,o,$t,r.quadtree,r.maxPointRadius);if(!l)return void(Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&Et(null),ze()));const s=hi(l.datum||{},l.x,l.y);if("multi"===Nt&&r.scene.length>0&&r.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=he(t.path,e,n);if(null===r)continue;const l=be(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=he(t.topPath,e,n);if(null===r)continue;const l=be(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:r,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(r.scene,l.x,$t),e=r.scales.y.invert,n=r.scales.x.invert;if(t.length>0){const i=n?n(l.x):l.x;s.xValue=i,s.xPx=l.x;const o=en.current;s.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||o,datum:t.datum}))}}Ze.current=s,Qe.current=l.node,tn(s),Et&&(Et(s),_e.current=!0),ze()},wn.current=()=>{Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&(Et(null),_e.current=!0),ze())};const _n=o(()=>{});_n.current=t=>{if(!Lt)return;const e=Xe.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ye.left,o=t.clientY-n.top-Ye.top;if(0>i||i>je||0>o||o>Fe)return void Lt(null);const r=hn.current;if(!r||0===r.scene.length)return void Lt(null);const l=de(r.scene,i,o,$t,r.quadtree,r.maxPointRadius);Lt(l?hi(l.datum||{},l.x,l.y):null)};const Mn=c(t=>_n.current(t),[]),Pn=o(-1),Cn=o(null),Tn=o(null),En=c(t=>{const e=hn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Tn.current&&Tn.current.version===n)i=Tn.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=ke(t),Tn.current={version:n,graph:i}}const o=Pn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Pn.current=0;const e=i.flat[0];Cn.current={shape:e.shape,w:e.w,h:e.h};const n=Me(e);return Ze.current=n,tn(n),Et&&Et(n),void ze()}const r=we(i,o),l=Ae(t.key,r,i);if(null===l)return;if(t.preventDefault(),0>l)return Pn.current=-1,Cn.current=null,Ze.current=null,Qe.current=null,tn(null),Et&&Et(null),void ze();Pn.current=l;const s=i.flat[l];Cn.current={shape:s.shape,w:s.w,h:s.h};const a=Me(s);Ze.current=a,tn(a),Et&&Et(a),ze()},[Et,ze]),Nn=c(t=>{Pn.current=-1,Cn.current=null,An(t)},[An]);We.current=()=>{var t,e;Ie.current=0;const n=Xe.current,i=Ge.current;if(!n||!i)return;const o=hn.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Te.current?r+1e6:r),s=!Te.current&&l,a=_e.current||l;a&&!s&&o.computeScene({width:je,height:Fe});const c=Un(),u=function(t){if(!t)return xi;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),l=i||e.getPropertyValue("--text-secondary").trim(),s=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return l||s||n||r?{axisStroke:a||xi.axisStroke,tickText:l||xi.tickText,crosshair:l?bi(l,"66"):xi.crosshair,hoverFill:c?bi(c,"4D"):xi.hoverFill,hoverStroke:l?bi(l,"99"):xi.hoverStroke,pointRing:c||xi.pointRing,primary:r||xi.primary}:xi}(n);en.current=u.primary;const d=null!==(t=null==ie?void 0:ie.threshold)&&void 0!==t?t:5e3,h=ie&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=qn(n,Ee,Ye,c);if(t){if(t.clearRect(-Ye.left,-Ye.top,Ee[0],Ee[1]),h&&(t.globalAlpha=null!==(e=null==ie?void 0:ie.dimOpacity)&&void 0!==e?e:.5),"transparent"!==Z&&!Xt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=Z||(e&&"transparent"!==e?e:null);i&&(t.fillStyle=i,t.fillRect(-Ye.left,-Ye.top,Ee[0],Ee[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,je,Fe),t.clip()),Vt&&o.scales)for(const e of Vt)t.save(),e(t,o.scene,o.scales,{width:je,height:Fe}),t.restore();const i=vi[w];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:je,height:Fe});t.restore(),h&&(t.globalAlpha=1)}}{const t=qn(i,Ee,Ye,c);if(t&&(t.clearRect(-Ye.left,-Ye.top,Ee[0],Ee[1]),He&&Ze.current&&o.scales&&function(t,e,n,i,o,r,l){var s;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(s=e.xPx)&&void 0!==s?s:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||l.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=l.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||l.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||l.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,Ze.current,je,Fe,"object"==typeof He?He:{},Qe.current,u),Qe.current&&Array.isArray(Tt))){const e=Tt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const l=n.group;if(void 0!==l)for(const n of e){if("line"!==n.type)continue;if(n.group!==l)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,Qe.current,e,u)}}a&&n&&n.setAttribute("aria-label",bn(o.scene,w+" chart"));const f=_e.current;if(_e.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Ue||t(Ue.x.domain()[0])!==t(o.scales.x.domain()[0])||t(Ue.x.domain()[1])!==t(o.scales.x.domain()[1])||t(Ue.y.domain()[0])!==t(o.scales.y.domain()[0])||t(Ue.y.domain()[1])!==t(o.scales.y.domain()[1])||Ue.x.range()[0]!==o.scales.x.range()[0]||Ue.x.range()[1]!==o.scales.x.range()[1]||Ue.y.range()[0]!==o.scales.y.range()[0]||Ue.y.range()[1]!==o.scales.y.range()[1])&&Ke(o.scales),ue){const t=o.getData(),e="function"==typeof P?P:t=>t[P||"x"],n="function"==typeof C?C:t=>t[C||"y"];ln(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),an(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&It&&It.length>0&&qe(t=>t+1),(null==ie?void 0:ie.showBadge)&&on(!!h),(s||null!=o.activeTransition||o.hasActivePulses)&&(Ie.current=requestAnimationFrame(()=>We.current()))},l(()=>(ze(),()=>{var t;null===(t=fn.current)||void 0===t||t.clear()}),[ze]),l(()=>{_e.current=!0,ze()},[w,je,Fe,vt,Z,Q,Vt,ze]),Pe(ie,hn,_e,ze,nn,on);const zn=r(()=>{if(wt||Mt)return;const t=hn.current;return(null==t?void 0:t.xIsDate)&&Ue?pi(Ue.x.domain()):void 0},[wt,Mt,Ue]),Yn=wt||Mt||zn,Rn=He&&Je?Dt?Dt(Je):t(wi,{hover:Je}):null,Bn=Rn?t(Wn,{x:Je.x,y:Je.y,containerWidth:je,containerHeight:Fe,margin:Ye,className:"stream-frame-tooltip",children:Rn}):null,jn=Cn.current,Fn=t(In,{active:Pn.current>=0,hoverPoint:Je,margin:Ye,size:Ee,shape:null==jn?void 0:jn.shape,width:null==jn?void 0:jn.w,height:null==jn?void 0:jn.h}),Hn=(t,e,n,i)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:{key:void 0,fn:null},Xn=Hn(P,R,"__semiotic_resolvedX","__semiotic_resolvedTime"),Gn=Hn(C,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),Kn=Xn.key,Zn=Gn.key,Qn=It&&It.length>0,Jn=t=>{if(!t||!Qn||!Xn.fn&&!Gn.fn)return t;let e=!1;const n=t.map(t=>{const n=Xn.fn&&Xn.key&&!(Xn.key in t),i=Gn.fn&&Gn.key&&!(Gn.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[Xn.key]=Xn.fn(t)),i&&(o[Gn.key]=Gn.fn(t)),o});return e?n:t};if(pn){const n=hn.current;n&&S&&(n.ingest({inserts:S,bounded:!0}),n.computeScene({width:je,height:Fe}));const o=null!==(a=null==n?void 0:n.scene)&&void 0!==a?a:[],r=null!==(u=null==n?void 0:n.scales)&&void 0!==u?u:null,l=Yn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return pi(r.x.domain())})();return e("div",{className:"stream-xy-frame"+(K?" "+K:""),role:"img","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:Ee[0],height:Ee[1]},children:[t(Ln,{summary:me}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${Ye.left},${Ye.top})`,children:Be}),e("g",{transform:`translate(${Ye.left},${Ye.top})`,children:[Z&&t("rect",{x:0,y:0,width:je,height:Fe,fill:Z}),qt&&r&&qt.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:je,height:Fe})},"svgpre-"+n)),o.map((n,i)=>function(n,i){var o,r,l;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const e=n;if(0===e.topPath.length)return null;const l=e.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...e.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:`M${l}L${s}Z`,fill:yn(e.style.fill),fillOpacity:null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.7,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:yn(e.style.fill),opacity:null!==(l=e.style.opacity)&&void 0!==l?l:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:yn(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,l,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*r+.587*l+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),l=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:l,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}(n,i)).filter(Boolean)]})]}),t(gn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:r,showAxes:vt,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:l,yFormat:_t||Ct,showGrid:zt,title:Ut,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,foregroundGraphics:Re,marginalGraphics:ue,xValues:[],yValues:[],annotations:It,svgAnnotationRules:Wt,annotationFrame:0,xAccessor:Kn,yAccessor:Zn,annotationData:Jn(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,linkedCrosshairName:xe,linkedCrosshairSourceId:Se})]})}return e("div",{ref:De,className:"stream-xy-frame"+(K?" "+K:""),role:"group","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),tabIndex:0,style:{position:"relative",width:V?"100%":Ee[0],height:q?"100%":Ee[1],overflow:"visible"},onKeyDown:En,children:[pe&&t(On,{tableId:Ne}),pe&&t(Dn,{scene:null!==(g=null===(h=hn.current)||void 0===h?void 0:h.scene)&&void 0!==g?g:[],chartType:w+" chart",tableId:Ne,chartTitle:"string"==typeof Ut?Ut:void 0}),t(Ln,{summary:me}),e("div",{role:"img","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:He?Nn:void 0,onMouseLeave:He?Sn:void 0,onClick:Lt?Mn:void 0,children:[Be&&t("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:t("g",{transform:`translate(${Ye.left},${Ye.top})`,children:Be})}),t(dn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:Ue,showAxes:vt,axes:mt,showGrid:zt,xFormat:Yn,yFormat:_t||Ct}),t("canvas",{ref:Xe,"aria-label":bn(null!==(p=null===(y=hn.current)||void 0===y?void 0:y.scene)&&void 0!==p?p:[],w+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:Ge,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t($n,{hoverPoint:Je}),t(gn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:Ue,showAxes:vt,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:Yn,yFormat:_t||Ct,showGrid:zt,title:Ut,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,foregroundGraphics:Re,marginalGraphics:ue,xValues:rn,yValues:sn,annotations:It,svgAnnotationRules:Wt,annotationFrame:Ve,xAccessor:Kn,yAccessor:Zn,annotationData:Jn(null===(v=hn.current)||void 0===v?void 0:v.getData()),pointNodes:null===(m=hn.current)||void 0===m?void 0:m.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0,linkedCrosshairName:xe,linkedCrosshairSourceId:Se}),(Zt||Qt)&&t(At,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,dimension:null!==(x=null==Zt?void 0:Zt.dimension)&&void 0!==x?x:"xy",scales:Ue,onBrush:null!=Qt?Qt:()=>{},binSize:N,snap:null==Zt?void 0:Zt.snap,binBoundaries:null!==(b=null==Zt?void 0:Zt.binBoundaries)&&void 0!==b?b:"bar"===w?null===(k=hn.current)||void 0===k?void 0:k.getBinBoundaries():void 0,snapDuring:null==Zt?void 0:Zt.snapDuring,streaming:"streaming"===A}),(null==ie?void 0:ie.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ie.badgePosition?{top:4,left:4}:"bottom-left"===ie.badgePosition?{bottom:4,left:4}:"bottom-right"===ie.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:nn?"#dc3545":"#28a745",color:"white"}),children:nn?"STALE":"LIVE"}),Fn,Bn]})]})});Ai.displayName="StreamXYFrame";const Si={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},_i={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Mi{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const l=this.particles[r];if(!l.active)continue;const s=n[l.edgeIndex];if(!s||!s.bezier){l.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[l.edgeIndex])&&void 0!==o?o:1;l.t+=t*e*a*(s.bezier.circular?.3:1),1>l.t?Pi(s.bezier,l.t,l.offset,l):(l.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function Pi(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,l=e*r,s=Math.min(Math.floor(l),r-1),a=l-s,[c,u,d,h]=t[s];Ci(c,u,d,h,a,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const t=f/y;o.x+=-g/y*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,l,s]=t.points;Ci(o,r,l,s,e,i);const a=s.x-o.x,c=s.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function Ci(t,e,n,i,o,r){const l=1-o,s=l*l,a=s*l,c=o*o,u=c*o;r.x=a*t.x+3*s*o*e.x+3*l*c*n.x+u*i.x,r.y=a*t.y+3*s*o*e.y+3*l*c*n.y+u*i.y}function Ti(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Di(t,e){var n,i=[],o=[],r=[],l={},s=[];function a(t){r[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;s[t].length>e;e++)(i=s[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;s[t].length>e;e++){var h=l[i=s[t][e]];h||(l[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),l=Array(e),s=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,l[a]=-1,s[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,a.push(y),c.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>l[y]||s[e].push(l[y])}r[e]=g}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(g=a.length-1;g>=0;--g){var x=a[g];if(o[x]=!1,p.push(x),v.push(s[x]),m+=s[x].length,l[x]=d.length,x===e){a.length=g;break}}d.push(p);var b=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)b[--m]=v[g][k];h.push(b)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var g=h[a];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,l=0;o.length>l;l++)for(var s=0;o[l].length>s;s++)r>o[l][s]&&(r=o[l][s],n=l);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];r[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return i}function Ei(t){return t.y0-t.y1>0?"up":"down"}function Li(t,e){return e(t.source)==e(t.target)}function Oi(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function $i(t){return t.target.x0-t.source.x1}function Ni(t,e){var n=Wi(t),i=$i(e)/Math.tan(n);return"up"==Ei(t)?t.y1-i:t.y1+i}function Ii(t,e){var n=Wi(t),i=$i(e)/Math.tan(n);return"up"==Ei(t)?t.y1+i:t.y1-i}function Wi(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function zi(t,e){return e(t)}function Yi(t){return Bi(t.source)}function Ri(t){return Bi(t.target)}function Bi(t){return(t.y0+t.y1)/2}function ji(t){return t.virtual?0:t.value}function Fi(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Li(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Li(t,e)?i+1:i}),n+i}function Hi(t){return t.target.depth}function Xi(t,e){return t.sourceLinks.length?t.depth:e-1}function Gi(t,e){return t.y0-e.y0}function Vi(t,e){return e.y0-t.y0}function qi(t,e){return t.y1-e.y1}function Ui(t,e){return e.y1-t.y1}function Ki(t,e){return Qi(t.source,e.source)||t.index-e.index}function Zi(t,e){return Qi(t.target,e.target)||t.index-e.index}function Qi(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ji(t,e){return to(t)==to(e)?"bottom"==t.circularLinkType?Vi(t,e):Gi(t,e):to(e)-to(t)}function to(t){return t.target.column-t.source.column}function eo(t,e){return no(t)==no(e)}function no(t){return t.y0-t.y1>0?"up":"down"}function io(t,e,n,i,o){let r=t;var l=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=W(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var a=r.links.filter(function(t){return t.circular});return a.sort(function(t,e){return e.value-t.value}),a.forEach(function(t,e){t._circularStub=e>=4}),oo(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),oo(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Li(t,e)&&Oi(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==l&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?Vi:Gi);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=r.links.filter(function(t){return t.target.column==l&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?Ui:qi),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function oo(t,e,n){t.sort(Ji);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Li(t,e)&&Oi(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var l=0;i.length>l;l++){var s=i[l];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ro(t,s)){var a=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ro(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function lo(t){return function(){return t}}function so(t){return t.index}function ao(t){return t.nodes}function co(t){return t.links}function uo(t,e,n){var i=z(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var l=o.length;if(e)o.sort(e);else if(r>0){var s=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Bi(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Bi(t.target)*e,i+=e}}),i>0?o/i:NaN);s.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=s.get(t),i=s.get(e),o=n.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Fi(e,n)-Fi(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Fi(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function ho(t,e,n,i,o,r){var l=z(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var s=1,a=r;a>0;--a)c(s*=.99,n),u();function c(e,n){var i=l.length;l.forEach(function(o){var r=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Fi(o,n)>0){var a=B(o.sourceLinks,Ri),c=B(o.targetLinks,Yi),u=a&&c?(a+c)/2:a||c;if(u){var d=(u-Bi(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==i-1&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.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=B(o.sourceLinks,Ri),f=B(o.targetLinks,Yi),g=((h&&f?(h+f)/2:h||f)-Bi(o))*e;o.y0+=g,o.y1+=g}})})}function u(){l.forEach(function(n){var r,l,s,a=t.y0,c=n.length;for(n.sort(e||Qi),s=0;c>s;++s)(l=a-(r=n[s]).y0)>0&&(r.y0+=l,r.y1+=l),a=r.y1+i;if((l=a-i-t.y1)>0)for(a=r.y0-=l,r.y1-=l,s=c-2;s>=0;--s)(l=(r=n[s]).y1+o-a)>0&&(r.y0-=l,r.y1-=l),a=r.y0})}}function fo(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Zi),t.targetLinks.sort(Ki)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function go(){var t=0,e=0,n=1,i=1,o=24,r=8,l=null,s=so,a=Xi,c=void 0,u=32,d=2,h=ao,f=co;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return j(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=Ti(n,i)),"object"!=typeof o&&(o=t.target=Ti(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,s),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],l=r.source.index,s=r.target.index;i[l]||(i[l]=[]),i[s]||(i[s]=[]),-1===i[l].indexOf(s)&&i[l].push(s)}var a=Di(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){zi(t,e)!=zi(o.source,e)&&zi(t,e)!=zi(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Li(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(R(t.sourceLinks,ji),R(t.targetLinks,ji)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==s?l:l+1,s=e(t)==s?s:e(t),t.column=l})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,a);var f=r;if(null!==l){var g=z(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=Y(g,function(t){return t.length});y>1&&(f=Math.max(1,(i-e)*l/(y-1)))}(function(t,e,n){var i=z(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=W(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/R(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=Y(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,o),uo(h,c,s),ho(h,c,s,f,f,u),fo(h),io(h,s,d,10,8),uo(h,c,s),ho(h,c,s,f,f,u),fo(h),io(h,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return zi(n.source,e)==zi(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!eo(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Ni(e,t);return t.y1-n}if(e.target.column>t.target.column)return Ni(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,l=0;o>r;r++)l+=i[r].width;e.y0=t.y1-l-e.width/2}})})}(h,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return zi(n.target,e)==zi(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!eo(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Ii(e,t);return t.y0-n}if(e.source.column>t.source.column)return Ii(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,l=0;o>r;r++)l+=i[r].width;e.y1=t.y1-l-e.width/2}})})}(h,s),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=W(e,function(t){return t.y0}),l=Y(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-r);function a(e){return(e-r)/(l-r)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1)}),n.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=a(t.y0)-t.y0;t.y0=a(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),io(h,s,d,10,8)}(g),g}return g.update=function(t){return fo(t),io(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:lo(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:lo(t),g):f},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:lo(t),g):s},g.nodeAlign=function(t){return arguments.length?(a="function"==typeof t?t:lo(t),g):a},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}const yo=t=>{let e,n,i,o,r,l,s,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,l=t.target.x0,s=ht(r,l),a=s(.5),c=s(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${l}L${i},${l}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,s=ht(e,n),i=s(.5),o=s(.5),r=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${l} ${n},${l}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function po(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,r=o.targetX,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+s},${i-n}L${e+s},${i+n}L${e},${i+n}ZM${r},${l-n}L${r-a},${l-n}L${r-a},${l+n}L${r},${l+n}Z`}const r=o.sourceX,l=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${l-h*n}L${c},${l-h*n}L${c+i},${l-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${s},${a-h*n}L${s},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${l+h*n}L${r},${l+h*n}Z`}const vo=new Set,mo=new WeakMap;function xo(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=mo.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,mo.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;vo.has(t)||(vo.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,i)}});return n.set(e,i),i}const bo={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Hi))-1:0},justify:Xi};function ko(t){return"string"==typeof t?t:t.id}const wo={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,l,s,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(l=n.iterations)&&void 0!==l?l:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=go().extent(m).links(v).nodes(p).nodeAlign(bo[h]||Xi).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,l=(null!==(a=null!==(s=i._circularWidth)&&void 0!==s?s:i.width)&&void 0!==a?a:0)/2;t>r.leftFullExtent-l&&(t=r.leftFullExtent-l),r.rightFullExtent+l>e&&(e=r.rightFullExtent+l),n>r.verticalFullExtent-l&&(n=r.verticalFullExtent-l),r.verticalFullExtent+l>o&&(o=r.verticalFullExtent+l)}const r=e-t,l=o-n,u=i[0],d=i[1];if(r>0&&l>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/l),i=-t*e+(u-r*e)/2,o=-n*e+(d-l*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=ko(t.source),n=ko(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=b.get(e),r=b.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,l,s,a,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:A,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[],b=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=d?d(xo(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};b.set(e.id,("string"==typeof o.fill?o.fill:null)||p.get(e.id)||"#4d430c"),v.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";o="function"==typeof g?g(t)||o:"target"===g?b.get(i.id)||p.get(i.id)||o:b.get(e.id)||p.get(e.id)||o;const u=h?h(xo(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=u.fill||o;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?po(t):yo(t),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};m.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let l,s,a;"down"===u?(l=n.y0+(n.y1-n.y0)/2,s=n.x1+14,a="start"):(i[0]/2>n.x0+t/2?(l=n.x0-6,a="end"):(l=n.x1+6,a="start"),s=n.y0+o/2),x.push({x:l,y:s,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:x}}},Ao={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,s=i[0]/2,a=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=So(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=_o(t.id),r=o%360*(Math.PI/180),l=10+o%20;t.x=e/i.length+l*Math.cos(r),t.y=n/i.length+l*Math.sin(r)}else{const e=_o(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=s+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=s+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,y=Mo(n.nodeSize,n.nodeSizeRange,t),p=t=>y(t);if(g>0){const n=ft().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*l:l)}).id(t=>t.id),i=gt().force("charge",yt().strength(t=>-25*p(t))).force("center",pt(s,a).strength(.8)).force("x",vt(s).strength(.15)).force("y",mt(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",n),i.force("link").links(t)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,l,s,a,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Mo(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:A,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],v=[],m=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xo(e,"nodeSize")),i=d?d(xo(e,"nodeStyle")):{},s={fill:i.fill||y.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:2,opacity:i.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:s,datum:e,id:e.id,label:e.id})}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),i="object"==typeof t.target?t.target:x.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(xo(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};v.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=f(xo(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}};function So(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id;let l=null;if(e===t?l=r:r===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function _o(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Mo(t,e,n){var i,o;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],l=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>r[0];const s=null!==(i=W(l))&&void 0!==i?i:0,a=null!==(o=Y(l))&&void 0!==o?o:1;if(s===a)return()=>(r[0]+r[1])/2;const c=x().domain([s,a]).range(r).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?r[0]:c(i)}}const Po=A,Co={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:l}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);y[n][i]=o}const p=bt().padAngle(o);l&&p.sortGroups(l);const v=p(y),m=v.groups,x=st().innerRadius(a).outerRadius(s);for(const e of m){const n=t[e.index],i=x.centroid(e);n.x=i[0]+c,n.y=i[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),i=b.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of v){const n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,i){var o,r,l,s;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,f=i[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Po,m=new Map;t.forEach((t,e)=>{m.set(t.id,v[e%v.length])});const x=xt().radius(d),b=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=g?g(xo(n,"nodeStyle")).fill||m.get(n.id)||v[e%v.length]:m.get(n.id)||v[e%v.length];const l=g?g(xo(n,"nodeStyle")):{},s={fill:r,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};b.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const o=To(i,h,f);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";if(y)a=y(xo(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===p&&n?a=m.get(n.id)||a:e&&(a=m.get(e.id)||a)}const u=y?y(xo(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=u+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,l=r-Math.PI/2;w.push({x:h+Math.cos(l)*i,y:f+Math.sin(l)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:b,sceneEdges:k,labels:w}}};function To(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const Do=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Eo(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}function Lo(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Oo(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function $o(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Do}function No(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Io(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Wo={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const l=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>{var e;return null!==(e=t[a])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},u=H(r,s);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,h]=i;switch(l){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=K();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=U();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const l=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(r=e.paddingTop)&&void 0!==r?r:0,a=V().size([n,i]).tile(q).padding(l);s>0&&a.paddingTop(s),a(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;G().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;X().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:Lo(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===l||"cluster"===l?zo(r,i,n):"treemap"===l||"partition"===l?Yo(r,i):"circlepack"===l&&Ro(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var l,s,a,c,u,d,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,x=i[0]/2,b=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=x,i+=b);const r=o(xo(e,"nodeStyle"));let a=r.fill||No(n);if(n.colorByDepth&&void 0!==e.depth){const t=$o(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.surface)||"#fff",strokeWidth:null!==(s=r.strokeWidth)&&void 0!==s?s:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,l=e.y,s=i.x,a=i.y;m&&(o+=x,l+=b,s+=x,a+=b);const f=Io(o,l,s,a,v),g=r(xo(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=Oo(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,l=n.x,s=n.y;if(m&&(l+=x,s+=b),m){const t=l-x,e=s-b,n=Math.sqrt(t*t+e*e);n>0?(i=l+t/n*10,o=s+e/n*10,r=0>t?"end":"start"):(i=l,o=s-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=l-k-6,r="end"):(i=l+k+6,r="start"),o=s):(i=l,o=s+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,l,s,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,l=n.y1-n.y0;if(0>=t||0>=l)continue;const s=i(xo(n,"nodeStyle"));let a=s.fill||No(e);if(e.colorByDepth&&void 0!==n.depth){const t=$o(e);a=t[n.depth%t.length]}const u={fill:a,stroke:s.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:l,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Oo(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(l=c.data)||void 0===l?void 0:l.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(xo(c,"nodeStyle")).fill||No(e);if(e.colorByDepth&&void 0!==c.depth){const t=$o(e);g=t[c.depth%t.length]}const y="string"==typeof g?Eo(g):null!==(a=null===(s=e.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,l,s,a,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(xo(n,"nodeStyle"));let c=a.fill||No(e);if(e.colorByDepth&&void 0!==n.depth){const t=$o(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=a.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Oo(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const l=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let s=i(xo(o,"nodeStyle")).fill||No(e);if(e.colorByDepth&&void 0!==o.depth){const t=$o(e);s=t[o.depth%t.length]}if(l){const n="string"==typeof s?Eo(s):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function zo(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Yo(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Ro(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Bo(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const jo={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,l;const s=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=Bo(n);g.metaMap.clear(),i.length=0,o.length=0;const y=new Map;function p(t){var e;const n=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(a(t));i.push({id:b,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,l,u,d,y){const v=s(e);if(!(null==v?void 0:v.length))return;const m=v.length;let x=0,b=0,k=0;for(;m>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let m=0;x>m;m++){const b=c[Math.min(m,c.length-1)],k=v.slice(w,w+b);if(!k.length)break;const A=(m+1)/x,S={id:n,depth:d,data:e,parentId:n},_=y?u/h(S)*A:u*A,M=ut().value(t=>{var e;return(null===(e=s(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=M(k),C=f(S);for(let e=0;k.length>e;e++){const s=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(a(c)),h=r+_*Math.sin(s),f=l+_*Math.cos(s)*C;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:_,angle:s,depth:d,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,_,d+1,!0)}w+=b}}(t,b,v,m,x,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,l,s,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Bo(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of o)for(let o=0;r>o;o++){const s=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(s),y1:e+n*Math.cos(s)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xo(e,"nodeSize")),i=d?d(xo(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=i.opacity)&&void 0!==s?s:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(xo(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Bo(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+s*a*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Fo={sankey:wo,force:Ao,chord:Co,tree:Wo,cluster:Wo,treemap:Wo,circlepack:Wo,partition:Wo,orbit:jo};function Ho(t){return Fo[t]}class Xo{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},Si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new Mi(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},Si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new Mi(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:l="value"}=this.config,s="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=s(e)+"";this.nodes.set(t,Object.assign(Object.assign({},Go(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Go(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Go(o)),{data:n}));const l=`${i}\0${o}\0${t}`;this.edges.set(l,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,Go(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,Go(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,r=!0);const s=this.edgeKey(e,n),a=this.edges.get(s);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,l,s,a;const c=Ho(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const s of u)if(void 0!==s._prevX0){const a=(null!==(e=s._prevX1)&&void 0!==e?e:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(i=s._prevY1)&&void 0!==i?i:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);t.set(s.id,{x:(null!==(r=s._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(l=s._prevY0)&&void 0!==l?l:0)+c/2})}else 0===s.x&&0===s.y||t.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),g=null!==(a=null===(s=this.config.transition)||void 0===s?void 0:s.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0;const y=new Set(this.nodes.keys()),p=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 y)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)y.has(t)||this.removedNodes.add(t);for(const t of p)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)p.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=y,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(t){const e=Ho(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:l}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=l}get isAnimating(){const t=Ho(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Ho(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(i,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=Vt(t,this.transition),n=Gt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=qt(t._prevX0,t._targetX0,n),t.x1=qt(t._prevX1,t._targetX1,n),t.y0=qt(t._prevY0,t._targetY0,n),t.y1=qt(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=qt(t._prevY0,t._targetY0,n),t.y1=qt(t._prevY1,t._targetY1,n),t.sankeyWidth=qt(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,l=ht(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,l=ht(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,l=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+l/3},{x:e.x+2*r/3,y:e.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const l=this.config.pulse;if(!l)return;const s=null!==(e=l.duration)&&void 0!==e?e:500,a=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=l.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;s>o&&(e._pulseIntensity=1-o/s,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!l)continue;const c=this.edgeTimestamps.get(`${i}\0${l}`);if(!c)continue;const u=t-c;s>u&&(e._pulseIntensity=1-u/s,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const o=this._decaySortedNodes,r=new Map;for(let t=0;o.length>t;t++)r.set(o[t][0],t);for(const o of this.sceneNodes){const l=o.id;if(!l)continue;const s=r.get(l);if(void 0===s)continue;const a=Ht(n,s,i),c=null!==(e=null===(t=o.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const a=i.metric(s);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,l=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){l.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return l.length>0&&this.layoutVersion++,l}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Go(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Vo(t,e,n,i,o=30){let r=null,l=o,s=1/0;for(const e of t){const t=qo(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;s>n&&(r=t,s=n)}else l>t.distance&&(r=t,l=t.distance)}if(r)return r;for(const t of e){const e=Jo(t,n,i);e&&l>e.distance&&(r=e,l=e.distance)}return r}function qo(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,l=Math.sqrt(o*o+r*r);return l>se(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,i);case"rect":return function(t,e,n){const i=le(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const l=ue(Math.atan2(o,i)),s=ue(t.startAngle),a=ue(t.endAngle);if(s>a?l>=s||a>=l:l>=s&&a>=l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let Uo=null,Ko=null;function Zo(){return Ko||(Uo=document.createElement("canvas"),Uo.width=1,Uo.height=1,Ko=Uo.getContext("2d")),Ko}function Qo(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function Jo(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Qo(t),l=Zo();if(!r||!l)return null;try{if(l.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,l="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&l?(r.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const s=l.lineWidth;l.lineWidth=10;const a=l.isPointInStroke(r,e,n);if(l.lineWidth=s,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let l=((e-t.x1)*i+(n-t.y1)*o)/r;l=Math.max(0,Math.min(1,l));const s=t.x1+l*i,a=t.y1+l*o,c=Math.sqrt(Math.pow(e-s,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:s,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Qo(t),o=Zo();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(i,e,n);if(o.lineWidth=r,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function tr(o){const{width:r,height:l,totalWidth:s,totalHeight:a,margin:c,labels:u,title:d,legend:h,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p,legendPosition:v="right",foregroundGraphics:m,sceneNodes:x,annotations:b,svgAnnotationRules:k}=o;return e(n,{children:[e("svg",{role:"img",width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t("title",{children:"string"==typeof d?d:"Network Chart"}),t("desc",{children:"string"==typeof d?d+" — network data visualization":"Network data visualization"}),e("g",{transform:`translate(${c.left},${c.top})`,children:[u.map((e,n)=>t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+n)),b&&b.filter(t=>"widget"!==t.type).map((e,n)=>{if(k){const o=k(e,n,{width:r,height:l,sceneNodes:x});if(o)return t(i.Fragment,{children:o},"annotation-"+n)}return null}),m]}),d&&"string"==typeof d?t("text",{x:s/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:d}):d?t("foreignObject",{x:0,y:0,width:s,height:c.top,children:d}):null,We({legend:h,totalWidth:s,totalHeight:a,margin:c,legendPosition:v,title:d,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p})]}),null==b?void 0:b.filter(t=>"widget"===t.type&&t.nodeId&&x).map((e,n)=>{var i,o,r,l,s,a,u,d,h;const f=x.find(t=>{var n,i,o,r,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const g=c.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=c.top+(null!==(r=f.cy)&&void 0!==r?r:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),p=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(a=e.dy)&&void 0!==a?a:-16,m=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t("div",{style:{position:"absolute",left:g+p-m/2,top:y+v-b/2,width:m,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function er(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function nr(t,e){var n,i,o,r,l,s;if(!e.pathD)return;t.save();const a=er(e);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,s="string"==typeof e.style.fill?e.style.fill:"#999",a=Xn(t,s)||s;o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(s=e.style.opacity)&&void 0!==s?s:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function ir(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=Xn(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function or(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const l=er(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function rr(t,e){var n,i;if(!e.pathD)return;t.save();const o=er(e),r=e.style.stroke||"#999";t.strokeStyle=Xn(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}tr.displayName="NetworkSVGOverlay";const lr={top:20,right:80,bottom:20,left:80},sr={top:40,right:40,bottom:40,left:40},ar=new Set(["chord","force","circlepack","orbit"]),cr=[800,600],ur={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function dr({data:n}){var i,o,r,l,s,a;if("edge"===n.nodeOrEdge){const t=n.data;return t?e("div",{className:"semiotic-tooltip",style:ur,children:[e("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&e("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const c=n.data;if(!c)return null;const u=c.__hierarchyNode;if(u){const n=[];let s=u;for(;s;){const t=null!==(l=null!==(o=null===(i=s.data)||void 0===i?void 0:i.name)&&void 0!==o?o:null===(r=s.data)||void 0===r?void 0:r.id)&&void 0!==l?l:c.id;null!=t&&n.unshift(t+""),s=s.parent}n.length>1&&n.shift();const a=n.length-1;return e("div",{className:"semiotic-tooltip",style:ur,children:[t("div",{children:n.map((n,i)=>e("span",{children:[i>0&&t("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),i===a?t("strong",{children:n}):t("span",{style:{opacity:.7},children:n})]},i))}),null!=c.value&&c.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const d=((null===(s=c.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=c.targetLinks)||void 0===a?void 0:a.length)||0),h=(c.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(c.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return e("div",{className:"semiotic-tooltip",style:ur,children:[t("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),d>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,h!==d&&` (weighted: ${h.toLocaleString()})`]})]})}const hr=h(function(n,i){var s,a,u,h,g,y,p,v,m,x,b,k,w,A,S,_,M;const{chartType:P,nodes:C,edges:T,data:D,initialEdges:E,nodeIDAccessor:L="id",sourceAccessor:O="source",targetAccessor:$="target",valueAccessor:N="value",edgeIdAccessor:I,childrenAccessor:W,hierarchySum:z,orientation:Y="horizontal",nodeAlign:R="justify",nodePaddingRatio:B=.05,nodeWidth:j=15,iterations:F=300,forceStrength:H=.1,padAngle:X=.01,groupWidth:G=20,sortGroups:V,edgeSort:q,treeOrientation:U="vertical",edgeType:K="curve",padding:Z,paddingTop:Q,tensionConfig:J,showParticles:tt=!1,particleStyle:et,nodeStyle:nt,edgeStyle:it,colorBy:ot,colorScheme:rt="category10",edgeColorBy:lt="source",edgeOpacity:at=.5,colorByDepth:ct=!1,nodeSize:ut=8,nodeSizeRange:dt=[5,20],nodeLabel:ht,showLabels:ft=!0,labelMode:gt,size:yt=cr,responsiveWidth:pt,responsiveHeight:vt,margin:mt,className:xt,background:bt,enableHover:kt=!0,tooltipContent:wt,customHoverBehavior:At,customClickBehavior:St,onObservation:_t,chartId:Mt,onTopologyChange:Ct,annotations:Tt,svgAnnotationRules:Dt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,title:Wt,foregroundGraphics:zt,backgroundGraphics:Yt,decay:Rt,pulse:Bt,transition:Ft,animate:Ht,staleness:Xt,thresholds:Gt,accessibleTable:Vt=!0,description:qt,summary:Ut,orbitMode:Kt,orbitSize:Zt,orbitSpeed:Qt,orbitRevolution:Jt,orbitRevolutionStyle:te,orbitEccentricity:ee,orbitShowRings:ne,orbitAnimated:ie}=n,oe=ar.has(P)?sr:lr,re=o(!0),le=Vn({sizeProp:yt,responsiveWidth:pt,responsiveHeight:vt,userMargin:mt,marginDefault:oe,foregroundGraphics:zt,backgroundGraphics:Yt,animate:Ht,transitionProp:Ft,themeDirtyRef:re}),{reducedMotionRef:se,responsiveRef:ae,size:ce,margin:ue,adjustedWidth:de,adjustedHeight:he,resolvedForeground:fe,resolvedBackground:ge,transition:ye,introEnabled:pe,tableId:ve,rafRef:me,renderFnRef:xe,scheduleRender:be,currentTheme:Se}=le,Me=r(()=>Object.assign(Object.assign({},Si),J),[J]),Ce=r(()=>Object.assign(Object.assign({},_i),et),[et]),Te=r(()=>{var t;return{chartType:P,nodeIDAccessor:L,sourceAccessor:O,targetAccessor:$,valueAccessor:N,edgeIdAccessor:I,childrenAccessor:W,hierarchySum:z,orientation:Y,nodeAlign:R,nodePaddingRatio:B,nodeWidth:j,iterations:F,forceStrength:H,padAngle:X,groupWidth:G,sortGroups:V,edgeSort:q,treeOrientation:U,edgeType:K,padding:Z,paddingTop:Q,tensionConfig:Me,showParticles:tt,particleStyle:Ce,nodeStyle:nt,edgeStyle:it,nodeLabel:ht,showLabels:ft,labelMode:gt,colorBy:ot,colorScheme:rt,themeCategorical:null===(t=null==Se?void 0:Se.colors)||void 0===t?void 0:t.categorical,themeSemantic:Pt(Se),edgeColorBy:lt,edgeOpacity:at,colorByDepth:ct,nodeSize:ut,nodeSizeRange:dt,decay:Rt,pulse:Bt,transition:ye,introAnimation:pe,staleness:Xt,thresholds:Gt,orbitMode:Kt,orbitSize:Zt,orbitSpeed:Qt,orbitRevolution:Jt,orbitRevolutionStyle:te,orbitEccentricity:ee,orbitShowRings:ne,orbitAnimated:ie}},[P,L,O,$,N,W,z,Y,R,B,j,F,H,X,G,V,q,U,K,Z,Q,Me,tt,Ce,nt,it,ht,ft,gt,ot,rt,lt,at,ct,ut,dt,Rt,Bt,null==ye?void 0:ye.duration,null==ye?void 0:ye.easing,pe,Xt,Gt,Kt,Zt,Qt,Jt,te,ee,ne,ie,Se]),De=o(null),Ee=o(0),Le=o(null);Le.current||(Le.current=new Xo(Te));const[Oe,$e]=d(null),[Ne,Ie]=d(0),[We,ze]=d(0),[Ye,Re]=d(!1),Be=o(null),je=o(new Map),Fe=o(0),He=c(t=>{if("function"==typeof ot)return ot(t)+"";if("string"==typeof ot&&t.data){const e=t.data[ot];if(void 0!==e){if(!je.current.has(e+"")){const t=Array.isArray(rt)?rt:jt;je.current.set(e+"",t[Fe.current++%t.length])}return je.current.get(e+"")}}if(je.current.has(t.id))return je.current.get(t.id);const e=Array.isArray(rt)?rt:jt,n=ot?e[Fe.current++%e.length]:e[0];return je.current.set(t.id,n),n},[ot,rt]),Xe=(null===(s=null==Se?void 0:Se.colors)||void 0===s?void 0:s.border)||(null===(a=null==Se?void 0:Se.colors)||void 0===a?void 0:a.secondary)||(null===(u=null==Se?void 0:Se.colors)||void 0===u?void 0:u.primary)||"#999",Ge=c(t=>{if("function"==typeof lt)return lt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===lt&&n?He(n):e?He(e):Xe},[lt,He,Xe]),Ve=c(t=>{if(!(null==et?void 0:et.colorBy))return Ge(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Ce.colorBy&&n?He(n):e?He(e):Xe},[null==et?void 0:et.colorBy,Ce.colorBy,He,Ge,Xe]),qe="sankey"===P&&tt||!!Bt||null!==(g=null===(h=Le.current)||void 0===h?void 0:h.isAnimating)&&void 0!==g&&g;l(()=>{var t;null===(t=Le.current)||void 0===t||t.updateConfig(Te),re.current=!0,be()},[Te,be]),l(()=>{var t;const e=Le.current;if(e){e.buildScene([de,he]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill);re.current=!0,be()}},[Se,de,he,be]);const Ue=c(()=>{var t;const e=Le.current;if(!e)return;e.runLayout([de,he]),e.buildScene([de,he]),re.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill);const n=Array.isArray(rt)?rt:jt,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];je.current.has(e.id)||je.current.set(e.id,n[t%n.length])}if(Fe.current=i.length,Ie(e.layoutVersion),Ct){const{nodes:t,edges:n}=e.getLayoutData();Ct(t,n)}},[de,he,Ct,rt]),Ke=c(t=>{const e=Le.current;e&&(e.ingestEdge(t)&&Ue(),be())},[Ue,be]),Ze=c(t=>{const e=Le.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&Ue(),be()},[Ue,be]),Qe=c(()=>{var t;null===(t=Le.current)||void 0===t||t.clear(),je.current.clear(),Fe.current=0,Ie(0),$e(null),Be.current=null,re.current=!0,be()},[be]),Je=c(()=>{const t=Le.current;t&&(t.tension+=999,Ue(),be())},[Ue,be]);f(i,()=>({push:Ke,pushMany:Ze,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Le.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=Be.current)||void 0===i?void 0:i.data)?"function"==typeof L?L(Be.current.data):Be.current.data[L]:void 0;Be.current&&"node"===Be.current.nodeOrEdge&&e===t&&(Be.current=null,$e(null)),je.current.delete(t),Ue(),re.current=!0,be()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Le.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(Be.current&&"edge"===Be.current.nodeOrEdge){const n=Be.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!I||!n||("function"==typeof I?I:t=>null==t?void 0:t[I])(n)===t,i&&(Be.current=null,$e(null))}Ue(),re.current=!0,be()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Le.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(re.current=!0,be()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Le.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(Ue(),re.current=!0,be()),r},clear:Qe,getTopology:()=>{var t,e;return null!==(e=null===(t=Le.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Le.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Je,getTension:()=>{var t,e;return null!==(e=null===(t=Le.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ke,Ze,Qe,Je,Ue,be]);const tn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),en=tn?D||(Array.isArray(T)?void 0:T):void 0;l(()=>{var t;const e=Le.current;if(e)if(tn&&en)e.ingestHierarchy(en,[de,he]),e.buildScene([de,he]),re.current=!0,be();else{const n=C||[],i=Array.isArray(T)?T:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[de,he]),e.buildScene([de,he]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill+"");const o=Array.isArray(rt)?rt:jt,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];je.current.has(e.id)||je.current.set(e.id,o[t%o.length])}Fe.current=r.length,re.current=!0,be()}},[C,T,D,en,tn,de,he,Te,be,rt]),l(()=>{E&&E.length>0&&Ze(E)},[]);const nn=c(t=>{if(At&&At(t),_t){const e=Date.now();_t(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[At,_t,Mt]),on=c(t=>{if(St&&St(t),_t){const e=Date.now();_t(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[St,_t,Mt]),{hoverHandlerRef:rn,hoverLeaveRef:ln,onPointerMove:sn,onPointerLeave:an}=le;rn.current=t=>{if(!kt)return;const e=De.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ue.left,o=t.clientY-n.top-ue.top;if(0>i||i>de||0>o||o>he)return void(Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be()));const r=Le.current;if(!r)return;const l=Vo(r.sceneNodes,r.sceneEdges,i,o);if(!l)return void(Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be()));const s=hi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});Be.current=s,$e(s),nn&&(nn(s),re.current=!0),be()},ln.current=()=>{Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be())};const cn=o(()=>{});cn.current=t=>{if(!St&&!_t)return;const e=De.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ue.left,o=t.clientY-n.top-ue.top;if(0>i||i>de||0>o||o>he)return;const r=Le.current;if(!r)return;const l=Vo(r.sceneNodes,r.sceneEdges,i,o);on(l?hi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)};const un=c(t=>cn.current(t),[]),dn=o(-1),hn=o(null),fn=o(-1),gn=c(t=>{var e;const n=Le.current;if(!n)return;const i=function(t){var e,n,i,o,r,l;const s=[];for(const a of t)"circle"===a.type&&null!=a.cx?s.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(n=null===(e=a.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===a.type&&null!=a.x?s.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=null===(i=a.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"}):"arc"===a.type&&null!=a.cx&&s.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(l=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==l?l:"_default"});return s.sort((t,e)=>t.x-e.x||t.y-e.y),s}(n.sceneNodes);if(0===i.length)return;const o=ke(i),r=dn.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),dn.current=0,fn.current=-1;const e=o.flat[0];hn.current={shape:e.shape,w:e.w,h:e.h};const n=hi(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return Be.current=n,$e(n),nn&&(nn(n),re.current=!0),void be()}const l=we(o,r),s=function(t,e,n,i,o){var r,l,s;const a=n.flat[e.flatIndex];if(!a)return Ae(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(l=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const l=t.flat[r];if(l===e)continue;const s=l.x-e.x,a=l.y-e.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(s)}if(!c)continue;const u=s*s+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n;const i=t+"",o=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,r=_e(e.source),l=_e(e.target),s=null!=r,a=null!=l;s&&r+""===i&&a?o.push(l+""):a&&l+""===i&&s&&o.push(r+"")}return o}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(s=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==s?s:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=Ae(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],fn);if(null===s)return;if(t.preventDefault(),0>s)return dn.current=-1,hn.current=null,fn.current=-1,Be.current=null,$e(null),nn&&(nn(null),re.current=!0),void be();dn.current=s;const a=o.flat[s];hn.current={shape:a.shape,w:a.w,h:a.h};const c=a.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:a.x,y:a.y,time:a.x,value:a.y,nodeOrEdge:"node"});Be.current=u,$e(u),nn&&(nn(u),re.current=!0),be()},[nn,be]),vn=c(t=>{dn.current=-1,hn.current=null,sn(t)},[sn]);xe.current=()=>{var t,e,n,i,o,r,l;me.current=0;const s=De.current;if(!s)return;const a=s.getContext("2d");if(!a)return;const c=Le.current;if(!c)return;const u=performance.now(),d=Ee.current?Math.min((u-Ee.current)/1e3,.1):.016;Ee.current=u;const h=c.advanceTransition(se.current?u+1e6:u),f=!se.current&&h,g=!se.current&&c.tickAnimation([de,he],d);(h||re.current||g)&&c.buildScene([de,he]);const y=Un();if(!qn(s,ce,ue,y))return;a.clearRect(-ue.left,-ue.top,ce[0],ce[1]),bt&&(a.fillStyle=bt,a.fillRect(0,0,de,he)),Rt&&c.applyDecay(),Bt&&c.applyPulse(u),Gt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Xt?void 0:Xt.threshold)&&void 0!==t?t:5e3,v=Xt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Xt?void 0:Xt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":nr(t,n);break;case"line":ir(t,n);break;case"ribbon":or(t,n);break;case"curved":rr(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),ni(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),ii(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),tt&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const l=null!==(o=i.spawnRate)&&void 0!==o?o:_i.spawnRate,s=null!==(r=i.maxPerEdge)&&void 0!==r?r:_i.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=s)continue;const r=o.value*l*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<s;e++)t.spawn(i)}}(c.particlePool,t,d,Ce);const e=.5*(null!==(n=Ce.speedMultiplier)&&void 0!==n?n:1);let i;if(Ce.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,l;const s=null!==(r=i.radius)&&void 0!==r?r:_i.radius,a=null!==(l=i.opacity)&&void 0!==l?l:_i.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const l=e.particles[r];if(!l.active)continue;const a=n[l.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):Xn(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(l.x,l.y,s,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Ce,Ve)}}v&&(a.globalAlpha=1);const m=re.current;if(re.current=!1,m||f||g){const t=De.current;t&&t.setAttribute("aria-label",kn(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(l=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==l?l:0,"Network chart"))}(m||f||g)&&ze(t=>t+1),(qe||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(me.current=requestAnimationFrame(()=>xe.current()))},l(()=>(be(),()=>{}),[be]),l(()=>{re.current=!0,be()},[P,de,he,bt,be]),Pe(Xt,Le,re,be,Ye,Re);const mn=kt&&Oe?t(Wn,{x:Oe.x,y:Oe.y,containerWidth:de,containerHeight:he,margin:ue,className:"stream-network-tooltip",zIndex:2,children:wt?wt(Oe):t(dr,{data:Oe})}):null;if(pn){const n=Le.current;if(n){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),e=t?D||(Array.isArray(T)?void 0:T):void 0;if(t&&e)n.ingestHierarchy(e,[de,he]),n.buildScene([de,he]);else{const t=C||[],e=Array.isArray(T)?T:[];(t.length>0||e.length>0)&&(n.ingestBounded(t,e,[de,he]),n.buildScene([de,he]))}}const i=null!==(y=null==n?void 0:n.sceneNodes)&&void 0!==y?y:[],o=null!==(p=null==n?void 0:n.sceneEdges)&&void 0!==p?p:[],r=null!==(v=null==n?void 0:n.labels)&&void 0!==v?v:[];return e("div",{className:"stream-network-frame"+(xt?" "+xt:""),role:"img","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),style:{position:"relative",width:ce[0],height:ce[1]},children:[t(Ln,{summary:Ut}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:ce[0],height:ce[1],style:{position:"absolute",left:0,top:0},children:[ge&&t("g",{transform:`translate(${ue.left},${ue.top})`,children:ge}),e("g",{transform:`translate(${ue.left},${ue.top})`,children:[bt&&t("rect",{x:0,y:0,width:de,height:he,fill:bt}),o.map((e,n)=>function(e,n){switch(e.type){case"line":return t("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t("path",{d:i.pathD,fill:yn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t("path",{d:i.pathD,fill:yn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t("path",{d:i.pathD,fill:yn(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),i.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=st().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)({})||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),r.map((e,n)=>function(e,n){return t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t(tr,{width:de,height:he,totalWidth:ce[0],totalHeight:ce[1],margin:ue,labels:r,sceneNodes:i,title:Wt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,foregroundGraphics:fe,annotations:Tt,svgAnnotationRules:Dt,annotationFrame:0})]})}const xn=Le.current;return e("div",{ref:ae,className:"stream-network-frame"+(xt?" "+xt:""),role:"group","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),tabIndex:0,style:{position:"relative",width:pt?"100%":ce[0],height:vt?"100%":ce[1],overflow:"visible"},onKeyDown:gn,children:[Vt&&t(On,{tableId:ve}),Vt&&t(En,{nodes:null!==(m=null==xn?void 0:xn.sceneNodes)&&void 0!==m?m:[],edges:null!==(x=null==xn?void 0:xn.sceneEdges)&&void 0!==x?x:[],chartType:"Network chart",tableId:ve,chartTitle:"string"==typeof Wt?Wt:void 0}),t(Ln,{summary:Ut}),e("div",{role:"img","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:kt?vn:void 0,onMouseLeave:kt?an:void 0,onClick:St||_t?un:void 0,children:[ge&&t("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ce[0],height:ce[1],pointerEvents:"none",overflow:"visible"},children:t("g",{transform:`translate(${ue.left},${ue.top})`,children:ge})}),t("canvas",{ref:De,"aria-label":kn(null!==(k=null===(b=null==xn?void 0:xn.sceneNodes)||void 0===b?void 0:b.length)&&void 0!==k?k:0,null!==(A=null===(w=null==xn?void 0:xn.sceneEdges)||void 0===w?void 0:w.length)&&void 0!==A?A:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t($n,{hoverPoint:Oe}),t(tr,{width:de,height:he,totalWidth:ce[0],totalHeight:ce[1],margin:ue,labels:(null==xn?void 0:xn.labels)||[],sceneNodes:null==xn?void 0:xn.sceneNodes,title:Wt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,foregroundGraphics:fe,annotations:Tt,svgAnnotationRules:Dt,annotationFrame:We}),t(In,{active:dn.current>=0,hoverPoint:Oe,margin:ue,size:ce,shape:null===(S=hn.current)||void 0===S?void 0:S.shape,width:null===(_=hn.current)||void 0===_?void 0:_.w,height:null===(M=hn.current)||void 0===M?void 0:M.h}),mn,(null==Xt?void 0:Xt.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Xt.badgePosition?{top:4,left:4}:"bottom-left"===Xt.badgePosition?{bottom:4,left:4}:"bottom-right"===Xt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ye?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Ye?"STALE":"LIVE"})]})]})});function fr(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function gr(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}hr.displayName="StreamNetworkFrame";const[yr,pr]=_t(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=gr(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=gr(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[vr,mr]=_t(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 xr(t){const e=g(),n=t.clientId||e,{name:i}=t,o=pr(t=>t.selections.get(i)),l=pr(t=>t.setClause),s=pr(t=>t.clearClause),a=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(fr(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:c(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};l(i,{clientId:n,type:"point",fields:e})},[n,i,l]),selectInterval:c(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};l(i,{clientId:n,type:"interval",fields:e})},[n,i,l]),clear:c(()=>{s(i,n)},[s,i,n]),clientId:n}}function br(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function kr({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:s,chartId:a,onClick:u,hoverHighlight:h,colorByField:f}){const y=g(),p=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,n),v=xr({name:(null==t?void 0:t.name)||"__unused__"}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:l}=xr({name:e});return{onHover:c(t=>{if(!t)return void l();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&r(e)},[n,r,l,e]),predicate:i,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||n||[]}),x=mr(t=>t.pushObservation),b=t?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=d(null),A=f||n[0],S=r(()=>{if(!h||null==k||!A)return null;const t=k,e=A;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,k,A]),_=c(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const t=null==e?void 0:e[p.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const i=Qe.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Qe={positions:new Map(Qe.positions).set(t,{xValue:e,sourceId:n})},tn())}(p.name||"hover",Number(t),y)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&en(p.name||"hover",y),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(h&&A)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[A];w(null!=n?n+"":null)}else w(null);if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),x&&x(t)}}},[e,m,p,y,o,s,a,x,h,A]),M=c(t=>{var e,n,i,r;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[p.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const i=Qe.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Qe.positions);return e.delete(t),Qe={positions:e},tn(),!1}Qe={positions:new Map(Qe.positions).set(t,{xValue:e,sourceId:n,locked:!0})},tn()}(p.name||"hover",Number(n),y)}if(t&&u){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),u(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),x&&x(t)}}},[u,o,x,s,a,p,y]);return l(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{nn(t,y),en(t,y)}},[null==p?void 0:p.mode,null==p?void 0:p.name,y]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:_,customClickBehavior:M,crosshairSourceId:y}}const wr={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Ar(t,e,n){var i,o,r,l,s,a,c;const u=wr[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:Sr(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function Sr(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}"undefined"!=typeof process&&process;const _r={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Mr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Pr(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},_r),{width:n,height:i}),children:o||"No data available"}):null}function Cr(e,n,i){if(!e)return null;const o=Math.min(5,Math.floor(i/40)),r=Math.max(8,Math.floor(i/(3*o))),l=Math.max(6,Math.floor(i/(2.5*o))),s=Math.floor((i-(o*(r+l)-l))/2);return t("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,i)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Mr),{position:"absolute",top:s+i*(r+l),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}const Tr=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:A="#007bff",strokeWidth:S=2,strokeDasharray:_,opacity:M,background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,transition:z,linkedHover:Y,selection:R,onObservation:B,chartId:j,loading:F,emptyContent:H,emphasis:X,legendPosition:G}=e,V=a.showAxes,q=a.enableHover,U=null!=d?d:a.marginDefaults,K=null!=u?u:[a.width,a.height],Z=null!=C?C:T,Q=o(null),{customHoverBehavior:J}=kr({selection:R,linkedHover:Y,unwrapData:!0,onObservation:B,chartType:"RealtimeLineChart",chartId:j}),tt=c(t=>{D&&D(t),J(t)},[D,J]);f(n,()=>({push:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Q.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Q.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const et=Cr(F,K[0],K[1]),nt=et?null:Pr(v,K[0],K[1],H),it={stroke:A,strokeWidth:S,strokeDasharray:_};return null!=M&&(it.opacity=M),et||nt||t(Ai,{ref:Q,chartType:"line",runtimeMode:"streaming",size:K,margin:U,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:it,showAxes:V,background:P,hoverAnnotation:q,tooltipContent:Z,customHoverBehavior:tt,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,transition:z,pointIdAccessor:e.pointIdAccessor,legendPosition:G})});Tr.displayName="RealtimeLineChart";const Dr=h(function(e,n){var i,l,s,a;const u=Ar(e.mode,{width:null!==(l=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==l?l:e.width,height:null!==(a=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==a?a:e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover}),{binSize:d,size:h,margin:g,className:y,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m=200,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:A,extentPadding:S,categoryAccessor:_,colors:M,fill:P,stroke:C,strokeWidth:T,opacity:D,gap:E,background:L,tooltipContent:O,tooltip:$,onHover:N,annotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:Y,linkedHover:R,selection:B,decay:j,pulse:F,staleness:H,transition:X,onObservation:G,chartId:V,loading:q,emptyContent:U,emphasis:K,legendPosition:Z,brush:Q,onBrush:J,linkedBrush:tt}=e,et=u.showAxes,nt=u.enableHover,it=null!=g?g:u.marginDefaults,ot=null!=h?h:[u.width,u.height],rt=null!=O?O:$,lt=o(null),{customHoverBehavior:st}=kr({selection:B,linkedHover:R,unwrapData:!0,onObservation:G,chartType:"RealtimeTemporalHistogram",chartId:V}),at=c(t=>{N&&N(t),st(t)},[N,st]),ct=!0===Q?{dimension:"x",snap:"bin"}:"x"===Q?{dimension:"x"}:"object"==typeof Q?Q:void 0,ut=(dt=tt)?"string"==typeof dt?{name:dt}:dt:null;var dt;const ht=function(t){const{name:e,xField:n,yField:i}=t,{predicate:o,isActive:l,selectInterval:s,clear:a}=xr({name:e}),u=n&&i?"xyBrush":n?"xBrush":"yBrush",d=c(t=>{if(!t)return void a();const e={};"xyBrush"===u&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),i&&(e[i]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&br(t)?n&&(e[n]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&br(t)&&i&&(e[i]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&s(e)},[u,n,i,s,a]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:o,isActive:l,clear:a}}(Object.assign({name:(null==ut?void 0:ut.name)||"__unused_hist_brush__",xField:(null==ut?void 0:ut.xField)||("string"==typeof b?b:"time")},(null==ut?void 0:ut.yField)?{yField:ut.yField}:{})),ft=o(ht.brushInteraction);ft.current=ht.brushInteraction;const gt=c(t=>{if(J&&J(t),G&&G(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:V}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:V}),ut){const e=ft.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[J,G,V,ut]);f(n,()=>({push:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=lt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=lt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=lt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const yt=Cr(q,ot[0],ot[1]),pt=yt?null:Pr(x,ot[0],ot[1],U),vt={};return null!=P&&(vt.fill=P),null!=C&&(vt.stroke=C),null!=T&&(vt.strokeWidth=T),null!=D&&(vt.opacity=D),null!=E&&(vt.gap=E),yt||pt||t(Ai,{ref:lt,chartType:"bar",runtimeMode:"streaming",size:ot,margin:it,className:K?`${y||""} semiotic-emphasis-${K}`.trim():y,arrowOfTime:p,windowMode:v,windowSize:m,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:A,extentPadding:S,binSize:d,categoryAccessor:_,barColors:M,barStyle:vt,showAxes:et,background:L,hoverAnnotation:nt,tooltipContent:rt,customHoverBehavior:at,annotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:Y,decay:j,pulse:F,staleness:H,transition:X,pointIdAccessor:e.pointIdAccessor,legendPosition:Z,brush:ct||(tt?{dimension:"x"}:void 0),onBrush:ct||tt?gt:void 0})});Dr.displayName="RealtimeTemporalHistogram";const Er=Dr,Lr=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:A,colors:S,radius:_,fill:M,opacity:P,stroke:C,strokeWidth:T,background:D,tooltipContent:E,tooltip:L,onHover:O,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:Y,onObservation:R,chartId:B,loading:j,emptyContent:F,emphasis:H,legendPosition:X}=e,G=a.showAxes,V=a.enableHover,q=null!=d?d:a.marginDefaults,U=null!=u?u:[a.width,a.height],K=null!=E?E:L,Z=o(null),{customHoverBehavior:Q}=kr({selection:Y,linkedHover:z,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:B}),J=c(t=>{O&&O(t),Q(t)},[O,Q]);f(n,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=Cr(j,U[0],U[1]),et=tt?null:Pr(v,U[0],U[1],F),nt={};return null!=_&&(nt.radius=_),null!=M&&(nt.fill=M),null!=P&&(nt.opacity=P),null!=C&&(nt.stroke=C),null!=T&&(nt.strokeWidth=T),tt||et||t(Ai,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:U,margin:q,className:H?`${h||""} semiotic-emphasis-${H}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:A,barColors:S,swarmStyle:nt,showAxes:G,background:D,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:e.pointIdAccessor})});Lr.displayName="RealtimeSwarmChart";const Or=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:A,negativeColor:S,connectorStroke:_,connectorWidth:M,gap:P,stroke:C,strokeWidth:T,opacity:D,background:E,tooltipContent:L,tooltip:O,onHover:$,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,linkedHover:Y,selection:R,onObservation:B,chartId:j,loading:F,emptyContent:H,emphasis:X,legendPosition:G}=e,V=a.showAxes,q=a.enableHover,U=null!=d?d:a.marginDefaults,K=null!=u?u:[a.width,a.height],Z=null!=L?L:O,Q=o(null),{customHoverBehavior:J}=kr({selection:R,linkedHover:Y,unwrapData:!0,onObservation:B,chartType:"RealtimeWaterfallChart",chartId:j}),tt=c(t=>{$&&$(t),J(t)},[$,J]);f(n,()=>({push:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Q.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Q.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const et=Cr(F,K[0],K[1]),nt=et?null:Pr(v,K[0],K[1],H),it={};return null!=A&&(it.positiveColor=A),null!=S&&(it.negativeColor=S),null!=_&&(it.connectorStroke=_),null!=M&&(it.connectorWidth=M),null!=P&&(it.gap=P),null!=C&&(it.stroke=C),null!=T&&(it.strokeWidth=T),null!=D&&(it.opacity=D),et||nt||t(Ai,{ref:Q,chartType:"waterfall",runtimeMode:"streaming",size:K,margin:U,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:it,showAxes:V,background:E,hoverAnnotation:q,tooltipContent:Z,customHoverBehavior:tt,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,legendPosition:G,pointIdAccessor:e.pointIdAccessor})});Or.displayName="RealtimeWaterfallChart";const $r=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:A,heatmapXBins:S=20,heatmapYBins:_=20,aggregation:M="count",background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,linkedHover:z,selection:Y,onObservation:R,chartId:B,loading:j,emptyContent:F,emphasis:H,legendPosition:X}=e,G=a.showAxes,V=a.enableHover,q=null!=d?d:a.marginDefaults,U=null!=u?u:[a.width,a.height],K=null!=C?C:T,Z=o(null),{customHoverBehavior:Q}=kr({selection:Y,linkedHover:z,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:B}),J=c(t=>{D&&D(t),Q(t)},[D,Q]);f(n,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=Cr(j,U[0],U[1]),et=tt?null:Pr(v,U[0],U[1],F);return tt||et||t(Ai,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:q,className:H?`${h||""} semiotic-emphasis-${H}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:A,heatmapXBins:S,heatmapYBins:_,heatmapAggregation:M,showAxes:G,background:P,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,legendPosition:X,pointIdAccessor:e.pointIdAccessor})});$r.displayName="RealtimeHeatmap";export{It as IncrementalExtent,$r as RealtimeHeatmap,Er as RealtimeHistogram,Tr as RealtimeLineChart,Lr as RealtimeSwarmChart,Or as RealtimeWaterfallChart,Nt as RingBuffer,hr as StreamNetworkFrame,Ai as StreamXYFrame};
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useEffect as l,useContext as s,useCallback as a,useSyncExternalStore as c,createContext as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as g,useImperativeHandle as y}from"react";import{select as p}from"d3-selection";import{brushX as v,brushY as m,brush as x}from"d3-brush";import{scaleLinear as b,scaleLog as k,scaleTime as w}from"d3-scale";import{quadtree as A}from"d3-quadtree";import{curveNatural as _,curveBasis as S,curveStepAfter as M,curveStepBefore as P,curveStep as C,curveCatmullRom as E,curveCardinal as T,curveMonotoneY as D,curveMonotoneX as O,line as L,area as $,curveLinear as I,arc as N,pie as W}from"d3-shape";import{bin as z,min as R,groups as Y,max as F,sum as j,mean as B,group as H}from"d3-array";import{packEnclose as X,hierarchy as G,partition as V,pack as q,treemap as U,treemapBinary as K,cluster as Z,tree as Q}from"d3-hierarchy";import J from"regression";import{interpolateNumber as tt}from"d3-interpolate";import{forceLink as et,forceSimulation as nt,forceManyBody as it,forceCenter as ot,forceX as rt,forceY as lt}from"d3-force";import{ribbon as st,chord as at}from"d3-chord";function ct(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function ut(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function dt({width:e,height:n,totalWidth:i,totalHeight:s,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:y,streaming:b}){const k=o(null),w=o(null),A=o(d);A.current=d;const _=o(u);_.current=u;const S=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),M=o(S);M.current=S;const P=o(!1),C=o(null);return l(()=>{if(!k.current)return;const t=p(k.current).select(".brush-g"),i="x"===c?v():"y"===c?m():x();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(P.current)return;const r=_.current;if(!r)return;if(!o.selection)return C.current=null,void A.current(null);let l,s;if("x"===c){const[t,e]=o.selection;l=[r.x.invert(t),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(0)]}else if("y"===c){const[t,n]=o.selection;l=[r.x.invert(0),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;l=[r.x.invert(t),r.x.invert(n)],s=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===o.type||"brush"===o.type&&y)){const e=M.current;e&&e.length>0?l=function(t,e){return 0===e.length?t:[ct(t[0],e),ut(t[1],e)]}(l,e):h&&h>0&&(l=[Math.floor(l[0]/h)*h,Math.ceil(l[1]/h)*h]);const n=r.x(l[0]),s=r.x(l[1]);if(P.current=!0,"x"===c)t.call(i.move,[n,s]);else if("xy"===c){const e=o.selection;t.call(i.move,[[n,e[0][1]],[s,e[1][1]]])}P.current=!1}const a={x:l,y:s};C.current=a,A.current(a)}),t.call(i),w.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),w.current=null}},[e,n,c,f,h,y]),l(()=>{if(!(b&&u&&w.current&&C.current))return;if(!k.current)return;if("y"===c)return;const t=C.current,e=u.x.domain()[0],n=p(k.current).select(".brush-g");if(e>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=M.current;t&&t.length>0?i=ut(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);o=!0}const r=u.x(i),l=u.x(t.x[1]);if(P.current=!0,"x"===c)n.call(w.current.move,[r,l]);else{const e=u.y(t.y[1]),i=u.y(t.y[0]);n.call(w.current.move,[[r,e],[l,i]])}if(P.current=!1,o){const e={x:[i,t.x[1]],y:t.y};C.current=e,A.current(e)}},[u,b,c,f,h]),t("svg",{ref:k,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}const ht=Object.freeze([]);function ft(t){if(!t)return ht;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}class gt{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=ft(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=ft(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function yt(e){let n=null;const i=()=>(n||(n=u(null)),n),l=pt(e);return[function({children:n,initialState:l}){const s=o(l),a=r(()=>pt(e,s.current),[]),c=i();return t(c.Provider,{value:a,children:n})},t=>{var e;const n=i(),r=null!==(e=s(n))&&void 0!==e?e:l,u=o(t);u.current=t;const d=a(()=>u.current(r.getState()),[r]),h=a(()=>u.current(r.getState()),[r]);return c(r.subscribe,d,h)}]}function pt(t,e){const n=new EventTarget;let i=Object.assign(Object.assign({},t(function(t){i=Object.assign(Object.assign({},i),t(i)),n.dispatchEvent(new Event("update"))})),null!=e?e:{});return{getState:()=>i,subscribe:function(t){return n.addEventListener("update",t),()=>n.removeEventListener("update",t)}}}function vt(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function mt(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:xt})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const xt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],bt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},kt={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},wt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:xt,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function At(t,e){if("light"===e)return bt;if("dark"===e)return kt;if("high-contrast"===e)return wt;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?kt:bt;return mt(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return mt(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[_t,St]=yt(t=>({theme:bt,setTheme(e){t(t=>({theme:At(t.theme,e)}))}}));class Mt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,l=this.buffer[r];if(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[r]=e(l)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class Pt{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function Ct(t,e,n,i,o){const r=new Map;for(const l of t){const t=e(l),s=n(l);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=s,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+s)}}return r}function Et(t,e,n,i,o,r){const l=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&l.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}l.sort((t,e)=>t.px-e.px);const s=Array(l.length),a=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];s[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:s,rawValues:a,style:o,datum:c,group:r}}function Tt(t,e,n,i,o,r,l,s){const a=[];for(const r of t){const t=n(r),l=i(r);if(!Number.isFinite(t)||!Number.isFinite(l))continue;const c=e.x(t),u=s?s(r):o;a.push({px:c,topY:e.y(l),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:l}}function Dt(t,e,n,i){var o,r,l;const s=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;s.set(i,-t/2)}else if("wiggle"===i){t.length>0&&s.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],l=t[i];let a=0,c=0,u=0;for(const t of e){const e=n(t,l)||0;a+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(o=s.get(r))&&void 0!==o?o:0;s.set(l,d-(c>0?a/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i+=(null!==(r=s.get(o))&&void 0!==r?r:0)+t/2}const o=i/t.length;for(const e of t)s.set(e,(null!==(l=s.get(e))&&void 0!==l?l:0)-o)}}else for(const e of t)s.set(e,0);return s}function Ot(t,e,n,i,o,r,l){const s=n(t),a=i(t);if(!Number.isFinite(s)||!Number.isFinite(a))return null;const c={type:"point",x:e.x(s),y:e.y(a),r:o,style:r,datum:t};return void 0!==l&&(c.pointId=l),c}function Lt(t,e,n,i,o,r,l){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:l}}function $t(t,e,n,i,o,r,l){const s={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==l?void 0:l.showValues)&&(s.showValues=!0,s.value=l.value,l.valueFormat&&(s.valueFormat=l.valueFormat)),s}function It(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Nt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Wt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function zt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}function Rt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Yt(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Ft(t){const e=t.map(Rt),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return Yt(t,n,i)}if(t>=1){const[t,i,o]=e[n];return Yt(t,i,o)}const i=t*n,o=Math.floor(i),r=i-o,[l,s,a]=e[o],[c,u,d]=e[o+1];return Yt(Math.round(l+(c-l)*r),Math.round(s+(u-s)*r),Math.round(a+(d-a)*r))}}const jt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Bt=Ft(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Ht=Ft(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Xt=Ft(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Gt=Ft(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Vt=Ft(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),qt=Ft(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Ut=Ft(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Kt=Ft(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Zt=Ft(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Qt=Ft(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Jt=Ft(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),te=Ft(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);Ft(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Ft(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Ft(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Ft(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Ft(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const ee={category10:jt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Bt,reds:Ht,greens:Xt,oranges:Gt,purples:Vt,viridis:Ut,plasma:Kt},ne=jt,ie=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function oe(t,e,n){var i,o,r;if(1>=n)return 1;const l=null!==(i=t.minOpacity)&&void 0!==i?i:.1,s=n-1-e;switch(t.type){case"linear":return l+(1-s/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,s/e)*(1-l)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>s?1:l;default:return 1}}function re(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function le(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function se(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ae(t,e,n){return t+(e-t)*n}function ce(t,e,n){var i,o,r,l;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function ue(t,e,n){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const l=t.getBounds(n),s=t.scales.x(e);if(l&&0!==l)i.push([s,t.scales.y(r+l)]),o.push([s,t.scales.y(r-l)]);else{const e=t.scales.y(r);i.push([s,e]),o.push([s,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function de(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const l of i.data){let i=t.config.pointStyle(l);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const s=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(l)+"":void 0,c=Ot(l,t.scales,t.getX,r,s,i,a);c&&n.push(c)}}}const he={blues:Bt,reds:Ht,greens:Xt,viridis:Ut,oranges:Gt,purples:Vt,greys:qt,plasma:Kt,inferno:Zt,magma:Qt,cividis:Jt,turbo:te},fe=new Map;class ge{constructor(t){if(this.xExtent=new Pt,this.yExtent=new Pt,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new Mt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Nt(t.timeAccessor||t.xAccessor,"time"),this.getY=Nt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Nt(t.xAccessor,"x"),this.getY=Nt(t.yAccessor,"y")),this.getGroup=zt(t.groupAccessor),this.getCategory=zt(t.categoryAccessor),this.getSize=t.sizeAccessor?Nt(t.sizeAccessor,"size"):void 0,this.getColor=zt(t.colorAccessor),this.getBounds=t.boundsAccessor?Nt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?Nt(t.y0Accessor,"y0"):void 0,this.getPointId=zt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Nt(t.openAccessor,"open"):void 0,this.getHigh=Nt(t.highAccessor,"high"),this.getLow=Nt(t.lowAccessor,"low"),this.getClose=n?Nt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new Mt(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Nt(this.config.timeAccessor||this.config.xAccessor,"time"):Nt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t))))}return!0}computeScene(t){var e,n,i,o,r,l,s,a,c,u,d,h,f,g;const{config:y,buffer:p}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(p,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),m=this.xExtent.extent,x=this.yExtent.extent;let A=y.xExtent?[null!==(n=y.xExtent[0])&&void 0!==n?n:m[0],null!==(i=y.xExtent[1])&&void 0!==i?i:m[1]]:m,_=y.yExtent?[null!==(o=y.yExtent[0])&&void 0!==o?o:x[0],null!==(r=y.yExtent[1])&&void 0!==r?r:x[1]]:x;const S=y.yExtent&&null!=y.yExtent[0]&&null!=y.yExtent[1];if("stackedarea"===y.chartType&&!S&&p.size>0)if(y.normalize)_=[0,1+y.extentPadding];else{const t=`${p.size}:${this._ingestVersion}:${null!==(l=y.baseline)&&void 0!==l?l:"zero"}:${null!==(s=y.stackOrder)&&void 0!==s?s:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)_=this._stackExtentCache.yDomain;else{const e=this.groupData(v),n=new Map,i=new Set;let o=0;const r=new Map,l=new Map;for(const t of e){const e=new Map;let s=0;for(const n of t.data){const t=this.getX(n),l=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(l))continue;e.set(t,(e.get(t)||0)+l),i.add(t),s+=l;const a=(r.get(t)||0)+l;r.set(t,a),a>o&&(o=a)}n.set(t.key,e),l.set(t.key,s)}const s=null!==(a=y.stackOrder)&&void 0!==a?a:"key",f=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===s){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=l.get(e))&&void 0!==n?n:0)-(null!==(i=l.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(c=l.get(e))&&void 0!==c?c:0):(i.push(e),r+=null!==(u=l.get(e))&&void 0!==u?u:0);g=[...i.reverse(),...n]}else g="asc"===s?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=l.get(t))&&void 0!==n?n:0)-(null!==(i=l.get(e))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):"desc"===s?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=l.get(e))&&void 0!==n?n:0)-(null!==(i=l.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===y.baseline||"silhouette"===y.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=Dt(t,g,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},y.baseline);let o=1/0,l=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,i=null!==(h=r.get(n))&&void 0!==h?h:0;o>t&&(o=t),t+i>l&&(l=t+i)}Number.isFinite(o)&&Number.isFinite(l)||(o=0,l=0);const s=l-o,a=s>0?s*y.extentPadding:1;_=[o-a,l+a]}else _=[0,o+(o>0?o*y.extentPadding:1)];this._stackExtentCache={key:t,yDomain:_}}}else if("bar"===y.chartType&&y.binSize&&!S&&p.size>0){const[,t]=function(t,e,n,i,o){const r=Ct(t,e,n,i,o);if(0===r.size)return[0,0];let l=0;for(const t of r.values())t.total>l&&(l=t.total);return[0,l]}(p,this.getX,this.getY,y.binSize,this.getCategory);_=[0,t+t*y.extentPadding]}else if("waterfall"===y.chartType&&!S&&p.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(p,this.getY),n=e-t,i=n>0?n*y.extentPadding:1;_=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!S&&_[0]!==1/0){if(this.getBounds)for(const t of v){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>_[1]&&(_[1]=e+n),_[0]>e-n&&(_[0]=e-n))}const t=_[1]-_[0],e=t>0?t*y.extentPadding:1,n=null===(f=y.yExtent)||void 0===f?void 0:f[0],i=null===(g=y.yExtent)||void 0===g?void 0:g[1];_=[null!=n?_[0]:_[0]-e,null!=i?_[1]:_[1]+e],"log"===y.yScaleType&&0>=_[0]&&x[0]>0&&(_[0]=null!=n?_[0]:x[0]/(1+y.extentPadding))}if(y.yExtent&&!S){const t=y.yExtent[0],e=y.yExtent[1];null==t&&null==e||(_=[null!=t?t:_[0],null!=e?e:_[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===y.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];_[0]!==1/0&&_[1]!==-1/0||(_=[0,1]);const M="streaming"===y.runtimeMode,P=Math.max(0,Math.min(y.scalePadding||0,Math.min(t.width,t.height)/2-1));if(M)if("x"==("up"===(C=y.arrowOfTime)||"down"===C?"y":"x")){const e="right"===y.arrowOfTime?[P,t.width-P]:[t.width-P,P];this.scales={x:b().domain(A).range(e),y:b().domain(_).range([t.height-P,P])}}else{const e="down"===y.arrowOfTime?[P,t.height-P]:[t.height-P,P];this.scales={x:b().domain(_).range([P,t.width-P]),y:b().domain(A).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return k().domain(t).range(n).clamp(!0)}return"time"===t?w().domain([new Date(e[0]),new Date(e[1])]).range(n):b().domain(e).range(n)};this.scales={x:e(y.xScaleType,A,[P,t.width-P]),y:e(y.yScaleType,_,[t.height-P,P])}}var C;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,ge.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=A().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return k().domain(t).range(n).clamp(!0)}return"time"===t?w().domain([new Date(e[0]),new Date(e[1])]).range(n):b().domain(e).range(n)},a=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=l[1]>l[0];this.scales={x:s(this.config.xScaleType,i,r[0]>r[1]?[t.width-a,a]:[a,t.width-a]),y:s(this.config.yScaleType,o,c?[a,t.height-a]:[t.height-a,a])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,i,o,r,l,s,a;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const a=null!==(n=c.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},d={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:a,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(i=c.themeSemantic)&&void 0!==i?i:{},categorical:null!==(o=c.themeCategorical)&&void 0!==o?o:ie},resolveColor:(t,e)=>{var n,i;const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(i=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==i?i:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(l=h.overlays)&&void 0!==l?l:null,null!==(s=h.nodes)&&void 0!==s?s:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(c.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const n=ue(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Et(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return de(t,i,o),o}(d,e);case"area":return function(t,e){const n=t.groupData(e),i=[],o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=Tt(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),i.push(l)}return de(t,n,i),i}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set,r=t.scales.y.domain()[0],l=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=Tt(e.data,t.scales,t.getX,t.getY,r,n,e.key,l);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Et(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return de(t,n,i),i}(d,e);case"stackedarea":return function(t,e){var n,i,o,r;const l=t.groupData(e),s=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",a=()=>l.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===s)a();else if("asc"===s||"desc"===s||"insideOut"===s){const e=new Map;for(const n of l){let i=0;for(const e of n.data){const n=t.getX(e),o=t.getY(e);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}e.set(n.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===s)l.sort((t,i)=>{var o,r;const l=(null!==(o=e.get(t.key))&&void 0!==o?o:0)-(null!==(r=e.get(i.key))&&void 0!==r?r:0);return 0!==l?l:n(t.key,i.key)});else if("desc"===s)l.sort((t,i)=>{var o,r;const l=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==l?l:n(t.key,i.key)});else{const t=[...l].sort((t,i)=>{var o,r;const l=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==l?l:n(t.key,i.key)}),r=[],s=[];let a=0,c=0;for(const n of t)c>a?(r.push(n),a+=null!==(i=e.get(n.key))&&void 0!==i?i:0):(s.push(n),c+=null!==(o=e.get(n.key))&&void 0!==o?o:0);l.length=0,l.push(...s.reverse(),...r)}}else a();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,i,o,r,l,s="zero"){var a,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const i of t)n+=(null===(a=h.get(i.key))||void 0===a?void 0:a.get(e))||0;f.set(e,n||1)}}const g=Dt(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},s),y=[],p=new Map,v=new Map;for(const t of d)v.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),i=[],s=[],a=new Map;for(const n of d){let o=t.get(n)||0;const l=v.get(n);r&&(o/=f.get(n));const c=l+o,u=e.x(n);s.push([u,e.y(l)]),i.push([u,e.y(c)]),v.set(n,c),a.set(n,c)}p.set(n.key,a);const c={type:"area",topPath:i,bottomPath:s,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(c.curve=l),y.push(c)}return{nodes:y,stackedTops:p}}(l,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of l){const i=h.get(n.key);if(i)for(const o of n.data){const n=t.getX(o),r=t.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||e.set(o,i.get(n))}}const n=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};de(t,l,f,n)}return f}(d,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let l=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);l=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(l&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=l(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=Ot(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(d,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const l=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),s=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Nt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/l,y=(f-h||1)/s,p=l*s;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/g),l-1),d=Math.min(Math.floor((r-h)/y),s-1);if(0>a||0>d)continue;const f=d*l+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,A=n.height/s,_=t.config.showValues,S=t.config.heatmapValueFormat,M=[];for(let t=0;s>t;t++){const e=t*l;for(let n=0;l>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-x)/k;M.push($t(n*w,(s-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*y,agg:a},_?{value:o,showValues:!0,valueFormat:S}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const i=Nt(t.config.valueAccessor,"value"),o=Wt(t.config.xAccessor,"x"),r=Wt(t.config.yAccessor,"y"),l=new Map,s=new Map,a=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);a[t]=i,c[t]=u,l.has(i)||l.set(i,l.size),s.has(u)||s.set(u,s.size)}const u=l.size,d=s.size;if(0===u||0===d)return[];const h=Array.from(l.keys()),f=Array.from(s.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),l.clear();for(let t=0;h.length>t;t++)l.set(h[t],t)}if(y){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(a[t]),r=s.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,v[g]=d,m[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in he?t:"blues";let n=fe.get(e);if(n)return n;n=Array(256);const i=he[e]||Bt;for(let t=0;256>t;t++)n[t]=i(t/255);return fe.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(w-k||1),S=n.width/u,M=n.height/d,P=t.config.showValues,C=t.config.heatmapValueFormat,E=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;E.push($t(i*S,(d-1-(n-i)/u)*M,S,M,A[Math.min((e-k)*_+.5|0,255)],m[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return E}(d,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Ct(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),l=Array.from(e).filter(t=>!i.has(t)).sort(),s=n.filter(t=>e.has(t)),a=s.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...s,...l],t.barCategoryCache={key:a,order:r})}const l=[],s=t.scales,[a,c]=s.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=s.x(n),y=s.x(o),p=Math.abs(y-h),v=p>f+1?f:0,m=Math.min(h,y)+v/2,x=Math.max(p-v,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=s.y(n),c=s.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";l.push(Lt(m,Math.min(a,c),x,Math.abs(a-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=s.y(0),n=s.y(e.total);l.push(Lt(m,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of o.values())y.add(t.start),y.add(t.end);return{nodes:l,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(d,e);return this._barCategoryCache=null!==(a=d.barCategoryCache)&&void 0!==a?a:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,l,s;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(l=c.opacity)&&void 0!==l?l:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let l=d;if(t.getCategory){const e=t.getCategory(n);l=(null===(s=t.config.barColors)||void 0===s?void 0:s[e])||l}const c={type:"point",x:o,y:r,r:u,style:{fill:l,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(d,e);case"waterfall":return function(t,e,n){var i,o,r,l,s,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",y=null!==(a=null!==(l=null==h?void 0:h.negativeColor)&&void 0!==l?l:null===(s=t.config.themeSemantic)||void 0===s?void 0:s.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),l=b+r;let s;s=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==s?d.x(o+s):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=l;continue}const A=d.y(b),_=d.y(l),S=Math.min(A,_),M=Math.abs(A-_),P={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(P.opacity=x),u.push(Lt(k,S,w,M,P,Object.assign(Object.assign({},i),{baseline:b,cumEnd:l,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=l}return u}(d,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],l=t.config.candlestickStyle||{},s=l.rangeColor||"#6366f1",a=o?s:l.upColor||"#28a745",c=o?s:l.downColor||"#dc3545",u=o?s:l.wickColor||"#333",d=l.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=l.bodyWidth)&&void 0!==i?i:0;if(null==l.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),l=t.getLow(n);if(null==i||Number.isNaN(i)||null==l||Number.isNaN(l))continue;const s=o?i:t.getOpen(n),h=o?l:t.getClose(n);if(!o&&[s,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(l),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(y.isRange=!0),r.push(y)}return r}(d,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?oe(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const l=new Map;for(let t=0;n.length>t;t++)l.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const s=l.get(e[n]);null!=s?(i[n]=oe(t,s,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let s=!1;for(let n=0;e.length>n;n++){const i=l.get(e[n]);null!=i?(o[n]=oe(t,i,r),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=oe(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const s=oe(t,e,r);if("heatcell"===n.type)n.style={opacity:s};else if("candlestick"===n.type)n._decayOpacity=s;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*s})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const l="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const s=re(t,r,l);s>o&&(o=s)}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=re(t,o,l);r>0&&(n._pulseIntensity=r,n._pulseColor=s,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,l,s;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=ce(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=ce(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,_,S,M,P,C,E,T,D,O,L,$,I,N,W,z,R,Y,F,j,B,H,X;if(0===i.size&&0===o.size)return n;const G=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let V=!1;const q=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],T=ce(t,r,e);if(!T)continue;if(r._transitionKey=T,"line"===r.type||"area"===r.type){const t=o.get(T);if(t){if(U.add(T),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}r._targetOpacity=null!==(l=r.style.opacity)&&void 0!==l?l:1,r._startOpacity=null!==(a=null!==(s=t.opacity)&&void 0!==s?s:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const D=i.get(T);if("point"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,D.x===t.x&&D.y===t.y&&D.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=D.x,r.y=D.y,r.r=null!==(d=D.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,D.x===t.x&&D.y===t.y&&D.w===t.w&&D.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=D.x,r.y=D.y,r.w=null!==(g=D.w)&&void 0!==g?g:r.w,r.h=null!==(y=D.h)&&void 0!==y?y:r.h,V=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(D){q.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,D.x===t.x&&D.y===t.y&&D.w===t.w&&D.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=D.x,r.y=D.y,r.w=null!==(x=D.w)&&void 0!==x?x:r.w,r.h=null!==(b=D.h)&&void 0!==b?b:r.h,V=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(D&&null!=D.openY){q.add(T);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(_=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==_?_:1,(D.x!==t.x||D.openY!==t.openY||D.closeY!==t.closeY||D.highY!==t.highY||D.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=D.x,r.openY=D.openY,r.closeY=null!==(S=D.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(M=D.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(P=D.lowY)&&void 0!==P?P:r.lowY,V=!0)}else r._targetOpacity=null!==(E=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==E?E:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(D=e.opacity)&&void 0!==D?D:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}for(const[t,e]of i)if(!q.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(O=e.r)&&void 0!==O?O:3,style:{opacity:null!==(L=e.opacity)&&void 0!==L?L:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==($=e.w)&&void 0!==$?$:0,h:null!==(I=e.h)&&void 0!==I?I:0,style:{opacity:null!==(N=e.opacity)&&void 0!==N?N:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(W=e.w)&&void 0!==W?W:0,h:null!==(z=e.h)&&void 0!==z?z:0,fill:"#999",datum:null,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(Y=e.openY)&&void 0!==Y?Y:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(F=e.closeY)&&void 0!==F?F:i,highY:null!==(j=e.highY)&&void 0!==j?j:i,lowY:null!==(B=e.lowY)&&void 0!==B?B:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:G}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,l,s,a,c;if(!n.activeTransition)return!1;const u=se(t,n.activeTransition),d=le(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=ae(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=ae(n.x,t._targetX,d),t.y=ae(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=ae(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=ae(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=ae(n.x,t._targetX,d),t.y=ae(n.y,t._targetY,d),void 0!==n.w&&(t.w=ae(n.w,t._targetW,d)),void 0!==n.h&&(t.h=ae(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ae(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=ae(n.x,t._targetX,d),t.y=ae(n.y,t._targetY,d),void 0!==n.w&&(t.w=ae(n.w,t._targetW,d)),void 0!==n.h&&(t.h=ae(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ae(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=ae(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=ae(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=ae(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=ae(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=ae(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ae(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=ae(e[i][0],n[i][0],d),t.path[i][1]=ae(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ae(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=ae(e[n][0],i[n][0],d),t.topPath[n][1]=ae(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ae(n[e][0],o[e][0],d),t.bottomPath[e][1]=ae(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ie,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const l=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:l,fillOpacity:.7,stroke:l,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||ie;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>ge.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let l=!1,s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!It(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=a||!It(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Nt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Nt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Nt(this.config.xAccessor,"x"),this.getY=Nt(this.config.yAccessor,"y")),l=!0,s=!0)}if("groupAccessor"in t&&!It(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?zt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!It(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?zt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!It(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Nt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!It(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?zt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!It(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Nt(this.config.y0Accessor,"y0"):void 0,l=!0,s=!0),"boundsAccessor"in t&&!It(t.boundsAccessor,r.boundsAccessor)&&(this.getBounds=this.config.boundsAccessor?Nt(this.config.boundsAccessor,"bounds"):void 0,l=!0,s=!0),"pointIdAccessor"in t&&!It(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?zt(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in t&&!It(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!It(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!It(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!It(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Nt(this.config.openAccessor,"open"):void 0,this.getHigh=Nt(this.config.highAccessor,"high"),this.getLow=Nt(this.config.lowAccessor,"low"),this.getClose=e?Nt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0,s=!0}if(!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){l=!0;break}}l&&(s&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function ye(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:i.createElement(i.Fragment,null,...e)}function pe(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function ve(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function me(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function xe(t,e){const n=me(t);if(!n)return!1;const i=me(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function be(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}ge.GROUP_COLOR_MAP_CAP=1e3,ge.QUADTREE_THRESHOLD=500;const ke=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,we=new WeakMap;let Ae=0,_e=!1,Se=null,Me=null,Pe=null;function Ce(t,e){var n,i;if(!e)return e;const o=ke.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(_e)return;if("undefined"==typeof window||"undefined"==typeof document)return;_e=!0;const t=()=>{Ae++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Se=new MutationObserver(t),Se.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Me=window.matchMedia("(prefers-color-scheme: dark)"),Pe=t,"function"==typeof Me.addEventListener?Me.addEventListener("change",Pe):"function"==typeof Me.addListener&&Me.addListener(Pe)}catch(t){}}();let l=we.get(r);l&&l.version===Ae||(l={version:Ae,map:new Map},we.set(r,l));const s=l.map.get(e);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return l.map.set(e,a),a}function Ee(t){switch(t){case"monotoneX":return O;case"monotoneY":return D;case"cardinal":return T;case"catmullRom":return E;case"step":return C;case"stepBefore":return P;case"stepAfter":return M;case"basis":return S;case"natural":return _;default:return null}}function Te(t,e,n){return null==e?n:"string"!=typeof e?e:Ce(t,e)||n}function De(t,e,n,i,o,r,l){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const s=t.createLinearGradient(i,o,r,l);for(const t of n)s.addColorStop(t.offset,t.color);return s}const{topOpacity:s,bottomOpacity:a}=e;if(!Number.isFinite(s)||!Number.isFinite(a))return null;const c=Math.max(0,Math.min(1,s)),u=Math.max(0,Math.min(1,a)),d=t.createLinearGradient(i,o,r,l),[h,f,g]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function Oe(t,e,n,i,o,r){const l=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>l.length)return null;const s=t.createLinearGradient(n,i,o,r);for(const t of l)s.addColorStop(t.offset,t.color);return s}const Le=new WeakMap;function $e(t,e){const n=Ee(e);if(!n)return t;const i=Le.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,l,s,a){if(!o)return o=[s,a],void i.push([s,a]);const[c,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*s,h*h*h*u+3*h*h*d*e+3*h*d*d*l+d*d*d*a])}o=[s,a]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return L().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return Le.set(t,o),o}function Ie(t,e,n,i=30,o,r=0){let l=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),l=e-r,s=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>s||l>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,l=t.y-n,s=Math.sqrt(r*r+l*l);ve(t.r,i)>=s&&d>s&&(u=t,d=s),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,r);t&&(l={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(o)break;t=We(r,e,n,i);break;case"line":t=ze(r,e,n,i);break;case"rect":if(null==r.datum)break;t=Ye(r,e,n);break;case"heatcell":t=Fe(r,e,n);break;case"area":if(!1===r.interactive)break;t=Be(r,e,n);break;case"candlestick":t=je(r,e,n)}t&&i>t.distance&&(l&&t.distance>=l.distance||(l=t))}return l}function Ne(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=He(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[l,s]=t[o],[a,c]=t[r];return a===l?s:s+Math.max(0,Math.min(1,(e-l)/(a-l)))*(c-s)}function We(t,e,n,i=30){const o=e-t.x,r=n-t.y,l=Math.sqrt(o*o+r*r);return l>ve(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function ze(t,e,n,i=30){var o,r,l,s;if(0===t.path.length)return null;const a=He(t.path,e);if(0>a)return null;const[c,u]=t.path[a];let d;if(t.path.length>1){let i=1/0;const o=Math.max(0,a-1),r=Math.min(t.path.length-2,a);for(let l=o;r>=l;l++){const[o,r]=t.path[l],[s,a]=t.path[l+1],c=Re(e,n,o,r,s,a);i>c&&(i=c)}d=i}else{const t=e-c,i=n-u;d=Math.sqrt(t*t+i*i)}const h=null!==(s=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==s?s:1;return d>Math.max(5,h/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:c,y:u,distance:d}}function Re(t,e,n,i,o,r){const l=o-n,s=r-i,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*l+(e-i)*s)/a;c=Math.max(0,Math.min(1,c));const u=i+c*s;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function Ye(t,e,n){const i=pe(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Fe(t,e,n){const i=pe(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function je(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,l=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+l*l)}}return null}function Be(t,e,n){if(0===t.topPath.length)return null;const i=He(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],l=e-o,s=n-r,a=Math.sqrt(l*l+s*s);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function He(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Xe(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:l}}function Ge(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function Ve(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?qe(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?qe(n,n.groups[t-1],r[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function qe(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function Ue(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function Ke(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}function Ze(t,e,n,i,o,r){l(()=>{if(!t)return;const l=setInterval(()=>{var l;const s=e.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(l=t.threshold)&&void 0!==l?l:5e3,u=a-s.lastIngestTime>c;u!==o&&(r(u),n.current=!0,i())},1e3);return()=>clearInterval(l)},[t,o,i])}const Qe={fill:e=>t("rect",{style:e,width:16,height:16}),line:e=>t("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Je(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,Qe[n])(i(t,e)),o}function tn(){return t("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function en(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const nn=(n,i,o,r,l,s,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=n,y=[];let p=0;const v=!(!i&&!o),m="isolate"===d||void 0===d&&null!=l;return g.forEach((n,d)=>{const x=Je(n,d,h,f),b=en(n,r,l),k=l&&l.size>0&&l.has(n.label);y.push(e("g",{transform:`translate(0,${p})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?c===s&&d===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&m?k||!1:void 0,"aria-current":v&&!m&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+g.length)%g.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:v?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,k&&t(tn,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),p+=22}),y};function on({config:n,orientation:o="vertical",width:r=100}){const{colorFn:l,domain:s,label:a,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:l(s[0]+n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),a&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:l(s[1]-n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[a&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])})]})}function rn(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical"}=n,[g,y]=i.useState(0),[p,v]=i.useState(0),m=i.useCallback((t,e)=>{y(t),v(e)},[]),x="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t("g",{className:"legend-item",transform:`translate(0,${d})`,children:nn(e,i,o,r,l,s,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h})=>{let f=0;const g=[];n.forEach((n,i)=>{let y=0;n.label&&(y+=16);const p=((n,i,o,r,l,s,a,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let v=0,m=0;const x=!(!i&&!o),b="isolate"===d||void 0===d&&null!=l;y.forEach((n,d)=>{const k=Je(n,d,f,g),w=en(n,r,l),A=l&&l.size>0&&l.has(n.label),_=26+7*n.label.length;h&&h>0&&v>0&&v+_>h&&(m++,v=0),p.push(e("g",{transform:`translate(${v},${22*m})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:x?c===s&&d===a?0:-1:void 0,role:x?"option":void 0,"aria-selected":x&&b?A||!1:void 0,"aria-current":x&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:x?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(d+("ArrowRight"===t.key?1:-1)+y.length)%y.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:x?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:x?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:x?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[x&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,A&&t(tn,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),v+=_});let k=0,w=0;for(const t of y){const e=26+7*t.label.length;h&&h>0&&w>0&&w+e>h?(k=Math.max(k,w),w=e):w+=e}k=Math.max(k,w);const A=m+1;return{items:p,offset:k,totalRows:A,totalHeight:22*A}})(n,r,l,s,a,c,u,i,d,h,o);y+=p.offset+5,g.push(Object.assign(Object.assign({label:n.label},p),{offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight})),f+=y+12});let y=f>o?0:Math.max(0,(o-f)/2);const p=[];return g.forEach((e,o)=>{const r=n[o];r.label&&(p.push(t("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),y+=16),p.push(t("g",{className:"legend-item",transform:`translate(${y},0)`,children:e.items},"legend-group-"+o)),y+=e.offset+5,n[o+1]&&p.push(t("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),t("g",{children:p})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}),b=!(!r&&!l);return e("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==c&&(void 0!==c||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),x]})}function ln(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function sn(t){return"object"==typeof t&&null!==t&&"gradient"in t}function an(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:l="right",title:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===l||"bottom"===l;let g,y;return"left"===l?(g=4,y=r.top):"top"===l?(g=0,y=s?32:8):"bottom"===l?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t("g",{transform:`translate(${g}, ${y})`,children:sn(n)?t(on,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):ln(n)?t(rn,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function cn(t){return"string"==typeof t?{type:t}:t}function un({orient:n,config:i,values:o,scale:l,size:s,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=r(()=>{if(0===o.length)return null;const i=l.domain(),r=s-8;if("boxplot"===c.type){const i=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],l=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*l),whiskerHigh:Math.min(e[n-1],r+1.5*l)}}(o);if(!i)return null;const{q1:s,median:a,q3:d,whiskerLow:h,whiskerHigh:f}=i,g=Math.min(.5*r,20),y=(r-g)/2+4;if(u){const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="top"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:m+v*(y+g/2),x2:p,y2:m+v*(y+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:m+v*y,x2:u,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:p,y1:m+v*y,x2:p,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?m-y-g:m+y,width:Math.abs(o-i),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?m-y-g:m+y,x2:r,y2:"top"===n?m-y:m+y+g,stroke:c.fill,strokeWidth:2})]})}{const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="left"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:m+v*(y+g/2),y1:u,x2:m+v*(y+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:u,x2:m+v*(y+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:p,x2:m+v*(y+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?m-y-g:m+y,y:Math.min(i,o),width:g,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?m-y-g:m+y,y1:r,x2:"left"===n?m-y:m+y+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=z().domain(i).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(s,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+s),width:o,height:Math.abs(s),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),s=l((t.x0+t.x1)/2);i.push(u?`${s},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${s}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const s=o.length/h*(r/2),a=l((o.x0+o.x1)/2);i.push(u?`${a},${"top"===n?-(e+s):e+s}`:`${"left"===n?-(e+s):e+s},${a}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,l,c,s,a,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function dn(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let l="";for(const t of o)l&&l.length+1+t.length>i?(r.push(l),l=t):l=l?`${l} ${t}`:t;return l&&r.push(l),r}function hn(t,e,n,i){return"curly"===t?i?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function fn(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:l,title:s,orientation:a,align:c,wrap:u=120,noWrap:d}=n;if(!l&&!s)return t("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>i?"end":"start";const y=16,p=s?d?[s]:dn(s,u):[],v=l?d?[l]:dn(l,u):[],m="leftRight"===h?"end"===g?-4:4:0;let x=0;const b=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:p.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-title")),x=p.length*y),v.length>0&&b.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:x,children:v.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-label"));let w=null;if((s||l)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===g?(n=-e,i=0):"middle"===g&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+v.length)*y+(v.length>0?y:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,p.length+v.length-1)*y;let _=0;return"topBottom"===h?_=0>o?-(A+2):18:"leftRight"===h&&(_="middle"===f?-(A+y+(v.length>0&&p.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==_?`translate(0,${_})`:void 0,children:b}),w]})}function gn(e,n,i,o,r){var l;const s=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&s.push(t("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&s.push(t("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,l=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;s.push(t("line",{x1:o,y1:(n.y1||0)-l,x2:o,y2:(n.y2||0)-l,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-l;s.push(t("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(t("line",{x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&s.push(t("path",{d:hn((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:s})}function yn(e,n,i,o,r,l){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==l?void 0:l.radius)){if("callout-rect"===r&&l){const t=l.width||0,i=l.height||0;if(t>0||i>0){const o=t/2,r=i/2,l=e-o,s=n-r;if(0!==l||0!==s){const e=Math.abs(l),n=Math.abs(s),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+l*h,c=r+s*h}}}else if("bracket"===r&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(l.radius||0)+(l.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);a=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(n-c,2))>.5&&(s.push(t("line",{x1:a,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,l=Math.atan2(n-c,e-a);s.push(t("path",{d:`M${a},${c}L${a+i*Math.cos(l+r)},${c+i*Math.sin(l+r)}L${a+i*Math.cos(l-r)},${c+i*Math.sin(l-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t("g",{className:"annotation-connector",children:s})}function pn(t){const{x:n=0,y:i=0,dx:o,dy:r,nx:l,ny:s,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=l&&(m=l-n),null!=s&&(x=s-i);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return e("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&yn(m,x,c,h,b,u),!v.has("subject")&&gn(b,u,h,n,i),!v.has("note")&&fn(a,m,x,h)]}))}function vn(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,l="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),s=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:s});return t(pn,Object.assign({"data-testid":"semiotic-annotation"},r,{type:l}),"multi-annotation-"+i)});return t("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t(pn,Object.assign({"data-testid":"semiotic-annotation",events:s},o,{type:l}),c)}function mn(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function xn(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function bn(t,e,n){var i,o,r,l;const s=t.anchor||"fixed";if("latest"===s){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,l;const s=t.data;if(!s||0===s.length)return null;const a=s[s.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let a=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(a=e.x,c=e.y)}if(null!=a&&null!=c||(a=mn(t,n),c=xn(t,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:a,y:c}),{x:a,y:c};if("sticky"===s){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function kn(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const wn={linear:I,monotoneX:O,monotoneY:D,step:C,stepAfter:M,stepBefore:P,basis:S,cardinal:T,catmullRom:E};let An={positions:new Map};const _n=new Set;function Sn(){for(const t of _n)t()}function Mn(t,e){const n=An.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(An.positions);i.delete(t),An={positions:i},Sn()}function Pn(t,e){const n=An.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(An.positions);i.delete(t),An={positions:i},Sn()}function Cn(){return An}function En(t){return _n.add(t),()=>_n.delete(t)}const Tn={positions:new Map};function Dn(){return()=>{}}function On(){return Tn}function Ln(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function $n(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let l="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${i+4*o}`,l+=`L${Math.min(n,e)},${i}`}return l}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let l=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);l+=`L${i+4*o},${Math.min(8*t+4,n)}`,l+=`L${i},${Math.min(e,n)}`}return l}}function In(n){const{width:i,height:o,totalWidth:l,totalHeight:s,margin:a,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g}=n,y=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||f||Nn,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=c.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),l=r.map(t=>t.valueOf()),s=r.map((t,e)=>({value:t,pixel:c.x(t),label:n(t,e,l)})),a=s.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Wn(s,Math.max(55,a+8))},[c,d,f,i]),p=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||g||Nn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return Wn(c.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:c.y(t),label:n(t)})),22)},[c,d,g,o]),v=h&&c,m=u&&c;if(!v&&!m)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),b=null==d?void 0:d.find(t=>"left"===t.orient),k=m&&(!x||!1!==x.baseline),w=m&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,_=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return t("svg",{width:l,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${a.left},${a.top})`,children:[v&&(()=>{var n,r;const l=Ln(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),s=Ln(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l},"xgrid-"+n)),p.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:S,strokeWidth:1}),A&&t("path",{d:$n("bottom",i,o),fill:"none",stroke:S,strokeWidth:1}),w&&!_&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),_&&t("path",{d:$n("left",i,o),fill:"none",stroke:S,strokeWidth:1})]})})}function Nn(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Wn(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function zn(i){var s,a;const{width:u,height:d,totalWidth:h,totalHeight:f,margin:g,scales:y,showAxes:p,axes:v,xLabel:m,yLabel:x,yLabelRight:b,xFormat:k,yFormat:w,showGrid:A,title:_,legend:S,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:E,legendPosition:T="right",foregroundGraphics:D,marginalGraphics:O,xValues:L,yValues:N,annotations:W,svgAnnotationRules:z,xAccessor:R,yAccessor:Y,annotationData:F,pointNodes:j,curve:B,underlayRendered:H,canvasObscuresUnderlay:G=!0,linkedCrosshairName:V,linkedCrosshairSourceId:q,children:U}=i,K=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||k||Nn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=y.x.ticks(Math.min(i,Math.max(2,Math.floor(u/70)))),r=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:y.x(t),label:n(t,e,r)})),s=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),a=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let c=Wn(l,a);if(c.length>1&&(c=c.filter((t,e)=>0===e||t.label+""!=c[e-1].label+"")),(null==e?void 0:e.includeMax)&&c.length>0){const t=y.x.domain()[1],e=y.x(t),i=c[c.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,c.length,r);a>e-i&&c.length>1&&(c=c.slice(0,-1)),c.push({value:t,pixel:e,label:o})}}return c},[p,y,v,k,u]),Z=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||w||Nn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=Wn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=y.y.domain()[1],e=y.y(t),i=o[o.length-1].pixel;if(Math.abs(e-i)>1){const r=n(t);22>Math.abs(e-i)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:r})}}return o},[p,y,v,w,d]),Q=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||w||Nn,i=null!==(t=e.ticks)&&void 0!==t?t:5;return Wn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.y(t),label:n(t)})),22)},[p,y,v,w,d]),tt=o(new Map),et=o(null!==(s=null==W?void 0:W.length)&&void 0!==s?s:0),nt=null!==(a=null==W?void 0:W.length)&&void 0!==a?a:0;et.current!==nt&&(et.current=nt,tt.current=new Map);const it=r(()=>{if(!W||0===W.length)return null;const n=function(n,i,o){var r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,_,S,M,P,C,E,T,D,O,L,N,W,z,R,Y,F,j,B,H,G,V,q,U,K,Z,Q,tt,et,nt;switch(n.type){case"label":{const e=bn(n,i,o);if(!e)return null;const{x:r,y:l}=e;return kn(r,l,o)?t(vn,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"label",connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"callout":{const e=bn(n,i,o);if(!e)return null;const{x:r,y:l}=e;return kn(r,l,o)?t(vn,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"callout-circle",subject:{radius:n.radius||12},connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"x-threshold":{const r=mn(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:r+4,y:a,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"y-threshold":{const r=xn(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"right";let a,c;return"left"===s?(a=4,c="start"):"center"===s?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:a,y:r-4,textAnchor:c,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"enclose":{const r=(n.coordinates||[]).map(t=>({x:mn(Object.assign(Object.assign({},t),{type:"point"}),o),y:xn(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=X(r),s=n.padding||10;return e("g",{children:[t("circle",{cx:l.x,cy:l.y,r:l.r+s,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:l.x,y:l.y-l.r-s-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"rect-enclose":{const r=(n.coordinates||[]).map(t=>({x:mn(Object.assign(Object.assign({},t),{type:"point"}),o),y:xn(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=n.padding||10,s=r.map(t=>t.x),a=r.map(t=>t.y),c=Math.min(...s)-l,u=Math.max(...s)+l,d=Math.min(...a)-l,h=Math.max(...a)+l;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"highlight":{const e=o.data||[],r="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],l={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:r.map((e,i)=>{const r=mn(e,o),s=xn(e,o);if(null==r||null==s)return null;const a="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||l;return t("circle",Object.assign({cx:r,cy:s,r:a},c),"hl-"+i)})},"ann-"+i)}case"bracket":{const e=mn(n,o),r=xn(n,o);return t(vn,{noteData:{x:null!=e?e:0,y:null!=r?r:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+i)}case"trend":{const h=o.data||[];if(2>h.length)return null;const f=o.xAccessor||"x",g=o.yAccessor||"y",y=h.map(t=>[t[f],t[g]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const p=null!==(l=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==l?l:null===(s=o.scales)||void 0===s?void 0:s.time,v=null!==(c=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=o.scales)||void 0===u?void 0:u.value;if(!p||!v)return null;const m=n.method||"linear";let x;x="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),s=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){s.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))s.push([e,h/u]);else{const t=(u*g-d*h)/y;s.push([e,(h-t*d)/u+t*e])}}return s}(y,null!==(d=n.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?J.polynomial(y,{order:n.order||2}):J.linear(y)).points;const b=x.map(([t,e])=>`${p(t)},${v(e)}`).join(" "),k=n.color||"#6366f1";return e("g",{children:[t("polyline",{points:b,fill:"none",stroke:k,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:p(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11,children:n.label})]},"ann-"+i)}case"band":{const r=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value,l=null!==(y=null==r?void 0:r(n.y0))&&void 0!==y?y:0,s=null!==(p=null==r?void 0:r(n.y1))&&void 0!==p?p:o.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(l,s),width:o.width||0,height:Math.abs(s-l),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(l,s)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+i)}case"envelope":{const r=o.data||[];if(2>r.length)return null;const l=o.xAccessor||"x",s=null!==(m=null===(v=o.scales)||void 0===v?void 0:v.x)&&void 0!==m?m:null===(x=o.scales)||void 0===x?void 0:x.time,a=null!==(k=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==k?k:null===(w=o.scales)||void 0===w?void 0:w.value;if(!s||!a)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=r.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[l]-e[l]);if(2>h.length)return null;const f=wn[o.curve||"linear"]||I,g=$().x(t=>s(t[l])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!g)return null;const y=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:y,fillOpacity:null!==(A=n.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:s(h[h.length-1][l])+4,y:a(h[h.length-1][c])-4,fill:y,fontSize:11,children:n.label})]},"ann-"+i)}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const l=o.yAccessor||"y",s=null!==(S=null===(_=o.scales)||void 0===_?void 0:_.x)&&void 0!==S?S:null===(M=o.scales)||void 0===M?void 0:M.time,a=null!==(C=null===(P=o.scales)||void 0===P?void 0:P.y)&&void 0!==C?C:null===(E=o.scales)||void 0===E?void 0:E.value;if(!s||!a)return null;const c=r.map(t=>t[l]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(T=n.threshold)&&void 0!==T?T:2,g=u-f*h,y=!1!==n.showBand,p=n.fill||"#6366f1",v=null!==(D=n.fillOpacity)&&void 0!==D?D:.1,m=n.anomalyColor||"#ef4444",x=null!==(O=n.anomalyRadius)&&void 0!==O?O:6,b=a(u+f*h),k=a(g),w=r.filter(t=>{const e=t[l];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[y&&t("rect",{x:0,y:Math.min(b,k),width:o.width||0,height:Math.abs(k-b),fill:p,fillOpacity:v}),w.map((e,n)=>{const i=mn(e,o),r=xn(e,o);return null==i||null==r?null:t("circle",{cx:i,cy:r,r:x,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(b,k)-4,textAnchor:"end",fill:p,fontSize:11,children:n.label})]},"ann-"+i)}case"forecast":{const r=o.data||[];if(3>r.length)return null;const l=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(N=null===(L=o.scales)||void 0===L?void 0:L.x)&&void 0!==N?N:null===(W=o.scales)||void 0===W?void 0:W.time,c=null!==(R=null===(z=o.scales)||void 0===z?void 0:z.y)&&void 0!==R?R:null===(Y=o.scales)||void 0===Y?void 0:Y.value;if(!a||!c)return null;const u=r.map(t=>[t[l],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=J.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const l=(t*o-e*n)/r,s=(n-l*e)/t;d=t=>s+l*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),y=u.reduce((t,e)=>t+e[0],0)/h,p=u.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),v=null!==(F=n.confidence)&&void 0!==F?F:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(j=n.steps)&&void 0!==j?j:5,b=u[h-1][0],k=(b-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(p>0?Math.pow(t-y,2)/p:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const _=`M${A.map(t=>`${a(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${c(t.yLower)}`).join(" L")} Z`,S=A.map(t=>`${a(t.x)},${c(t.yCenter)}`).join(" "),M=`${a(b)},${c(d(b))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:_,fill:n.fill||"#6366f1",fillOpacity:null!==(B=n.fillOpacity)&&void 0!==B?B:.15,stroke:"none"}),t("polyline",{points:`${M} ${S}`,fill:"none",stroke:P,strokeWidth:null!==(H=n.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(G=n.strokeDasharray)&&void 0!==G?G:"6,3"}),n.label&&A.length>0&&t("text",{x:a(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+i)}case"widget":{let e=null,r=null;if(null!=n.px&&null!=n.py)e=n.px,r=n.py;else{const t=bn(n,i,o);if(!t)return null;e=t.x,r=t.y}if(null==e||null==r)return null;if(!kn(e,r,o))return null;const l=null!==(V=n.dx)&&void 0!==V?V:0,s=null!==(q=n.dy)&&void 0!==q?q:0,a=null!==(U=n.width)&&void 0!==U?U:32,c=null!==(K=n.height)&&void 0!==K?K:32,u=null!==(Z=n.content)&&void 0!==Z?Z:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+l-a/2,y:r+s-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+i)}case"text":{const e=bn(n,i,o);if(!e)return null;const{x:r,y:l}=e;return t("text",{x:r+(n.dx||0),y:l+(n.dy||0),fill:n.color||"var(--semiotic-text, #333)",fontSize:n.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label},"ann-text-"+i)}case"category-highlight":{const r=n.category;if(null==r)return null;const l=null===(Q=o.scales)||void 0===Q?void 0:Q.o,s=null===(tt=o.scales)||void 0===tt?void 0:tt.x,a=null===(et=o.scales)||void 0===et?void 0:et.y,c=(null==l?void 0:l.bandwidth)?l:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!c)return null;const u=c(r);if(null==u)return null;const d=c.bandwidth(),h=n.color||"var(--semiotic-primary, #4589ff)",f=null!==(nt=n.opacity)&&void 0!==nt?nt:.15,g=n.label;return e("g",(o.projection?"vertical"===o.projection:c===s)?{children:[t("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&t("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&t("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+i)}default:return null}},i={scales:y?{x:y.x,y:y.y,time:y.x,value:y.y}:null,timeAxis:"x",xAccessor:R,yAccessor:Y,width:u,height:d,data:F,frameType:"xy",pointNodes:j,curve:B,stickyPositionCache:tt.current};return W.map((t,e)=>{if(z){const o=z(t,e,i);return null!=o?o:n(t,e,i)}return n(t,e,i)}).filter(Boolean)},[W,z,u,d,R,Y,F,y,j,B]),ot=function(t){var e;const n=c(t?En:Dn,t?Cn:On,t?Cn:On);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(V);return l(()=>{if(!(null==ot?void 0:ot.locked)||!V)return;const t=t=>{"Escape"===t.key&&Pn(V)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==ot?void 0:ot.locked,V]),p||_||S||D||O||it&&it.length>0||A||U||ot?e("svg",{role:"img",width:h,height:f,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof _?_:"XY Chart"}),t("desc",{children:"string"==typeof _?_+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[A&&y&&(!H||G)&&(()=>{var n,i;const o=Ln(null===(n=null==v?void 0:v.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=Ln(null===(i=null==v?void 0:v.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[K.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:d,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),Z.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:u,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),p&&y&&(()=>{const i=null==v?void 0:v.find(t=>"left"===t.orient),o=null==v?void 0:v.find(t=>"bottom"===t.orient),r=!i||!1!==i.baseline,l=!o||!1!==o.baseline,s=(null==i?void 0:i.jaggedBase)||!1,a=(null==o?void 0:o.jaggedBase)||!1,c=null==o?void 0:o.landmarkTicks,h=null==i?void 0:i.landmarkTicks,f="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",k=!!(null==o?void 0:o.autoRotate)&&K.length>1&&(()=>{const t=u/Math.max(K.length-1,1),e=K.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})();return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(!H||G)&&l&&!a&&t("line",{x1:0,y1:d,x2:u,y2:d,stroke:f,strokeWidth:1}),(!H||G)&&a&&t("path",{d:$n("bottom",u,d),fill:"none",stroke:f,strokeWidth:1}),K.map((n,i)=>{const o=!!c&&("function"==typeof c?c(n.value,i):xe(n.value,i>0?K[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${d})`,children:[t("line",{y2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:k?10:18,textAnchor:k?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},transform:k?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:n.label})})]},"xtick-"+i)}),m&&t("text",{x:u/2,y:d+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:m}),(!H||G)&&r&&!s&&t("line",{x1:0,y1:0,x2:0,y2:d,stroke:f,strokeWidth:1}),(!H||G)&&s&&t("path",{d:$n("left",u,d),fill:"none",stroke:f,strokeWidth:1}),Z.map((n,i)=>{const o=!!h&&("function"==typeof h?h(n.value,i):xe(n.value,i>0?Z[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==i?void 0:i.label)||x;return e?t("text",{x:15-g.left,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-g.left}, ${d/2})`,style:{userSelect:"none"},children:e}):null})(),(()=>{const i=null==v?void 0:v.find(t=>"right"===t.orient);if(!i||0===Q.length)return null;const o=i.landmarkTicks,r=i.label||b;return e(n,{children:[!1!==i.baseline&&t("line",{x1:u,y1:0,x2:u,y2:d,stroke:f,strokeWidth:1}),Q.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):xe(n.value,i>0?Q[i-1].value:void 0));return e("g",{transform:`translate(${u},${n.pixel})`,children:[t("line",{x2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:u+g.right-15,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${u+g.right-15}, ${d/2})`,style:{userSelect:"none"},children:r})]})})()]})})(),it,O&&y&&L&&N&&e(n,{children:[O.top&&t("g",{transform:"translate(0, 0)",children:t(un,{orient:"top",config:cn(O.top),values:L,scale:y.x,size:g.top,length:u})}),O.bottom&&t("g",{transform:`translate(0, ${d})`,children:t(un,{orient:"bottom",config:cn(O.bottom),values:L,scale:y.x,size:g.bottom,length:u})}),O.left&&t("g",{transform:"translate(0, 0)",children:t(un,{orient:"left",config:cn(O.left),values:N,scale:y.y,size:g.left,length:d})}),O.right&&t("g",{transform:`translate(${u}, 0)`,children:t(un,{orient:"right",config:cn(O.right),values:N,scale:y.y,size:g.right,length:d})})]}),D,ot&&ot.sourceId!==q&&(null==y?void 0:y.x)&&(()=>{const e=y.x(ot.xValue);if(null==e||0>e||e>u)return null;const n=ot.locked;return t("line",{x1:e,y1:0,x2:e,y2:d,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),U]}),_&&t("text",{x:h/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof _?_:null}),an({legend:S,totalWidth:h,totalHeight:f,margin:g,legendPosition:T,title:_,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:E})]}):null}const Rn={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Yn(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Fn="undefined"==typeof window||"undefined"==typeof document,jn="undefined"!=typeof window?h:l;function Bn(){const[t,e]=d(!1);return jn(()=>{e(!0)},[]),t}const Hn=()=>()=>{},Xn=()=>!1,Gn=()=>!0;function Vn(){const t=c(Hn,Xn,Gn);return o(t).current}function qn(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;jn(()=>{var t,o;e&&n&&(null===(o=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===o||o.call(t)),r.current=!0,s.current()},[e,n]);const c=o(a);c.current=a,l(()=>()=>{var t;return null===(t=c.current)||void 0===t?void 0:t.call(c)},[])}function Un(t){const e=o(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return Zn(t,e);if(!Qn(t)||!Qn(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Zn(n,o))return!1}else{if(!Qn(n)||!Qn(o))return!1;if(!Kn(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function Kn(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function Zn(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Qn(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const Jn=i.createContext(null);function ti(){return i.useContext(Jn)}const ei={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ni(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const i=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of l)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function ii(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const oi=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},ri={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},li={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},si={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ai={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ci={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},ui={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},di={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function hi({scene:n,chartType:o,tableId:r,chartTitle:l}){var s;const[a,c]=i.useState(!1),u=ti(),d=null!==(s=null==u?void 0:u.visible)&&void 0!==s&&s,h=a||d,f=i.useRef(null),g=l?"Data summary for "+l:r?`Data summary for ${o} ${r}`:"Data summary for "+o,y=i.useCallback(()=>{a||d||c(!0)},[a,d]),p=i.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[d]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:ei}):null;if(!h)return t("div",{id:r,tabIndex:-1,onFocus:y,style:ei,role:"region","aria-label":g,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const v=function(t){var e,n,i,o,r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,_,S;const M=[];if(!Array.isArray(t))return M;for(const P of t)if(P&&"object"==typeof P)try{switch(P.type){case"point":M.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;M.push({label:"Bar",values:{category:r,value:null!=l?l:""}});break}case"heatcell":M.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":M.push({label:"Wedge",values:{category:null!==(a=null!==(l=null===(r=P.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:null===(s=P.datum)||void 0===s?void 0:s.label)&&void 0!==a?a:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":M.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(g=P.cy)&&void 0!==g?g:P.y}});break;case"arc":M.push({label:"Arc",values:{id:null!==(p=null===(y=P.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m:P.y}});break;case"candlestick":M.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":M.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(S=null===(_=P.datum)||void 0===_?void 0:_.value)&&void 0!==S?S:""}})}}catch(t){}return M}(n),m=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(v),x=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${oi(t.min)} to ${oi(t.max)}, mean ${oi(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(v.length,m),b=v.slice(0,5),k=new Set;for(const t of b)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return e("div",{ref:f,id:r,tabIndex:-1,onBlur:p,style:ri,role:"region","aria-label":g,children:[t("button",{type:"button",onClick:()=>{d&&u&&u.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:si,children:"×"}),t("div",{role:"note",style:li,children:x}),e("table",{role:"table","aria-label":"Sample data for "+o,style:ai,children:[e("caption",{style:di,children:["First ",b.length," of ",v.length," data points"]}),t("thead",{children:e("tr",{children:[t("th",{style:ci,children:"type"}),w.map(e=>t("th",{style:ci,children:e},e))]})}),t("tbody",{children:b.map((n,i)=>e("tr",{children:[t("td",{style:ui,children:n.label}),w.map(e=>{return t("td",{style:ui,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":oi(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]})]})}function fi({nodes:n,edges:o,chartType:r,tableId:l,chartTitle:s}){var a,c,u,d,h,f,g,y,p,v,m,x,b,k;const[w,A]=i.useState(!1),_=ti(),S=null!==(a=null==_?void 0:_.visible)&&void 0!==a&&a,M=w||S,P=s?"Data summary for "+s:l?`Data summary for ${r} ${l}`:"Data summary for "+r,C=i.useRef(null),E=i.useCallback(()=>{w||S||A(!0)},[w,S]),T=i.useCallback(t=>{var e;S||(null===(e=C.current)||void 0===e?void 0:e.contains(t.relatedTarget))||A(!1)},[S]);if(!n||0===n.length)return l?t("span",{id:l,tabIndex:-1,style:ei}):null;if(!M)return t("div",{id:l,tabIndex:-1,onFocus:E,style:ei,role:"region","aria-label":P,children:e("button",{type:"button",onClick:()=>A(!0),children:["View data summary (",n.length," nodes, ",o.length," edges)"]})});const D=Array.isArray(n)?n:[],O=Array.isArray(o)?o:[],L=new Map,$=new Map,I=new Map,N=new Map;for(const t of O){if(!t||"object"!=typeof t)continue;const e=null!==(c=t.datum)&&void 0!==c?c:t,n="object"==typeof e.source?null===(u=e.source)||void 0===u?void 0:u.id:e.source,i="object"==typeof e.target?null===(d=e.target)||void 0===d?void 0:d.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";$.set(t,(null!==(h=$.get(t))&&void 0!==h?h:0)+1),N.set(t,(null!==(f=N.get(t))&&void 0!==f?f:0)+o)}if(null!=i&&""!==i){const t=i+"";L.set(t,(null!==(g=L.get(t))&&void 0!==g?g:0)+1),I.set(t,(null!==(y=I.get(t))&&void 0!==y?y:0)+o)}}const W=[];for(let t=0;D.length>t;t++){const e=D[t];if(!e||"object"!=typeof e)continue;const n=null!==(v=null===(p=e.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:e.id,i=null!=n?n+"":"node-"+t,o=null!==(m=L.get(i))&&void 0!==m?m:0,r=null!==(x=$.get(i))&&void 0!==x?x:0,l=null!==(b=I.get(i))&&void 0!==b?b:0,s=null!==(k=N.get(i))&&void 0!==k?k:0;W.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:l+s,wInDeg:l,wOutDeg:s})}W.sort((t,e)=>e.degree-t.degree);let z=0,R=0;if(W.length>0){let t=0;for(const e of W)t+=e.degree,e.degree>R&&(R=e.degree);z=t/W.length}const Y=O.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),F=[`${W.length} nodes, ${O.length} edges.`];W.length>0&&F.push(`Mean degree: ${oi(z)}, max degree: ${R}.`);const j=W.slice(0,5);return e("div",{ref:C,id:l,tabIndex:-1,onBlur:T,style:ri,role:"region","aria-label":P,children:[t("button",{type:"button",onClick:()=>{S&&_&&_.setVisible(!1),A(!1)},"aria-label":"Close data summary",style:si,children:"×"}),t("div",{role:"note",style:li,children:F.join(" ")}),e("table",{role:"table","aria-label":"Node degree summary for "+r,style:ai,children:[e("caption",{style:di,children:["Top ",j.length," of ",W.length," nodes by degree"]}),t("thead",{children:e("tr",{children:[t("th",{style:ci,children:"id"}),t("th",{style:ci,children:"degree"}),t("th",{style:ci,children:"in"}),t("th",{style:ci,children:"out"}),Y&&t("th",{style:ci,children:"w. degree"}),Y&&t("th",{style:ci,children:"w. in"}),Y&&t("th",{style:ci,children:"w. out"})]})}),t("tbody",{children:j.map((n,i)=>e("tr",{children:[t("td",{style:ui,children:n.id}),t("td",{style:ui,children:n.degree}),t("td",{style:ui,children:n.inDeg}),t("td",{style:ui,children:n.outDeg}),Y&&t("td",{style:ui,children:oi(n.wDegree)}),Y&&t("td",{style:ui,children:oi(n.wInDeg)}),Y&&t("td",{style:ui,children:oi(n.wOutDeg)})]},i))})]})]})}function gi({summary:e}){return e?t("div",{role:"note",style:ei,children:e}):null}function yi({tableId:e}){return t("a",{href:"#"+e,style:ei,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,ei)},children:"Skip to data table"})}function pi({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:ei,children:n})}const vi="var(--semiotic-focus, #005fcc)";function mi({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:l,height:s}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=l&&null!=s){const e=Math.max(l,4),n=Math.max(s,4);u=t("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:vi,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:vi,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:vi,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function xi({x:e,y:n,containerWidth:o,containerHeight:r,margin:l,children:s,className:a="stream-frame-tooltip",zIndex:c=1}){const u=i.useRef(null),[d,h]=i.useState(null);i.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,a,o,r]);let f;return f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,t("div",{ref:u,className:a,style:{position:"absolute",left:l.left+e,top:l.top+n,transform:f,pointerEvents:"none",zIndex:c,width:"max-content"},children:s})}const bi="undefined"==typeof window?l:h;function ki(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function wi(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return l(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[s,c]=function(t,e,n){const i=o(null),[r,s]=d(null);return l(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),u=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=c[0]-u.left-u.right,f=c[1]-u.top-u.bottom,g=ki(t.foregroundGraphics,c,u),y=ki(t.backgroundGraphics,c,u),p=St(t=>t.theme),{transition:v,introEnabled:m}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),x="semiotic-table-"+i.useId(),b=o(0),k=o(()=>{}),w=a(()=>{b.current||(b.current=requestAnimationFrame(()=>k.current()))},[]);l(()=>()=>{b.current&&(cancelAnimationFrame(b.current),b.current=0)},[]);const A=o(()=>{}),_=o(()=>{}),S=o(null),M=o(0),P=a(()=>{M.current=0;const t=S.current;S.current=null,t&&A.current(t)},[]),C=a(t=>{S.current={clientX:t.clientX,clientY:t.clientY},0===M.current&&(M.current=requestAnimationFrame(P))},[P]),E=a(()=>{S.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0),_.current()},[]);l(()=>()=>{S.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0)},[]);const T=t.themeDirtyRef;return bi(()=>{T&&(Ae++,T.current=!0,w())},[p,w,T]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:c,margin:u,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:v,introEnabled:m,tableId:x,rafRef:b,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:_,onPointerMove:C,onPointerLeave:E}}function Ai(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,l=e[1]*i,s=e[0]+"px",a=e[1]+"px";return t.style.width!==s&&(t.style.width=s),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===l||(t.width=r,t.height=l),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function _i(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Si(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Mi(t,e,n,i,o,r){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+i*i))}const s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(l[n]+l[n+1])/2;let r=o;a>i&&(r*=i/a),a>s-i&&(r*=(s-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const Pi=(t,e,n,i)=>{var o,r;const l=e.filter(t=>"line"===t.type);for(const s of l){if(2>s.path.length)continue;const a=s._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=s.style.stroke||"#007bff",u=Ce(t,c)||c,d=s.style.strokeWidth||2,h=s.colorThresholds,f=s.rawValues;if(t.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(t.globalAlpha=s.style.opacity),t.lineWidth=d,t.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const v=null!==(o=s.style.opacity)&&void 0!==o?o:1;Mi(t,s.path,u,d,v,s.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=Ee(s.curve),y=h&&h.length>0&&f&&f.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!y){t.strokeStyle=u;const m=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let x=0;s.path.length-1>x;x++)t.globalAlpha=.5*(p[x]+p[x+1])*m,t.beginPath(),t.moveTo(s.path[x][0],s.path[x][1]),t.lineTo(s.path[x+1][0],s.path[x+1][1]),t.stroke()}else if(y){let b=null,k=null,w=null,A=null,_=!1;function S(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),_=!0}function M(){_&&(t.stroke(),_=!1)}for(let P=0;s.path.length>P;P++){const[C,E]=s.path[P],T=f[P],D=Si(T,h,u);if(null!==b&&null!==A&&null!==w){if(D===A)t.lineTo(C,E);else{const O=[];for(const $ of h){const I=$.value;(w>I||I>T)&&(I>w||T>I)||w===I||T===I||O.push({t:(I-w)/(T-w)})}O.sort((t,e)=>t.t-e.t);for(const N of O){const W=b+(C-b)*N.t,z=k+(E-k)*N.t,R=Si(w+(T-w)*Math.min(N.t+1e-4,1),h,u);t.lineTo(W,z),M(),S(R,W,z)}t.lineTo(C,E)}b=C,k=E,w=T,A=D}else S(D,C,E),b=C,k=E,w=T,A=D}M()}else{t.beginPath();const Y=s.strokeGradient&&s.path.length>=2?Oe(t,s.strokeGradient,s.path[0][0],0,s.path[s.path.length-1][0],0):null;if(t.strokeStyle=Y||u,g)L().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[F,j]=s.path[0];t.moveTo(F,j);for(let B=1;s.path.length>B;B++)t.lineTo(s.path[B][0],s.path[B][1])}t.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=s.style.fillOpacity,t.fillStyle=Te(t,s.style.fill,s.style.fill),g&&!y)L().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[X,G]=s.path[0];t.moveTo(X,G);for(let V=1;s.path.length>V;V++)t.lineTo(s.path[V][0],s.path[V][1])}const H=s.path[0][0];t.lineTo(s.path[s.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Ci(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ei(t,e,n=.3){Ci(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Ti(t,e,n=.6){var i,o,r,l,s;if(!Ci(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(s=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==s?s:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Di(t,e,n,i=.35){Ci(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Oi(t,e){const n=Ee(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const i=$().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Li=(t,e,n,i)=>{var o,r,l;const s=e.filter(t=>"area"===t.type);for(const e of s){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const s=e._introClipFraction;void 0!==s&&1>s&&(t.save(),t.beginPath(),t.rect(0,0,i.width*s,i.height),t.clip());const a=e.style.fill||"#4e79a7",c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=a;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(c[i]+c[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(c[n]+c[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(Oi(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=De(t,e.fillGradient,"string"==typeof a?a:"#4e79a7",0,n,0,i);t.fillStyle=o||a,t.globalAlpha=u}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*u,t.fillStyle=a}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Oi(t,e),Di(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?Oe(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=Ee(e.curve);if(t.beginPath(),i)L().x(t=>t[0]).y(t=>t[1]).curve(i).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==s&&1>s&&t.restore(),n&&t.restore(),t.globalAlpha=1}},$i=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=Te(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=Te(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),Ti(t,e),t.globalAlpha=1}}finally{t.restore()}}};function Ii(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const Ni=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Wi(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=Te(t,e.style.fill,Ce(t,"var(--semiotic-primary, #007bff)")),i=Ii(e),o=e.fillGradient&&"string"==typeof n?De(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:l,y:s,w:a,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(l,s),t.lineTo(l+a-r,s),t.arcTo(l+a,s,l+a,s+r,r),t.lineTo(l+a,s+c-r),t.arcTo(l+a,s+c,l+a-r,s+c,r),t.lineTo(l,s+c);break;case"left":t.moveTo(l+a,s),t.lineTo(l+r,s),t.arcTo(l,s,l,s+r,r),t.lineTo(l,s+c-r),t.arcTo(l,s+c,l+r,s+c,r),t.lineTo(l+a,s+c);break;case"bottom":t.moveTo(l,s),t.lineTo(l+a,s),t.lineTo(l+a,s+c-r),t.arcTo(l+a,s+c,l+a-r,s+c,r),t.lineTo(l+r,s+c),t.arcTo(l,s+c,l,s+c-r,r);break;default:t.moveTo(l,s+c),t.lineTo(l,s+r),t.arcTo(l,s,l+r,s,r),t.lineTo(l+a-r,s),t.arcTo(l+a,s,l+a,s+r,r),t.lineTo(l+a,s+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=Te(t,e.style.fill,Ce(t,"var(--semiotic-primary, #007bff)")),i=Ii(e),o=e.fillGradient&&"string"==typeof n?De(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Ei(t,e),t.globalAlpha=1}};function Wi(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,l=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,l,i,o,o)}else{const r=o+i,l=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,l,o,o)}t.restore()}function zi(t,e,n,i){return Object.assign({data:t,x:e,y:n,__semioticHoverData:!0},i)}function Ri(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function Yi(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Fi=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Ce(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Ei(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Yi(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Ri(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},ji=(t,e,n,i)=>{var o,r,l;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const s=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(l=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==l?l:1);1!==s&&(t.globalAlpha=s);const a=Ce(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=Ce(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}},Bi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Hi(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Bi[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Bi[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Xi={line:[Li,Pi,$i],area:[Li,$i],stackedarea:[Li,$i],scatter:[$i],bubble:[$i],heatmap:[Fi],bar:[Ni],swarm:[$i],waterfall:[(t,e,n,i)=>{var o,r,l;Ni(t,e);const s=e.filter(t=>"rect"===t.type);if(2>s.length)return;const a=s[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=Ce(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const i=s[e],o=s[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[ji],mixed:[Li,Pi,$i],custom:[Li,Ni,Fi,Pi,$i,ji]},Gi={top:20,right:20,bottom:30,left:40},Vi={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function qi(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Ui={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ki({hover:n}){var i,o,r;const l=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",s=null!==(i=n.data)&&void 0!==i?i:{},a=null!==(o=s.y)&&void 0!==o?o:s.value,c=null!==(r=s.x)&&void 0!==r?r:s.time;return e("div",{className:"semiotic-tooltip",style:Ui,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:l(a)}),t("div",{style:{opacity:.7,fontSize:11},children:l(c)})]})}const Zi=f(function(n,s){var c,u,h,f,p,v,m,x,b,k,w,A,_;const{chartType:S,runtimeMode:M,data:P,chunkThreshold:C,chunkSize:E,xAccessor:T,yAccessor:D,colorAccessor:O,sizeAccessor:L,groupAccessor:$,lineDataAccessor:I,curve:N,normalize:W,baseline:z,stackOrder:R,binSize:Y,valueAccessor:F,arrowOfTime:j="right",windowMode:B="sliding",windowSize:H=200,timeAccessor:X,xExtent:G,yExtent:V,extentPadding:q=.1,scalePadding:U,sizeRange:K,size:Z=[500,300],responsiveWidth:Q,responsiveHeight:J,margin:tt,className:et,background:nt,lineStyle:it,pointStyle:ot,areaStyle:rt,barStyle:lt,waterfallStyle:st,swarmStyle:at,barColors:ct,colorScheme:ut,boundsAccessor:ht,boundsStyle:yt,y0Accessor:pt,gradientFill:mt,lineGradient:xt,areaGroups:bt,openAccessor:kt,highAccessor:wt,lowAccessor:At,closeAccessor:_t,candlestickStyle:St,showAxes:Mt=!0,axes:Pt,xLabel:Ct,yLabel:Et,yLabelRight:Tt,xFormat:Dt,yFormat:Ot,tickFormatTime:Lt,tickFormatValue:$t,hoverAnnotation:It,tooltipContent:Nt,customHoverBehavior:Wt,customClickBehavior:zt,enableHover:Rt,hoverRadius:Yt=30,tooltipMode:Ft,annotations:jt,svgAnnotationRules:Bt,showGrid:Ht,legend:Xt,legendHoverBehavior:Gt,legendClickBehavior:Vt,legendHighlightedCategory:qt,legendIsolatedCategories:Ut,legendPosition:Kt,legendCategoryAccessor:Zt,onCategoriesChange:Qt,backgroundGraphics:Jt,foregroundGraphics:te,canvasPreRenderers:ee,svgPreRenderers:ne,title:ie,categoryAccessor:oe,brush:re,onBrush:le,decay:se,pulse:ae,transition:ce,animate:ue,staleness:de,heatmapAggregation:he,heatmapXBins:fe,heatmapYBins:pe,showValues:ve,heatmapValueFormat:me,marginalGraphics:xe,pointIdAccessor:be,xScaleType:ke,yScaleType:we,accessibleTable:Ae=!0,description:_e,summary:Se,linkedCrosshairName:Me,linkedCrosshairSourceId:Pe,customLayout:Ee,layoutConfig:Te}=n,De=g().replace(/:/g,""),Oe=o(!1),Le=wi({sizeProp:Z,responsiveWidth:Q,responsiveHeight:J,userMargin:tt,marginDefault:Gi,animate:ue,transitionProp:ce,themeDirtyRef:Oe}),We=Bn(),ze=Vn(),{reducedMotionRef:Re,responsiveRef:Ye,size:Fe,currentTheme:je,transition:Be,introEnabled:qe,tableId:Ue,rafRef:Qe,renderFnRef:Je,scheduleRender:tn}=Le;let en=Le.margin;if(xe){const t=60,e=Object.assign({},Le.margin);xe.top&&t>e.top&&(e.top=t),xe.bottom&&t>e.bottom&&(e.bottom=t),xe.left&&t>e.left&&(e.left=t),xe.right&&t>e.right&&(e.right=t),en=e}const nn="function"==typeof te?te({size:Fe,margin:en}):te,on="function"==typeof Jt?Jt({size:Fe,margin:en}):Jt,rn=Fe[0]-en.left-en.right,ln=Fe[1]-en.top-en.bottom,sn=r(()=>ft(P),[P]),an=null!=It?It:Rt,cn=o(null),un=o(null),[dn,hn]=d(0),[fn,gn]=d(null),yn=o(null),pn=o(null),[vn,mn]=d(null),xn=o(Vi.primary),bn=o([]),kn=o(Zt),wn=o(Qt);kn.current=Zt,wn.current=Qt;const[An,_n]=d(!1),[Sn,Mn]=d([]),[Pn,Cn]=d([]),En="streaming"===M||["bar","swarm","waterfall"].includes(S),Tn=r(()=>{var t,e,n;return{chartType:S,runtimeMode:En?"streaming":"bounded",windowSize:H,windowMode:B,arrowOfTime:En?j:"right",extentPadding:q,scalePadding:U,xAccessor:T,yAccessor:D,timeAccessor:En?X:void 0,valueAccessor:F,colorAccessor:O,sizeAccessor:L,groupAccessor:$||(I?"_lineGroup":void 0),categoryAccessor:oe,lineDataAccessor:I,xScaleType:ke,yScaleType:we,xExtent:G,yExtent:V,sizeRange:K,binSize:Y,normalize:W,baseline:z,stackOrder:R,boundsAccessor:ht,boundsStyle:yt,y0Accessor:pt,gradientFill:!0===mt?{topOpacity:.8,bottomOpacity:.05}:!1===mt?void 0:mt,areaGroups:bt?new Set(bt):void 0,lineGradient:xt,openAccessor:kt,highAccessor:wt,lowAccessor:At,closeAccessor:_t,candlestickStyle:St,lineStyle:it,pointStyle:ot,areaStyle:rt,swarmStyle:at,waterfallStyle:st,colorScheme:ut,barColors:ct,barStyle:lt,annotations:jt,decay:se,pulse:ae,transition:Be,introAnimation:qe,staleness:de,heatmapAggregation:he,heatmapXBins:fe,heatmapYBins:pe,showValues:ve,heatmapValueFormat:me,pointIdAccessor:be,curve:N,themeCategorical:null===(t=null==je?void 0:je.colors)||void 0===t?void 0:t.categorical,themeSemantic:vt(je),themeSequential:null===(e=null==je?void 0:je.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==je?void 0:je.colors)||void 0===n?void 0:n.diverging,customLayout:Ee,layoutConfig:Te,layoutMargin:en}},[S,H,B,j,q,U,T,D,X,F,ke,we,O,L,$,oe,I,G,V,K,Y,W,z,R,ht,yt,pt,mt,xt,bt,kt,wt,At,_t,St,it,ot,rt,at,st,lt,ut,ct,jt,se,ae,null==Be?void 0:Be.duration,null==Be?void 0:Be.easing,qe,de,he,fe,pe,ve,me,En,be,N,je,Ee,Te,en]),Dn=Un(Tn),On=o(null);On.current||(On.current=new ge(Dn));const Ln=a(()=>{var t,e;const n=kn.current,i=wn.current;if(!i||!n)return;const o=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(null!==(e=null===(t=On.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(o,bn.current)||(bn.current=o,i(o))},[]);l(()=>{var t;null===(t=On.current)||void 0===t||t.updateConfig(Dn),Oe.current=!0,tn()},[Dn,tn]);const $n=o(null);$n.current||($n.current=new gt(t=>{const e=On.current;e&&e.ingest(t)&&(Oe.current=!0,tn())},{chunkThreshold:C,chunkSize:E})),l(()=>{var t;null===(t=$n.current)||void 0===t||t.updateChunkOptions({chunkThreshold:C,chunkSize:E})},[C,E]);const Nn=a(t=>{var e;null===(e=$n.current)||void 0===e||e.push(t)},[]),Wn=a(t=>{var e;null===(e=$n.current)||void 0===e||e.pushMany(t)},[]),Rn=a(()=>{var t,e;null===(t=$n.current)||void 0===t||t.clear(),null===(e=On.current)||void 0===e||e.clear(),Oe.current=!0,tn()},[tn]);y(s,()=>({push:Nn,pushMany:Wn,remove:t=>{var e,n,i;null===(e=$n.current)||void 0===e||e.flush();const o=null!==(i=null===(n=On.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(yn.current&&o.some(t=>{var e;return t===(null===(e=yn.current)||void 0===e?void 0:e.data)})&&(yn.current=null,mn(null)),Oe.current=!0,tn()),o},update:(t,e)=>{var n,i,o;null===(n=$n.current)||void 0===n||n.flush();const r=null!==(o=null===(i=On.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Oe.current=!0,tn()),r},clear:Rn,getData:()=>{var t,e,n;return null===(t=$n.current)||void 0===t||t.flush(),null!==(n=null===(e=On.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=On.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=On.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Nn,Wn,Rn,tn]),l(()=>{var t,e;if(P){if(I&&sn.length>0&&"object"==typeof sn[0]&&null!==sn[0]){const e="string"==typeof I?I:"coordinates";if(Array.isArray(sn[0][e])){const n=[];for(const t of sn){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=$n.current)||void 0===t||t.setBoundedData(n))}}null===(e=$n.current)||void 0===e||e.setBoundedData(sn)}},[P,sn,I]);const{hoverHandlerRef:jn,hoverLeaveRef:Hn,onPointerMove:Xn,onPointerLeave:Gn}=Le;jn.current=t=>{var e,n,i;if(!an)return;const o=cn.current;if(!o)return;const r=o.getBoundingClientRect(),l=t.clientX-r.left-en.left,s=t.clientY-r.top-en.top;if(0>l||l>rn||0>s||s>ln)return void(yn.current&&(yn.current=null,pn.current=null,mn(null),Wt&&(Wt(null),Oe.current=!0),tn()));const a=On.current;if(!a||0===a.scene.length)return;const c=Ie(a.scene,l,s,Yt,a.quadtree,a.maxPointRadius),u="multi"===Ft,d=()=>{yn.current&&(yn.current=null,pn.current=null,mn(null),Wt&&Wt(null),tn())};if(!c&&!u)return void d();const h=u||!c?l:c.x,f=u||!c?s:c.y;let g=zi(null!==(e=null==c?void 0:c.datum)&&void 0!==e?e:{},h,f);if(u&&a.scene.length>0&&a.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=Ne($e(t.path,t.curve),e,n);if(null===r)continue;const l=He(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=$e(t.topPath,t.curve),l=$e(t.bottomPath,t.curve),s=Ne(r,e,n);if(null===s)continue;const a=Ne(l,e,n),c=He(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:s,y0:null!=a?a:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(a.scene,h,Math.max(Yt,rn));if(t.length>0){const e=a.scales.y.invert,n=a.scales.x.invert,i=xn.current,o=n?n(h):h;if(c)g.xValue=o,g.xPx=h;else{const t={xValue:o};"string"==typeof T&&(t[T]=o),g=zi(t,h,f,{xValue:o,xPx:h})}g.allSeries=t.map(t=>{const n=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===S&&null!=o?n-o:n,valuePx:t.y,color:t.color||i,datum:t.datum}})}}c||(null===(n=g.allSeries)||void 0===n?void 0:n.length)?(yn.current=g,pn.current=null!==(i=null==c?void 0:c.node)&&void 0!==i?i:null,mn(g),Wt&&(Wt(g),Oe.current=!0),tn()):d()},Hn.current=()=>{yn.current&&(yn.current=null,pn.current=null,mn(null),Wt&&(Wt(null),Oe.current=!0),tn())};const Kn=o(()=>{});Kn.current=t=>{if(!zt)return;const e=cn.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-en.left,o=t.clientY-n.top-en.top;if(0>i||i>rn||0>o||o>ln)return void zt(null);const r=On.current;if(!r||0===r.scene.length)return void zt(null);const l=Ie(r.scene,i,o,Yt,r.quadtree,r.maxPointRadius);zt(l?zi(l.datum||{},l.x,l.y):null)};const Zn=a(t=>Kn.current(t),[]),Qn=o(-1),Jn=o(null),ti=o(null),ei=a(t=>{const e=On.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(ti.current&&ti.current.version===n)i=ti.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=Xe(t),ti.current={version:n,graph:i}}const o=Qn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Qn.current=0;const e=i.flat[0];Jn.current={shape:e.shape,w:e.w,h:e.h};const n=Ke(e);return yn.current=n,mn(n),Wt&&Wt(n),void tn()}const r=Ge(i,o),l=Ve(t.key,r,i);if(null===l)return;if(t.preventDefault(),0>l)return Qn.current=-1,Jn.current=null,yn.current=null,pn.current=null,mn(null),Wt&&Wt(null),void tn();Qn.current=l;const s=i.flat[l];Jn.current={shape:s.shape,w:s.w,h:s.h};const a=Ke(s);yn.current=a,mn(a),Wt&&Wt(a),tn()},[Wt,tn]),ii=a(t=>{Qn.current=-1,Jn.current=null,Xn(t)},[Xn]);Je.current=()=>{var t,e;Qe.current=0;const n=cn.current,i=un.current;if(!n||!i)return;const o=On.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Re.current?r+1e6:r),s=!Re.current&&l,a=Oe.current||l;a&&!s&&(o.computeScene({width:rn,height:ln}),Ln());const c=_i(),u=function(t){if(!t)return Vi;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),l=i||e.getPropertyValue("--text-secondary").trim(),s=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return l||s||n||r?{axisStroke:a||Vi.axisStroke,tickText:l||Vi.tickText,crosshair:l?qi(l,"66"):Vi.crosshair,hoverFill:c?qi(c,"4D"):Vi.hoverFill,hoverStroke:l?qi(l,"99"):Vi.hoverStroke,pointRing:c||Vi.pointRing,primary:r||Vi.primary}:Vi}(n);xn.current=u.primary;const d=null!==(t=null==de?void 0:de.threshold)&&void 0!==t?t:5e3,h=de&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=Ai(n,Fe,en,c);if(t){if(t.clearRect(-en.left,-en.top,Fe[0],Fe[1]),h&&(t.globalAlpha=null!==(e=null==de?void 0:de.dimOpacity)&&void 0!==e?e:.5),"transparent"!==nt&&!Jt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=nt||(e&&"transparent"!==e?e:null),o=i?Ce(t,i):null;o&&(t.fillStyle=o,t.fillRect(-en.left,-en.top,Fe[0],Fe[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,rn,ln),t.clip()),ee&&o.scales)for(const e of ee)t.save(),e(t,o.scene,o.scales,{width:rn,height:ln}),t.restore();const i=Ee?Xi.custom:Xi[S];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:rn,height:ln});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ai(i,Fe,en,c);if(t&&(t.clearRect(-en.left,-en.top,Fe[0],Fe[1]),an&&yn.current&&o.scales&&function(t,e,n,i,o,r,l){var s;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(s=e.xPx)&&void 0!==s?s:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||l.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=l.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||l.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||l.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,yn.current,rn,ln,"object"==typeof an?an:{},pn.current,u),pn.current&&Array.isArray(It))){const e=It.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const l=n.group;if(void 0!==l)for(const n of e){if("line"!==n.type)continue;if(n.group!==l)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,pn.current,e,u)}}a&&n&&n.setAttribute("aria-label",ni(o.scene,S+" chart"));const f=Oe.current;if(Oe.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!fn||t(fn.x.domain()[0])!==t(o.scales.x.domain()[0])||t(fn.x.domain()[1])!==t(o.scales.x.domain()[1])||t(fn.y.domain()[0])!==t(o.scales.y.domain()[0])||t(fn.y.domain()[1])!==t(o.scales.y.domain()[1])||fn.x.range()[0]!==o.scales.x.range()[0]||fn.x.range()[1]!==o.scales.x.range()[1]||fn.y.range()[0]!==o.scales.y.range()[0]||fn.y.range()[1]!==o.scales.y.range()[1])&&gn(o.scales),xe){const t=o.getData(),e="function"==typeof T?T:t=>t[T||"x"],n="function"==typeof D?D:t=>t[D||"y"];Mn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Cn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&jt&&jt.length>0&&hn(t=>t+1),(null==de?void 0:de.showBadge)&&_n(!!h),(s||null!=o.activeTransition||o.hasActivePulses)&&(Qe.current=requestAnimationFrame(()=>Je.current()))},qn({hydrated:We,wasHydratingFromSSR:ze,storeRef:On,dirtyRef:Oe,renderFnRef:Je,cleanup:()=>{var t;return null===(t=$n.current)||void 0===t?void 0:t.clear()}}),l(()=>{Oe.current=!0,tn()},[S,rn,ln,Mt,nt,it,ee,tn]),Ze(de,On,Oe,tn,An,_n);const oi=r(()=>{if(Dt||Lt)return;const t=On.current;return(null==t?void 0:t.xIsDate)&&fn?Hi(fn.x.domain()):void 0},[Dt,Lt,fn]),ri=Dt||Lt||oi,li=an&&vn?Nt?Nt(vn):t(Ki,{hover:vn}):null,si=li?t(xi,{x:vn.x,y:vn.y,containerWidth:rn,containerHeight:ln,margin:en,className:"stream-frame-tooltip",children:li}):null,ai=Jn.current,ci=t(mi,{active:Qn.current>=0,hoverPoint:vn,margin:en,size:Fe,shape:null==ai?void 0:ai.shape,width:null==ai?void 0:ai.w,height:null==ai?void 0:ai.h}),ui=(t,e,n,i)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:{key:void 0,fn:null},di=ui(T,X,"__semiotic_resolvedX","__semiotic_resolvedTime"),fi=ui(D,F,"__semiotic_resolvedY","__semiotic_resolvedValue"),vi=di.key,bi=fi.key,ki=jt&&jt.length>0,Si=t=>{if(!t||!ki||!di.fn&&!fi.fn)return t;let e=!1;const n=t.map(t=>{const n=di.fn&&di.key&&!(di.key in t),i=fi.fn&&fi.key&&!(fi.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[di.key]=di.fn(t)),i&&(o[fi.key]=fi.fn(t)),o});return e?n:t};if(Fn||!We&&ze){const n=On.current;n&&P&&(n.ingest({inserts:sn,bounded:!0}),n.computeScene({width:rn,height:ln}));const o=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(u=null==n?void 0:n.scales)&&void 0!==u?u:null,l=ri||(()=>{if((null==n?void 0:n.xIsDate)&&r)return Hi(r.x.domain())})();return e("div",{ref:Ye,className:"stream-xy-frame"+(et?" "+et:""),role:"img","aria-label":_e||("string"==typeof ie?ie:"XY chart"),style:{position:"relative",width:Q?"100%":Fe[0],height:J?"100%":Fe[1]},children:[t(gi,{summary:Se}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Fe[0],height:Fe[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${en.left},${en.top})`,children:on}),e("g",{transform:`translate(${en.left},${en.top})`,children:[nt&&t("rect",{x:0,y:0,width:rn,height:ln,fill:nt}),ne&&r&&ne.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:rn,height:ln})},"svgpre-"+n)),o.map((n,i)=>function(n,i,o){var r,l,s,a,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${o?o+"-":""}area-clip-${i}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:Yn(c.style.fill),fillOpacity:null!==(l=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==l?l:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+i)}return t("path",{d:u,fill:Yn(c.style.fill),fillOpacity:null!==(a=null!==(s=c.style.fillOpacity)&&void 0!==s?s:c.style.opacity)&&void 0!==a?a:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:Yn(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:Yn(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,l,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*r+.587*l+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),l=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:l,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}(n,i,De)).filter(Boolean)]})]}),t(zn,{width:rn,height:ln,totalWidth:Fe[0],totalHeight:Fe[1],margin:en,scales:r,showAxes:Mt,axes:Pt,xLabel:Ct,yLabel:Et,yLabelRight:Tt,xFormat:l,yFormat:Ot||$t,showGrid:Ht,title:ie,legend:Xt,legendHoverBehavior:Gt,legendClickBehavior:Vt,legendHighlightedCategory:qt,legendIsolatedCategories:Ut,legendPosition:Kt,foregroundGraphics:ye(nn,null===(h=On.current)||void 0===h?void 0:h.customLayoutOverlays),marginalGraphics:xe,xValues:[],yValues:[],annotations:jt,svgAnnotationRules:Bt,annotationFrame:0,xAccessor:vi,yAccessor:bi,annotationData:Si(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof N?N:void 0,linkedCrosshairName:Me,linkedCrosshairSourceId:Pe})]})}return e("div",{ref:Ye,className:"stream-xy-frame"+(et?" "+et:""),role:"group","aria-label":_e||("string"==typeof ie?ie:"XY chart"),tabIndex:0,style:{position:"relative",width:Q?"100%":Fe[0],height:J?"100%":Fe[1],overflow:"visible"},onKeyDown:ei,children:[Ae&&t(yi,{tableId:Ue}),Ae&&t(hi,{scene:null!==(p=null===(f=On.current)||void 0===f?void 0:f.scene)&&void 0!==p?p:[],chartType:S+" chart",tableId:Ue,chartTitle:"string"==typeof ie?ie:void 0}),t(gi,{summary:Se}),e("div",{role:"img","aria-label":_e||("string"==typeof ie?ie:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:an?ii:void 0,onMouseLeave:an?Gn:void 0,onClick:zt?Zn:void 0,children:[on&&t("svg",{style:{position:"absolute",left:0,top:0,width:Fe[0],height:Fe[1],pointerEvents:"none"},children:t("g",{transform:`translate(${en.left},${en.top})`,children:on})}),t(In,{width:rn,height:ln,totalWidth:Fe[0],totalHeight:Fe[1],margin:en,scales:fn,showAxes:Mt,axes:Pt,showGrid:Ht,xFormat:ri,yFormat:Ot||$t}),t("canvas",{ref:cn,"aria-label":ni(null!==(m=null===(v=On.current)||void 0===v?void 0:v.scene)&&void 0!==m?m:[],S+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:un,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(pi,{hoverPoint:vn}),t(zn,{width:rn,height:ln,totalWidth:Fe[0],totalHeight:Fe[1],margin:en,scales:fn,showAxes:Mt,axes:Pt,xLabel:Ct,yLabel:Et,yLabelRight:Tt,xFormat:ri,yFormat:Ot||$t,showGrid:Ht,title:ie,legend:Xt,legendHoverBehavior:Gt,legendClickBehavior:Vt,legendHighlightedCategory:qt,legendIsolatedCategories:Ut,legendPosition:Kt,foregroundGraphics:ye(nn,null===(x=On.current)||void 0===x?void 0:x.customLayoutOverlays),marginalGraphics:xe,xValues:Sn,yValues:Pn,annotations:jt,svgAnnotationRules:Bt,annotationFrame:dn,xAccessor:vi,yAccessor:bi,annotationData:Si(null===(b=On.current)||void 0===b?void 0:b.getData()),pointNodes:null===(k=On.current)||void 0===k?void 0:k.scene.filter(t=>"point"===t.type),curve:"string"==typeof N?N:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==nt&&!Jt,linkedCrosshairName:Me,linkedCrosshairSourceId:Pe}),(re||le)&&t(dt,{width:rn,height:ln,totalWidth:Fe[0],totalHeight:Fe[1],margin:en,dimension:null!==(w=null==re?void 0:re.dimension)&&void 0!==w?w:"xy",scales:fn,onBrush:null!=le?le:()=>{},binSize:Y,snap:null==re?void 0:re.snap,binBoundaries:null!==(A=null==re?void 0:re.binBoundaries)&&void 0!==A?A:"bar"===S?null===(_=On.current)||void 0===_?void 0:_.getBinBoundaries():void 0,snapDuring:null==re?void 0:re.snapDuring,streaming:"streaming"===M}),(null==de?void 0:de.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===de.badgePosition?{top:4,left:4}:"bottom-left"===de.badgePosition?{bottom:4,left:4}:"bottom-right"===de.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:An?"#dc3545":"#28a745",color:"white"}),children:An?"STALE":"LIVE"}),ci,si]})]})});Zi.displayName="StreamXYFrame";const Qi={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ji={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class to{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const l=this.particles[r];if(!l.active)continue;const s=n[l.edgeIndex];if(!s||!s.bezier){l.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[l.edgeIndex])&&void 0!==o?o:1;l.t+=t*e*a*(s.bezier.circular?.3:1),1>l.t?eo(s.bezier,l.t,l.offset,l):(l.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function eo(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,l=e*r,s=Math.min(Math.floor(l),r-1),a=l-s,[c,u,d,h]=t[s];no(c,u,d,h,a,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const t=f/y;o.x+=-g/y*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,l,s]=t.points;no(o,r,l,s,e,i);const a=s.x-o.x,c=s.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function no(t,e,n,i,o,r){const l=1-o,s=l*l,a=s*l,c=o*o,u=c*o;r.x=a*t.x+3*s*o*e.x+3*l*c*n.x+u*i.x,r.y=a*t.y+3*s*o*e.y+3*l*c*n.y+u*i.y}function io(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function oo(t,e){var n,i=[],o=[],r=[],l={},s=[];function a(t){r[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;s[t].length>e;e++)(i=s[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;s[t].length>e;e++){var h=l[i=s[t][e]];h||(l[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),l=Array(e),s=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,l[a]=-1,s[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,a.push(y),c.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>l[y]||s[e].push(l[y])}r[e]=g}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(g=a.length-1;g>=0;--g){var x=a[g];if(o[x]=!1,p.push(x),v.push(s[x]),m+=s[x].length,l[x]=d.length,x===e){a.length=g;break}}d.push(p);var b=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)b[--m]=v[g][k];h.push(b)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var g=h[a];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,l=0;o.length>l;l++)for(var s=0;o[l].length>s;s++)r>o[l][s]&&(r=o[l][s],n=l);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];r[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return i}function ro(t){return t.y0-t.y1>0?"up":"down"}function lo(t,e){return e(t.source)==e(t.target)}function so(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function ao(t){return t.target.x0-t.source.x1}function co(t,e){var n=ho(t),i=ao(e)/Math.tan(n);return"up"==ro(t)?t.y1-i:t.y1+i}function uo(t,e){var n=ho(t),i=ao(e)/Math.tan(n);return"up"==ro(t)?t.y1+i:t.y1-i}function ho(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function fo(t,e){return e(t)}function go(t){return po(t.source)}function yo(t){return po(t.target)}function po(t){return(t.y0+t.y1)/2}function vo(t){return t.virtual?0:t.value}function mo(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!lo(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!lo(t,e)?i+1:i}),n+i}function xo(t){return t.target.depth}function bo(t,e){return t.sourceLinks.length?t.depth:e-1}function ko(t,e){return t.y0-e.y0}function wo(t,e){return e.y0-t.y0}function Ao(t,e){return t.y1-e.y1}function _o(t,e){return e.y1-t.y1}function So(t,e){return Po(t.source,e.source)||t.index-e.index}function Mo(t,e){return Po(t.target,e.target)||t.index-e.index}function Po(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Co(t,e){return Eo(t)==Eo(e)?"bottom"==t.circularLinkType?wo(t,e):ko(t,e):Eo(e)-Eo(t)}function Eo(t){return t.target.column-t.source.column}function To(t,e){return Do(t)==Do(e)}function Do(t){return t.y0-t.y1>0?"up":"down"}function Oo(t,e,n,i,o){let r=t;var l=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=R(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var a=r.links.filter(function(t){return t.circular});return a.sort(function(t,e){return e.value-t.value}),a.forEach(function(t,e){t._circularStub=e>=4}),Lo(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Lo(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,lo(t,e)&&so(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==l&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?wo:ko);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=r.links.filter(function(t){return t.target.column==l&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?_o:Ao),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function Lo(t,e,n){t.sort(Co);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(lo(t,e)&&so(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var l=0;i.length>l;l++){var s=i[l];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&$o(t,s)){var a=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function $o(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Io(t){return function(){return t}}function No(t){return t.index}function Wo(t){return t.nodes}function zo(t){return t.links}function Ro(t,e,n){var i=Y(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var l=o.length;if(e)o.sort(e);else if(r>0){var s=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=po(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=po(t.target)*e,i+=e}}),i>0?o/i:NaN);s.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=s.get(t),i=s.get(e),o=n.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?mo(e,n)-mo(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==mo(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function Yo(t,e,n,i,o,r){var l=Y(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var s=1,a=r;a>0;--a)c(s*=.99,n),u();function c(e,n){var i=l.length;l.forEach(function(o){var r=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&mo(o,n)>0){var a=B(o.sourceLinks,yo),c=B(o.targetLinks,go),u=a&&c?(a+c)/2:a||c;if(u){var d=(u-po(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==i-1&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.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=B(o.sourceLinks,yo),f=B(o.targetLinks,go),g=((h&&f?(h+f)/2:h||f)-po(o))*e;o.y0+=g,o.y1+=g}})})}function u(){l.forEach(function(n){var r,l,s,a=t.y0,c=n.length;for(n.sort(e||Po),s=0;c>s;++s)(l=a-(r=n[s]).y0)>0&&(r.y0+=l,r.y1+=l),a=r.y1+i;if((l=a-i-t.y1)>0)for(a=r.y0-=l,r.y1-=l,s=c-2;s>=0;--s)(l=(r=n[s]).y1+o-a)>0&&(r.y0-=l,r.y1-=l),a=r.y0})}}function Fo(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Mo),t.targetLinks.sort(So)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function jo(){var t=0,e=0,n=1,i=1,o=24,r=8,l=null,s=No,a=bo,c=void 0,u=32,d=2,h=Wo,f=zo;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return H(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=io(n,i)),"object"!=typeof o&&(o=t.target=io(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,s),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],l=r.source.index,s=r.target.index;i[l]||(i[l]=[]),i[s]||(i[s]=[]),-1===i[l].indexOf(s)&&i[l].push(s)}var a=oo(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){fo(t,e)!=fo(o.source,e)&&fo(t,e)!=fo(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),lo(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(j(t.sourceLinks,vo),j(t.targetLinks,vo)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==s?l:l+1,s=e(t)==s?s:e(t),t.column=l})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,a);var f=r;if(null!==l){var g=Y(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=F(g,function(t){return t.length});y>1&&(f=Math.max(1,(i-e)*l/(y-1)))}(function(t,e,n){var i=Y(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=R(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/j(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=F(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,o),Ro(h,c,s),Yo(h,c,s,f,f,u),Fo(h),Oo(h,s,d,10,8),Ro(h,c,s),Yo(h,c,s,f,f,u),Fo(h),Oo(h,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return fo(n.source,e)==fo(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!To(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=co(e,t);return t.y1-n}if(e.target.column>t.target.column)return co(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,l=0;o>r;r++)l+=i[r].width;e.y0=t.y1-l-e.width/2}})})}(h,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return fo(n.target,e)==fo(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!To(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=uo(e,t);return t.y0-n}if(e.source.column>t.source.column)return uo(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,l=0;o>r;r++)l+=i[r].width;e.y1=t.y1-l-e.width/2}})})}(h,s),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=R(e,function(t){return t.y0}),l=F(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-r);function a(e){return(e-r)/(l-r)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1)}),n.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=a(t.y0)-t.y0;t.y0=a(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),Oo(h,s,d,10,8)}(g),g}return g.update=function(t){return Fo(t),Oo(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:Io(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:Io(t),g):f},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:Io(t),g):s},g.nodeAlign=function(t){return arguments.length?(a="function"==typeof t?t:Io(t),g):a},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}const Bo=t=>{let e,n,i,o,r,l,s,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,l=t.target.x0,s=tt(r,l),a=s(.5),c=s(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${l}L${i},${l}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,s=tt(e,n),i=s(.5),o=s(.5),r=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${l} ${n},${l}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function Ho(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,r=o.targetX,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+s},${i-n}L${e+s},${i+n}L${e},${i+n}ZM${r},${l-n}L${r-a},${l-n}L${r-a},${l+n}L${r},${l+n}Z`}const r=o.sourceX,l=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${l-h*n}L${c},${l-h*n}L${c+i},${l-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${s},${a-h*n}L${s},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${l+h*n}L${r},${l+h*n}Z`}const Xo=new Set,Go=new WeakMap;function Vo(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Go.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Go.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Xo.has(t)||(Xo.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,i)}});return n.set(e,i),i}const qo={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(xo))-1:0},justify:bo};function Uo(t){return"string"==typeof t?t:t.id}const Ko={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,l,s,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(l=n.iterations)&&void 0!==l?l:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=jo().extent(m).links(v).nodes(p).nodeAlign(qo[h]||bo).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,l=(null!==(a=null!==(s=i._circularWidth)&&void 0!==s?s:i.width)&&void 0!==a?a:0)/2;t>r.leftFullExtent-l&&(t=r.leftFullExtent-l),r.rightFullExtent+l>e&&(e=r.rightFullExtent+l),n>r.verticalFullExtent-l&&(n=r.verticalFullExtent-l),r.verticalFullExtent+l>o&&(o=r.verticalFullExtent+l)}const r=e-t,l=o-n,u=i[0],d=i[1];if(r>0&&l>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/l),i=-t*e+(u-r*e)/2,o=-n*e+(d-l*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=Uo(t.source),n=Uo(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=b.get(e),r=b.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,l,s,a,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:jt,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[],b=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=d?d(Vo(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};b.set(e.id,("string"==typeof o.fill?o.fill:null)||p.get(e.id)||"#4d430c"),v.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";o="function"==typeof g?g(t)||o:"target"===g?b.get(i.id)||p.get(i.id)||o:b.get(e.id)||p.get(e.id)||o;const u=h?h(Vo(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=u.fill||o;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?Ho(t):Bo(t),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};m.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let l,s,a;"down"===u?(l=n.y0+(n.y1-n.y0)/2,s=n.x1+14,a="start"):(i[0]/2>n.x0+t/2?(l=n.x0-6,a="end"):(l=n.x1+6,a="start"),s=n.y0+o/2),x.push({x:l,y:s,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:x}}},Zo={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,s=i[0]/2,a=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Qo(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=Jo(t.id),r=o%360*(Math.PI/180),l=10+o%20;t.x=e/i.length+l*Math.cos(r),t.y=n/i.length+l*Math.sin(r)}else{const e=Jo(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=s+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=s+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,y=tr(n.nodeSize,n.nodeSizeRange,t),p=t=>y(t);if(g>0){const n=et().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*l:l)}).id(t=>t.id),i=nt().force("charge",it().strength(t=>-25*p(t))).force("center",ot(s,a).strength(.8)).force("x",rt(s).strength(.15)).force("y",lt(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",n),i.force("link").links(t)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,l,s,a,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=tr(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:jt,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],v=[],m=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Vo(e,"nodeSize")),i=d?d(Vo(e,"nodeStyle")):{},s={fill:i.fill||y.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:2,opacity:i.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:s,datum:e,id:e.id,label:e.id})}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),i="object"==typeof t.target?t.target:x.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(Vo(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};v.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=f(Vo(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}};function Qo(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id;let l=null;if(e===t?l=r:r===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function Jo(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function tr(t,e,n){var i,o;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],l=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>r[0];const s=null!==(i=R(l))&&void 0!==i?i:0,a=null!==(o=F(l))&&void 0!==o?o:1;if(s===a)return()=>(r[0]+r[1])/2;const c=b().domain([s,a]).range(r).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?r[0]:c(i)}}const er=jt,nr={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:l}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);y[n][i]=o}const p=at().padAngle(o);l&&p.sortGroups(l);const v=p(y),m=v.groups,x=N().innerRadius(a).outerRadius(s);for(const e of m){const n=t[e.index],i=x.centroid({innerRadius:a,outerRadius:s,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+c,n.y=i[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),i=b.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of v){const n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){var o,r,l,s;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,f=i[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:er,m=new Map;t.forEach((t,e)=>{m.set(t.id,v[e%v.length])});const x=st().radius(d),b=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=g?g(Vo(n,"nodeStyle")).fill||m.get(n.id)||v[e%v.length]:m.get(n.id)||v[e%v.length];const l=g?g(Vo(n,"nodeStyle")):{},s={fill:r,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};b.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=x(e);if(!i)continue;const o=ir(i,h,f);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";if(y)a=y(Vo(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===p&&n?a=m.get(n.id)||a:e&&(a=m.get(e.id)||a)}const u=y?y(Vo(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,l=r-Math.PI/2;w.push({x:h+Math.cos(l)*i,y:f+Math.sin(l)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:b,sceneEdges:k,labels:w}}};function ir(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const or=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function rr(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}function lr(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function sr(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function ar(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:or}function cr(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function ur(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const dr={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const l=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,u=G(r,s);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,h]=i;switch(l){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=Q();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=Z();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const l=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(r=e.paddingTop)&&void 0!==r?r:0,a=U().size([n,i]).tile(K).padding(l);s>0&&a.paddingTop(s),a(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;q().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;V().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:lr(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===l||"cluster"===l?hr(r,i,n):"treemap"===l||"partition"===l?fr(r,i):"circlepack"===l&&gr(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var l,s,a,c,u,d,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,x=i[0]/2,b=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=x,i+=b);const r=o(Vo(e,"nodeStyle"));let a=r.fill||cr(n);if(n.colorByDepth&&void 0!==e.depth){const t=ar(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.surface)||"#fff",strokeWidth:null!==(s=r.strokeWidth)&&void 0!==s?s:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,l=e.y,s=i.x,a=i.y;m&&(o+=x,l+=b,s+=x,a+=b);const f=ur(o,l,s,a,v),g=r(Vo(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=sr(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,l=n.x,s=n.y;if(m&&(l+=x,s+=b),m){const t=l-x,e=s-b,n=Math.sqrt(t*t+e*e);n>0?(i=l+t/n*10,o=s+e/n*10,r=0>t?"end":"start"):(i=l,o=s-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=l-k-6,r="end"):(i=l+k+6,r="start"),o=s):(i=l,o=s+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,l,s,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,l=n.y1-n.y0;if(0>=t||0>=l)continue;const s=i(Vo(n,"nodeStyle"));let a=s.fill||cr(e);if(e.colorByDepth&&void 0!==n.depth){const t=ar(e);a=t[n.depth%t.length]}const u={fill:a,stroke:s.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:l,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=sr(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(l=c.data)||void 0===l?void 0:l.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(Vo(c,"nodeStyle")).fill||cr(e);if(e.colorByDepth&&void 0!==c.depth){const t=ar(e);g=t[c.depth%t.length]}const y="string"==typeof g?rr(g):null!==(a=null===(s=e.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,l,s,a,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(Vo(n,"nodeStyle"));let c=a.fill||cr(e);if(e.colorByDepth&&void 0!==n.depth){const t=ar(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=a.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=sr(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const l=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let s=i(Vo(o,"nodeStyle")).fill||cr(e);if(e.colorByDepth&&void 0!==o.depth){const t=ar(e);s=t[o.depth%t.length]}if(l){const n="string"==typeof s?rr(s):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function hr(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function fr(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function gr(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function yr(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const pr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,l;const s=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=yr(n);g.metaMap.clear(),i.length=0,o.length=0;const y=new Map;function p(t){var e;const n=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(a(t));i.push({id:b,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,l,u,d,y){const v=s(e);if(!(null==v?void 0:v.length))return;const m=v.length;let x=0,b=0,k=0;for(;m>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let m=0;x>m;m++){const b=c[Math.min(m,c.length-1)],k=v.slice(w,w+b);if(!k.length)break;const A=(m+1)/x,_={id:n,depth:d,data:e,parentId:n},S=y?u/h(_)*A:u*A,M=W().value(t=>{var e;return(null===(e=s(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=M(k),C=f(_);for(let e=0;k.length>e;e++){const s=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(a(c)),h=r+S*Math.sin(s),f=l+S*Math.cos(s)*C;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:S,angle:s,depth:d,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,S,d+1,!0)}w+=b}}(t,b,v,m,x,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,l,s,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=yr(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of o)for(let o=0;r>o;o++){const s=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(s),y1:e+n*Math.cos(s)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Vo(e,"nodeSize")),i=d?d(Vo(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=i.opacity)&&void 0!==s?s:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(Vo(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=yr(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+s*a*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},vr={sankey:Ko,force:Zo,chord:nr,tree:dr,cluster:dr,treemap:dr,circlepack:dr,partition:dr,orbit:pr};function mr(t){return vr[t]}function xr(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(i)%t.length])&&void 0!==n?n:"#4e79a7"}}class br{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},Qi),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new to(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},Qi),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new to(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:l="value"}=this.config,s="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=s(e)+"";this.nodes.set(t,Object.assign(Object.assign({},kr(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},kr(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},kr(o)),{data:n}));const l=`${i}\0${o}\0${t}`;this.edges.set(l,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,kr(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,kr(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,r=!0);const s=this.edgeKey(e,n),a=this.edges.get(s);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,l,s,a;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=mr(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const s of u)if(void 0!==s._prevX0){const a=(null!==(e=s._prevX1)&&void 0!==e?e:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(i=s._prevY1)&&void 0!==i?i:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);t.set(s.id,{x:(null!==(r=s._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(l=s._prevY0)&&void 0!==l?l:0)+c/2})}else 0===s.x&&0===s.y||t.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),g=null!==(a=null===(s=this.config.transition)||void 0===s?void 0:s.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const t=new Set(this.nodes.keys()),e=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of t)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)t.has(e)||this.removedNodes.add(e);for(const t of e)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)e.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=t,this.previousEdgeKeys=e}buildScene(t){var e,n,i,o,r,l;const s=Array.from(this.nodes.values()),a=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=function(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=ee[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,jt),u={nodes:s,edges:a,dimensions:{width:t[0],height:t[1],plot:{x:0,y:0,width:t[0],height:t[1]}},theme:{semantic:null!==(e=this.config.themeSemantic)&&void 0!==e?e:{},categorical:[...c]},resolveColor:xr(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};let d;try{d=this.config.customNetworkLayout(u)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(i=d.sceneNodes)&&void 0!==i?i:[],this.sceneEdges=null!==(o=d.sceneEdges)&&void 0!==o?o:[],this.labels=null!==(r=d.labels)&&void 0!==r?r:[],void(this.customLayoutOverlays=null!==(l=d.overlays)&&void 0!==l?l:null)}this.customLayoutOverlays=null;const c=mr(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(s,a,this.config,t);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const t=mr(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=mr(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(i,o,this.config,t,e)}cancelIntroAnimation(){this.transition=null;for(const t of this.nodes.values())t._prevX0=void 0,t._prevX1=void 0,t._prevY0=void 0,t._prevY1=void 0;for(const t of this.edges.values())t._prevY0=void 0,t._prevY1=void 0,t._prevSankeyWidth=void 0,t._introFromZero=!1}advanceTransition(t){if(!this.transition)return!1;const e=se(t,this.transition),n=le(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=ae(t._prevX0,t._targetX0,n),t.x1=ae(t._prevX1,t._targetX1,n),t.y0=ae(t._prevY0,t._targetY0,n),t.y1=ae(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=ae(t._prevY0,t._targetY0,n),t.y1=ae(t._prevY1,t._targetY1,n),t.sankeyWidth=ae(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,l=tt(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,l=tt(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,l=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+l/3},{x:e.x+2*r/3,y:e.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const l=this.config.pulse;if(!l)return;const s=null!==(e=l.duration)&&void 0!==e?e:500,a=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=l.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;s>o&&(e._pulseIntensity=1-o/s,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!l)continue;const c=this.edgeTimestamps.get(`${i}\0${l}`);if(!c)continue;const u=t-c;s>u&&(e._pulseIntensity=1-u/s,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const o=this._decaySortedNodes,r=new Map;for(let t=0;o.length>t;t++)r.set(o[t][0],t);for(const o of this.sceneNodes){const l=o.id;if(!l)continue;const s=r.get(l);if(void 0===s)continue;const a=oe(n,s,i),c=null!==(e=null===(t=o.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const a=i.metric(s);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,l=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){l.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return l.length>0&&this.layoutVersion++,l}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function kr(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function wr(t,e,n,i,o=30){let r=null,l=o,s=1/0;for(const e of t){const t=Ar(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;s>n&&(r=t,s=n)}else l>t.distance&&(r=t,l=t.distance)}if(r)return r;for(const t of e){const e=Cr(t,n,i);e&&l>e.distance&&(r=e,l=e.distance)}return r}function Ar(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,l=Math.sqrt(o*o+r*r);return l>ve(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,i);case"rect":return function(t,e,n){const i=pe(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const l=be(Math.atan2(o,i)),s=be(t.startAngle),a=be(t.endAngle);if(s>a?l>=s||a>=l:l>=s&&a>=l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let _r=null,Sr=null;function Mr(){return Sr||(_r=document.createElement("canvas"),_r.width=1,_r.height=1,Sr=_r.getContext("2d")),Sr}function Pr(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function Cr(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Pr(t),l=Mr();if(!r||!l)return null;try{if(l.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,l="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&l?(r.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const s=l.lineWidth;l.lineWidth=10;const a=l.isPointInStroke(r,e,n);if(l.lineWidth=s,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let l=((e-t.x1)*i+(n-t.y1)*o)/r;l=Math.max(0,Math.min(1,l));const s=t.x1+l*i,a=t.y1+l*o,c=Math.sqrt(Math.pow(e-s,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:s,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Pr(t),o=Mr();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(i,e,n);if(o.lineWidth=r,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function Er(o){const{width:r,height:l,totalWidth:s,totalHeight:a,margin:c,labels:u,title:d,legend:h,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p,legendPosition:v="right",foregroundGraphics:m,sceneNodes:x,annotations:b,svgAnnotationRules:k}=o;return e(n,{children:[e("svg",{role:"img",width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t("title",{children:"string"==typeof d?d:"Network Chart"}),t("desc",{children:"string"==typeof d?d+" — network data visualization":"Network data visualization"}),e("g",{transform:`translate(${c.left},${c.top})`,children:[u.map((e,n)=>t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+n)),b&&b.filter(t=>"widget"!==t.type).map((e,n)=>{if(k){const o=k(e,n,{width:r,height:l,sceneNodes:x});if(o)return t(i.Fragment,{children:o},"annotation-"+n)}return null}),m]}),d&&"string"==typeof d?t("text",{x:s/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:d}):d?t("foreignObject",{x:0,y:0,width:s,height:c.top,children:d}):null,an({legend:h,totalWidth:s,totalHeight:a,margin:c,legendPosition:v,title:d,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p})]}),null==b?void 0:b.filter(t=>"widget"===t.type&&t.nodeId&&x).map((e,n)=>{var i,o,r,l,s,a,u,d,h;const f=x.find(t=>{var n,i,o,r,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const g=c.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=c.top+(null!==(r=f.cy)&&void 0!==r?r:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),p=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(a=e.dy)&&void 0!==a?a:-16,m=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t("div",{style:{position:"absolute",left:g+p-m/2,top:y+v-b/2,width:m,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function Tr(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function Dr(t,e){var n,i,o,r,l,s;if(!e.pathD)return;t.save();const a=Tr(e);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,s="string"==typeof e.style.fill?e.style.fill:"#999",a=Ce(t,s)||s;o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(s=e.style.opacity)&&void 0!==s?s:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function Or(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=Ce(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Lr(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const l=Tr(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function $r(t,e){var n,i;if(!e.pathD)return;t.save();const o=Tr(e),r=e.style.stroke||"#999";t.strokeStyle=Ce(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}Er.displayName="NetworkSVGOverlay";const Ir={top:20,right:80,bottom:20,left:80},Nr={top:40,right:40,bottom:40,left:40},Wr=new Set(["chord","force","circlepack","orbit"]),zr=[800,600],Rr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Yr({data:n}){var i,o,r,l,s,a;if("edge"===n.nodeOrEdge){const t=n.data;return t?e("div",{className:"semiotic-tooltip",style:Rr,children:[e("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&e("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const c=n.data;if(!c)return null;const u=c.__hierarchyNode;if(u){const n=[];let s=u;for(;s;){const t=null!==(l=null!==(o=null===(i=s.data)||void 0===i?void 0:i.name)&&void 0!==o?o:null===(r=s.data)||void 0===r?void 0:r.id)&&void 0!==l?l:c.id;null!=t&&n.unshift(t+""),s=s.parent}n.length>1&&n.shift();const a=n.length-1;return e("div",{className:"semiotic-tooltip",style:Rr,children:[t("div",{children:n.map((n,i)=>e("span",{children:[i>0&&t("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),i===a?t("strong",{children:n}):t("span",{style:{opacity:.7},children:n})]},i))}),null!=c.value&&c.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const d=((null===(s=c.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=c.targetLinks)||void 0===a?void 0:a.length)||0),h=(c.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(c.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return e("div",{className:"semiotic-tooltip",style:Rr,children:[t("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),d>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,h!==d&&` (weighted: ${h.toLocaleString()})`]})]})}const Fr=f(function(n,i){var s,c,u,h,f,g,p,v,m,x,b,k,w,A,_,S,M,P;const{chartType:C,nodes:E,edges:T,data:D,initialEdges:O,nodeIDAccessor:L="id",sourceAccessor:$="source",targetAccessor:I="target",valueAccessor:W="value",edgeIdAccessor:z,childrenAccessor:R,hierarchySum:Y,orientation:F="horizontal",nodeAlign:j="justify",nodePaddingRatio:B=.05,nodeWidth:H=15,iterations:X=300,forceStrength:G=.1,padAngle:V=.01,groupWidth:q=20,sortGroups:U,edgeSort:K,treeOrientation:Z="vertical",edgeType:Q="curve",padding:J,paddingTop:tt,tensionConfig:et,showParticles:nt=!1,particleStyle:it,nodeStyle:ot,edgeStyle:rt,colorBy:lt,colorScheme:st="category10",edgeColorBy:at="source",edgeOpacity:ct=.5,colorByDepth:ut=!1,nodeSize:dt=8,nodeSizeRange:ht=[5,20],nodeLabel:gt,showLabels:yt=!0,labelMode:pt,size:mt=zr,responsiveWidth:xt,responsiveHeight:bt,margin:kt,className:wt,background:At,enableHover:_t=!0,tooltipContent:St,customHoverBehavior:Mt,customClickBehavior:Pt,onObservation:Ct,chartId:Et,onTopologyChange:Tt,annotations:Dt,svgAnnotationRules:Ot,legend:Lt,legendPosition:$t,legendHoverBehavior:It,legendClickBehavior:Nt,legendHighlightedCategory:Wt,legendIsolatedCategories:zt,title:Rt,foregroundGraphics:Yt,backgroundGraphics:Ft,decay:jt,pulse:Bt,transition:Ht,animate:Xt,staleness:Gt,thresholds:Vt,accessibleTable:qt=!0,description:Ut,summary:Kt,orbitMode:Zt,orbitSize:Qt,orbitSpeed:Jt,orbitRevolution:te,orbitRevolutionStyle:ee,orbitEccentricity:ie,orbitShowRings:oe,orbitAnimated:re,customNetworkLayout:le,layoutConfig:se}=n,ae=Wr.has(C)?Nr:Ir,ce=o(!0),ue=wi({sizeProp:mt,responsiveWidth:xt,responsiveHeight:bt,userMargin:kt,marginDefault:ae,foregroundGraphics:Yt,backgroundGraphics:Ft,animate:Xt,transitionProp:Ht,themeDirtyRef:ce}),{reducedMotionRef:de,responsiveRef:he,size:fe,margin:ge,adjustedWidth:pe,adjustedHeight:ve,resolvedForeground:me,resolvedBackground:xe,transition:be,introEnabled:ke,tableId:we,rafRef:Ae,renderFnRef:_e,scheduleRender:Se,currentTheme:Me}=ue,Pe=Bn(),Ee=Vn(),Te=r(()=>ft(E),[E]),De=r(()=>Array.isArray(T)?ft(T):T,[T]),Oe=r(()=>Object.assign(Object.assign({},Qi),et),[et]),Le=r(()=>Object.assign(Object.assign({},Ji),it),[it]),$e=r(()=>{var t;return{chartType:C,nodeIDAccessor:L,sourceAccessor:$,targetAccessor:I,valueAccessor:W,edgeIdAccessor:z,childrenAccessor:R,hierarchySum:Y,orientation:F,nodeAlign:j,nodePaddingRatio:B,nodeWidth:H,iterations:X,forceStrength:G,padAngle:V,groupWidth:q,sortGroups:U,edgeSort:K,treeOrientation:Z,edgeType:Q,padding:J,paddingTop:tt,tensionConfig:Oe,showParticles:nt,particleStyle:Le,nodeStyle:ot,edgeStyle:rt,nodeLabel:gt,showLabels:yt,labelMode:pt,colorBy:lt,colorScheme:st,themeCategorical:null===(t=null==Me?void 0:Me.colors)||void 0===t?void 0:t.categorical,themeSemantic:vt(Me),edgeColorBy:at,edgeOpacity:ct,colorByDepth:ut,nodeSize:dt,nodeSizeRange:ht,decay:jt,pulse:Bt,transition:be,introAnimation:ke,staleness:Gt,thresholds:Vt,orbitMode:Zt,orbitSize:Qt,orbitSpeed:Jt,orbitRevolution:te,orbitRevolutionStyle:ee,orbitEccentricity:ie,orbitShowRings:oe,orbitAnimated:re,customNetworkLayout:le,layoutConfig:se}},[C,L,$,I,W,R,Y,F,j,B,H,X,G,V,q,U,K,Z,Q,J,tt,Oe,nt,Le,ot,rt,gt,yt,pt,lt,st,at,ct,ut,dt,ht,jt,Bt,null==be?void 0:be.duration,null==be?void 0:be.easing,ke,Gt,Vt,Zt,Qt,Jt,te,ee,ie,oe,re,Me,le,se]),Ie=Un($e),Ne=o(null),We=o(0),ze=o(0),Re=o(!1),Ye=o(null);Ye.current||(Ye.current=new br(Ie));const[Fe,je]=d(null),[Be,He]=d(0),[qe,Ke]=d(0),[Qe,Je]=d(!1),[tn,en]=d(null),nn=o(null),on=o(new Map),rn=o(0),ln=a(t=>{if("function"==typeof lt)return lt(t)+"";if("string"==typeof lt&&t.data){const e=t.data[lt];if(void 0!==e){if(!on.current.has(e+"")){const t=Array.isArray(st)?st:ne;on.current.set(e+"",t[rn.current++%t.length])}return on.current.get(e+"")}}if(on.current.has(t.id))return on.current.get(t.id);const e=Array.isArray(st)?st:ne,n=lt?e[rn.current++%e.length]:e[0];return on.current.set(t.id,n),n},[lt,st]),sn=(null===(s=null==Me?void 0:Me.colors)||void 0===s?void 0:s.border)||(null===(c=null==Me?void 0:Me.colors)||void 0===c?void 0:c.secondary)||(null===(u=null==Me?void 0:Me.colors)||void 0===u?void 0:u.primary)||"#999",an=a(t=>{if("function"==typeof at)return at(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===at&&n?ln(n):e?ln(e):sn},[at,ln,sn]),cn=a(t=>{if(!(null==it?void 0:it.colorBy))return an(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Le.colorBy&&n?ln(n):e?ln(e):sn},[null==it?void 0:it.colorBy,Le.colorBy,ln,an,sn]),un="sankey"===C&&nt||!!Bt||null!==(f=null===(h=Ye.current)||void 0===h?void 0:h.isAnimating)&&void 0!==f&&f;l(()=>{var t;null===(t=Ye.current)||void 0===t||t.updateConfig(Ie),ce.current=!0,Se()},[Ie,Se]);const dn=a(()=>{var t,e;en(null!==(e=null===(t=Ye.current)||void 0===t?void 0:t.customLayoutOverlays)&&void 0!==e?e:null)},[]);l(()=>{var t;const e=Ye.current;if(e){e.buildScene([pe,ve]),dn();for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill);ce.current=!0,Se()}},[Me,pe,ve,Se,dn]);const hn=a(()=>{var t;const e=Ye.current;if(!e)return;e.runLayout([pe,ve]),e.buildScene([pe,ve]),dn(),ce.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill);const n=Array.isArray(st)?st:ne,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];on.current.has(e.id)||on.current.set(e.id,n[t%n.length])}if(rn.current=i.length,He(e.layoutVersion),Tt){const{nodes:t,edges:n}=e.getLayoutData();Tt(t,n)}},[pe,ve,Tt,st,dn]),fn=a(t=>{if(null==t||"object"!=typeof t)return;const e=Ye.current;e&&(e.ingestEdge(t)&&hn(),Se())},[hn,Se]),gn=a(t=>{const e=Ye.current;if(!e)return;let n=!1;for(const i of t)null!=i&&"object"==typeof i&&e.ingestEdge(i)&&(n=!0);n&&hn(),Se()},[hn,Se]),yn=a(()=>{var t;null===(t=Ye.current)||void 0===t||t.clear(),on.current.clear(),rn.current=0,He(0),je(null),nn.current=null,ce.current=!0,Se()},[Se]),pn=a(()=>{const t=Ye.current;t&&(t.tension+=999,hn(),Se())},[hn,Se]);y(i,()=>({push:fn,pushMany:gn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Ye.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=nn.current)||void 0===i?void 0:i.data)?"function"==typeof L?L(nn.current.data):nn.current.data[L]:void 0;nn.current&&"node"===nn.current.nodeOrEdge&&e===t&&(nn.current=null,je(null)),on.current.delete(t),hn(),ce.current=!0,Se()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ye.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(nn.current&&"edge"===nn.current.nodeOrEdge){const n=nn.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!z||!n||("function"==typeof z?z:t=>null==t?void 0:t[z])(n)===t,i&&(nn.current=null,je(null))}hn(),ce.current=!0,Se()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Ye.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(ce.current=!0,Se()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Ye.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(hn(),ce.current=!0,Se()),r},clear:yn,getTopology:()=>{var t,e;return null!==(e=null===(t=Ye.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Ye.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:pn,getTension:()=>{var t,e;return null!==(e=null===(t=Ye.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[fn,gn,yn,pn,hn,Se]);const vn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(C),mn=vn?D||(Array.isArray(T)?void 0:T):void 0;l(()=>{var t;const e=Ye.current;if(e)if(vn&&mn)e.ingestHierarchy(mn,[pe,ve]),e.buildScene([pe,ve]),dn(),ce.current=!0,Se();else{const n=Te,i=Array.isArray(De)?De:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[pe,ve]),e.buildScene([pe,ve]),dn();for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&on.current.set(n.id,n.style.fill+"");const o=Array.isArray(st)?st:ne,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];on.current.has(e.id)||on.current.set(e.id,o[t%o.length])}rn.current=r.length,ce.current=!0,Se()}},[Te,De,D,mn,vn,pe,ve,Ie,Se,st,dn]),l(()=>{O&&O.length>0&&gn(O)},[]);const xn=a(t=>{if(Mt&&Mt(t),Ct){const e=Date.now();Ct(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Et}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Et})}},[Mt,Ct,Et]),bn=a(t=>{if(Pt&&Pt(t),Ct){const e=Date.now();Ct(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Et}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Et})}},[Pt,Ct,Et]),{hoverHandlerRef:kn,hoverLeaveRef:wn,onPointerMove:An,onPointerLeave:_n}=ue;kn.current=t=>{if(!_t)return;const e=Ne.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ge.left,o=t.clientY-n.top-ge.top;if(0>i||i>pe||0>o||o>ve)return void(nn.current&&(nn.current=null,je(null),xn&&(xn(null),ce.current=!0),Se()));const r=Ye.current;if(!r)return;const l=wr(r.sceneNodes,r.sceneEdges,i,o);if(!l)return void(nn.current&&(nn.current=null,je(null),xn&&(xn(null),ce.current=!0),Se()));const s=zi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});nn.current=s,je(s),xn&&(xn(s),ce.current=!0),Se()},wn.current=()=>{nn.current&&(nn.current=null,je(null),xn&&(xn(null),ce.current=!0),Se())};const Sn=o(()=>{});Sn.current=t=>{if(!Pt&&!Ct)return;const e=Ne.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ge.left,o=t.clientY-n.top-ge.top;if(0>i||i>pe||0>o||o>ve)return;const r=Ye.current;if(!r)return;const l=wr(r.sceneNodes,r.sceneEdges,i,o);bn(l?zi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)};const Mn=a(t=>Sn.current(t),[]),Pn=o(-1),Cn=o(null),En=o(-1),Tn=a(t=>{var e;const n=Ye.current;if(!n)return;const i=function(t){var e,n,i,o,r,l;const s=[];for(const a of t)"circle"===a.type&&null!=a.cx?s.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(n=null===(e=a.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===a.type&&null!=a.x?s.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=null===(i=a.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"}):"arc"===a.type&&null!=a.cx&&s.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(l=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==l?l:"_default"});return s.sort((t,e)=>t.x-e.x||t.y-e.y),s}(n.sceneNodes);if(0===i.length)return;const o=Xe(i),r=Pn.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),Pn.current=0,En.current=-1;const e=o.flat[0];Cn.current={shape:e.shape,w:e.w,h:e.h};const n=zi(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return nn.current=n,je(n),xn&&(xn(n),ce.current=!0),void Se()}const l=Ge(o,r),s=function(t,e,n,i,o){var r,l,s;const a=n.flat[e.flatIndex];if(!a)return Ve(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(l=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const l=t.flat[r];if(l===e)continue;const s=l.x-e.x,a=l.y-e.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(s)}if(!c)continue;const u=s*s+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n;const i=t+"",o=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,r=Ue(e.source),l=Ue(e.target),s=null!=r,a=null!=l;s&&r+""===i&&a?o.push(l+""):a&&l+""===i&&s&&o.push(r+"")}return o}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(s=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==s?s:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=Ve(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],En);if(null===s)return;if(t.preventDefault(),0>s)return Pn.current=-1,Cn.current=null,En.current=-1,nn.current=null,je(null),xn&&(xn(null),ce.current=!0),void Se();Pn.current=s;const a=o.flat[s];Cn.current={shape:a.shape,w:a.w,h:a.h};const c={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};nn.current=c,je(c),xn&&(xn(c),ce.current=!0),Se()},[xn,Se]),Dn=a(t=>{Pn.current=-1,Cn.current=null,An(t)},[An]);_e.current=()=>{var t,e,n,i,o,r,l;Ae.current=0;const s=Ne.current;if(!s)return;const a=s.getContext("2d");if(!a)return;const c=Ye.current;if(!c)return;const u=performance.now(),d=We.current?Math.min((u-We.current)/1e3,.1):.016;We.current=u;const h=c.advanceTransition(de.current?u+1e6:u),f=!de.current&&h,g=!de.current&&c.tickAnimation([pe,ve],d);(h||ce.current||g)&&c.buildScene([pe,ve]);const y=_i();if(!Ai(s,fe,ge,y))return;if(a.clearRect(-ge.left,-ge.top,fe[0],fe[1]),At){const t=Ce(a,At);t&&(a.fillStyle=t,a.fillRect(0,0,pe,ve))}jt&&c.applyDecay(),Bt&&c.applyPulse(u),Vt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Gt?void 0:Gt.threshold)&&void 0!==t?t:5e3,v=Gt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Gt?void 0:Gt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Dr(t,n);break;case"line":Or(t,n);break;case"ribbon":Lr(t,n);break;case"curved":$r(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),Ei(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Ti(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Ce(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),nt&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const l=null!==(o=i.spawnRate)&&void 0!==o?o:Ji.spawnRate,s=null!==(r=i.maxPerEdge)&&void 0!==r?r:Ji.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=s)continue;const r=o.value*l*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<s;e++)t.spawn(i)}}(c.particlePool,t,d,Le);const e=.5*(null!==(n=Le.speedMultiplier)&&void 0!==n?n:1);let i;if(Le.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,l;const s=null!==(r=i.radius)&&void 0!==r?r:Ji.radius,a=null!==(l=i.opacity)&&void 0!==l?l:Ji.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const l=e.particles[r];if(!l.active)continue;const a=n[l.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):Ce(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(l.x,l.y,s,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Le,cn)}}v&&(a.globalAlpha=1);const m=ce.current;if(ce.current=!1,m||f||g){const t=Ne.current;t&&t.setAttribute("aria-label",ii(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(l=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==l?l:0,"Network chart"))}const x=m||f||g||Re.current;x&&u-ze.current>=33?(Ke(t=>t+1),ze.current=u,Re.current=!1):Re.current=!!x,(un||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Re.current)&&(Ae.current=requestAnimationFrame(()=>_e.current()))},qn({hydrated:Pe,wasHydratingFromSSR:Ee,storeRef:Ye,dirtyRef:ce,renderFnRef:_e}),l(()=>{ce.current=!0,Se()},[C,pe,ve,At,Se]),Ze(Gt,Ye,ce,Se,Qe,Je);const On=_t&&Fe?t(xi,{x:Fe.x,y:Fe.y,containerWidth:pe,containerHeight:ve,margin:ge,className:"stream-network-tooltip",zIndex:2,children:St?St(Fe):t(Yr,{data:Fe})}):null;if(Fn||!Pe&&Ee){const n=Ye.current;if(n){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(C),e=t?D||(Array.isArray(T)?void 0:T):void 0;if(t&&e)n.ingestHierarchy(e,[pe,ve]),n.buildScene([pe,ve]);else{const t=Te,e=Array.isArray(De)?De:[];(t.length>0||e.length>0)&&(n.ingestBounded(t,e,[pe,ve]),n.buildScene([pe,ve]))}}const i=null!==(g=null==n?void 0:n.sceneNodes)&&void 0!==g?g:[],o=null!==(p=null==n?void 0:n.sceneEdges)&&void 0!==p?p:[],r=null!==(v=null==n?void 0:n.labels)&&void 0!==v?v:[];return e("div",{ref:he,className:"stream-network-frame"+(wt?" "+wt:""),role:"img","aria-label":Ut||("string"==typeof Rt?Rt:"Network chart"),style:{position:"relative",width:xt?"100%":fe[0],height:bt?"100%":fe[1]},children:[t(gi,{summary:Kt}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:fe[0],height:fe[1],style:{position:"absolute",left:0,top:0},children:[xe&&t("g",{transform:`translate(${ge.left},${ge.top})`,children:xe}),e("g",{transform:`translate(${ge.left},${ge.top})`,children:[At&&t("rect",{x:0,y:0,width:pe,height:ve,fill:At}),o.map((e,n)=>function(e,n){switch(e.type){case"line":return t("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t("path",{d:i.pathD,fill:Yn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t("path",{d:i.pathD,fill:Yn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t("path",{d:i.pathD,fill:Yn(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),i.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:Yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:Yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=N().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Rn)||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:Yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),r.map((e,n)=>function(e,n){return t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t(Er,{width:pe,height:ve,totalWidth:fe[0],totalHeight:fe[1],margin:ge,labels:r,sceneNodes:i,title:Rt,legend:Lt,legendPosition:$t,legendHoverBehavior:It,legendClickBehavior:Nt,legendHighlightedCategory:Wt,legendIsolatedCategories:zt,foregroundGraphics:ye(me,null===(m=Ye.current)||void 0===m?void 0:m.customLayoutOverlays),annotations:Dt,svgAnnotationRules:Ot,annotationFrame:0})]})}const Ln=Ye.current;return e("div",{ref:he,className:"stream-network-frame"+(wt?" "+wt:""),role:"group","aria-label":Ut||("string"==typeof Rt?Rt:"Network chart"),tabIndex:0,style:{position:"relative",width:xt?"100%":fe[0],height:bt?"100%":fe[1],overflow:"visible"},onKeyDown:Tn,children:[qt&&t(yi,{tableId:we}),qt&&t(fi,{nodes:null!==(x=null==Ln?void 0:Ln.sceneNodes)&&void 0!==x?x:[],edges:null!==(b=null==Ln?void 0:Ln.sceneEdges)&&void 0!==b?b:[],chartType:"Network chart",tableId:we,chartTitle:"string"==typeof Rt?Rt:void 0}),t(gi,{summary:Kt}),e("div",{role:"img","aria-label":Ut||("string"==typeof Rt?Rt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:_t?Dn:void 0,onMouseLeave:_t?_n:void 0,onClick:Pt||Ct?Mn:void 0,children:[xe&&t("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:fe[0],height:fe[1],pointerEvents:"none",overflow:"visible"},children:t("g",{transform:`translate(${ge.left},${ge.top})`,children:xe})}),t("canvas",{ref:Ne,"aria-label":ii(null!==(w=null===(k=null==Ln?void 0:Ln.sceneNodes)||void 0===k?void 0:k.length)&&void 0!==w?w:0,null!==(_=null===(A=null==Ln?void 0:Ln.sceneEdges)||void 0===A?void 0:A.length)&&void 0!==_?_:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t(pi,{hoverPoint:Fe}),t(Er,{width:pe,height:ve,totalWidth:fe[0],totalHeight:fe[1],margin:ge,labels:(null==Ln?void 0:Ln.labels)||[],sceneNodes:null==Ln?void 0:Ln.sceneNodes,title:Rt,legend:Lt,legendPosition:$t,legendHoverBehavior:It,legendClickBehavior:Nt,legendHighlightedCategory:Wt,legendIsolatedCategories:zt,foregroundGraphics:ye(me,tn),annotations:Dt,svgAnnotationRules:Ot,annotationFrame:qe}),t(mi,{active:Pn.current>=0,hoverPoint:Fe,margin:ge,size:fe,shape:null===(S=Cn.current)||void 0===S?void 0:S.shape,width:null===(M=Cn.current)||void 0===M?void 0:M.w,height:null===(P=Cn.current)||void 0===P?void 0:P.h}),On,(null==Gt?void 0:Gt.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Gt.badgePosition?{top:4,left:4}:"bottom-left"===Gt.badgePosition?{bottom:4,left:4}:"bottom-right"===Gt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Qe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Qe?"STALE":"LIVE"})]})]})});function jr(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function Br(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Fr.displayName="StreamNetworkFrame";const[Hr,Xr]=yt(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=Br(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=Br(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[Gr,Vr]=yt(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 qr(t){const e=g(),n=t.clientId||e,{name:i}=t,o=Xr(t=>t.selections.get(i)),l=Xr(t=>t.setClause),s=Xr(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(jr(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};l(i,{clientId:n,type:"point",fields:e})},[n,i,l]),selectInterval:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};l(i,{clientId:n,type:"interval",fields:e})},[n,i,l]),clear:a(()=>{s(i,n)},[s,i,n]),clientId:n}}function Ur(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function Kr(t,e,n){var i;const o=null!==(i=t.xValue)&&void 0!==i?i:null==e?void 0:e[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function Zr(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function Qr({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:s,chartId:c,onClick:u,hoverHighlight:h,colorByField:f}){const y=g(),p=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,n),v=qr({name:(null==t?void 0:t.name)||"__unused__"}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:l}=qr({name:e});return{onHover:a(t=>{if(!t)return void l();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&r(e)},[n,r,l,e]),predicate:i,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||n||[]}),x=Vr(t=>t.pushObservation),b=t?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=d(null),A=f||n[0],_=r(()=>{if(!h||null==k||!A)return null;const t=k,e=A;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,k,A]),S=a(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const n=Kr(t,e,p.xField);null!=n&&function(t,e,n){const i=An.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(An={positions:new Map(An.positions).set(t,{xValue:e,sourceId:n})},Sn())}(p.name||"hover",n,y)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&Mn(p.name||"hover",y),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(h&&A)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[A];w(null!=n?n+"":null)}else w(null);if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:c};if(t){const r=Zr(t),l=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),x&&x(t)}}},[e,m,p,y,o,s,c,x,h,A]),M=a(t=>{var e,n,i,r;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=Kr(t,e,p.xField);null!=n&&function(t,e,n){const i=An.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(An.positions);return e.delete(t),An={positions:e},Sn(),!1}An={positions:new Map(An.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Sn()}(p.name||"hover",n,y)}if(t&&u){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),u(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:c};if(t){const n=Zr(t),l=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),x&&x(t)}}},[u,o,x,s,c,p,y]);return l(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{Pn(t,y),Mn(t,y)}},[null==p?void 0:p.mode,null==p?void 0:p.name,y]),{activeSelectionHook:b,hoverSelectionHook:_,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:y}}const Jr={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function tl(t,e,n){var i,o,r,l,s,a,c;const u=Jr[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:el(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function el(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}const nl={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"},il={opacity:.7,marginRight:4};function ol(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function rl(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function ll(t={}){const{timeAccessor:n,valueAccessor:i,xLabel:o="x",yLabel:r="y"}=t;return t=>{var l;const s=null!==(l=null==t?void 0:t.data)&&void 0!==l?l:null,a=ol(s,n,"time"),c=ol(s,i,"value");return e("div",{className:"semiotic-tooltip",style:nl,children:[e("div",{children:[e("span",{style:il,children:[o,":"]}),rl(a)]}),e("div",{children:[e("span",{style:il,children:[r,":"]}),rl(c)]})]})}}"undefined"!=typeof process&&process;const sl={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},al={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function cl(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},sl),{width:n,height:i}),children:o||"No data available"}):null}function ul(e,n,i){if(!e)return null;const o=Math.min(5,Math.floor(i/40)),r=Math.max(8,Math.floor(i/(3*o))),l=Math.max(6,Math.floor(i/(2.5*o))),s=Math.floor((i-(o*(r+l)-l))/2);return t("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,i)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},al),{position:"absolute",top:s+i*(r+l),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}function dl(t,e){var n;return null!=t?t:Math.max(null!==(n=null==e?void 0:e.length)&&void 0!==n?n:0,200)}const hl=f(function(e,n){var i,r,l,s,c;const u=tl(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:g="right",windowMode:p="sliding",windowSize:v,data:m,timeAccessor:x,valueAccessor:b,timeExtent:k,valueExtent:w,extentPadding:A,stroke:_="#007bff",strokeWidth:S=2,strokeDasharray:M,opacity:P,background:C,tooltipContent:E,tooltip:T,onHover:D,annotations:O,svgAnnotationRules:L,tickFormatTime:$,tickFormatValue:I,decay:N,pulse:W,staleness:z,transition:R,linkedHover:Y,selection:F,onObservation:j,chartId:B,loading:H,emptyContent:X,emphasis:G,legendPosition:V}=e,q=u.showAxes,U=u.enableHover,K=null!=h?h:u.marginDefaults,Z=null!=d?d:[u.width,u.height],Q=null!==(c=null!=E?E:T)&&void 0!==c?c:ll({timeAccessor:x,valueAccessor:b}),J=o(null),{customHoverBehavior:tt}=Qr({selection:F,linkedHover:Y,unwrapData:!0,onObservation:j,chartType:"RealtimeLineChart",chartId:B}),et=a(t=>{D&&D(t),tt(t)},[D,tt]);y(n,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=J.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=J.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const nt=ul(H,Z[0],Z[1]),it=nt?null:cl(m,Z[0],Z[1],X),ot={stroke:_,strokeWidth:S,strokeDasharray:M};null!=P&&(ot.opacity=P);const rt=dl(v,m);return nt||it||t(Zi,{ref:J,chartType:"line",runtimeMode:"streaming",size:Z,margin:K,className:G?`${f||""} semiotic-emphasis-${G}`.trim():f,arrowOfTime:g,windowMode:p,windowSize:rt,data:m,timeAccessor:x,valueAccessor:b,xExtent:k,yExtent:w,extentPadding:A,lineStyle:ot,showAxes:q,background:C,hoverAnnotation:U,tooltipContent:Q,customHoverBehavior:et,annotations:O,svgAnnotationRules:L,tickFormatTime:$,tickFormatValue:I,decay:N,pulse:W,staleness:z,transition:R,pointIdAccessor:e.pointIdAccessor,legendPosition:V})});hl.displayName="RealtimeLineChart";const fl=f(function(e,n){var i,l,s,c,u;const d=tl(e.mode,{width:null!==(l=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==l?l:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover}),{binSize:h,size:f,margin:g,className:p,arrowOfTime:v="right",windowMode:m="sliding",windowSize:x,data:b,timeAccessor:k,valueAccessor:w,timeExtent:A,valueExtent:_,extentPadding:S,categoryAccessor:M,colors:P,fill:C,stroke:E,strokeWidth:T,opacity:D,gap:O,background:L,tooltipContent:$,tooltip:I,onHover:N,annotations:W,svgAnnotationRules:z,tickFormatTime:R,tickFormatValue:Y,linkedHover:F,selection:j,decay:B,pulse:H,staleness:X,transition:G,onObservation:V,chartId:q,loading:U,emptyContent:K,emphasis:Z,legendPosition:Q,brush:J,onBrush:tt,linkedBrush:et}=e,nt=d.showAxes,it=d.enableHover,ot=null!=g?g:d.marginDefaults,rt=null!=f?f:[d.width,d.height],lt=null!==(u=null!=$?$:I)&&void 0!==u?u:ll({timeAccessor:k,valueAccessor:w}),st=o(null),{customHoverBehavior:at}=Qr({selection:j,linkedHover:F,unwrapData:!0,onObservation:V,chartType:"RealtimeTemporalHistogram",chartId:q}),ct=a(t=>{N&&N(t),at(t)},[N,at]),ut=!0===J?{dimension:"x",snap:"bin"}:"x"===J?{dimension:"x"}:"object"==typeof J?J:void 0,dt=(ht=et)?"string"==typeof ht?{name:ht}:ht:null;var ht;const ft=function(t){const{name:e,xField:n,yField:i}=t,{predicate:o,isActive:l,selectInterval:s,clear:c}=qr({name:e}),u=n&&i?"xyBrush":n?"xBrush":"yBrush",d=a(t=>{if(!t)return void c();const e={};"xyBrush"===u&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),i&&(e[i]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&Ur(t)?n&&(e[n]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&Ur(t)&&i&&(e[i]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&s(e)},[u,n,i,s,c]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:o,isActive:l,clear:c}}(Object.assign({name:(null==dt?void 0:dt.name)||"__unused_hist_brush__",xField:(null==dt?void 0:dt.xField)||("string"==typeof k?k:"time")},(null==dt?void 0:dt.yField)?{yField:dt.yField}:{})),gt=o(ft.brushInteraction);gt.current=ft.brushInteraction;const yt=a(t=>{if(tt&&tt(t),V&&V(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:q}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:q}),dt){const e=gt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[tt,V,q,dt]);y(n,()=>({push:t=>{var e;return null===(e=st.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=st.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=st.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=st.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=st.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=st.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=st.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const pt=ul(U,rt[0],rt[1]),vt=pt?null:cl(b,rt[0],rt[1],K),mt={};null!=C&&(mt.fill=C),null!=E&&(mt.stroke=E),null!=T&&(mt.strokeWidth=T),null!=D&&(mt.opacity=D),null!=O&&(mt.gap=O);const xt=Z?`${p||""} semiotic-emphasis-${Z}`.trim():p,bt=dl(x,b);return pt||vt||t(Zi,{ref:st,chartType:"bar",runtimeMode:"streaming",size:rt,margin:ot,className:xt,arrowOfTime:v,windowMode:m,windowSize:bt,data:b,timeAccessor:k,valueAccessor:w,xExtent:A,yExtent:_,extentPadding:S,binSize:h,categoryAccessor:M,barColors:P,barStyle:mt,showAxes:nt,background:L,hoverAnnotation:it,tooltipContent:lt,customHoverBehavior:ct,annotations:W,svgAnnotationRules:z,tickFormatTime:R,tickFormatValue:Y,decay:B,pulse:H,staleness:X,transition:G,pointIdAccessor:e.pointIdAccessor,legendPosition:Q,brush:ut||(et?{dimension:"x"}:void 0),onBrush:ut||et?yt:void 0})});fl.displayName="RealtimeTemporalHistogram";const gl=fl,yl=f(function(e,n){var i,r,l,s,c;const u=tl(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:g="right",windowMode:p="sliding",windowSize:v,data:m,timeAccessor:x,valueAccessor:b,timeExtent:k,valueExtent:w,extentPadding:A,categoryAccessor:_,colors:S,radius:M,fill:P,opacity:C,stroke:E,strokeWidth:T,background:D,tooltipContent:O,tooltip:L,onHover:$,annotations:I,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:z,linkedHover:R,selection:Y,onObservation:F,chartId:j,loading:B,emptyContent:H,emphasis:X,legendPosition:G}=e,V=u.showAxes,q=u.enableHover,U=null!=h?h:u.marginDefaults,K=null!=d?d:[u.width,u.height],Z=null!==(c=null!=O?O:L)&&void 0!==c?c:ll({timeAccessor:x,valueAccessor:b}),Q=o(null),{customHoverBehavior:J}=Qr({selection:Y,linkedHover:R,unwrapData:!0,onObservation:F,chartType:"RealtimeSwarmChart",chartId:j}),tt=a(t=>{$&&$(t),J(t)},[$,J]);y(n,()=>({push:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Q.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Q.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const et=ul(B,K[0],K[1]),nt=et?null:cl(m,K[0],K[1],H),it={};null!=M&&(it.radius=M),null!=P&&(it.fill=P),null!=C&&(it.opacity=C),null!=E&&(it.stroke=E),null!=T&&(it.strokeWidth=T);const ot=X?`${f||""} semiotic-emphasis-${X}`.trim():f,rt=dl(v,m);return et||nt||t(Zi,{ref:Q,chartType:"swarm",runtimeMode:"streaming",size:K,margin:U,className:ot,arrowOfTime:g,windowMode:p,windowSize:rt,data:m,timeAccessor:x,valueAccessor:b,xExtent:k,yExtent:w,extentPadding:A,categoryAccessor:_,barColors:S,swarmStyle:it,showAxes:V,background:D,hoverAnnotation:q,tooltipContent:Z,customHoverBehavior:tt,annotations:I,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:z,legendPosition:G,pointIdAccessor:e.pointIdAccessor})});yl.displayName="RealtimeSwarmChart";const pl=f(function(n,i){var r,l,s,c,u;const d=tl(n.mode,{width:null!==(l=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==l?l:n.width,height:null!==(c=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:f,className:g,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:A,extentPadding:_,positiveColor:S,negativeColor:M,connectorStroke:P,connectorWidth:C,gap:E,stroke:T,strokeWidth:D,opacity:O,background:L,tooltipContent:$,tooltip:I,onHover:N,annotations:W,svgAnnotationRules:z,tickFormatTime:R,tickFormatValue:Y,linkedHover:F,selection:j,onObservation:B,chartId:H,loading:X,emptyContent:G,emphasis:V,legendPosition:q}=n,U=d.showAxes,K=d.enableHover,Z=null!=f?f:d.marginDefaults,Q=null!=h?h:[d.width,d.height],J=null!==(u=null!=$?$:I)&&void 0!==u?u:function(n={}){const{timeAccessor:i,valueAccessor:o}=n;return n=>{var r,l;const s=null!==(r=null==n?void 0:n.data)&&void 0!==r?r:null,a=ol(s,i,"time"),c=null!==(l=null==s?void 0:s.delta)&&void 0!==l?l:ol(s,o,"value"),u=null==s?void 0:s.cumEnd,d="number"==typeof c?0>c?rl(c):"+"+rl(c):rl(c);return e("div",{className:"semiotic-tooltip",style:nl,children:[e("div",{children:[t("span",{style:il,children:"x:"}),rl(a)]}),e("div",{children:[t("span",{style:il,children:"Δ:"}),d]}),null!=u&&e("div",{children:[t("span",{style:il,children:"total:"}),rl(u)]})]})}}({timeAccessor:b,valueAccessor:k}),tt=o(null),{customHoverBehavior:et}=Qr({selection:j,linkedHover:F,unwrapData:!0,onObservation:B,chartType:"RealtimeWaterfallChart",chartId:H}),nt=a(t=>{N&&N(t),et(t)},[N,et]);y(i,()=>({push:t=>{var e;return null===(e=tt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=tt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=tt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=tt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=tt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=tt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=tt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const it=ul(X,Q[0],Q[1]),ot=it?null:cl(x,Q[0],Q[1],G),rt={};null!=S&&(rt.positiveColor=S),null!=M&&(rt.negativeColor=M),null!=P&&(rt.connectorStroke=P),null!=C&&(rt.connectorWidth=C),null!=E&&(rt.gap=E),null!=T&&(rt.stroke=T),null!=D&&(rt.strokeWidth=D),null!=O&&(rt.opacity=O);const lt=V?`${g||""} semiotic-emphasis-${V}`.trim():g,st=dl(m,x);return it||ot||t(Zi,{ref:tt,chartType:"waterfall",runtimeMode:"streaming",size:Q,margin:Z,className:lt,arrowOfTime:p,windowMode:v,windowSize:st,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:A,extentPadding:_,waterfallStyle:rt,showAxes:U,background:L,hoverAnnotation:K,tooltipContent:J,customHoverBehavior:nt,annotations:W,svgAnnotationRules:z,tickFormatTime:R,tickFormatValue:Y,legendPosition:q,pointIdAccessor:n.pointIdAccessor})});pl.displayName="RealtimeWaterfallChart";const vl=f(function(n,i){var r,l,s,c,u;const d=tl(n.mode,{width:null!==(l=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==l?l:n.width,height:null!==(c=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:f,className:g,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m,data:x,timeAccessor:b,valueAccessor:k,categoryAccessor:w,timeExtent:A,valueExtent:_,extentPadding:S,heatmapXBins:M=20,heatmapYBins:P=20,aggregation:C="count",background:E,tooltipContent:T,tooltip:D,onHover:O,annotations:L,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:N,decay:W,pulse:z,staleness:R,linkedHover:Y,selection:F,onObservation:j,chartId:B,loading:H,emptyContent:X,emphasis:G,legendPosition:V}=n,q=d.showAxes,U=d.enableHover,K=null!=f?f:d.marginDefaults,Z=null!=h?h:[d.width,d.height],Q=null!==(u=null!=T?T:D)&&void 0!==u?u:function(n={}){const{timeAccessor:i,valueAccessor:o,xLabel:r="x",yLabel:l="y"}=n;return n=>{var s,a,c,u;const d=null!==(s=null==n?void 0:n.data)&&void 0!==s?s:null,h=null!==(a=null==d?void 0:d.xCenter)&&void 0!==a?a:ol(d,i,"time"),f=null!==(c=null==d?void 0:d.yCenter)&&void 0!==c?c:ol(d,o,"value"),g=null==d?void 0:d.count,y=null==d?void 0:d.sum,p=null==d?void 0:d.value,v=null!==(u=null==d?void 0:d.agg)&&void 0!==u?u:"count";return e("div",{className:"semiotic-tooltip",style:nl,children:[e("div",{children:[e("span",{style:il,children:[r,":"]}),rl(h)]}),e("div",{children:[e("span",{style:il,children:[l,":"]}),rl(f)]}),null!=g&&e("div",{children:[t("span",{style:il,children:"count:"}),rl(g)]}),"sum"===v&&null!=y&&e("div",{children:[t("span",{style:il,children:"sum:"}),rl(y)]}),"mean"===v&&null!=p&&e("div",{children:[t("span",{style:il,children:"mean:"}),rl(p)]})]})}}({timeAccessor:b,valueAccessor:k}),J=o(null),{customHoverBehavior:tt}=Qr({selection:F,linkedHover:Y,unwrapData:!0,onObservation:j,chartType:"RealtimeHeatmap",chartId:B}),et=a(t=>{O&&O(t),tt(t)},[O,tt]);y(i,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=J.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=J.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const nt=ul(H,Z[0],Z[1]),it=nt?null:cl(x,Z[0],Z[1],X),ot=G?`${g||""} semiotic-emphasis-${G}`.trim():g,rt=dl(m,x);return nt||it||t(Zi,{ref:J,chartType:"heatmap",runtimeMode:"streaming",size:Z,margin:K,className:ot,arrowOfTime:p,windowMode:v,windowSize:rt,data:x,timeAccessor:b,valueAccessor:k,categoryAccessor:w,xExtent:A,yExtent:_,extentPadding:S,heatmapXBins:M,heatmapYBins:P,heatmapAggregation:C,showAxes:q,background:E,hoverAnnotation:U,tooltipContent:Q,customHoverBehavior:et,annotations:L,svgAnnotationRules:$,tickFormatTime:I,tickFormatValue:N,decay:W,pulse:z,staleness:R,legendPosition:V,pointIdAccessor:n.pointIdAccessor})});vl.displayName="RealtimeHeatmap";export{Pt as IncrementalExtent,vl as RealtimeHeatmap,gl as RealtimeHistogram,hl as RealtimeLineChart,yl as RealtimeSwarmChart,pl as RealtimeWaterfallChart,Mt as RingBuffer,Fr as StreamNetworkFrame,Zi as StreamXYFrame};
|