semiotic 3.3.1 → 3.4.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 +25 -6
- package/README.md +1 -1
- package/ai/dist/mcp-server.js +104 -9
- package/ai/schema.json +42 -1
- package/ai/system-prompt.md +4 -0
- package/dist/components/Annotation.d.ts +42 -2
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartGrid.d.ts +1 -1
- package/dist/components/ContextLayout.d.ts +1 -1
- package/dist/components/DataSummaryContext.d.ts +1 -1
- package/dist/components/DetailsPanel.d.ts +3 -2
- package/dist/components/Legend.d.ts +2 -3
- package/dist/components/LinkedCharts.d.ts +9 -1
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
- package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
- package/dist/components/charts/geo/FlowMap.d.ts +4 -4
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
- package/dist/components/charts/index.d.ts +3 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
- package/dist/components/charts/network/CirclePack.d.ts +3 -3
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
- package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
- package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
- package/dist/components/charts/network/Treemap.d.ts +3 -3
- package/dist/components/charts/ordinal/BarChart.d.ts +30 -4
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
- package/dist/components/charts/ordinal/DotPlot.d.ts +13 -4
- package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
- package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
- package/dist/components/charts/ordinal/LikertChart.d.ts +8 -4
- package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
- package/dist/components/charts/shared/ChartError.d.ts +1 -2
- package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/colorUtils.d.ts +4 -3
- package/dist/components/charts/shared/datumTypes.d.ts +20 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
- package/dist/components/charts/shared/formatUtils.d.ts +4 -2
- package/dist/components/charts/shared/hooks.d.ts +41 -24
- package/dist/components/charts/shared/legendUtils.d.ts +3 -2
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
- package/dist/components/charts/shared/networkUtils.d.ts +7 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +14 -11
- package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
- package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
- package/dist/components/charts/shared/tooltipUtils.d.ts +20 -7
- package/dist/components/charts/shared/types.d.ts +27 -19
- package/dist/components/charts/shared/useChartSetup.d.ts +15 -6
- package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
- package/dist/components/charts/shared/useResolvedSelection.d.ts +2 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
- package/dist/components/charts/shared/validateChartData.d.ts +2 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -8
- package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +4 -3
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
- package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
- package/dist/components/charts/xy/Heatmap.d.ts +12 -7
- package/dist/components/charts/xy/LineChart.d.ts +4 -3
- package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
- package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
- package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
- package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
- package/dist/components/data/transforms.d.ts +8 -7
- package/dist/components/export/chartConfig.d.ts +4 -3
- package/dist/components/geo/mergeData.d.ts +2 -1
- package/dist/components/realtime/BinAccumulator.d.ts +3 -2
- package/dist/components/realtime/renderers/types.d.ts +2 -1
- package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
- package/dist/components/realtime/types.d.ts +32 -16
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +7 -0
- package/dist/components/semiotic-ordinal.d.ts +8 -0
- package/dist/components/semiotic-themes.d.ts +2 -1
- package/dist/components/semiotic-xy.d.ts +11 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/animatedGif.d.ts +4 -18
- package/dist/components/server/renderToStaticSVG.d.ts +6 -5
- package/dist/components/server/serverChartConfigs.d.ts +2 -10
- package/dist/components/server/staticAnnotations.d.ts +2 -1
- package/dist/components/server/staticLegend.d.ts +2 -1
- package/dist/components/store/ObservationStore.d.ts +4 -3
- package/dist/components/store/SelectionStore.d.ts +3 -8
- package/dist/components/store/ThemeStore.d.ts +34 -4
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/useSelection.d.ts +6 -5
- package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
- package/dist/components/stream/CanvasHitTester.d.ts +10 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +19 -1
- package/dist/components/stream/FocusRing.d.ts +1 -2
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoParticlePool.d.ts +2 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +26 -7
- package/dist/components/stream/MarginalGraphics.d.ts +1 -2
- package/dist/components/stream/NetworkPipelineStore.d.ts +8 -2
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -4
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +3 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +44 -6
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
- package/dist/components/stream/ParticlePool.d.ts +4 -0
- package/dist/components/stream/PipelineStore.d.ts +80 -30
- package/dist/components/stream/SVGOverlay.d.ts +10 -10
- package/dist/components/stream/SceneGraph.d.ts +6 -5
- package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
- package/dist/components/stream/StreamXYFrame.d.ts +19 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
- package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
- package/dist/components/stream/geoTypes.d.ts +32 -18
- package/dist/components/stream/hoverUtils.d.ts +14 -1
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
- package/dist/components/stream/networkTypes.d.ts +51 -28
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
- package/dist/components/stream/ordinalTypes.d.ts +102 -29
- package/dist/components/stream/pipelineDecay.d.ts +2 -1
- package/dist/components/stream/pipelinePulse.d.ts +2 -1
- package/dist/components/stream/pipelineTransitionUtils.d.ts +21 -0
- package/dist/components/stream/pipelineTransitions.d.ts +16 -4
- package/dist/components/stream/quadtreeHitTest.d.ts +22 -0
- package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +23 -6
- package/dist/components/stream/types.d.ts +63 -8
- package/dist/components/stream/useFrame.d.ts +122 -0
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
- package/dist/components/types/marginType.d.ts +15 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +7 -0
- package/dist/semiotic-ordinal.d.ts +8 -0
- package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +11 -0
- package/dist/semiotic.d.ts +3 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/canvasMock.d.ts +35 -1
- package/dist/test-utils/ordinalFixtures.d.ts +48 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +50 -42
- package/dist/components/types/annotationTypes.d.ts +0 -145
- package/dist/components/types/generalTypes.d.ts +0 -241
- package/dist/components/types/interactionTypes.d.ts +0 -72
- package/dist/components/types/networkTypes.d.ts +0 -174
- package/dist/components/types/ordinalTypes.d.ts +0 -112
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{createContext as e,useMemo as i,useContext as o,useRef as r,useCallback as n,useSyncExternalStore as s}from"react";import{scaleLinear as a,scaleLog as c,scaleTime as l,scaleBand as u,scaleOrdinal as h}from"d3-scale";import{quadtree as f}from"d3-quadtree";import{interpolateViridis as d,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeCategory10 as m}from"d3-scale-chromatic";import{min as x,groups as v,max as b,sum as k,mean as A,group as w,quantile as S}from"d3-array";import{interpolateNumber as _}from"d3-interpolate";import{forceLink as P,forceSimulation as E,forceManyBody as M,forceCenter as O,forceX as T,forceY as L}from"d3-force";import{ribbon as $,chord as z}from"d3-chord";import{arc as D,pie as j}from"d3-shape";import{hierarchy as N,partition as B,pack as R,treemap as W,treemapBinary as F,cluster as C,tree as I}from"d3-hierarchy";import{geoPath as Y,geoGraticule as X,geoDistance as q,geoInterpolate as G,geoEqualEarth as V,geoEquirectangular as H,geoNaturalEarth1 as Z,geoOrthographic as K,geoAlbersUsa as U,geoMercator as Q}from"d3-geo";function J(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class tt{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 i of t){const t=this.push(i);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;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class et{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 i of t){const t=e?e(i):i;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 it(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function ot(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function rt(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function nt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function st(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const at=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function ct(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function lt(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function ut(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ht(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ft(t,e,i){return t+(e-t)*i}function dt(){return"undefined"!=typeof performance?performance.now():Date.now()}function gt(t,e,i){var o,r,n,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function yt(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function pt(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function mt(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function xt(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function vt(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function bt(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function kt(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=mt(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const At={blues:p,reds:y,greens:g,viridis:d},wt=new Map;class St{constructor(t){if(this.xExtent=new et,this.yExtent=new et,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,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.config=t,this.buffer=new tt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=rt(t.timeAccessor||t.xAccessor,"time"),this.getY=rt(t.valueAccessor||t.yAccessor,"value")):(this.getX=rt(t.xAccessor,"x"),this.getY=rt(t.yAccessor,"y")),this.getGroup=st(t.groupAccessor),this.getCategory=st(t.categoryAccessor),this.getSize=t.sizeAccessor?rt(t.sizeAccessor,"size"):void 0,this.getColor=st(t.colorAccessor),this.getBounds=t.boundsAccessor?rt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?rt(t.y0Accessor,"y0"):void 0,this.getPointId=st(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?rt(t.openAccessor,"open"):void 0,this.getHigh=rt(t.highAccessor,"high"),this.getLow=rt(t.lowAccessor,"low"),this.getClose=i?rt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new tt(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?rt(this.config.timeAccessor||this.config.xAccessor,"time"):rt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i 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(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),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,i,o,r,n,s,u;const{config:h,buffer:f}=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(f,this.getX),this.yExtent.dirty)if("candlestick"===h.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of f)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(f,this.getY);const d=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=h.xExtent?[null!==(i=h.xExtent[0])&&void 0!==i?i:g[0],null!==(o=h.xExtent[1])&&void 0!==o?o:g[1]]:g,m=h.yExtent?[null!==(r=h.yExtent[0])&&void 0!==r?r:y[0],null!==(n=h.yExtent[1])&&void 0!==n?n:y[1]]:y;const x=h.yExtent&&null!=h.yExtent[0]&&null!=h.yExtent[1];if("stackedarea"===h.chartType&&!x&&f.size>0)if(h.normalize)m=[0,1+h.extentPadding];else{const t=`${f.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(d),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||i.set(t,(i.get(t)||0)+o)}let o=0;for(const t of i.values())t>o&&(o=t);m=[0,o+(o>0?o*h.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===h.chartType&&h.binSize&&!x&&f.size>0){const[,t]=function(t,e,i,o,r){const n=it(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(f,this.getX,this.getY,h.binSize,this.getCategory);m=[0,t+t*h.extentPadding]}else if("waterfall"===h.chartType&&!x&&f.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(f,this.getY),i=e-t,o=i>0?i*h.extentPadding:1;m=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!x&&m[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>m[1]&&(m[1]=e+i),m[0]>e-i&&(m[0]=e-i))}const t=m[1]-m[0],e=t>0?t*h.extentPadding:1,i=null===(s=h.yExtent)||void 0===s?void 0:s[0],o=null===(u=h.yExtent)||void 0===u?void 0:u[1];m=[null!=i?m[0]:m[0]-e,null!=o?m[1]:m[1]+e],"log"===h.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+h.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===h.xScaleType){const t=Date.now();p=[t-864e5,t]}else p=[0,1];m[0]!==1/0&&m[1]!==-1/0||(m=[0,1]);const v="streaming"===h.runtimeMode,b=Math.max(0,Math.min(h.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(k=h.arrowOfTime)||"down"===k?"y":"x")){const e="right"===h.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:a().domain(p).range(e),y:a().domain(m).range([t.height-b,b])}}else{const e="down"===h.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:a().domain(m).range([b,t.width-b]),y:a().domain(p).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)};this.scales={x:e(h.xScaleType,p,[b,t.width-b]),y:e(h.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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 void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>St.QUADTREE_THRESHOLD?f().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),r=this.scales.y.domain(),n=this.scales.x.range(),s=this.scales.y.range(),u=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)},h=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),f=s[1]>s[0];this.scales={x:u(this.config.xScaleType,o,n[0]>n[1]?[t.width-h,h]:[h,t.width-h]),y:u(this.config.yScaleType,r,f?[h,t.height-h]:[t.height-h,h])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:o,scales:r}=this;if(!r||0===e.length)return[];const n={scales:r,config:o,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(o.chartType){case"line":return function(t,e){var i;const o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.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 o){const i=bt(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=yt(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return kt(t,o,r),r}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=pt(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return kt(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=pt(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=yt(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return kt(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:n}=function(t,e,i,o,r,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),o=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);n&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,o),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=n.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};kt(t,i,s,o)}return s}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);n=i=>t===e?(r[0]+r[1])/2:r[0]+(i-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const r of e){let e=t.config.pointStyle?t.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=e.r||o;if(n&&t.getSize){const e=t.getSize(r);null==e||Number.isNaN(e)||(a=n(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(r);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(r)+"":void 0,l=mt(r,t.scales,t.getX,t.getY,a,e,c);l&&i.push(l)}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=rt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/s,y=(d-f||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-f)/y),a-1);if(0>c||0>h)continue;const d=h*s+c;m[d]++;const p=l(o);x[d]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const k=b-v||1,A=i.width/s,w=i.height/a,S=t.config.showValues,_=t.config.heatmapValueFormat,P=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/k;P.push(vt(i*A,(a-1-t)*w,A,w,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o]},S?{value:r,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=rt(t.config.valueAccessor,"value"),r=nt(t.config.xAccessor,"x"),n=nt(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),u=n(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const f=Array.from(s.keys()),d=Array.from(a.keys()),g=f.every(t=>"number"==typeof t&&!isNaN(t)),y=d.every(t=>"number"==typeof t&&!isNaN(t));if(g){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}if(y){d.sort((t,e)=>t-e),a.clear();for(let t=0;d.length>t;t++)a.set(d[t],t)}const m=new Float64Array(e.length),x=new Float64Array(e.length),v=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const h=o(i),f=n*u+r,d=b.get(f);let g;void 0!==d?g=d:(g=k++,b.set(f,g)),m[g]=f,x[g]=h,v[g]=i}let A=1/0,w=-1/0;for(let t=0;k>t;t++){const e=x[t];isFinite(e)&&(A>e&&(A=e),e>w&&(w=e))}if(!isFinite(A)||!isFinite(w))return[];const S=function(t){const e=t in At?t:"blues";let i=wt.get(e);if(i)return i;i=Array(256);const o=At[e]||p;for(let t=0;256>t;t++)i[t]=o(t/255);return wt.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),_=255/(w-A||1),P=i.width/u,E=i.height/h,M=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;k>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],o=i%u;T.push(vt(o*P,(h-1-(i-o)/u)*E,P,E,S[Math.min((e-A)*_+.5|0,255)],v[t],M?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(n,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=it(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 i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(i),s=Array.from(e).filter(t=>!n.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:c,order:r})}const n=[],s=t.scales,[a,c]=s.x.domain();for(const e of o.values()){const o=Math.max(e.start,a),l=Math.min(e.end,c);if(o>=l)continue;const u=s.x(o),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(r&&e.categories.size>0){let o=0;for(const a of r){const r=e.categories.get(a)||0;if(0===r)continue;const c=s.y(o),l=s.y(o+r);n.push(xt(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:r},a)),o+=r}}else{const t=s.y(0),i=s.y(e.total);n.push(xt(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of o.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=null!==(i=n.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n;const s=[],a=t.config.swarmStyle||{},c=null!==(i=a.radius)&&void 0!==i?i:3,l=null!==(o=a.fill)&&void 0!==o?o:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,h=a.stroke,f=a.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),a=t.scales.y(o);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:r,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),s.push(g)}return s}(n,e);case"waterfall":return function(t,e,i){var o,r,n;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===l.length)return s;const u=null!==(o=null==c?void 0:c.positiveColor)&&void 0!==o?o:"#28a745",h=null!==(r=null==c?void 0:c.negativeColor)&&void 0!==r?r:"#dc3545",f=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const o=l[e],r=t.getX(o),n=t.getY(o),p=y+n;let m;m=l.length-1>e?t.getX(l[e+1])-r:e>0?r-t.getX(l[e-1]):0;const x=a.x(r),v=0!==m?a.x(r+m):x+i.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const A=a.y(y),w=a.y(p);s.push(xt(b,Math.min(A,w),k,Math.abs(A-w),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},o),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(n,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=r?0:null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(!r&&null==s.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const o=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));o>0&&e>o&&(e=o)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else r||null!=s.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),f=r?s:t.getClose(i);if(!r&&[a,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(f),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?ct(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=ct(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=ct(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=ct(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=ct(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=lt(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=lt(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(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,i,o){var r,n,s;i.clear(),o.clear();for(let a=0;e.length>a;a++){const c=e[a],l=gt(t,c,a);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?o.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(n=c.style)||void 0===n?void 0:n.opacity}):"area"===c.type&&o.set(l,{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)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,u,h,f,d,g,y,p,m,x,v,b,k,A,w,S,_,P,E,M,O,T,L,$;if(0===o.size&&0===r.size)return i;const z=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let D=!1;const j=new Set,N=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],w=gt(t,n,e);if(!w)continue;if(n._transitionKey=w,"line"===n.type||"area"===n.type){const t=r.get(w);if(t){if(N.add(w),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];D=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];D=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;continue}const S=o.get(w);if("point"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,S.x===t.x&&S.y===t.y&&S.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=S.x,n.y=S.y,n.r=null!==(h=S.r)&&void 0!==h?h:n.r,D=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;else if("rect"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(g=S.w)&&void 0!==g?g:n.w,n.h=null!==(y=S.h)&&void 0!==y?y:n.h,D=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;else if("heatcell"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(v=S.w)&&void 0!==v?v:n.w,n.h=null!==(b=S.h)&&void 0!==b?b:n.h,D=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),D=!0}for(const[t,e]of r)if(!N.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(w=e.opacity)&&void 0!==w?w:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),D=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(S=e.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),D=!0}for(const[t,e]of o)if(!j.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(P=e.opacity)&&void 0!==P?P:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(M=e.h)&&void 0!==M?M:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(T=e.w)&&void 0!==T?T:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}D=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),D&&(i.activeTransition={startTime:dt(),duration:z}),i}(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},i=function(t,e,i,o){var r,n,s,a,c;if(!i.activeTransition)return!1;const l=ht(t,i.activeTransition),u=ut(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=ft(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=ft(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=ft(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ft(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}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:ft(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=ft(e[o][0],i[o][0],u),t.path[o][1]=ft(e[o][1],i[o][1],u)}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:ft(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=ft(e[i][0],o[i][0],u),t.topPath[i][1]=ft(e[i][1],o[i][1],u);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ft(i[e][0],r[e][0],u),t.bottomPath[e][1]=ft(i[e][1],r[e][1],u)}}if(l>=1){for(const t of i.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("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.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,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n},n}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const o=i(e||{},t);if(o&&!o.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},o),{stroke:e})}return o}return i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(t)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,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 i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,o=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);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.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)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)=>{r.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++,n}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.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._colorMapCache=null,this._groupColorMap=new Map,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,i,o,r;const n=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!ot(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!ot(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=rt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=rt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=rt(this.config.xAccessor,"x"),this.getY=rt(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!ot(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?st(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!ot(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?st(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!ot(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?rt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!ot(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!ot(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?rt(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!ot(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?st(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!ot(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!ot(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!ot(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!ot(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?rt(this.config.openAccessor,"open"):void 0,this.getHigh=rt(this.config.highAccessor,"high"),this.getLow=rt(this.config.lowAccessor,"low"),this.getClose=e?rt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function _t(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Pt(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[o=a[t][e]];f||(s[o]=f={}),f[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>n[e]){for(var g=n[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=f}return o}function Et(t){return t.y0-t.y1>0?"up":"down"}function Mt(t,e){return e(t.source)==e(t.target)}function Ot(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Tt(t){return t.target.x0-t.source.x1}function Lt(t,e){var i=zt(t),o=Tt(e)/Math.tan(i);return"up"==Et(t)?t.y1-o:t.y1+o}function $t(t,e){var i=zt(t),o=Tt(e)/Math.tan(i);return"up"==Et(t)?t.y1+o:t.y1-o}function zt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Dt(t,e){return e(t)}function jt(t){return Bt(t.source)}function Nt(t){return Bt(t.target)}function Bt(t){return(t.y0+t.y1)/2}function Rt(t){return t.virtual?0:t.value}function Wt(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Mt(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Mt(t,e)?o+1:o}),i+o}function Ft(t){return t.target.depth}function Ct(t,e){return t.sourceLinks.length?t.depth:e-1}function It(t,e){return t.y0-e.y0}function Yt(t,e){return e.y0-t.y0}function Xt(t,e){return t.y1-e.y1}function qt(t,e){return e.y1-t.y1}function Gt(t,e){return Ht(t.source,e.source)||t.index-e.index}function Vt(t,e){return Ht(t.target,e.target)||t.index-e.index}function Ht(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Zt(t,e){return Kt(t)==Kt(e)?"bottom"==t.circularLinkType?Yt(t,e):It(t,e):Kt(e)-Kt(t)}function Kt(t){return t.target.column-t.source.column}function Ut(t,e){return Qt(t)==Qt(e)}function Qt(t){return t.y0-t.y1>0?"up":"down"}function Jt(t,e,i,o,r){let n=t;var s=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=x(n.links,function(t){return t.source.y0});n.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=n.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),te(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),te(n.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),n.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Mt(t,e)&&Ot(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=n.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Yt:It);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=n.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?qt:Xt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(n.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-r-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,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),n}function te(t,e,i){t.sort(Zt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Mt(t,e)&&Ot(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ee(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function ee(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ie(t){return function(){return t}}function oe(t){return t.index}function re(t){return t.nodes}function ne(t){return t.links}function se(t,e,i){var o=v(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Bt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Bt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Wt(e,i)-Wt(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Wt(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function ae(t,e,i,o,r,n){var s=v(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 a=1,c=n;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(r){var n=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Wt(r,i)>0){var c=A(r.sourceLinks,Nt),l=A(r.targetLinks,jt),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Bt(r))*e*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(s==o-1&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var f=A(r.sourceLinks,Nt),d=A(r.targetLinks,jt),g=((f&&d?(f+d)/2:f||d)-Bt(r))*e;r.y0+=g,r.y1+=g}})})}function u(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||Ht),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function ce(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vt),t.targetLinks.sort(Gt)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function le(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=oe,c=Ct,l=void 0,u=32,h=2,f=re,d=ne;function g(){var g={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return w(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=_t(i,o)),"object"!=typeof r&&(r=t.target=_t(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,a),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Pt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,l),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){Dt(t,e)!=Dt(r.source,e)&&Dt(t,e)!=Dt(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Mt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(k(t.sourceLinks,Rt),k(t.targetLinks,Rt)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(f,l,c);var d=n;if(null!==s){var g=v(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=b(g,function(t){return t.length});y>1&&(d=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=v(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 r=x(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/k(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=b(t.nodes,function(t){return t.column});t.nodes.forEach(n>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/n),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(f,d,r),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Dt(i.source,e)==Dt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Lt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Lt(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 n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Dt(i.target,e)==Dt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=$t(e,t);return t.y0-i}if(e.source.column>t.source.column)return $t(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 n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var n=x(e,function(t){return t.y0}),s=b(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-n);function c(e){return(e-n)/(s-n)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),i.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(f),Jt(f,a,h,10,8)}(g),g}return g.update=function(t){return ce(t),Jt(t,a,h,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(n=+t,g):n},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ie(t),g):f},g.links=function(t){return arguments.length?(d="function"==typeof t?t:ie(t),g):d},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:ie(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ie(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],g):[[t,e],[i,o]]},g.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],g):[i-t,o-e]},g}St.QUADTREE_THRESHOLD=500;const ue=t=>{let e,i,o,r,n,s,a,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,s=t.target.x0,a=_(n,s),c=a(.5),l=a(.5),`M${e},${n}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,a=_(e,i),o=a(.5),r=a(.5),n=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${n}C${o},${n} ${r},${s} ${i},${s}L${i},${c}C${r},${c} ${o},${l} ${e},${l}Z`)};function he(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(o,15));return`M${n},${s-f*i}L${l},${s-f*i}L${l+o},${s-f*i+f*d}L${l+o},${h+f*o-f*d}L${l+o-d},${h+f*o}L${u-o+d},${h+f*o}L${u-o},${h+f*o-f*d}L${u-o},${c-f*i+f*d}L${u-o+d},${c-f*i}L${a},${c-f*i}L${a},${c+f*i}L${u+o},${c+f*i}L${u+o},${h-f*o}L${l-o},${h-f*o}L${l-o},${s+f*i}L${n},${s+f*i}Z`}const fe=new Set,de=new WeakMap;function ge(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=de.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,de.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;fe.has(t)||(fe.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const ye={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(Ft))-1:0},justify:Ct},pe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=le().extent(x).links(m).nodes(p).nodeAlign(ye[f]||Ct).nodeId(t=>t.id).nodeWidth(d).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,o="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${o}\0${r}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(o),i=b.get(r);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var r,n,s,a;const c="vertical"===i.orientation?"down":"right",l=i.nodeStyle,u=i.edgeStyle,h=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,f=i.edgeColorBy||"source",d=Array.isArray(i.colorScheme)?i.colorScheme:m,g=new Map;t.forEach((t,e)=>{g.set(t.id,d[e%d.length])});const y=[],p=[],x=[],v=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=l?l(ge(e,"nodeStyle")):{},r={fill:o.fill||g.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};v.set(e.id,("string"==typeof r.fill?r.fill:null)||g.get(e.id)||"#4d430c"),y.push("down"===c?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){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="#999";o="function"==typeof f?f(t)||o:"target"===f?v.get(i.id)||g.get(i.id)||o:v.get(e.id)||g.get(e.id)||o;const r=u?u(ge(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=r.fill||o;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+a},${e.sourceY-i}L${e.sourceX+a},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:h,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let c;if(c=t.circular&&t.circularPathData?he(t):ue(t),!c)continue;const l={fill:r.fill||o,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,l;"down"===c?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,l="middle"):(o[0]/2>i.x0+t/2?(s=i.x0-6,l="end"):(s=i.x1+6,l="start"),a=i.y0+r/2),x.push({x:s,y:a,text:n+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:y,sceneEdges:p,labels:x}}},me={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,a=o[0]/2,c=o[1]/2,l=i.__previousPositions;let u=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==l?void 0:l.get(e.id);t?u++:i?(e.x=i.x,e.y=i.y,u++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of h){const o=xe(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=ve(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=ve(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(i),t.y=c+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=a+t*Math.cos(r),o.y=c+t*Math.sin(r)}}}const d=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===i.iterations?0:f?40:d,y=be(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=P().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),o=E().force("charge",M().strength(t=>-25*p(t))).force("center",O(a,c).strength(.8)).force("x",T(a).strength(.15)).force("y",L(c).strength(.15));if(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;g>t;++t)o.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(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){var r,n,s;const a=i.nodeStyle,c=i.edgeStyle,l=be(i.nodeSize,i.nodeSizeRange,t),u=Array.isArray(i.colorScheme)?i.colorScheme:m,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const f=[],d=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=l(ge(e,"nodeSize")),i=a?a(ge(e,"nodeStyle")):{},o={fill:i.fill||h.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:2,opacity:i.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:o,datum:e,id:e.id,label:e.id})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.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=c?c(ge(t,"edgeStyle")):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(n=o.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==i.showLabels){const e=(p=i.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=l(ge(i,"nodeSize"));g.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:f,sceneEdges:d,labels:g}}};function xe(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function ve(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function be(t,e,i){var o,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const n=e||[5,20],s=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>n[0];const c=null!==(o=x(s))&&void 0!==o?o:0,l=null!==(r=b(s))&&void 0!==r?r:1;if(c===l)return()=>(n[0]+n[1])/2;const u=a().domain([c,l]).range(n).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?n[0]:u(o)}}const ke=m,Ae={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-n,l=o[0]/2,u=o[1]/2,h=(f=i.valueAccessor)?"function"==typeof f?f:t=>{var e;return null!==(e=t[f])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var f;const d=new Map;for(let e=0;t.length>e;e++)d.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,i=d.get("string"==typeof t.source?t.source:t.source.id),o=d.get(e);if(void 0===i||void 0===o)continue;const r=h(t);y[i][o]=r}const p=z().padAngle(r);s&&p.sortGroups(s);const m=p(y),x=m.groups,v=D().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=v.centroid(e);i.x=o[0]+l,i.y=o[1]+u,i.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,i=b.get("string"==typeof t.source?t.source:t.source.id),o=b.get(e);i&&(t.source=i),o&&(t.target=o)}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 m){const i=t[e.source.index].id,o=t[e.target.index].id,r=k.get(`${i}\0${o}`)||k.get(`${o}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,o){var r,n;const{groupWidth:s=20,edgeOpacity:a=.5}=i,c=Math.min(o[0],o[1])/2,l=c-s,u=o[0]/2,h=o[1]/2,f=i.nodeStyle,d=i.edgeStyle,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:ke,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=$().radius(l),x=[],v=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=f?f(ge(i,"nodeStyle")).fill||p.get(i.id)||y[e%y.length]:p.get(i.id)||y[e%y.length];const s=f?f(ge(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};x.push({type:"arc",cx:u,cy:h,innerR:l,outerR:c,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=m(e);if(!i)continue;const o=we(i,u,h);let r="#999";if(d)r=d(ge(t,"edgeStyle")).fill||r;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===g&&i?r=p.get(i.id)||r:e&&(r=p.get(e.id)||r)}const s=d?d(ge(t,"edgeStyle")):{},c={fill:r,fillOpacity:null!==(n=s.fillOpacity)&&void 0!==n?n:a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};v.push({type:"ribbon",pathD:o,style:c,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,o=c+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;b.push({x:u+Math.cos(s)*o,y:h+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:x,sceneEdges:v,labels:b}}};function we(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const Se=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function _e(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Pe(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ee(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function Me(t){return Array.isArray(t.colorScheme)?t.colorScheme:Se}function Oe(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:"#4d430c"}function Te(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const Le={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},u=N(n,a);u.sum(l),u.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=I();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=C();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=W().size([i,o]).tile(F).padding(s);a>0&&c.paddingTop(a),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;R().size([i,o]).padding(n)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,o){var r;B().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;d.length>e;e++){const o=d[e],n={id:Pe(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?$e(n,o,i):"treemap"===s||"partition"===s?ze(n,o):"circlepack"===s&&De(n,o),n.__hierarchyNode=o,t.push(n),g.set(o,n)}if("tree"===s||"cluster"===s)for(const t of d)if(t.parent){const i=g.get(t.parent),o=g.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=o[0]/2,m=o[1]/2,x="number"==typeof(v=i.nodeSize)?v:5;var v;for(const e of t){let t=e.x,o=e.y;y&&(t+=p,o+=m);const n=r(ge(e,"nodeStyle"));let a=n.fill||Oe(i);if(i.colorByDepth&&void 0!==e.depth){const t=Me(i);a=t[e.depth%t.length]}const c={fill:a,stroke:n.stroke||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:o,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=i.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,r=e.y,s=i.x,a=i.y;y&&(o+=p,r+=m,s+=p,a+=m);const u=Te(o,r,s,a,g),h=n(ge(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Ee(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(o=s-x-6,n="end"):(o=s+x+6,n="start"),r=a):(o=s,r=a+x+14,n="middle");d.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n;const s=[],a=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const a=o(ge(i,"nodeStyle"));let c=a.fill||Oe(e);if(e.colorByDepth&&void 0!==i.depth){const t=Me(e);c=t[i.depth%t.length]}const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};s.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel),r=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(n=c.data)||void 0===n?void 0:n.children)&&c.data.children.length>0);if(!s){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=o(ge(c,"nodeStyle")).fill||Oe(e);if(e.colorByDepth&&void 0!==c.depth){const t=Me(e);f=t[c.depth%t.length]}const d=_e(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const a=o(ge(i,"nodeStyle"));let c=a.fill||Oe(e);if(e.colorByDepth&&void 0!==i.depth){const t=Me(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel);for(const r of t){const t=null!==(a=r.__radius)&&void 0!==a?a:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let l=o(ge(r,"nodeStyle")).fill||Oe(e);if(e.colorByDepth&&void 0!==r.depth){const t=Me(e);l=t[r.depth%t.length]}if(s){const e=_e(l);u.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function $e(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function ze(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 De(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function je(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Ne={sankey:pe,force:me,chord:Ae,tree:Le,cluster:Le,treemap:Le,circlepack:Le,partition:Le,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),l=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),u=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,h=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof u?()=>u:u,d="number"==typeof h?()=>h:h,g=je(i);g.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function p(t){var e;const i=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,i+1),0===i?t:`${t}__${i}`}const m=e[0]/2,x=e[1]/2,v=Math.min(e[0],e[1])/2*.85,b=p(c(t));o.push({id:b,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:v,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,u,h,y){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=l[Math.min(k,l.length-1)],k++,v++;let A=0;for(let x=0;v>x;x++){const b=l[Math.min(x,l.length-1)],k=m.slice(A,A+b);if(!k.length)break;const w=(x+1)/v,S={id:i,depth:h,data:e,parentId:i},_=y?u/f(S)*w:u*w,P=j().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),E=P(k),M=d(S);for(let e=0;k.length>e;e++){const a=(E[e].startAngle+E[e].endAngle)/2,l=k[e],u=p(c(l)),f=n+_*Math.sin(a),d=s+_*Math.cos(a)*M;o.push({id:u,x:f,y:d,x0:f,x1:f,y0:d,y1:d,width:0,height:0,value:0,depth:h,data:l}),g.metaMap.set(u,{ring:_,angle:a,depth:h,parentId:i,eccentricity:M}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,f,d,_,h+1,!0)}A+=b}}(t,b,m,x,v,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=je(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(ge(e,"nodeSize")),i=l?l(ge(e,"nodeStyle")):{},o={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:1,opacity:null!==(n=i.opacity)&&void 0!==n?n:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:o,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(ge(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(c=null===(a=i.data)||void 0===a?void 0:a[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=je(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Be(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function Re(t){var e,i,o;const r=t.length,n=t[0],s=t[r-1];return{n:r,min:n,q1:null!==(e=S(t,.25))&&void 0!==e?e:n,median:null!==(i=S(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(o=S(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/r}}const We={bar:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,getStack:a,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="horizontal"===u,g=n.normalize,y=[];if(a){const t=new Set;for(const e of Object.values(r))for(const i of e.pieceData){const e=a(i);t.has(e)||(t.add(e),y.push(e))}}else y.push("_default");for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=s(i),o.pieces.push(i)}let i=0;if(g)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of y){const s=e.get(n);if(!s)continue;let u=s.total;g&&i>0&&(u/=i);const y=c(s.pieces[0],a?n:t.name),p=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(f){const e=l(0>u?r:o+u),i=0>u?l(r+u)-l(r):l(o)-l(o+u);h.push(xt(t.x,e,t.width,Math.abs(i),y,p,n)),0>u?r+=u:o+=u}else if(d){const e=l(0>u?r+u:o),i=0>u?l(r)-l(r+u):l(o+u)-l(o);h.push(xt(e,t.x,Math.abs(i),t.width,y,p,n)),0>u?r+=u:o+=u}}}if(n.roundedTop&&n.roundedTop>0){const t=Math.max(0,n.roundedTop),e=new Map;for(const t of h){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}const o="vertical"===u;for(const i of e.values()){if(0===i.length)continue;const e=i.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),r=i.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});if(e.length>0){const i=e.reduce(o?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e);i.roundedTop=t,i.roundedEdge=o?"top":"right"}if(r.length>0){const e=r.reduce(o?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e);e.roundedTop=t,e.roundedEdge=o?"bottom":"left"}}}return h},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f=[],d=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";d.has(t)||(d.add(t),f.push(t))}const g=f.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;f.length>s;s++){const l=r.get(f[s])||[];for(const r of l){const l=n(r),d=a(r,f[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(xt(n,Math.min(a,h),o,Math.abs(a-h),d,r,f[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(xt(Math.min(a,h),n,Math.abs(h-a),o,d,r,f[s]))}}}}if(r.roundedTop&&r.roundedTop>0){const t=Math.max(0,r.roundedTop);for(const e of u){if("rect"!==e.type)continue;const i=n(e.datum);e.roundedTop=t,e.roundedEdge=h?0>i?"bottom":"top":0>i?"left":"right"}}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else f?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:o})}}return c},pie:Be,donut:Be,boxplot:function(t,e){var i,o,r,n,s;const{scales:a,columns:c,config:l,getR:u,resolveSummaryStyle:h}=t,{r:f,projection:d}=a,g=[],y="vertical"===d,p=!1!==l.showOutliers;for(const t of Object.values(c)){const e=t.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const a=e[0],c=e[e.length-1],l=null!==(i=S(e,.25))&&void 0!==i?i:a,d=null!==(o=S(e,.5))&&void 0!==o?o:(a+c)/2,m=null!==(r=S(e,.75))&&void 0!==r?r:c,x=m-l,v=l-1.5*x,b=m+1.5*x,k=null!==(n=e.find(t=>t>=v))&&void 0!==n?n:a,A=null!==(s=[...e].reverse().find(t=>b>=t))&&void 0!==s?s:c,w=h(t.pieceData[0],t.name),_=[];if(p)for(const e of t.pieceData){const i=u(e);if(v>i||i>b){const o=y?t.middle:f(i),r=y?f(i):t.middle;_.push({px:o,py:r,value:i,datum:e})}}if(g.push({type:"boxplot",x:y?t.middle:0,y:y?0:t.middle,projection:y?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(k),q1Pos:f(l),medianPos:f(d),q3Pos:f(m),maxPos:f(A),stats:{n:e.length,min:k,q1:l,median:d,q3:m,max:A,mean:e.reduce((t,e)=>t+e,0)/e.length},style:w,datum:t.pieceData,category:t.name,outliers:_}),p)for(const t of _)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:w.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:u,projection:h}=n,f=[],d="vertical"===h,g=a.bins||20,y=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],s=e[e.length-1],a=(s-n)/g||1,h=Array(g).fill(0);for(const t of e)h[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...h,1),m=t.width/2*.9;let x="";if(d){x=`M ${t.middle} ${u(n)}`;for(let e=0;g>e;e++){const i=u(n+(e+.5)*a);x+=` L ${t.middle+h[e]/p*m} ${i}`}x+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const i=u(n+(e+.5)*a);x+=` L ${t.middle-h[e]/p*m} ${i}`}x+=" Z"}else{x=`M ${u(n)} ${t.middle}`;for(let e=0;g>e;e++)x+=` L ${u(n+(e+.5)*a)} ${t.middle-h[e]/p*m}`;x+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)x+=` L ${u(n+(e+.5)*a)} ${t.middle+h[e]/p*m}`;x+=" Z"}const v=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=S(e,.25))&&void 0!==i?i:n,c=null!==(o=S(e,.5))&&void 0!==o?o:(n+s)/2,l=null!==(r=S(e,.75))&&void 0!==r?r:s;b={q1Pos:u(a),medianPos:u(c),q3Pos:u(l),centerPos:t.middle,isVertical:d}}const k=d?{x:t.x,y:Math.min(u(s),u(n)),width:t.width,height:Math.abs(u(s)-u(n))}:{x:Math.min(u(n),u(s)),y:t.x,width:Math.abs(u(s)-u(n)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:Re(e),style:v,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const f=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const o=(h?n[e]/f:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(xt(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,f="horizontal"===l,d=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=f?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Re(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(xt(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(xt(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var i,o,r,n,s,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=e.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const x=[],v=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";v.has(t)||(v.add(t),x.push(t))}const b=x.length>1&&"_default"!==x[0],k=[];let A=0;for(const t of m){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=h(o);r.total+=n,r.pieces.push(o),i+=n}k.push({col:t,groups:e,stepTotal:i}),b||i>A&&(A=i)}if(b)for(const t of k){let e=0,i=0;for(let o=0;x.length>o;o++){const r=t.groups.get(x[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>A&&(A=o)}if(0===A)return g;const w=new Map;for(const t of x){const e=k[0].groups.get(t);w.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const S=k[0].stepTotal,_=b?.95*y:.9*e.width,P=a().domain([0,A]).range([0,_]),E=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let M=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,o=0===t,a=i.width,u=.55*a,h=i.x+(a-u)/2,f=new Map;if(b){let t=0;for(const i of x){const o=e.groups.get(i);o&&(t+=P(o.total))}let r=y,n=y;for(let a=0;x.length>a;a++){const c=x[a],l=e.groups.get(c);if(!l)continue;const m=P(l.total),v=a%2==0,b=v?r:n-m;v?r+=m:n-=m;const k=d(l.pieces[0],c),A=null!==(s=w.get(c))&&void 0!==s?s:l.total,S=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:o,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===a&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(xt(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,s=P(t),a=y-s/2,c=x[0],l="_default"!==c,m=null!==(n=null===(r=e.groups.get(c))||void 0===r?void 0:r.pieces[0])&&void 0!==n?n:i.pieceData[0],v=l?c:i.name,b=d(m,v),k=S>0?t/S*100:0,A=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:o,category:l?c:i.name});p&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=y,A.__funnelStepLabelY=h,A.__funnelRowWidth=s,A.__funnelValueLabelX=y,A.__funnelValueLabelY=h,A.__funnelBarW=s),g.push(xt(a,h,s,u,b,A,v)),f.set(c,{x:a,y:h,w:s,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const o of t){const t=M.get(o),r=f.get(o);if(!t||!r)continue;const n=(()=>{const t=e.groups.get(o);return d(t?t.pieces[0]:i.pieceData[0],"_default"===o?i.name:o)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:n.fill||"#999",opacity:E},datum:null!==(l=null===(c=e.groups.get(o))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===o?i.name:o};g.push(s)}}M=f}return g},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,v=null!==(r=m.get(f))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(f),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=o?0:Math.max(0,A-p),S=i.x+t*a+c/2,_=x(p),P=x(0)-_,E=l(g.pieces[0],y?f:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(xt(S,_,u,P,E,M,y?f:i.name)),w>0){const t=x(p+w),e=_-t,o=Object.assign({},E),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:v>0?w/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(xt(S,t,u,e,o,r,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(o)){let e=0;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,h=s(i,c);if(u){const r=a(e),n=a(e+o);l.push(xt(r,t.x,n-r,t.width,h,i,c))}else{const r=a(e+o),n=a(e);l.push(xt(t.x,r,t.width,n-r,h,i,c))}e+=o}}return l}};class Fe{constructor(t){this.rExtent=new et,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new tt(t.windowSize),this.getO=st(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>rt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new et)):(this.getR=rt(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=st(t.stackBy),this.getGroup=st(t.groupBy),this.getColor=st(t.colorAccessor),this.getConnector=st(t.connectorAccessor),this.getDataId=st(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new tt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const o=i.toArray(),r=e.projection||"vertical",n=e.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,n),c="horizontal"===r,l=null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1;let h,f;if("radial"===r){h=u().domain(n).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=a().domain(s).range([o,i])}else c?(h=u().domain(n).range([0,t.height]).padding(l),f=a().domain(s).range([0,t.width])):(h=u().domain(n).range([0,t.width]).padding(l),f=a().domain(s).range([t.height,0]));this.scales={o:h,r:f,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{var n;const s=this.rExtents[r];s.dirty&&s.recalculate(i,o);let[l,u]=s.extent;l===1/0&&(l=0,u=1);const h=null!==(n=e.extentPadding)&&void 0!==n?n:.05,f=u-l,d=f>0?f*h:1;return l-=d,u+=d,l>0&&(l=0),c?a().domain([l,u]).range([0,t.width]):a().domain([l,u]).range([t.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(d,n,h,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const o=Math.max(50,3*i.size);if(this.categories.size>o){let t=this.categories.size-o;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const o=new Map;for(const e of t){const t=this.getO(e);o.set(t,(o.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(o.get(t)||0)-(o.get(e)||0):(t,e)=>(o.get(e)||0)-(o.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,o,r){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,d=i.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),o=We[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:r,getO:n}=t;if(!r||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=r(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:n(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const o=e[i],r=e[i+1],n="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:n,datum:o.datum,group:t})}}return s}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?ct(i,t,e):1}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=new Map;for(let t=0;e.length>t;t++)n.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let o=0;for(let i=0;e.length>i;i++){const r=e[i],a=this.config.oAccessor;if(("function"==typeof a?a(r):r[a||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=n-c;if(s>l){const t=1-l/s;t>o&&(o=t)}}o>0&&(i._pulseIntensity=o,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}getNodeKey(t,e){var i,o;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(o=a.style.opacity)&&void 0!==o?o:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(r=l.w)&&void 0!==r?r:a.w,a.h=null!==(n=l.h)&&void 0!==n?n:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:dt(),duration:f})}advanceTransition(t){var e,i,o;if(!this.activeTransition)return!1;const r=ht(t,this.activeTransition),n=ut(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=ft(r,t._targetOpacity,n)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=ft(o.x,t._targetX,n),t.y=ft(o.y,t._targetY,n)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=ft(r,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,n),t.y=ft(i.y,t._targetY,n),void 0!==i.w&&(t.w=ft(i.w,t._targetW,n),t.h=ft(i.h,t._targetH,n))}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=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}if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(ot(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=st(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],o=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==o.length||i.some((t,e)=>!ot(t,o[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>rt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new et)):(this.getR=rt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!ot(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?st(this.config.stackBy):void 0),"groupBy"in t&&!ot(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?st(this.config.groupBy):void 0),"colorAccessor"in t&&!ot(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!ot(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?st(this.config.connectorAccessor):void 0)}}const Ce={mercator:Q,equalEarth:V,albersUsa:U,orthographic:K,naturalEarth:Z,equirectangular:H};function Ie(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Ye(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Xe(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const qe={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},Ge={fill:"#4e79a7",r:4,fillOpacity:.8},Ve={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function He(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function Ze(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function Ke(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function Ue(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class Qe{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new tt(t),this.timestampBuffer=new tt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return V();if("string"==typeof t){const e=Ce[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),V())}if("object"==typeof t&&"type"in t){const e=Ce[t.type],i=e?e():V();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=Y(this.projection),this.fitProjection(t),this.geoPath=Y(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const o=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=Ie(a.xAccessor,"lon"),u=Ie(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=Ye(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=Ie(n.xAccessor,"lon"),l=Ie(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=X();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=Xe(n.areaStyle,t,qe);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const u=Ye(n.lineDataAccessor);for(const e of this.lineData){const i=u(e);if(!i||2>i.length)continue;const o=i.map(t=>[c(t),l(t)]);let a;if("geo"===n.lineType){const t=[];for(let e=0;o.length-1>e;e++){const i=o[e],r=o[e+1],n=q(i,r)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),a=G(i,r);for(let i=0;s>=i;i++)e>0&&0===i||t.push(a(i/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=o.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const h=Xe(n.lineStyle,e,Ve),f="number"==typeof h.strokeWidth?h.strokeWidth:1;2!==o.length||2>a.length||"arc"!==n.flowStyle?2!==o.length||2>a.length||"offset"!==n.flowStyle||(a="geo"===n.lineType?Ke(a,f):Ue(a[0],a[a.length-1],0,0,f)):a=Ze(a[0],a[a.length-1]);const d=He(a,t.width);if(d.length>1)for(const t of d){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},h),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>a.length&&d[0]||a,style:h,datum:e})}const h=this.getPoints(),f=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,d=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,g=d>0?d*Math.PI/180:null,y=s.rotate?s.rotate():[0,0,0],p="function"==typeof s.center?s.center():[0,0],m=[(null!==(i=p[0])&&void 0!==i?i:0)-y[0],(null!==(o=p[1])&&void 0!==o?o:0)-y[1]];for(let t=0;h.length>t;t++){const e=h[t],i=c(e),o=l(e);if(null!=g&&q([i,o],m)>g)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},Ge),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:f?f(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var i,o,r;const n=this.scene.filter(t=>"point"===t.type);if(2>n.length)return;const s=null!==(i=t.strength)&&void 0!==i?i:1;if(0===s)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=n.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=n.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(e.width,e.height)/2,p=a().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of n){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*s;t.x=h+Math.cos(e)*r,t.y=f+Math.sin(e)*r}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of n)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(o=e.datum)||void 0===o?void 0:o.source,n=null===(r=e.datum)||void 0===r?void 0:r.target;if(i&&n){const o=t.get(i+""),r=t.get(n+"");o&&r&&(e.path=[o,r])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=ct(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(t){if(!this.activeTransition)return!1;const e=ht(t,this.activeTransition),i=ut(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ft(t.x,t._targetX,i),t.y=ft(e,t._targetY,i)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function Je(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function ti(e,i){var o,r,n;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+i,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})}case"area":{const n=e;if(0===n.topPath.length)return null;const s=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+i,d:`M${s}L${a}Z`,fill:Je(n.style.fill),fillOpacity:null!==(r=null!==(o=n.style.fillOpacity)&&void 0!==o?o:n.style.opacity)&&void 0!==r?r:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"point":{const o=e;return t.createElement("circle",{key:"point-"+i,cx:o.x,cy:o.y,r:o.r,fill:Je(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"rect":{const o=e;return t.createElement("rect",{key:"rect-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:Je(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,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*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.createElement("g",{key:"heatcell-"+i},t.createElement("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.createElement("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px"},e))}return t.createElement("rect",{key:"heatcell-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill})}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.createElement("g",{key:"candle-"+i},t.createElement("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.createElement("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1}))}default:return null}}function ei(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",l=t=>`ord-${e.type}-${c}-${i}-${t}`,u=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e;if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:r,w:n,h:s}=i;let a;switch(i.roundedEdge){case"right":a=`M${o},${r} L${o+n-e},${r} A${e},${e} 0 0 1 ${o+n},${r+e} L${o+n},${r+s-e} A${e},${e} 0 0 1 ${o+n-e},${r+s} L${o},${r+s} Z`;break;case"left":a=`M${o+n},${r} L${o+e},${r} A${e},${e} 0 0 0 ${o},${r+e} L${o},${r+s-e} A${e},${e} 0 0 0 ${o+e},${r+s} L${o+n},${r+s} Z`;break;case"bottom":a=`M${o},${r} L${o+n},${r} L${o+n},${r+s-e} A${e},${e} 0 0 1 ${o+n-e},${r+s} L${o+e},${r+s} A${e},${e} 0 0 1 ${o},${r+s-e} Z`;break;default:a=`M${o},${r+s} L${o},${r+e} A${e},${e} 0 0 1 ${o+e},${r} L${o+n-e},${r} A${e},${e} 0 0 1 ${o+n},${r+e} L${o+n},${r+s} Z`}return t.createElement("path",{key:u,d:a,fill:Je(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}return t.createElement("rect",{key:u,x:i.x,y:i.y,width:i.w,height:i.h,fill:Je(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const i=e;return t.createElement("circle",{key:u,cx:i.x,cy:i.y,r:i.r,fill:Je(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"wedge":{const i=e,o=D().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o({})||"";return t.createElement("path",{key:u,d:r,transform:`translate(${i.cx},${i.cy})`,fill:Je(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"boxplot":{const i=e,o=i.columnWidth/2;return"vertical"===i.projection?t.createElement("g",{key:u},t.createElement("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:Je(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})):t.createElement("g",{key:u},t.createElement("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:Je(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}))}case"violin":{const i=e,o=[t.createElement("path",{key:l("path"),d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:Je(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1})];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.createElement("line",{key:l("iqr"),x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1})):o.push(t.createElement("line",{key:l("iqr"),x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1}))}return t.createElement("g",{key:u},o)}case"connector":return t.createElement("line",{key:u,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.createElement("polygon",{key:u,points:o,fill:Je(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}default:return null}}const ii={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},oi={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ri={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},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"};e(null),function(t){const e=new EventTarget;let i=t(function(t){i=Object.assign(Object.assign({},i),t(i)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:ii,setTheme(e){t(t=>{if("light"===e)return{theme:ii};if("dark"===e)return{theme:oi};if("high-contrast"===e)return{theme:ri};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?oi:ii;return{theme: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: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||{})})}})}}));const ni={light:ii,dark:oi,"high-contrast":ri,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function si(t){if(!t)return ii;if("string"==typeof t){if("light"===t)return ii;if("dark"===t)return oi;if("high-contrast"===t)return ri;return ni[t]||ii}const e="dark"===t.mode?oi:ii;return Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})})}function ai(t){var e,i,o,r;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function ci(e){const{categories:i,colorScheme:o,theme:r,position:n="right",totalWidth:s,totalHeight:a,margin:c,hasTitle:l=!1}=e;if(!i||0===i.length)return null;const u=function(t,e,i){const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:m;return h().domain(t).range(o)}(i,o,r),f="top"===n||"bottom"===n;let d,g;if("left"===n?(d=4,g=c.top):"top"===n?(d=c.left,g=l?32:8):"bottom"===n?(d=c.left,g=Math.min(a-c.bottom+38,a-16)):(d=s-c.right+10,g=c.top),f){let e=0;const o=i.map((i,o)=>{const n=e;return e+=22+6.5*i.length+8,t.createElement("g",{key:"legend-"+o,transform:`translate(${n},0)`},t.createElement("rect",{width:14,height:14,fill:u(i),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily},i))});return t.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},o)}const y=i.map((e,i)=>t.createElement("g",{key:"legend-"+i,transform:`translate(0,${20*i})`},t.createElement("rect",{width:14,height:14,fill:u(e),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily},e)));return t.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},y)}function li(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function ui(t,e){return t.color||e.colors.annotation||e.colors.text}function hi(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=fi(i[t],t,e);r&&o.push(r)}return o.length>0?t.createElement("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},o):null}function fi(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:f}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=ui(e,u),a=e.label,h=e.labelPosition||"right",f=e.strokeDasharray||"6,4",d=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=ui(e,u),a=e.label,h=e.labelPosition||"top",f=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.createElement("g",{key:"ann-xthresh-"+i},t.createElement("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.createElement("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||ui(e,u),f=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.createElement("g",{key:"ann-band-"+i},t.createElement("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:f}),e.label&&t.createElement("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily},e.label))}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=ui(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.createElement("rect","horizontal"===o.projection?{key:"ann-cathighlight-"+i,x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{key:"ann-cathighlight-"+i,x:r,y:0,width:n,height:l.height,fill:s,opacity:h})}case"label":case"text":{const o=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(e,c,h),r=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(e,c,f);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.createElement("g",{key:"ann-label-"+i},"label"===e.type&&t.createElement("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.createElement("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight},e.label||e.title))}default:return null}}const di={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},o)},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,f=null!==(c=r.arcWidth)&&void 0!==c?c:.3,d=180+(360-h)/2,g=r.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-f)),sweepAngle:h,startAngle:d,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:f,value:r.value,startAngleDeg:d,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)}},gi=require("react-dom/server");function yi(t){return Math.round(100*t)/100+""}function pi(e,i){const o=ai(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily}},n&&t.createElement("title",{id:s},n),i.description&&t.createElement("desc",{id:a},i.description),i.defs&&t.createElement("defs",null,i.defs),i.background&&"transparent"!==i.background&&t.createElement("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.createElement("g",{id:r+"data-area",transform:i.innerTransform},e),n&&t.createElement("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily},n),i.legend&&t.createElement("g",{id:r+"legend"},i.legend),i.outerElements)}function mi(e){var i,o,r,n;const s=si(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=e.legendPosition;e.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:f&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:f?void 0:e.xAccessor,yAccessor:f?void 0:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},g=new St(d);if(e.data&&g.ingest({inserts:e.data,bounded:!0}),g.computeScene({width:u,height:h}),!g.scales||0===g.scene.length)return gi.renderToStaticMarkup(pi(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const y=e._idPrefix,p=e.showGrid?function(e,i,o,r){const{grid:n}=ai(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.createElement("g",{id:s+"grid",className:"semiotic-grid",opacity:.8},a.map((o,r)=>{const s=e.x(o);return t.createElement("line",{key:"gx-"+r,x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5})}),c.map((o,r)=>{const s=e.y(o);return t.createElement("line",{key:"gy-"+r,x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5})}))}(g.scales,{width:u,height:h},s,y):null,m=g.scene.map((t,e)=>ti(t,e)).filter(Boolean),x=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=ai(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||yi)(t)})),f=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||yi)(t)}));return t.createElement("g",{id:(n?n+"-":"")+"axes",className:"stream-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.createElement("g",{key:"xtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:u.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),o.xLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily},o.xLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),f.map((e,i)=>t.createElement("g",{key:"ytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),o.yLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},o.yLabel))}(g.scales,{width:u,height:h},e,s,y):null,v=e.annotations?hi({annotations:e.annotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:u,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:y}):null,b=e.showLegend?(()=>{const t=li(e.data||[],e.colorAccessor||e.groupAccessor);return 0===t.length?null:ci({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,k=t.createElement(t.Fragment,null,p,v,m,x);return gi.renderToStaticMarkup(pi(k,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:b,idPrefix:e._idPrefix}))}function xi(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const vi=new Set(["tree","cluster","treemap","circlepack","partition"]);function bi(e){const i=si(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=r[0]-n.left-n.right,a=r[1]-n.top-n.bottom,c=function(t){return Ne[t]}(o);if(!c)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let u,h;if(vi.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return gi.renderToStaticMarkup(pi(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));l.__hierarchyRoot=t,u=[],h=[]}else{const t=e.nodes||[],o=Array.isArray(e.edges)?e.edges:[];if(0===t.length&&0===o.length)return gi.renderToStaticMarkup(pi(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(h=function(t,e){const i=xi(e.sourceAccessor,"source"),o=xi(e.targetAccessor,"target"),r=xi(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,l),0===t.length&&h.length>0){const t=new Set;for(const e of h){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}u=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else u=function(t,e){const i=xi(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,l)}c.computeLayout(u,h,l,[s,a]);const{sceneNodes:f,sceneEdges:d,labels:g}=c.buildScene(u,h,l,[s,a]),y=ai(i);for(const t of g)t.fill||(t.fill=y.text);const p=d.map((e,i)=>function(e,i){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+i,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});case"bezier":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"ribbon":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"curved":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity})}default:return null}}(e,i)).filter(Boolean),m=f.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.createElement("circle",{key:"net-circle-"+i,cx:o.cx,cy:o.cy,r:o.r,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"rect":{const o=e;return t.createElement("rect",{key:"net-rect-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"arc":{const o=e,r=D().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t.createElement("path",{key:"net-arc-"+i,d:r,transform:`translate(${o.cx},${o.cy})`,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}default:return null}}(e,i)).filter(Boolean),x=g.map((e,i)=>function(e,i){return t.createElement("text",{key:"net-label-"+i,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},e.text)}(e,i)).filter(Boolean),v=t.createElement(t.Fragment,null,p,m,x);return gi.renderToStaticMarkup(pi(v,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}))}function ki(e){var i,o,r,n,s;const a=si(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const h=c[0]-l.left-l.right,f=c[1]-l.top-l.bottom,d=e.projection||"vertical",g="radial"===d,y={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:d,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},p=new Fe(y);if(e.data&&p.ingest({inserts:e.data,bounded:!0}),p.computeScene({width:h,height:f}),!p.scales||0===p.scene.length)return gi.renderToStaticMarkup(pi(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const m=e._idPrefix,x=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=ai(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.createElement("g",{id:a+"grid",className:"semiotic-grid",opacity:.8},l.map(c?(e,o)=>{const r=n.r(e);return t.createElement("line",{key:"gr-"+o,x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5})}:(e,o)=>{const r=n.r(e);return t.createElement("line",{key:"gr-"+o,x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5})}))}(p,{width:h,height:f},a,m):null,v=p.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let b=null;if(v){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of p.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.createElement("pattern",{key:i,id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0},o&&"transparent"!==o&&t.createElement("rect",{width:c,height:c,fill:o}),t.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.createElement("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n}))}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of p.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const k=p.scene.map((t,e)=>ei(t,e)).filter(Boolean),A=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,f,d;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ai(r),p="vertical"===g.projection,m=Object.values(e.columns).map(t=>({pixel:t.middle,label:(o.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(o.rFormat||yi)(t)}));return p?t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,o)=>t.createElement("g",{key:"oxtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.oLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},o.oLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.rLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},o.rLabel)):t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,o)=>t.createElement("g",{key:"oxtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.rLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},o.rLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.oLabel&&t.createElement("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(d=null===(f=o.margin)||void 0===f?void 0:f.left)&&void 0!==d?d:40)}, ${i.height/2})`},o.oLabel))}(p,{width:h,height:f},e,a,m):null,w=e.annotations?hi({annotations:e.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:h,height:f},theme:a,projection:d,idPrefix:m}):null,S=e.showLegend?(()=>{const t=li(e.data||[],e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:ci({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,_=g?l.left+h/2:l.left,P=g?l.top+f/2:l.top,E=t.createElement(t.Fragment,null,x,w,k,A);return gi.renderToStaticMarkup(pi(E,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${_},${P})`,legend:S,defs:b,idPrefix:e._idPrefix}))}function Ai(e){var i,o,r,n,s,a,c,l;const u=si(e.theme),h=e.size||[e.width||600,e.height||400],f=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),d=h[0]-(null!==(i=f.left)&&void 0!==i?i:0)-(null!==(o=f.right)&&void 0!==o?o:0),g=h[1]-(null!==(r=f.top)&&void 0!==r?r:0)-(null!==(n=f.bottom)&&void 0!==n?n:0),y=new Qe({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);y.setAreas(e.areas)}if(e.points&&y.setPoints(e.points),e.lines&&y.setLines(e.lines),y.computeScene({width:d,height:g}),0===y.scene.length)return gi.renderToStaticMarkup(pi(null,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(s=f.left)&&void 0!==s?s:0},${null!==(a=f.top)&&void 0!==a?a:0})`,idPrefix:e._idPrefix}));const p=y.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.createElement("path",{key:"geoarea-"+i,d:n.pathData,fill:Je(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const o=e;return t.createElement("circle",{key:"point-"+i,cx:o.x,cy:o.y,r:o.r,fill:Je(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1})}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.createElement("path",{key:"line-"+i,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1})}default:return null}}(e,i)).filter(Boolean),m=t.createElement(t.Fragment,null,p);return gi.renderToStaticMarkup(pi(m,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(c=f.left)&&void 0!==c?c:0},${null!==(l=f.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}))}function wi(t,e){switch(t){case"xy":return mi(e);case"ordinal":return ki(e);case"network":return bi(e);case"geo":return Ai(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Si(t){return mi(t)}function _i(t){return ki(t)}function Pi(t){return bi(t)}function Ei(t){return Ai(t)}function Mi(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:f,background:d,className:g,annotations:y,margin:p,colorScheme:m,colorBy:x,legendPosition:v}=i,b=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),k=[s,a],A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},b.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:f,background:d,className:g,annotations:y,size:k}),void 0!==p&&{margin:p}),void 0!==m&&{colorScheme:m}),void 0!==v&&{legendPosition:v}),{_idPrefix:b._idPrefix}),w=di[e];if(!w)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const S=w.buildProps(n,x,m,A,b);let _=(0,{xy:mi,ordinal:ki,network:bi,geo:Ai}[w.frameType])(S);if("GaugeChart"===e&&S.__gauge){const e=S.__gauge,i=A.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,f=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),d=(e.startAngleDeg+(e.gMax===e.gMin?0:(f-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,g=si(c).colors.text,y=gi.renderToStaticMarkup(t.createElement(t.Fragment,null,t.createElement("line",{x1:u,y1:h,x2:u+l*Math.cos(d),y2:h+l*Math.sin(d),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),t.createElement("circle",{cx:u,cy:h,r:4,fill:g})));_=_.replace("</svg>",y+"</svg>")}return _}function Oi(t,e){return J(this,arguments,void 0,function*(t,e,i={}){var o,r;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?wi(t,e):Mi(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(u*s),Math.round(h*s));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function Ti(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=ai(si(s)),f=l.columns||2,d=null!==(o=l.gap)&&void 0!==o?o:16;let g=0;r&&(g+=30),n&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-d-d*(f-1))/f),p=[];let m=0,x=g+d,v=0;for(const t of e){const e=Math.min(t.colSpan||1,f),i=t.props.height||300;m+e>f&&(x+=v+d,m=0,v=0),p.push({chart:t,x:d/2+m*(y+d),y:x,w:y*e+d*(e-1),h:i}),v=Math.max(v,i),m+=e}const b=c||x+v+d,k=p.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?Mi(o.component,l):o.frameType?wi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.createElement("g",{key:"dashboard-chart-"+i,transform:`translate(${r},${n})`},t.createElement("foreignObject",{width:a,height:c},t.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})))}),A=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily}},r&&t.createElement("title",null,r),u&&t.createElement("rect",{x:0,y:0,width:a,height:b,fill:u}),r&&t.createElement("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily},r),n&&t.createElement("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily},n),k);return gi.renderToStaticMarkup(A)}const Li=require("react-dom/server");function $i(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=o,d=i.width||600,g=i.height||400,y=si(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=d-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},f&&{decay:f}),c=new Fe(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ni(c.scene,d,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new St(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(ji(v.scene,d,g,y,p,b)),l>0&&o>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(ji(v.scene,d,g,y,p,b))}}return w}function zi(t,e,i={}){return e.map(e=>{try{return Mi(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Di(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function ji(e,i,o,r,n,s){const a=ai(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=Di(n,r),f=e.map((t,e)=>ti(t,e)).filter(Boolean),d=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=ai(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,f=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,d=u.labelPosition||"right";l.push(t.createElement("g",{key:"ann-"+r},t.createElement("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:f,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.createElement("text",{x:"left"===d?4:"center"===d?i/2:i-4,y:e-5,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily},u.label)))}}return l.length>0?t.createElement(t.Fragment,null,l):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),g="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily}},g&&t.createElement("title",{id:p},g),y&&t.createElement("desc",{id:m},y),h&&t.createElement("rect",{x:0,y:0,width:i,height:o,fill:h}),t.createElement("g",{transform:`translate(${c.left},${c.top})`},d,f),g&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},g));return Li.renderToStaticMarkup(v)}function Ni(e,i,o,r,n){const s=ai(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=Di(n,r),f=e.map((t,e)=>ei(t,e)).filter(Boolean),d="string"==typeof n.title?n.title:void 0,g="string"==typeof n.description?n.description:void 0,y=d?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily}},d&&t.createElement("title",{id:y},d),g&&t.createElement("desc",{id:p},g),h&&t.createElement("rect",{x:0,y:0,width:i,height:o,fill:h}),t.createElement("g",{transform:`translate(${l},${u})`},f),d&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily},d));return Li.renderToStaticMarkup(x)}function Bi(t,e,i){return J(this,arguments,void 0,function*(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.height||400,l=Math.round((i.width||600)*s),u=Math.round(c*s),h=$i(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===h.length)throw Error("No frames generated — check that data is not empty");let f,d,g,y;try{f=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");d=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/r),m=d();for(let t=0;h.length>t;t++){const e=h[t],i=yield f(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,u,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{$i as generateFrameSVGs,zi as generateFrameSequence,Mi as renderChart,Ti as renderDashboard,Ei as renderGeoToStaticSVG,Pi as renderNetworkToStaticSVG,_i as renderOrdinalToStaticSVG,Bi as renderToAnimatedGif,Oi as renderToImage,wi as renderToStaticSVG,Si as renderXYToStaticSVG,si as resolveTheme,ai as themeStyles};
|
|
1
|
+
import{jsx as t,jsxs as e,Fragment as i}from"react/jsx-runtime";import*as o from"react-dom/server";import{scaleOrdinal as r,scaleLinear as n,scaleLog as s,scaleTime as a,scaleBand as c}from"d3-scale";import{quadtree as l}from"d3-quadtree";import{interpolatePlasma as h,interpolateViridis as u,interpolatePurples as d,interpolateOranges as f,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeSet3 as m,schemeTableau10 as v,schemeCategory10 as x,interpolateTurbo as b,interpolateCividis as k,interpolateMagma as A,interpolateInferno as w,interpolateGreys as S}from"d3-scale-chromatic";import{min as _,groups as P,max as M,sum as O,mean as T,group as E,quantile as L}from"d3-array";import{interpolateNumber as j}from"d3-interpolate";import{forceLink as D,forceSimulation as z,forceManyBody as $,forceCenter as R,forceX as C,forceY as N}from"d3-force";import{ribbon as W,chord as B}from"d3-chord";import{arc as F,pie as Y}from"d3-shape";import{hierarchy as I,partition as X,pack as q,treemap as G,treemapBinary as V,cluster as H,tree as Q}from"d3-hierarchy";import{geoPath as Z,geoGraticule as U,geoDistance as K,geoInterpolate as J,geoEqualEarth as tt,geoEquirectangular as et,geoNaturalEarth1 as it,geoOrthographic as ot,geoAlbersUsa as rt,geoMercator as nt}from"d3-geo";import*as st from"react";import{createContext as at,useMemo as ct,useContext as lt,useRef as ht,useCallback as ut,useSyncExternalStore as dt}from"react";function ft(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class gt{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 i of t){const t=this.push(i);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 i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class yt{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 i of t){const t=e?e(i):i;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 pt(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function mt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function vt(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function xt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const kt={category10:x,tableau10:v,set3:m,blues:p,reds:y,greens:g,oranges:f,purples:d,viridis:u,plasma:h},At=x,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function _t(t,e,i="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=o.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(i))return r().domain(o).range(i).unknown("#999");const s=kt[i]||kt.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:At;return r().domain(o).range(t).unknown("#999")}}function Pt(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function Mt(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function Ot(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Tt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Et(t,e,i){return t+(e-t)*i}function Lt(){return"undefined"!=typeof performance?performance.now():Date.now()}function jt(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Dt(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function zt(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),h=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(h)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),h=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],h[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:h,style:n,datum:t,group:s}}function $t(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function Rt(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function Ct(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Nt(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function Wt(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=$t(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const Bt={blues:p,reds:y,greens:g,viridis:u,oranges:f,purples:d,greys:S,plasma:h,inferno:w,magma:A,cividis:k,turbo:b},Ft=new Map;class Yt{constructor(t){if(this.xExtent=new yt,this.yExtent=new yt,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 gt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=vt(t.timeAccessor||t.xAccessor,"time"),this.getY=vt(t.valueAccessor||t.yAccessor,"value")):(this.getX=vt(t.xAccessor,"x"),this.getY=vt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?vt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?vt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?vt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?vt(t.openAccessor,"open"):void 0,this.getHigh=vt(t.highAccessor,"high"),this.getLow=vt(t.lowAccessor,"low"),this.getClose=i?vt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new gt(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?vt(this.config.timeAccessor||this.config.xAccessor,"time"):vt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i 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(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),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,i,o,r,c,l,h;const{config:u,buffer:d}=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(d,this.getX),this.yExtent.dirty)if("candlestick"===u.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of d)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(d,this.getY);const f=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=u.xExtent?[null!==(i=u.xExtent[0])&&void 0!==i?i:g[0],null!==(o=u.xExtent[1])&&void 0!==o?o:g[1]]:g,m=u.yExtent?[null!==(r=u.yExtent[0])&&void 0!==r?r:y[0],null!==(c=u.yExtent[1])&&void 0!==c?c:y[1]]:y;const v=u.yExtent&&null!=u.yExtent[0]&&null!=u.yExtent[1];if("stackedarea"===u.chartType&&!v&&d.size>0)if(u.normalize)m=[0,1+u.extentPadding];else{const t=`${d.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(f),i=new Map;let o=0;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const n=(i.get(t)||0)+r;i.set(t,n),n>o&&(o=n)}m=[0,o+(o>0?o*u.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===u.chartType&&u.binSize&&!v&&d.size>0){const[,t]=function(t,e,i,o,r){const n=pt(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(d,this.getX,this.getY,u.binSize,this.getCategory);m=[0,t+t*u.extentPadding]}else if("waterfall"===u.chartType&&!v&&d.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(d,this.getY),i=e-t,o=i>0?i*u.extentPadding:1;m=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!v&&m[0]!==1/0){if(this.getBounds)for(const t of f){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>m[1]&&(m[1]=e+i),m[0]>e-i&&(m[0]=e-i))}const t=m[1]-m[0],e=t>0?t*u.extentPadding:1,i=null===(l=u.yExtent)||void 0===l?void 0:l[0],o=null===(h=u.yExtent)||void 0===h?void 0:h[1];m=[null!=i?m[0]:m[0]-e,null!=o?m[1]:m[1]+e],"log"===u.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+u.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===u.xScaleType){const t=Date.now();p=[t-864e5,t]}else p=[0,1];m[0]!==1/0&&m[1]!==-1/0||(m=[0,1]);const x="streaming"===u.runtimeMode,b=Math.max(0,Math.min(u.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(k=u.arrowOfTime)||"down"===k?"y":"x")){const e="right"===u.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:n().domain(p).range(e),y:n().domain(m).range([t.height-b,b])}}else{const e="down"===u.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:n().domain(m).range([b,t.width-b]),y:n().domain(p).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)};this.scales={x:e(u.xScaleType,p,[b,t.width-b]),y:e(u.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,f),this.config.decay&&this.applyDecay(this.scene,f),this.config.pulse&&this.applyPulse(this.scene,f),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,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,Yt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=l().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),r=this.scales.y.domain(),c=this.scales.x.range(),l=this.scales.y.range(),h=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)},u=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),d=l[1]>l[0];this.scales={x:h(this.config.xScaleType,o,c[0]>c[1]?[t.width-u,u]:[u,t.width-u]),y:h(this.config.yScaleType,r,d?[u,t.height-u]:[t.height-u,u])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:o,scales:r}=this;if(!r||0===e.length)return[];const n={scales:r,config:o,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(o.chartType){case"line":return function(t,e){var i;const o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.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 o){const i=Nt(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=Dt(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return Wt(t,o,r),r}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=zt(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Wt(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=zt(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=Dt(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Wt(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:n}=function(t,e,i,o,r,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}h.set(e.key,t)}let u;if(n){u=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=h.get(o.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const d=[],f=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=h.get(i.key),o=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);n&&(r/=u.get(i));const l=s+r,h=e.x(i);a.push([h,e.y(s)]),o.push([h,e.y(l)]),g.set(i,l),c.set(i,l)}f.set(i.key,c);const y={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),d.push(y)}return{nodes:d,stackedTops:f}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,o),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=n.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};Wt(t,i,s,o)}return s}(n,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,h=$t(i,t.scales,t.getX,t.getY,n,e,l);h&&o.push(h)}return o}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=vt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[h,u]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(u-h||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-h)/g),s-1),u=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>u)continue;const f=u*s+c;m[f]++;const p=l(o);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,A=i.width/s,w=i.height/a,S=t.config.showValues,_=t.config.heatmapValueFormat,P=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const n=(r-x)/k;P.push(Ct(i*A,(a-1-t)*w,A,w,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=vt(t.config.valueAccessor,"value"),r=xt(t.config.xAccessor,"x"),n=xt(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),h=n(i);c[t]=o,l[t]=h,s.has(o)||s.set(o,s.size),a.has(h)||a.set(h,a.size)}const h=s.size,u=a.size;if(0===h||0===u)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),g=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const m=new Float64Array(e.length),v=new Float64Array(e.length),x=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const u=o(i),d=n*h+r,f=b.get(d);let g;void 0!==f?g=f:(g=k++,b.set(d,g)),m[g]=d,v[g]=u,x[g]=i}let A=1/0,w=-1/0;for(let t=0;k>t;t++){const e=v[t];isFinite(e)&&(A>e&&(A=e),e>w&&(w=e))}if(!isFinite(A)||!isFinite(w))return[];const S=function(t){const e=t in Bt?t:"blues";let i=Ft.get(e);if(i)return i;i=Array(256);const o=Bt[e]||p;for(let t=0;256>t;t++)i[t]=o(t/255);return Ft.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(w-A||1),P=i.width/h,M=i.height/u,O=t.config.showValues,T=t.config.heatmapValueFormat,E=[];for(let t=0;k>t;t++){const e=v[t];if(!isFinite(e))continue;const i=m[t],o=i%h;E.push(Ct(o*P,(u-1-(i-o)/h)*M,P,M,S[Math.min((e-A)*_+.5|0,255)],x[t],O?{value:e,showValues:!0,valueFormat:T}:void 0))}return E}(n,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),h=t.config.barStyle,u=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==h?void 0:h.gap,f="number"!=typeof d||0>d?1:d,g={};(null==h?void 0:h.stroke)&&(g.stroke=h.stroke),"number"==typeof(null==h?void 0:h.strokeWidth)&&(g.strokeWidth=h.strokeWidth),"number"==typeof(null==h?void 0:h.opacity)&&(g.opacity=h.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,v=Math.min(d,y)+m/2,x=Math.max(p-m,1);if(x>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==h?void 0:h.fill)||u||"#4e79a7";s.push(Rt(v,Math.min(c,l),x,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(Rt(v,Math.min(t,i),x,Math.abs(t-i),Object.assign({fill:(null==h?void 0:h.fill)||u||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=null!==(i=n.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n,s,a;const c=[],l=t.config.swarmStyle||{},h=null!==(i=l.radius)&&void 0!==i?i:3,u=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),n=t.scales.y(o);let s=u;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:h,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(n,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const h=[],u=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return h;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,v=null==d?void 0:d.strokeWidth,x=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=u.x(r),l=0!==a?u.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const w=u.y(b),S=u.y(s),_=Math.min(w,S),P=Math.abs(w-S),M={fill:0>n?y:g,stroke:m,strokeWidth:v};null!=x&&(M.opacity=x),h.push(Rt(k,_,A,P,M,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return h}(n,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",h=r?a:s.wickColor||"#333",u=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:h,wickWidth:u,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Pt(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=Pt(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=Pt(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=Pt(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=Pt(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=Mt(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=Mt(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(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,i,o){var r,n,s,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],h=jt(t,l,c);h&&("point"===l.type?i.set(h,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(h,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(h,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(h,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=jt(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{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,i,o,r){var n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b,k,A,w,S,_,P,M,O,T,E,L,j,D,z,$,R,C,N,W,B,F,Y,I,X,q;if(0===o.size&&0===r.size)return i;const G=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let V=!1;const H=new Set,Q=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],E=jt(t,n,e);if(!E)continue;if(n._transitionKey=E,"line"===n.type||"area"===n.type){const t=r.get(E);if(t){if(Q.add(E),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;continue}const L=o.get(E);if("point"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(h=n.style.opacity)&&void 0!==h?h:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(u=L.r)&&void 0!==u?u:n.r,V=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("rect"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,V=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("heatcell"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(v=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(x=L.w)&&void 0!==x?x:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,V=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){H.add(E);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(M=L.lowY)&&void 0!==M?M:n.lowY,V=!0)}else n._targetOpacity=null!==(T=null===(O=n.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0}for(const[t,e]of r)if(!Q.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}for(const[t,e]of o)if(!H.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(j=e.r)&&void 0!==j?j:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(W=e.opacity)&&void 0!==W?W:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(F=e.closeY)&&void 0!==F?F:o,highY:null!==(Y=e.highY)&&void 0!==Y?Y:o,lowY:null!==(I=e.lowY)&&void 0!==I?I:o,bodyWidth:null!==(X=e.w)&&void 0!==X?X:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(q=e.opacity)&&void 0!==q?q:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}V=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),V&&(i.activeTransition={startTime:Lt(),duration:G}),i}(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},i=function(t,e,i,o){var r,n,s,a,c,l;if(!i.activeTransition)return!1;const h=Tt(t,i.activeTransition),u=Ot(h,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=Et(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=Et(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=Et(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(i.h,t._targetH,u))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),void 0!==i.openY&&(t.openY=Et(i.openY,t._targetOpenY,u)),void 0!==i.closeY&&(t.closeY=Et(i.closeY,t._targetCloseY,u)),void 0!==i.highY&&(t.highY=Et(i.highY,t._targetHighY,u)),void 0!==i.lowY&&(t.lowY=Et(i.lowY,t._targetLowY,u))}else if("line"===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:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=u);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Et(e[o][0],i[o][0],u),t.path[o][1]=Et(e[o][1],i[o][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=u);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=Et(e[i][0],o[i][0],u),t.topPath[i][1]=Et(e[i][1],o[i][1],u);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Et(i[e][0],r[e][0],u),t.bottomPath[e][1]=Et(i[e][1],r[e][1],u)}}if(h>=1){for(const t of i.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 i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.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,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}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 i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||wt,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=(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)||wt;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>Yt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);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.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)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)=>{r.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++,n}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,i,o,r;const n=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 s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!mt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!mt(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=vt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=vt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=vt(this.config.xAccessor,"x"),this.getY=vt(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!mt(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!mt(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!mt(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?vt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!mt(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!mt(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?vt(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!mt(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!mt(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!mt(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!mt(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!mt(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?vt(this.config.openAccessor,"open"):void 0,this.getHigh=vt(this.config.highAccessor,"high"),this.getLow=vt(this.config.lowAccessor,"low"),this.getClose=e?vt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function It(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Xt(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,u=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(h(i,r),u=!0):n[o]||(u=l(o));if(u)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),u}function h(t,e){var i=[].concat(e).concat(t);o.push(i)}function u(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,h=0,u=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=h,r[e]=!0,h+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=h,r[y]=!0,h+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var x=c[g];if(r[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=u.length,x===e){c.length=g;break}}u.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);d[c]=l}}return{components:u,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var d=t.length;d>i;){var f=u(i);if(i=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=d}return o}function qt(t){return t.y0-t.y1>0?"up":"down"}function Gt(t,e){return e(t.source)==e(t.target)}function Vt(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Ht(t){return t.target.x0-t.source.x1}function Qt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1-o:t.y1+o}function Zt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1+o:t.y1-o}function Ut(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Kt(t,e){return e(t)}function Jt(t){return ee(t.source)}function te(t){return ee(t.target)}function ee(t){return(t.y0+t.y1)/2}function ie(t){return t.virtual?0:t.value}function oe(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Gt(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Gt(t,e)?o+1:o}),i+o}function re(t){return t.target.depth}function ne(t,e){return t.sourceLinks.length?t.depth:e-1}function se(t,e){return t.y0-e.y0}function ae(t,e){return e.y0-t.y0}function ce(t,e){return t.y1-e.y1}function le(t,e){return e.y1-t.y1}function he(t,e){return de(t.source,e.source)||t.index-e.index}function ue(t,e){return de(t.target,e.target)||t.index-e.index}function de(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function fe(t,e){return ge(t)==ge(e)?"bottom"==t.circularLinkType?ae(t,e):se(t,e):ge(e)-ge(t)}function ge(t){return t.target.column-t.source.column}function ye(t,e){return pe(t)==pe(e)}function pe(t){return t.y0-t.y1>0?"up":"down"}function me(t,e,i,o,r){let n=t;var s=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=_(n.links,function(t){return t.source.y0});n.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=n.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),ve(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),ve(n.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),n.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Gt(t,e)&&Vt(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=n.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?ae:se);var h=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=e._circularWidth||e.width}),s=t.target.column,(l=n.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?le:ce),h=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(n.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-r-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,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),n}function ve(t,e,i){t.sort(fe);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Gt(t,e)&&Vt(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&xe(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function xe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function be(t){return function(){return t}}function ke(t){return t.index}function Ae(t){return t.nodes}function we(t){return t.links}function Se(t,e,i){var o=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=ee(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=ee(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?oe(e,i)-oe(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==oe(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function _e(t,e,i,o,r,n){var s=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var a=1,c=n;c>0;--c)l(a*=.99,i),h();function l(e,i){var o=s.length;s.forEach(function(r){var n=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&oe(r,i)>0){var c=T(r.sourceLinks,te),l=T(r.targetLinks,Jt),h=c&&l?(c+l)/2:c||l;if(h){var u=(h-ee(r))*e*.3;r.y0+=u,r.y1+=u}}else if(0==s&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(s==o-1&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var d=T(r.sourceLinks,te),f=T(r.targetLinks,Jt),g=((d&&f?(d+f)/2:d||f)-ee(r))*e;r.y0+=g,r.y1+=g}})})}function h(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||de),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function Pe(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ue),t.targetLinks.sort(he)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Me(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=ke,c=ne,l=void 0,h=32,u=2,d=Ae,f=we;function g(){var g={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return E(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=It(i,o)),"object"!=typeof r&&(r=t.target=It(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(d,a),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Xt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var h=c[r].slice(-2);l[h[0]]||(l[h[0]]={}),l[h[0]][h[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,l),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){Kt(t,e)!=Kt(r.source,e)&&Kt(t,e)!=Kt(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Gt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(O(t.sourceLinks,ie),O(t.targetLinks,ie)),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)})})}(d),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(d,l,c);var f=n;if(null!==s){var g=P(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=M(g,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=P(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 r=_(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/O(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=M(t.nodes,function(t){return t.column});t.nodes.forEach(n>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/n),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,f,r),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,10,8),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Kt(i.source,e)==Kt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ye(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Qt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Qt(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 n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Kt(i.target,e)==Kt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ye(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=Zt(e,t);return t.y0-i}if(e.source.column>t.source.column)return Zt(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 n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var n=_(e,function(t){return t.y0}),s=M(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-n);function c(e){return(e-n)/(s-n)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),i.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),me(d,a,u,10,8)}(g),g}return g.update=function(t){return Pe(t),me(t,a,u,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(n=+t,g):n},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(d="function"==typeof t?t:be(t),g):d},g.links=function(t){return arguments.length?(f="function"==typeof t?t:be(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:be(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:be(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(u=+t,g):u},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],g):[[t,e],[i,o]]},g.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],g):[i-t,o-e]},g}Yt.GROUP_COLOR_MAP_CAP=1e3,Yt.QUADTREE_THRESHOLD=500;const Oe=t=>{let e,i,o,r,n,s,a,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,s=t.target.x0,a=j(n,s),c=a(.5),l=a(.5),`M${e},${n}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,a=j(e,i),o=a(.5),r=a(.5),n=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${n}C${o},${n} ${r},${s} ${i},${s}L${i},${c}C${r},${c} ${o},${l} ${e},${l}Z`)};function Te(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,h=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${u+d*o-d*f}L${l+o-f},${u+d*o}L${h-o+f},${u+d*o}L${h-o},${u+d*o-d*f}L${h-o},${c-d*i+d*f}L${h-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${h+o},${c+d*i}L${h+o},${u-d*o}L${l-o},${u-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Ee=new Set,Le=new WeakMap;function je(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Le.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Le.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Ee.has(t)||(Ee.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const De={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(re))-1:0},justify:ne},ze={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,h;if(0===t.length)return;const u="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===u?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const x=Me().extent(v).links(m).nodes(p).nodeAlign(De[d]||ne).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,h=o[0],u=o[1];if(n>0&&s>0&&(0>t||0>i||e>h||r>u)){const e=Math.min(h/n,u/s),o=-t*e+(h-n*e)/2,r=-i*e+(u-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,o="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${o}\0${r}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(h=t.width)&&void 0!==h?h:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=u;const e=b.get(o),i=b.get(r);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var r,n,s,a,c,l;const h="vertical"===i.orientation?"down":"right",u=i.nodeStyle,d=i.edgeStyle,f=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],b=[],k=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=u?u(je(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(e.id,("string"==typeof r.fill?r.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===h?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const A=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of A){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(t)||r:"target"===g?k.get(o.id)||p.get(o.id)||r:k.get(e.id)||p.get(e.id)||r;const h=d?d(je(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=h.fill||r;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:s,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-n},${e.targetY-i}L${e.targetX-n},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:s,fillOpacity:null!==(c=h.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let u;if(u=t.circular&&t.circularPathData?Te(t):Oe(t),!u)continue;const y={fill:h.fill||r,fillOpacity:null!==(l=h.fillOpacity)&&void 0!==l?l:f,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};v.push({type:"bezier",pathD:u,bezierCache:t.bezier,style:y,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,c;"down"===h?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="middle"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),b.push({x:s,y:a,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},$e={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,a=o[0]/2,c=o[1]/2,l=i.__previousPositions;let h=0;const u=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==l?void 0:l.get(e.id);t?h++:i?(e.x=i.x,e.y=i.y,h++):u.push(e)}const d=h>0&&.3>=(t.length>0?u.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of u){const o=Re(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=Ce(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=Ce(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(i),t.y=c+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=a+t*Math.cos(r),o.y=c+t*Math.sin(r)}}}const f=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===i.iterations?0:d?40:f,y=Ne(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=D().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=z().force("charge",$().strength(t=>-25*p(t))).force("center",R(a,c).strength(.8)).force("x",C(a).strength(.15)).force("y",N(c).strength(.15));if(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));o.force("link",i),o.force("link").links(t)}d?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;g>t;++t)o.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(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){var r,n,s,a,c,l,h;const u=i.nodeStyle,d=i.edgeStyle,f=Ne(i.nodeSize,i.nodeSizeRange,t),g=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=u?u(je(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=d?d(je(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(a=i.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=i.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(h=r.opacity)&&void 0!==h?h:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=f(je(i,"nodeSize"));v.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Re(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Ce(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function Ne(t,e,i){var o,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=e||[5,20],a=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===a.length)return()=>s[0];const c=null!==(o=_(a))&&void 0!==o?o:0,l=null!==(r=M(a))&&void 0!==r?r:1;if(c===l)return()=>(s[0]+s[1])/2;const h=n().domain([c,l]).range(s).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?s[0]:h(o)}}const We=x,Be={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-n,l=o[0]/2,h=o[1]/2,u=(d=i.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;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,i=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const r=u(t);y[i][o]=r}const p=B().padAngle(r);s&&p.sortGroups(s);const m=p(y),v=m.groups,x=F().innerRadius(c).outerRadius(a);for(const e of v){const i=t[e.index],o=x.centroid(e);i.x=o[0]+l,i.y=o[1]+h,i.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,i=b.get("string"==typeof t.source?t.source:t.source.id),o=b.get(e);i&&(t.source=i),o&&(t.target=o)}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 m){const i=t[e.source.index].id,o=t[e.target.index].id,r=k.get(`${i}\0${o}`)||k.get(`${o}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,o){var r,n,s,a;const{groupWidth:c=20,edgeOpacity:l=.5}=i,h=Math.min(o[0],o[1])/2,u=h-c,d=o[0]/2,f=o[1]/2,g=i.nodeStyle,y=i.edgeStyle,p=i.edgeColorBy||"source",m=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:We,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const x=W().radius(u),b=[],k=[],A=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=g?g(je(i,"nodeStyle")).fill||v.get(i.id)||m[e%m.length]:v.get(i.id)||m[e%m.length];const s=g?g(je(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};b.push({type:"arc",cx:d,cy:f,innerR:u,outerR:h,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const o=x(e);if(!o)continue;const r=Fe(o,d,f);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)c=y(je(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===p&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const h=y?y(je(t,"edgeStyle")):{},u={fill:c,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:l,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};k.push({type:"ribbon",pathD:r,style:u,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,o=h+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;A.push({x:d+Math.cos(s)*o,y:f+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:k,labels:A}}};function Fe(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const Ye=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ie(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Xe(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function qe(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function Ge(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ye}function Ve(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 He(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const Qe={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},h=I(n,a);h.sum(l),h.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[u,d]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=Q();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=H();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=G().size([i,o]).tile(V).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,u,d);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;q().size([i,o]).padding(n)(t)}(h,i,u,d);break;case"partition":!function(t,e,i,o){var r;X().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,u,d)}const f=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const o=f[e],n={id:Xe(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ze(n,o,i):"treemap"===s||"partition"===s?Ue(n,o):"circlepack"===s&&Ke(n,o),n.__hierarchyNode=o,t.push(n),g.set(o,n)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const i=g.get(t.parent),o=g.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,h,u,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",v="radial"===m,x=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;v&&(t+=x,o+=b);const n=r(je(e,"nodeStyle"));let c=n.fill||Ve(i);if(i.colorByDepth&&void 0!==e.depth){const t=Ge(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;v&&(r+=x,s+=b,a+=x,c+=b);const f=He(r,s,a,c,m),g=n(je(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(h=i.themeSemantic)||void 0===h?void 0:h.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=qe(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(v&&(s+=x,a+=b),v){const t=s-x,e=a-b,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],h=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o(je(i,"nodeStyle"));let c=a.fill||Ve(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ge(e);c=t[i.depth%t.length]}const h={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=qe(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,u=l.y1-l.y0;if(0>=t||0>=u)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>u)continue;let g=o(je(l,"nodeStyle")).fill||Ve(e);if(e.colorByDepth&&void 0!==l.depth){const t=Ge(e);g=t[l.depth%t.length]}const y="string"==typeof g?Ie(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";h.push(d?{x:l.x0+t/2,y:l.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:h}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,h,u,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o(je(i,"nodeStyle"));let l=c.fill||Ve(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ge(e);l=t[i.depth%t.length]}const h={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=qe(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o(je(r,"nodeStyle")).fill||Ve(e);if(e.colorByDepth&&void 0!==r.depth){const t=Ge(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?Ie(a):null!==(u=null===(h=e.themeSemantic)||void 0===h?void 0:h.text)&&void 0!==u?u:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(d=e.themeSemantic)||void 0===d?void 0:d.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,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ze(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Ue(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 Ke(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function Je(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const ti={sankey:ze,force:$e,chord:Be,tree:Qe,cluster:Qe,treemap:Qe,circlepack:Qe,partition:Qe,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),l=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),h=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,u=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,f="number"==typeof u?()=>u:u,g=Je(i);g.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function p(t){var e;const i=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,i+1),0===i?t:`${t}__${i}`}const m=e[0]/2,v=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(c(t));o.push({id:b,x:m,y:v,x0:m,x1:m,y0:v,y1:v,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,i,n,s,h,u,y){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=l[Math.min(k,l.length-1)],k++,x++;let A=0;for(let v=0;x>v;v++){const b=l[Math.min(v,l.length-1)],k=m.slice(A,A+b);if(!k.length)break;const w=(v+1)/x,S={id:i,depth:u,data:e,parentId:i},_=y?h/d(S)*w:h*w,P=Y().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=P(k),O=f(S);for(let e=0;k.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=k[e],h=p(c(l)),d=n+_*Math.sin(a),f=s+_*Math.cos(a)*O;o.push({id:h,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:u,data:l}),g.metaMap.set(h,{ring:_,angle:a,depth:u,parentId:i,eccentricity:O}),r.push({source:i,target:h,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:h}}),t(l,h,d,f,_,u+1,!0)}A+=b}}(t,b,m,v,x,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,h;const u=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=Je(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;y.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=u?u(je(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=f(je(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(h=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==h?h:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=Je(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function ei(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,h=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:h,datum:t.pieceData,category:t.name}))}return n}function ii(t){var e,i,o;const r=t.length,n=t[0],s=t[r-1];return{n:r,min:n,q1:null!==(e=L(t,.25))&&void 0!==e?e:n,median:null!==(i=L(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(o=L(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/r}}const oi={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:h}=t,{r:u,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=h(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=u(0>a?r:o+a),i=0>a?u(r+a)-u(r):u(o)-u(o+a);f.push(Rt(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=u(0>a?r+a:o),i=0>a?u(r)-u(r+a):u(o+a)-u(o);f.push(Rt(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const v="vertical"===d,x=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(x>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),i=e.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=x),i.length>0&&(i.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=x)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,h=[],u="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(u){const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(n,Math.min(a,u),o,Math.abs(a-u),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(Math.min(a,u),n,Math.abs(u-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of h){if("rect"!==t.type)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=u?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return h},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:h}=r,u=[],d="vertical"===h,f="radial"===h,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),h=g&&a[r]||l,m=c(e,t.name),v=m.r||5;let x,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=h(n);x=Math.cos(e)*i,b=Math.sin(e)*i}else d?(x=t.middle,b=h(n)):(x=h(n),b=t.middle);u.push({type:"point",x:x,y:b,r:v,style:m,datum:e})}return u},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),h=n(o,t.name),u=h.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:u,style:h,datum:o})}}return c},pie:ei,donut:ei,boxplot:function(t,e){var i,o,r,n,s,a;const{scales:c,columns:l,config:h,getR:u,resolveSummaryStyle:d}=t,{r:f,projection:g}=c,y=[],p="vertical"===g,m=!1!==h.showOutliers;for(const e of Object.values(l)){const c=e.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const l=c[0],h=c[c.length-1],g=null!==(i=L(c,.25))&&void 0!==i?i:l,v=null!==(o=L(c,.5))&&void 0!==o?o:(l+h)/2,x=null!==(r=L(c,.75))&&void 0!==r?r:h,b=x-g,k=g-1.5*b,A=x+1.5*b,w=null!==(n=c.find(t=>t>=k))&&void 0!==n?n:l,S=null!==(s=[...c].reverse().find(t=>A>=t))&&void 0!==s?s:h,_=d(e.pieceData[0],e.name),P=[];if(m)for(const t of e.pieceData){const i=u(t);if(k>i||i>A){const o=p?e.middle:f(i),r=p?f(i):e.middle;P.push({px:o,py:r,value:i,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(w),q1Pos:f(g),medianPos:f(v),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:w,q1:g,median:v,q3:x,max:S,mean:c.reduce((t,e)=>t+e,0)/c.length},style:_,datum:e.pieceData,category:e.name,outliers:P}),m)for(const e of P)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:_.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return y},violin:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:h,projection:u}=n,d=[],f="vertical"===u,g=a.bins||20,y=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],s=e[e.length-1],a=(s-n)/g||1,u=Array(g).fill(0);for(const t of e)u[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...u,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${h(n)}`;for(let e=0;g>e;e++){const i=h(n+(e+.5)*a);v+=` L ${t.middle+u[e]/p*m} ${i}`}v+=` L ${t.middle} ${h(s)}`;for(let e=g-1;e>=0;e--){const i=h(n+(e+.5)*a);v+=` L ${t.middle-u[e]/p*m} ${i}`}v+=" Z"}else{v=`M ${h(n)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${h(n+(e+.5)*a)} ${t.middle-u[e]/p*m}`;v+=` L ${h(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${h(n+(e+.5)*a)} ${t.middle+u[e]/p*m}`;v+=" Z"}const x=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=L(e,.25))&&void 0!==i?i:n,c=null!==(o=L(e,.5))&&void 0!==o?o:(n+s)/2,l=null!==(r=L(e,.75))&&void 0!==r?r:s;b={q1Pos:h(a),medianPos:h(c),q3Pos:h(l),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(h(s),h(n)),width:t.width,height:Math.abs(h(s)-h(n))}:{x:Math.min(h(n),h(s)),y:t.x,width:Math.abs(h(s)-h(n)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:ii(e),style:x,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],h=n.bins||25,u=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/h||1,n=Array(h).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),h-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;h>e;e++){if(0===n[e])continue;const o=(u?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(Rt(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,h=[],u=n.bins||20,d="horizontal"===l,f=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/u||1,l=Array(u).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),u-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;u>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;u>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const v=d?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};h.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:ii(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return h},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,h=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Rt(i,t.x,r-i,t.width,h,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Rt(t.x,i,t.width,r-i,h,e,t.name))}}return c},funnel:function(t,e){var i,o,r,s,a,c,l,h;const{columns:u,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===v.length)return y;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],A=[];let w=0;for(const t of v){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>w&&(w=i)}if(k)for(const t of A){let e=0,i=0;for(let o=0;x.length>o;o++){const r=t.groups.get(x[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>w&&(w=o)}if(0===w)return y;const S=new Map;for(const t of x){const e=A[0].groups.get(t);S.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const _=A[0].stepTotal,P=k?.95*p:.9*e.width,M=n().domain([0,w]).range([0,P]),O=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let T=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,n=0===e,u=o.width,d=.55*u,f=o.x+(u-d)/2,v=new Map;if(k){let t=0;for(const e of x){const o=i.groups.get(e);o&&(t+=M(o.total))}let e=p,r=p;for(let s=0;x.length>s;s++){const c=x[s],l=i.groups.get(c);if(!l)continue;const h=M(l.total),u=s%2==0,b=u?e:r-h;u?e+=h:r-=h;const k=g(l.pieces[0],c),A=null!==(a=S.get(c))&&void 0!==a?a:l.total,w=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=f,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+h/2,_.__funnelValueLabelY=f,_.__funnelBarW=h),y.push(Rt(b,f,h,d,k,_,c)),v.set(c,{x:b,y:f,w:h,h:d})}}else{const t=i.stepTotal,e=M(t),a=p-e/2,c=x[0],l="_default"!==c,h=null!==(s=null===(r=i.groups.get(c))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],u=l?c:o.name,b=g(h,u),k=_>0?t/_*100:0,A=Object.assign(Object.assign({},h),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:n,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(Rt(a,f,e,d,b,A,u)),v.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&T.size>0){const e=k?x:[x[0]];for(const r of e){const e=T.get(r),n=v.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:O},datum:null!==(h=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==h?h:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}T=v}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:h}=t,u=[],d=h.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return u;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of f){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const v=h.r,x=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/x,c=a*b,h=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,x=null!==(r=m.get(d))&&void 0!==r?r:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=o?0:Math.max(0,A-p),S=i.x+t*a+c/2,_=v(p),P=v(0)-_,M=l(g.pieces[0],y?d:i.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+h/2,__barFunnelLabelY:v(p+w)});if(u.push(Rt(S,_,h,P,M,O,y?d:i.name)),w>0){const t=v(p+w),e=_-t,o=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:x>0?w/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});u.push(Rt(S,t,h,e,o,r,y?d:i.name))}}}return u},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],h="horizontal"===c;for(const t of Object.values(o)){let e=0;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,u=s(i,c);if(h){const r=a(e),n=a(e+o);l.push(Rt(r,t.x,n-r,t.width,u,i,c))}else{const r=a(e+o),n=a(e);l.push(Rt(t.x,r,t.width,n-r,u,i,c))}e+=o}}return l}};class ri{constructor(t){this.rExtent=new yt,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new gt(t.windowSize),this.getO=bt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new yt)):(this.getR=vt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=bt(t.stackBy),this.getGroup=bt(t.groupBy),this.getColor=bt(t.colorAccessor),this.getConnector=bt(t.connectorAccessor),this.getDataId=bt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new gt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const o=i.toArray(),r=e.projection||"vertical",s=e.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,s),l="horizontal"===r,h="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,f;if(h){d=c().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=n().domain(a).range([o,i])}else l?(d=c().domain(s).range([0,t.height]).padding(u),f=n().domain(a).range([0,t.width])):(d=c().domain(s).range([0,t.width]).padding(u),f=n().domain(a).range([t.height,0]));this.scales={o:d,r:f,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(i,o);let[c,h]=a.extent;c===1/0&&(c=0,h=1);const u=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=h-c,f=d>0?d*u:1;return c-=f,h+=f,c>0&&(c=0),l?n().domain([c,h]).range([0,t.width]):n().domain([c,h]).range([t.height,0])}):[];let g=o;this.rAccessors.length>1&&(g=o.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(g,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,h=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,h=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>h&&(h=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>h&&(h=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>h&&(h=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>h&&(h=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(h=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(h=this.config.rExtent[1]));const u="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(u&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>h&&(h=0)),"bar-funnel"!==a){const t=h-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||u&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||u&&!this.config.baselinePadding&&0===h||"swimlane"===a||(h+=e)}return[l,h]}buildColumns(t,e,i,o,r){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let h=null;if(l&&"radial"!==o){h=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),h.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of h)h.set(e,i/t*n)}let u=0,d=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,f;h?(l=d,f=h.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:u},u+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),o=oi[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,h=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),h.has(i)||h.set(i,[]),h.get(i).push({x:o,y:r,datum:e,category:a(e)})}const u=r.o.domain(),d=n.connectorStyle;for(const[e,r]of h)if(r.length>=2){r.sort((t,e)=>u.indexOf(t.category)-u.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||wt,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Pt(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ri.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=l().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=this.getDatumIndexMap(e);let h=null;for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;h||(h=this.getCategoryIndexMap(e));const o=h.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],h=this.getNodeKey(l,S);if(!h)continue;l._transitionKey=h;const u=this.prevPositionMap.get(h);if("point"===l.type)u?(w.add(h),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(u.x!==l.x||u.y!==l.y||void 0!==u.r&&u.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=u.x,l.y=u.y,void 0!==u.r&&(l.r=u.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)u?(w.add(h),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,u.x===l.x&&u.y===l.y&&u.w===l.w&&u.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=u.x,l.y=u.y,l.w=null!==(r=u.w)&&void 0!==r?r:l.w,l.h=null!==(n=u.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(u)w.add(h),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,u.startAngle===l.startAngle&&u.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=u.startAngle,l.endAngle=u.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(h,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(u=e.w)&&void 0!==u?u:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2;this.exitNodes.push({type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t})}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:Lt(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=Tt(t,this.activeTransition),s=Ot(n,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=Et(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Et(o.x,t._targetX,s),t.y=Et(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=Et(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=Et(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,s),t.y=Et(i.y,t._targetY,s),void 0!==i.w&&(t.w=Et(i.w,t._targetW,s),t.h=Et(i.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Et(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=Et(i.startAngle,t._targetStartAngle,s),t.endAngle=Et(i.endAngle,t._targetEndAngle,s))}}}if(n>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!mt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!mt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(mt(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=bt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!mt(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new yt)):(this.getR=vt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!mt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?bt(this.config.stackBy):void 0),"groupBy"in t&&!mt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?bt(this.config.groupBy):void 0),"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!mt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?bt(this.config.connectorAccessor):void 0)}}ri.QUADTREE_THRESHOLD=500;const ni={mercator:nt,equalEarth:tt,albersUsa:rt,orthographic:ot,naturalEarth:it,equirectangular:et};function si(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ai(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ci(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function li(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function hi(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,h=(t[1]+e[1])/2+a*c,u=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;u.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*h+r*r*e[1]])}return u}function ui(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function di(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,h=r/2+1;return[[t[0]+c*h,t[1]+l*h],[e[0]+c*h,e[1]+l*h]]}class fi{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new gt(t),this.timestampBuffer=new gt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return tt();if("string"==typeof t){const e=ni[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),tt())}if("object"==typeof t&&"type"in t){const e=ni[t.type],i=e?e():tt();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=Z(this.projection),this.fitProjection(t),this.geoPath=Z(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=si(a.xAccessor,"lon"),h=si(a.yAccessor,"lat"),u=this.getPoints();if(u.length>0){const t=u.map(t=>[l(t),h(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const d=ai(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),h(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Z(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Z(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=Z(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,fi.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=l().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=si(n.xAccessor,"lon"),l=si(n.yAccessor,"lat"),h=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),u=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),d=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=U();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=ci(n.areaStyle,t,h);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const f=ai(n.lineDataAccessor);for(const e of this.lineData){const i=f(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=K(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=J(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=ci(n.lineStyle,e,u),h="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?ui(o,h):di(o[0],o[o.length-1],0,0,h)):o=hi(o[0],o[o.length-1]);const d=li(o,t.width);if(d.length>1)for(const t of d){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&d[0]||o,style:a,datum:e})}const g=this.getPoints(),y=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,p=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=p>0?p*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],x="function"==typeof s.center?s.center():[0,0],b=[(null!==(i=x[0])&&void 0!==i?i:0)-v[0],(null!==(o=x[1])&&void 0!==o?o:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],i=c(e),o=l(e);if(null!=m&&K([i,o],b)>m)continue;const a=s([i,o]);if(!a)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},d),u={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:y?y(e)+"":void 0};r.push(u)}return r}applyCartogramTransform(t,e){var i,o,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],h=s.find(e=>c(e.datum)+""==t.center+"");if(!h)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=h.x,d=h.y,f=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=n().domain([0,g]).range([0,y]);this.cartogramLayout={cx:u,cy:d,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===h)continue;const e=Math.atan2(t.y-d,t.x-u),i=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=u+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,v=e.height/2,x=m-h.x,b=v-h.y;if(Math.abs(x)>.5||Math.abs(b)>.5)for(const t of s)t.x+=x,t.y+=b;this.cartogramLayout={cx:m,cy:v,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(o=e.datum)||void 0===o?void 0:o.source,n=null===(r=e.datum)||void 0===r?void 0:r.target;if(i&&n){const o=t.get(i+""),r=t.get(n+"");o&&r&&(e.path=[o,r])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=Pt(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Tt(t,this.activeTransition),i=Ot(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Et(t.x,t._targetX,i),t.y=Et(e,t._targetY,i)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function gi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function yi(i,o){var r,n,s;switch(i.type){case"line":{const e=i;if(0===e.path.length)return null;const r="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:r,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+o)}case"area":{const e=i;if(0===e.topPath.length)return null;const s=e.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...e.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:`M${s}L${a}Z`,fill:gi(e.style.fill),fillOpacity:null!==(n=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==n?n:.7,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"area-"+o)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+o)}case"rect":{const e=i;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:gi(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+o)}case"heatcell":{const r=i;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const i=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[n,s,a]=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]}(r.fill),c=.299*n+.587*s+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return e("g",{children:[t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:c,fontSize:l+"px",children:i})]},"heatcell-"+o)}return t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill},"heatcell-"+o)}case"candlestick":{const r=i,n=Math.min(r.openY,r.closeY),s=Math.max(Math.abs(r.openY-r.closeY),1),a=r.isUp?r.upColor:r.downColor;return e("g",{children:[t("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t("rect",{x:r.x-r.bodyWidth/2,y:n,width:r.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+o)}default:return null}}function pi(i,o){var r,n,s,a,c;const l=("category"in i?i.category:void 0)||("group"in i?i.group:void 0)||"",h=t=>`ord-${i.type}-${l}-${o}-${t}`,u=`ord-${i.type}-${l}-${o}`;switch(i.type){case"rect":{const o=i,r=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(u)+"-grad",n=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=gi(e.style.fill);c.push(t("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(o,r),s=n?`url(#${r})`:gi(o.style.fill);if(o.roundedTop&&o.roundedTop>0){const i=Math.min(o.roundedTop,o.w/2,o.h/2),{x:r,y:a,w:c,h:l}=o;let h;switch(o.roundedEdge){case"right":h=`M${r},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r},${a+l} Z`;break;case"left":h=`M${r+c},${a} L${r+i},${a} A${i},${i} 0 0 0 ${r},${a+i} L${r},${a+l-i} A${i},${i} 0 0 0 ${r+i},${a+l} L${r+c},${a+l} Z`;break;case"bottom":h=`M${r},${a} L${r+c},${a} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r+i},${a+l} A${i},${i} 0 0 1 ${r},${a+l-i} Z`;break;default:h=`M${r},${a+l} L${r},${a+i} A${i},${i} 0 0 1 ${r+i},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l} Z`}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("path",{d:h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}case"wedge":{const e=i,o=F().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&o.cornerRadius(e.cornerRadius);const r=o({})||"";return t("path",{d:r,transform:`translate(${e.cx},${e.cy})`,fill:gi(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity},u)}case"boxplot":{const o=i,r=o.columnWidth/2;return e("g","vertical"===o.projection?{children:[t("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:o.x-r,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:gi(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-r,y1:o.medianPos,x2:o.x+r,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.x-.5*r,y1:o.minPos,x2:o.x+.5*r,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-.5*r,y1:o.maxPos,x2:o.x+.5*r,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-r,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:gi(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.medianPos,y1:o.y-r,x2:o.medianPos,y2:o.y+r,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.minPos,y1:o.y-.5*r,x2:o.minPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.maxPos,y1:o.y-.5*r,x2:o.maxPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1})]},u)}case"violin":{const e=i,o=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:gi(e.style.fill),fillOpacity:null!==(a=e.style.fillOpacity)&&void 0!==a?a:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},h("path"))];if(e.iqrLine&&e.bounds){const i=e.bounds,r=i.x+i.width/2,n=i.y+i.height/2;i.height>i.width?o.push(t("line",{x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:r,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med"))):o.push(t("line",{x1:e.iqrLine.q1Pos,y1:n,x2:e.iqrLine.q3Pos,y2:n,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med")))}return t("g",{children:o},u)}case"connector":return t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:null!==(c=i.style.opacity)&&void 0!==c?c:.5},u);case"trapezoid":{const e=i,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:o,fill:gi(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}default:return null}}function mi(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:vi})})),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}fi.QUADTREE_THRESHOLD=500;const vi=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],xi={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}},bi={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}},ki={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:vi,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"};at(null),function(t){const e=new EventTarget;let i=t(function(t){i=Object.assign(Object.assign({},i),t(i)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:xi,setTheme(e){t(t=>{if("light"===e)return{theme:xi};if("dark"===e)return{theme:bi};if("high-contrast"===e)return{theme:ki};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?bi:xi;return{theme:mi(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:mi(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||{})}))}})}}));const Ai={light:xi,dark:bi,"high-contrast":ki,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function wi(t){if(!t)return xi;if("string"==typeof t){if("light"===t)return xi;if("dark"===t)return bi;if("high-contrast"===t)return ki;return Ai[t]||xi}const e="dark"===t.mode?bi:xi;return mi(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function Si(t){var e,i,o,r;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function _i(i){const{categories:o,colorScheme:n,theme:s,position:a="right",totalWidth:c,totalHeight:l,margin:h,hasTitle:u=!1}=i;if(!o||0===o.length)return null;const d=function(t,e,i){const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:x;return r().domain(t).range(o)}(o,n,s),f="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=h.top):"top"===a?(g=h.left,y=u?32:8):"bottom"===a?(g=h.left,y=Math.min(l-h.bottom+38,l-16)):(g=c-h.right+10,y=h.top),f){let i=0;const r=o.map((o,r)=>{const n=i;return i+=22+6.5*o.length+8,e("g",{transform:`translate(${n},0)`,children:[t("rect",{width:14,height:14,fill:d(o),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:o})]},"legend-"+r)});return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:r})}const p=o.map((i,o)=>e("g",{transform:`translate(0,${20*o})`,children:[t("rect",{width:14,height:14,fill:d(i),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:i})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Pi(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function Mi(t,e){return t.color||e.colors.annotation||e.colors.text}function Oi(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=Ti(i[t],t,e);r&&o.push(r)}return o.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function Ti(i,o,r){var n,s,a,c;const{scales:l,layout:h,theme:u,xAccessor:d,yAccessor:f}=r;switch(i.type){case"y-threshold":{const s=i.value;if(null==s)return null;const a=Mi(i,u),c=i.label,d=i.labelPosition||"right",f=i.strokeDasharray||"6,4",g=null!==(n=i.strokeWidth)&&void 0!==n?n:1.5;if("horizontal"===r.projection&&l.r){const i=l.r(s);return null==i?null:e("g",{children:[t("line",{x1:i,y1:0,x2:i,y2:h.height,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:i+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}const y=l.y?l.y(s):l.r?l.r(s):null;return null==y?null:e("g",{children:[t("line",{x1:0,y1:y,x2:h.width,y2:y,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:"left"===d?4:"center"===d?h.width/2:h.width-4,y:y-6,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}case"x-threshold":{const r=i.value;if(null==r||!l.x)return null;const n=l.x(r);if(null==n)return null;const a=Mi(i,u),c=i.label,d=i.labelPosition||"top",f=null!==(s=i.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:h.height,stroke:a,strokeWidth:f,strokeDasharray:i.strokeDasharray||"6,4"}),c&&t("text",{x:n+4,y:"bottom"===d?h.height-4:"center"===d?h.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-xthresh-"+o)}case"band":{const r=null!=i.y0&&l.y?l.y(i.y0):null,n=null!=i.y1&&l.y?l.y(i.y1):null;if(null==r||null==n)return null;const s=Math.min(r,n),c=Math.abs(n-r),d=i.fill||Mi(i,u),f=null!==(a=i.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:h.width,height:c,fill:d,opacity:f}),i.label&&t("text",{x:h.width-4,y:s+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:d,fontFamily:u.typography.fontFamily,children:i.label})]},"ann-band-"+o)}case"category-highlight":{if(!i.category||!l.o)return null;const e=l.o(i.category);if(null==e)return null;const n=l.o.bandwidth?l.o.bandwidth():40,s=Mi(i,u),a=null!==(c=i.opacity)&&void 0!==c?c:.1;return t("rect","horizontal"===r.projection?{x:0,y:e,width:h.width,height:n,fill:s,opacity:a}:{x:e,y:0,width:n,height:h.height,fill:s,opacity:a},"ann-cathighlight-"+o)}case"label":case"text":{const r=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(i,l,d),n=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(i,l,f);if(null==r||null==n)return null;const s=i.dx||0,a=i.dy||0,c=i.color||u.colors.text;return e("g",{children:["label"===i.type&&t("line",{x1:r,y1:n,x2:r+s,y2:n+a,stroke:u.colors.textSecondary,strokeWidth:1}),t("text",{x:r+s,y:n+a,textAnchor:i.textAnchor||"start",fontSize:i.fontSize||u.typography.labelSize,fill:c,fontFamily:u.typography.fontFamily,fontWeight:i.fontWeight,children:i.label||i.title})]},"ann-label-"+o)}default:return null}}const Ei={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},o)},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,h=null!==(s=r.max)&&void 0!==s?s:100,u=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-u)/2,g=r.thresholds||[{value:h,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[v,x]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),x-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:u,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:h,sweep:u,arcWidth:d,value:r.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const h=(Array.isArray(t)?t:null)||r.flows||[],u=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[u]+"",t);const x=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof x,k=h.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),i=v.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=x?b?_t(k.map(t=>({[A]:x(t)})),A,i||"category10"):_t(k,x,i||"category10"):null,S=t=>x&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||St.has(e)}(o)?i(o):o}const o=null==t?void 0:t[e];return i?i(o):At[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o+""))%At.length]}(t,x,w):"#007bff";let _=1/0,P=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>P&&(P=e))}const M=P>_?P-_:0,[O,T]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],E=T-O,L=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,j=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=O+Math.max(0,Math.min(1,M>0?((Number.isFinite(e)?e:_)-_)/M:0))*E;return{stroke:S(t),strokeWidth:i,strokeLinecap:j,opacity:L,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Li(t){return Math.round(100*t)/100+""}function ji(i,o){const r=Si(o.theme),n=o.idPrefix?o.idPrefix+"-":"",s="string"==typeof o.title?o.title:void 0,a=s?n+"semiotic-title":void 0,c=o.description?n+"semiotic-desc":void 0,l=[a,c].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:o.className,width:o.width,height:o.height,role:"img","aria-labelledby":l,style:{fontFamily:r.fontFamily},children:[s&&t("title",{id:a,children:s}),o.description&&t("desc",{id:c,children:o.description}),o.defs&&t("defs",{children:o.defs}),o.background&&"transparent"!==o.background&&t("rect",{x:0,y:0,width:o.width,height:o.height,fill:o.background}),t("g",{id:n+"data-area",transform:o.innerTransform,children:i}),s&&t("text",{id:n+"chart-title",x:o.width/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:s}),o.legend&&t("g",{id:n+"legend",children:o.legend}),o.outerElements]})}function Di(r){var n,s,a,c;const l=wi(r.theme),h=r.size||[500,300],u=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),d=r.legendPosition;r.showLegend&&(d&&"right"!==d?"left"===d?u.left=Math.max(u.left,100):"bottom"===d?u.bottom=Math.max(u.bottom,70):"top"===d&&(u.top=Math.max(u.top,40)):u.right=Math.max(u.right,100));const f=h[0]-u.left-u.right,g=h[1]-u.top-u.bottom,y="streaming"===r.runtimeMode||["bar","swarm","waterfall"].includes(r.chartType),p={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:200,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",arrowOfTime:y&&null!==(a=r.arrowOfTime)&&void 0!==a?a:"right",extentPadding:null!==(c=r.extentPadding)&&void 0!==c?c:.1,xAccessor:y?void 0:r.xAccessor,yAccessor:y?void 0:r.yAccessor,timeAccessor:y?r.timeAccessor:void 0,valueAccessor:r.valueAccessor,colorAccessor:r.colorAccessor,sizeAccessor:r.sizeAccessor,groupAccessor:r.groupAccessor,categoryAccessor:r.categoryAccessor,lineDataAccessor:r.lineDataAccessor,xExtent:r.xExtent,yExtent:r.yExtent,sizeRange:r.sizeRange,binSize:r.binSize,normalize:r.normalize,boundsAccessor:r.boundsAccessor,boundsStyle:r.boundsStyle,openAccessor:r.openAccessor,highAccessor:r.highAccessor,lowAccessor:r.lowAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,lineStyle:r.lineStyle,pointStyle:r.pointStyle,areaStyle:r.areaStyle,colorScheme:r.colorScheme||l.colors.categorical,barColors:r.barColors},m=new Yt(p);if(r.data&&m.ingest({inserts:r.data,bounded:!0}),m.computeScene({width:f,height:g}),!m.scales||0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,idPrefix:r._idPrefix}));const v=r._idPrefix,x=r.showGrid?function(i,o,r,n){const{grid:s}=Si(r),a=n?n+"-":"",c=i.x.ticks(5),l=i.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[c.map((e,r)=>{const n=i.x(e);return t("line",{x1:n,y1:0,x2:n,y2:o.height,stroke:s,strokeWidth:.5},"gx-"+r)}),l.map((e,r)=>{const n=i.y(e);return t("line",{x1:0,y1:n,x2:o.width,y2:n,stroke:s,strokeWidth:.5},"gy-"+r)})]})}(m.scales,{width:f,height:g},l,v):null,b=m.scene.map((t,e)=>yi(t,e)).filter(Boolean),k=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h;const u=Si(n),d=i.x.ticks(5).map(t=>({pixel:i.x(t),label:(r.xFormat||r.tickFormatTime||Li)(t)})),f=i.y.ticks(5).map(t=>({pixel:i.y(t),label:(r.yFormat||r.tickFormatValue||Li)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:u.border,strokeWidth:1}),d.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:u.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"xtick-"+r)),r.xLabel&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:r.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:u.border,strokeWidth:1}),f.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:u.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"ytick-"+o)),r.yLabel&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:r.yLabel})]})}(m.scales,{width:f,height:g},r,l,v):null,A=r.annotations?Oi({annotations:r.annotations,scales:{x:m.scales.x,y:m.scales.y},layout:{width:f,height:g},theme:l,xAccessor:"string"==typeof r.xAccessor?r.xAccessor:void 0,yAccessor:"string"==typeof r.yAccessor?r.yAccessor:void 0,idPrefix:v}):null,w=r.showLegend?(()=>{const t=Pi(r.data||[],r.colorAccessor||r.groupAccessor);return 0===t.length?null:_i({categories:t,colorScheme:r.colorScheme,theme:l,position:r.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:u,hasTitle:!!r.title})})():null,S=e(i,{children:[x,A,b,k]});return o.renderToStaticMarkup(ji(S,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,legend:w,idPrefix:r._idPrefix}))}function zi(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const $i=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ri(r){const n=wi(r.theme),s=r.chartType||"force",a=r.size||[500,500],c=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),r.margin),l=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,u=function(t){return ti[t]}(s);if(!u)throw Error(`No layout plugin found for chart type: "${s}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:s,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,childrenAccessor:r.childrenAccessor,hierarchySum:r.hierarchySum,orientation:r.orientation,nodeAlign:r.nodeAlign,nodePaddingRatio:r.nodePaddingRatio,nodeWidth:r.nodeWidth,iterations:r.iterations,forceStrength:r.forceStrength,padAngle:r.padAngle,groupWidth:r.groupWidth,sortGroups:r.sortGroups,edgeSort:r.edgeSort,treeOrientation:r.treeOrientation,edgeType:r.edgeType,padding:r.padding,paddingTop:r.paddingTop,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,nodeLabel:r.nodeLabel,showLabels:r.showLabels,colorBy:r.colorBy,colorScheme:r.colorScheme||n.colors.categorical,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,colorByDepth:r.colorByDepth,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange};let f,g;if($i.has(s)){const t=r.data||r.edges;if(!t||Array.isArray(t))return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));d.__hierarchyRoot=t,f=[],g=[]}else{const t=r.nodes||[],e=Array.isArray(r.edges)?r.edges:[];if(0===t.length&&0===e.length)return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));if(g=function(t,e){const i=zi(e.sourceAccessor,"source"),o=zi(e.targetAccessor,"target"),r=zi(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(e,d),0===t.length&&g.length>0){const t=new Set;for(const e of g){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}f=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else f=function(t,e){const i=zi(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,d)}u.computeLayout(f,g,d,[l,h]);const{sceneNodes:y,sceneEdges:p,labels:m}=u.buildScene(f,g,d,[l,h]),v=Si(n);for(const t of m)t.fill||(t.fill=v.text);const x=p.map((e,i)=>function(e,i){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-"+i);case"bezier":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),b=y.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=F().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),k=m.map((e,i)=>function(e,i){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-"+i)}(e,i)).filter(Boolean),A=e(i,{children:[x,b,k]});return o.renderToStaticMarkup(ji(A,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}))}function Ci(r){var n,s,a,c,l;const h=wi(r.theme),u=r.size||[500,400],d=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),f=r.legendPosition;r.showLegend&&(f&&"right"!==f?"left"===f?d.left=Math.max(d.left,100):"bottom"===f?d.bottom=Math.max(d.bottom,70):"top"===f&&(d.top=Math.max(d.top,40)):d.right=Math.max(d.right,100));const g=u[0]-d.left-d.right,y=u[1]-d.top-d.bottom,p=r.projection||"vertical",m="radial"===p,v={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:1e4,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",extentPadding:null!==(a=r.extentPadding)&&void 0!==a?a:.05,projection:p,oAccessor:r.oAccessor,rAccessor:r.rAccessor,colorAccessor:r.colorAccessor,stackBy:r.stackBy,groupBy:r.groupBy,categoryAccessor:r.categoryAccessor,valueAccessor:r.valueAccessor,timeAccessor:r.timeAccessor,rExtent:r.rExtent,oExtent:r.oExtent,barPadding:r.barPadding,roundedTop:r.roundedTop,innerRadius:r.innerRadius,cornerRadius:r.cornerRadius,normalize:r.normalize,startAngle:r.startAngle,sweepAngle:r.sweepAngle,bins:r.bins,showOutliers:r.showOutliers,showIQR:r.showIQR,amplitude:r.amplitude,oSort:r.oSort,connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,dynamicColumnWidth:r.dynamicColumnWidth,pieceStyle:r.pieceStyle,summaryStyle:r.summaryStyle,colorScheme:r.colorScheme||h.colors.categorical,barColors:r.barColors},x=new ri(v);if(r.data&&x.ingest({inserts:r.data,bounded:!0}),x.computeScene({width:g,height:y}),!x.scales||0===x.scene.length)return o.renderToStaticMarkup(ji(null,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${d.left},${d.top})`,idPrefix:r._idPrefix}));const b=r._idPrefix,k=r.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Si(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(x,{width:g,height:y},h,b):null,A=x.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let w=null;if(A){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(r),o=new Set;for(const t of x.scene)"rect"===t.type&&(null===(c=t.datum)||void 0===c?void 0:c.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(o).map((o,r)=>function(i){const{id:o,background:r="transparent",stroke:n="#000",lineWidth:s=1.5,spacing:a=6,angle:c=45}=i,l=Math.max(8,Math.ceil(2*a));return e("pattern",{id:o,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==c?`rotate(${c})`:void 0,children:[r&&"transparent"!==r&&t("rect",{width:l,height:l,fill:r}),t("line",{x1:0,y1:0,x2:0,y2:l,stroke:n,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:l,stroke:n,strokeWidth:s})]},o)}({id:`funnel-hatch-${i}-${r}`,background:o,stroke:"transparent"===h.colors.background?"#fff":h.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,e)=>n.set(t,`funnel-hatch-${i}-${e}`));for(const t of x.scene)if("rect"===t.type&&(null===(l=t.datum)||void 0===l?void 0:l.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${n.get(e)})`})}}const S=x.scene.map((t,e)=>pi(t,e)).filter(Boolean),_=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h,u,d,f,g;const y=i.scales;if(!y)return null;if("radial"===y.projection)return null;const p=Si(n),m="vertical"===y.projection,v=r.categoryFormat||r.oFormat,x=r.valueFormat||r.rFormat,b=r.categoryLabel||r.oLabel,k=r.valueLabel||r.rLabel,A=Object.values(i.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),w=y.r.ticks(5).map(t=>({pixel:y.r(t),label:(x||Li)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),b&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:b}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),k&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),k&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),b&&t("text",{x:15-(null!==(d=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=r.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${o.height/2})`,children:b})]})}(x,{width:g,height:y},r,h,b):null,P=r.annotations?Oi({annotations:r.annotations,scales:{r:x.scales.r,y:"vertical"===x.scales.projection?x.scales.r:void 0},layout:{width:g,height:y},theme:h,projection:p,idPrefix:b}):null,M=r.showLegend?(()=>{const t=Pi(r.data||[],r.colorAccessor||r.stackBy||r.groupBy);return 0===t.length?null:_i({categories:t,colorScheme:r.colorScheme,theme:h,position:r.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!r.title})})():null,O=m?d.left+g/2:d.left,T=m?d.top+y/2:d.top,E=e(i,{children:[k,P,S,_]});return o.renderToStaticMarkup(ji(E,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${O},${T})`,legend:M,defs:w,idPrefix:r._idPrefix}))}function Ni(e){var r,n,s,a,c,l,h,u;const d=wi(e.theme),f=e.size||[e.width||600,e.height||400],g=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),y=f[0]-(null!==(r=g.left)&&void 0!==r?r:0)-(null!==(n=g.right)&&void 0!==n?n:0),p=f[1]-(null!==(s=g.top)&&void 0!==s?s:0)-(null!==(a=g.bottom)&&void 0!==a?a:0),m=new fi({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);m.setAreas(e.areas)}if(e.points&&m.setPoints(e.points),e.lines&&m.setLines(e.lines),m.computeScene({width:y,height:p}),0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(c=g.left)&&void 0!==c?c:0},${null!==(l=g.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}));const v=m.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t("path",{d:n.pathData,fill:gi(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1},"geoarea-"+i):null}case"point":{const o=e;return t("circle",{cx:o.x,cy:o.y,r:o.r,fill:gi(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+i)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1},"line-"+i)}default:return null}}(e,i)).filter(Boolean),x=t(i,{children:v});return o.renderToStaticMarkup(ji(x,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(h=g.left)&&void 0!==h?h:0},${null!==(u=g.top)&&void 0!==u?u:0})`,idPrefix:e._idPrefix}))}function Wi(t,e){switch(t){case"xy":return Di(e);case"ordinal":return Ci(e);case"network":return Ri(e);case"geo":return Ni(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Bi(t){return Di(t)}function Fi(t){return Ci(t)}function Yi(t){return Ri(t)}function Ii(t){return Ni(t)}function Xi(r,n,s){var a;const{data:c,width:l=600,height:h=400,theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,margin:x,colorScheme:b,colorBy:k,legendPosition:A}=n,w=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),S=[l,h],_=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w.frameProps||{}),{theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,size:S}),void 0!==x&&{margin:x}),void 0!==b&&{colorScheme:b}),void 0!==A&&{legendPosition:A}),{_idPrefix:w._idPrefix}),P=Ei[r];if(!P)throw Error(`Unknown chart component: "${r}". See CLAUDE.md for supported chart types.`);const M=P.buildProps(c,k,b,_,w);let O=(0,{xy:Di,ordinal:Ci,network:Ri,geo:Ni}[P.frameType])(M);if("GaugeChart"===r&&M.__gauge){const r=M.__gauge,n=_.margin||{top:20,right:20,bottom:30,left:40},s=(l||300)-n.left-n.right,c=(h||300)-n.top-n.bottom,d=Math.min(s,c)/2*.85,f=n.left+s/2,g=n.top+c/2,y=Math.max(r.gMin,Math.min(r.gMax,null!==(a=r.value)&&void 0!==a?a:r.gMin)),p=(r.startAngleDeg+(r.gMax===r.gMin?0:(y-r.gMin)/(r.gMax-r.gMin))*r.sweep-90)*Math.PI/180,m=wi(u).colors.text,v=o.renderToStaticMarkup(e(i,{children:[t("line",{x1:f,y1:g,x2:f+d*Math.cos(p),y2:g+d*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:f,cy:g,r:4,fill:m})]}));O=O.replace("</svg>",v+"</svg>")}return O}function qi(t,e){return ft(this,arguments,void 0,function*(t,e,i={}){var o,r;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?Wi(t,e):Xi(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const h=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,u=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,d=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(h*s),Math.round(u*s));return"jpeg"===n?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})}function Gi(i,r={}){var n;const{title:s,subtitle:a,theme:c,width:l=1200,height:h,layout:u={},background:d}=r,f=Si(wi(c)),g=u.columns||2,y=null!==(n=u.gap)&&void 0!==n?n:16;let p=0;s&&(p+=30),a&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-y-y*(g-1))/g),v=[];let x=0,b=p+y,k=0;for(const t of i){const e=Math.min(t.colSpan||1,g),i=t.props.height||300;x+e>g&&(b+=k+y,x=0,k=0),v.push({chart:t,x:y/2+x*(m+y),y:b,w:m*e+y*(e-1),h:i}),k=Math.max(k,i),x+=e}const A=h||b+k+y,w=v.map((e,i)=>{const{chart:o,x:r,y:n,w:s,h:a}=e,l=Object.assign(Object.assign({},o.props),{width:s,height:a,theme:c,_idPrefix:"chart-"+i});let h;return h=o.component?Xi(o.component,l):o.frameType?Wi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,t("g",{transform:`translate(${r},${n})`,children:t("foreignObject",{width:s,height:a,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:h}})})},"dashboard-chart-"+i)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:A,role:"img","aria-label":s||"Dashboard",style:{fontFamily:f.fontFamily},children:[s&&t("title",{children:s}),d&&t("rect",{x:0,y:0,width:l,height:A,fill:d}),s&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:f.titleSize+4,fontWeight:"bold",fill:f.text,fontFamily:f.fontFamily,children:s}),a&&t("text",{x:l/2,y:s?46:20,textAnchor:"middle",fontSize:f.labelSize,fill:f.textSecondary,fontFamily:f.fontFamily,children:a}),w]});return o.renderToStaticMarkup(S)}function Vi(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:u="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=wi(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const x=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(x)for(let o=0;v.length>o;o++){const r=v[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},d&&{decay:d}),c=new ri(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ui(c.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const r=v[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/h),easing:u}}),x=new Yt(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(w.push(Zi(x.scene,f,g,y,p,b)),l>0&&o>0&&x.activeTransition){const t=l*(1e3/h);for(let e=1;l>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/l*t),w.push(Zi(x.scene,f,g,y,p,b))}}return w}function Hi(t,e,i={}){return e.map(e=>{try{return Xi(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Qi(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Zi(r,n,s,a,c,l){const h=Si(a),u=Object.assign({top:20,right:20,bottom:30,left:40},c.margin),d=n-u.left-u.right,f=s-u.top-u.bottom,g=Qi(c,a),y=r.map((t,e)=>yi(t,e)).filter(Boolean),p=function(o,r,n,s,a,c){var l;if(!o||0===o.length)return null;const h=Si(s),u=[];for(let i=0;o.length>i;i++){const s=o[i];if("y-threshold"===s.type&&null!=s.value){let o=null;if(c)o=c(s.value);else if(a){const[t,e]=a,i=e-t;if(0===i)continue;o=n-(s.value-t)/i*n}if(null==o)continue;const d=s.color||h.primary,f=null!==(l=s.strokeWidth)&&void 0!==l?l:1.5,g=s.labelPosition||"right";u.push(e("g",{children:[t("line",{x1:0,y1:o,x2:r,y2:o,stroke:d,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?r/2:r-4,y:o-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:h.tickSize,fill:d,fontFamily:h.fontFamily,children:s.label})]},"ann-"+i))}}return u.length>0?t(i,{children:u}):null}(c.annotations,d,f,a,c.yExtent,null==l?void 0:l.y),m="string"==typeof c.title?c.title:void 0,v="string"==typeof c.description?c.description:void 0,x=m?"semiotic-title":void 0,b=v?"semiotic-desc":void 0,k=[x,b].filter(Boolean).join(" ")||void 0,A=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:s,role:"img","aria-labelledby":k,style:{fontFamily:h.fontFamily},children:[m&&t("title",{id:x,children:m}),v&&t("desc",{id:b,children:v}),g&&t("rect",{x:0,y:0,width:n,height:s,fill:g}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,y]}),m&&t("text",{x:n/2,y:16,textAnchor:"middle",fontSize:h.titleSize,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:m})]});return o.renderToStaticMarkup(A)}function Ui(i,r,n,s,a){const c=Si(s),l=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),h="radial"===a.projection,u=h?l.left+(r-l.left-l.right)/2:l.left,d=h?l.top+(n-l.top-l.bottom)/2:l.top,f=Qi(a,s),g=i.map((t,e)=>pi(t,e)).filter(Boolean),y="string"==typeof a.title?a.title:void 0,p="string"==typeof a.description?a.description:void 0,m=y?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,x=[m,v].filter(Boolean).join(" ")||void 0,b=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:n,role:"img","aria-labelledby":x,style:{fontFamily:c.fontFamily},children:[y&&t("title",{id:m,children:y}),p&&t("desc",{id:v,children:p}),f&&t("rect",{x:0,y:0,width:r,height:n,fill:f}),t("g",{transform:`translate(${u},${d})`,children:g}),y&&t("text",{x:r/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:y})]});return o.renderToStaticMarkup(b)}function Ki(t,e,i){return ft(this,arguments,void 0,function*(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.height||400,l=Math.round((i.width||600)*s),h=Math.round(c*s),u=Vi(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");let d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/r),m=f();for(let t=0;u.length>t;t++){const e=u[t],i=yield d(Buffer.from(e),{density:72*s}).resize(l,h).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,h,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{Vi as generateFrameSVGs,Hi as generateFrameSequence,Xi as renderChart,Gi as renderDashboard,Ii as renderGeoToStaticSVG,Yi as renderNetworkToStaticSVG,Fi as renderOrdinalToStaticSVG,Ki as renderToAnimatedGif,qi as renderToImage,Wi as renderToStaticSVG,Bi as renderXYToStaticSVG,wi as resolveTheme,Si as themeStyles};
|